:root {
  --bg: #f6f1e8;
  --paper: #fffdf8;
  --ink: #1f2a2a;
  --muted: #63706f;
  --line: rgba(31, 42, 42, 0.12);
  --brand: #1e76c7;
  --brand-soft: #d6efea;
  --accent: #e29f2d;
  --danger: #a6472f;
  --shadow: 0 18px 40px rgba(24, 37, 37, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(226, 159, 45, 0.18), transparent 28%),
    linear-gradient(180deg, #fff7ea 0%, var(--bg) 100%);
}

a {
  color: var(--brand);
  text-decoration: none;
}

.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(214, 239, 234, 0.88));
  box-shadow: var(--shadow);
}

.hero h1,
.section-header h2,
.card h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0.01em;
}

.hero-copy,
.section-copy,
.subtle,
.meta-label,
.runtime-detail {
  color: var(--muted);
}

.hero-meta {
  display: grid;
  gap: 12px;
  min-width: 240px;
}

.meta-card,
.runtime-banner,
.flash,
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.meta-card {
  padding: 16px;
}

.meta-label,
.eyebrow {
  display: block;
  margin-bottom: 6px;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.eyebrow {
  color: var(--brand);
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.top-nav a,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.button--ghost,
.top-nav a {
  background: rgba(15, 118, 110, 0.08);
  color: var(--brand);
}

.runtime-banner,
.flash {
  margin-bottom: 16px;
  padding: 14px 16px;
}

.runtime-banner--warning {
  background: rgba(226, 159, 45, 0.12);
}

.flash--success {
  background: var(--brand-soft);
}

.content {
  display: grid;
  gap: 20px;
}

.section-header,
.grid {
  display: grid;
  gap: 20px;
}

.section-header {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  padding: 22px;
  box-shadow: var(--shadow);
}

.card--center {
  text-align: center;
  padding: 48px 24px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tag-row,
.button-row,
.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--brand);
  font-size: 0.9rem;
}

.status-pill {
  background: rgba(226, 159, 45, 0.14);
  color: #8a5c09;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  margin: 0;
}

.detail-list div {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.84rem;
}

.detail-list dd {
  margin: 4px 0 0;
  font-weight: 700;
}

.form-card,
.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-group {
  display: grid;
  gap: 8px;
}

.form-group label {
  font-weight: 700;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  color: inherit;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

/* apply ページ専用レイアウト */
.apply-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 48px;
}

.apply-card {
  width: 100%;
  max-width: 560px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 40px 36px;
  box-shadow: var(--shadow);
}

.apply-brand {
  text-align: center;
  margin-bottom: 28px;
}

.apply-brand__img {
  max-height: 80px;
  display: block;
  margin: 0 auto;
}
.apply-brand__logo {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.04em;
  display: block;
}

.apply-brand__service {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 4px;
}

.apply-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 8px;
  text-align: center;
}

.apply-desc {
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  margin: 0 0 28px;
}

.apply-form .field-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 2px 0 4px;
}

.apply-form .field-error {
  display: none;
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 4px;
}

.service-select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.service-select legend {
  font-weight: 600;
  font-size: 0.95rem;
}
.service-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.service-option:last-of-type {
  border-bottom: none;
}
.service-option input[type="checkbox"] {
  margin-top: 3px;
}
.service-option label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}
.service-desc {
  font-size: 0.8rem;
  color: var(--muted);
}

.privacy-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  margin-bottom: 24px;
}

.privacy-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--brand);
}

.privacy-row__label {
  font-size: 0.9rem;
  line-height: 1.5;
}

.submit-wrap {
  margin-top: 4px;
}

.submit-wrap .btn--apply {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 14px;
  border: none;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.submit-wrap .btn--apply:hover {
  background: #0d6460;
  transform: translateY(-1px);
}

.submit-wrap .btn--apply:active {
  transform: translateY(0);
}

.apply-success {
  text-align: center;
  padding: 16px 0;
}

.apply-success__icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}

/* 公開ページ用言語切替 */
.lang-switcher {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.lang-btn {
  padding: 4px 12px;
  font-size: 0.8rem;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.15s;
}

.lang-btn:hover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand);
}

.lang-btn--active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* 管理画面ナビ用言語切替 */
.nav-lang-switcher {
  display: flex;
  gap: 4px;
  align-items: center;
}

.toggle-card {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.toggle-card input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.toggle-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.check-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

/* --- ユーザーバッジ --- */
.top-nav {
  justify-content: space-between;
  align-items: center;
}
.top-nav__links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.user-badge__email {
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-badge__role {
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.user-badge__role--superadmin {
  background: var(--accent);
  color: #fff;
}
.user-badge__role--tenant_admin {
  background: var(--brand-soft);
  color: var(--brand);
}
.user-badge__role--readonly {
  background: var(--line);
  color: var(--muted);
}
.user-badge__logout {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.user-badge__logout:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* --- RBAC ガード --- */
.role-notice {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}
.role-notice--info {
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--brand);
}
.toggle-card--readonly {
  opacity: 0.6;
  pointer-events: none;
}

/* --- セットアップフォーム --- */
.form-label--required::after {
  content: " *";
  color: var(--danger);
}
.setup-defaults-notice {
  padding: 12px 16px;
  background: var(--brand-soft);
  border-radius: 10px;
  font-size: 13px;
  margin-top: 8px;
}
.defaults-list {
  margin: 6px 0 0 16px;
  color: var(--muted);
}

/* --- 確認モーダル --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] {
  display: none;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.modal__panel {
  position: relative;
  background: var(--paper);
  border-radius: 18px;
  padding: 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal__title {
  margin: 0 0 8px;
  font-size: 18px;
}
.modal__body {
  color: var(--muted);
  margin: 0 0 16px;
}
.modal__actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.confirm-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  font-size: 14px;
}
.confirm-list dt {
  color: var(--muted);
  font-weight: 500;
}

/* --- サマリー画面 --- */
.section-header--success h2::before {
  content: "✓ ";
  color: var(--brand);
}
.grid--three {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.summary-card__title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 14px;
  color: var(--brand);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.summary-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 14px;
}
.summary-dl dt {
  color: var(--muted);
  font-weight: 500;
}
.app-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.app-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-badge {
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.app-badge--toriteki { background: #dbeafe; color: #1d4ed8; }
.app-badge--mitsumori { background: #fef3c7; color: #92400e; }
.app-badge--core { background: #ede9fe; color: #5b21b6; }
.button--sm {
  padding: 3px 12px;
  font-size: 12px;
  border-radius: 8px;
}
.next-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.next-steps__link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s;
}
.next-steps__link:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
}
.next-steps__arrow {
  color: var(--muted);
  font-size: 16px;
}
.card--warning {
  border: 1px solid var(--accent);
  background: #fffbeb;
}
.card--warning h3 {
  color: var(--accent);
}
.blocker-list {
  padding-left: 18px;
  color: var(--ink);
}
.page-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.button--primary {
  background: var(--brand);
  color: #fff;
}
.empty-state {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 860px) {
  .hero,
  .section-header,
  .grid--two,
  .grid--three,
  .detail-list,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 22px;
  }

  .top-nav,
  .button-row,
  .stack {
    flex-direction: column;
  }
}

.apply-footer {
  text-align: center;
  padding: 24px 16px;
  margin-top: 32px;
  font-size: 0.8rem;
  color: var(--muted);
}
.apply-footer__links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}
.apply-footer__links a {
  color: var(--muted);
  text-decoration: underline;
}
.apply-footer__copy {
  margin: 0;
}
