:root {
  --ivory: #f4efe5;
  --ivory-2: #fbf8f1;
  --espresso: #2d251f;
  --charcoal: #3b3935;
  --gold: #b99555;
  --gold-soft: #dbc89b;
  --line: rgba(73, 57, 39, .14);
  --muted: #766e64;
  --success: #496858;
  --danger: #9a4e43;
  --shadow: 0 24px 70px rgba(40, 31, 23, .14);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ivory); }
body { margin: 0; color: var(--espresso); font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", system-ui, sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-weight: 500; letter-spacing: .04em; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 14px; letter-spacing: .19em; font-size: 11px; font-weight: 700; }
.eyebrow.dark { color: var(--gold); }
.eyebrow.light { color: var(--gold-soft); }
.muted { color: var(--muted); line-height: 1.8; }
.tiny { font-size: 12px; color: var(--muted); }
.notice { padding: 13px 15px; margin-bottom: 18px; border: 1px solid var(--line); background: rgba(255,255,255,.64); line-height: 1.6; }
.notice.error { border-color: rgba(154,78,67,.4); color: var(--danger); background: #fff5f2; }
.notice.success { border-color: rgba(73,104,88,.35); color: var(--success); background: #f3f8f4; }

.auth-page { min-height: 100vh; background: radial-gradient(circle at top left, #5a4b3d 0, #2d251f 42%, #1e1915 100%); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.15fr .85fr; }
.brand-panel { padding: clamp(48px, 8vw, 110px); color: #f8f1e4; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.brand-panel::after { content: ""; position: absolute; width: 520px; height: 520px; border: 1px solid rgba(219,200,155,.2); border-radius: 50%; right: -180px; bottom: -190px; box-shadow: 0 0 0 70px rgba(219,200,155,.035), 0 0 0 140px rgba(219,200,155,.02); }
.brand-mark { width: 64px; height: 64px; border: 1px solid var(--gold-soft); display: grid; place-items: center; font-family: "Yu Mincho", serif; letter-spacing: .1em; color: var(--gold-soft); margin-bottom: 48px; }
.brand-panel h1 { font-size: clamp(44px, 6vw, 82px); line-height: 1.05; margin: 0 0 28px; }
.brand-panel .lead { max-width: 620px; color: rgba(248,241,228,.72); line-height: 2; font-size: 16px; }
.gold-line { width: 110px; height: 1px; background: var(--gold); margin: 38px 0; }
.fine { font-size: 10px; letter-spacing: .22em; color: rgba(248,241,228,.54); }
.auth-card { background: var(--ivory-2); padding: clamp(42px, 7vw, 100px); display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.auth-card h2 { font-size: 36px; margin: 0 0 18px; }
.step form { display: grid; gap: 20px; margin-top: 28px; }
label { display: grid; gap: 9px; font-weight: 700; font-size: 13px; letter-spacing: .04em; }
input, select { width: 100%; border: 1px solid var(--line); background: rgba(255,255,255,.78); color: var(--espresso); padding: 14px 15px; outline: none; border-radius: 2px; }
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(185,149,85,.12); }
.code-input { font-size: 28px; letter-spacing: .35em; text-align: center; }
.primary, .secondary { border: 0; padding: 15px 20px; font-weight: 700; letter-spacing: .05em; transition: .2s ease; }
.primary { background: var(--espresso); color: #fff9ed; box-shadow: 0 12px 28px rgba(45,37,31,.18); }
.primary:hover { transform: translateY(-1px); background: #1e1915; }
.primary.inline { width: auto; }
.secondary { border: 1px solid var(--line); background: transparent; color: var(--espresso); }
.text-button, .danger-text { border: 0; background: transparent; padding: 12px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 4px; }
.danger-text { color: var(--danger); margin-top: 18px; }
.secret-panel { padding: 18px; border: 1px solid var(--gold-soft); background: #fffaf0; margin: 22px 0; }
.secret-panel code { display: block; margin: 12px 0; font-size: 17px; letter-spacing: .12em; word-break: break-all; }

.dashboard-page { min-height: 100vh; background: var(--ivory); }
.dashboard-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar { background: var(--espresso); color: #f9f2e6; padding: 28px 20px; display: flex; flex-direction: column; min-height: 100vh; position: sticky; top: 0; }
.brand-row { display: flex; align-items: center; gap: 14px; font-family: "Yu Mincho", serif; letter-spacing: .04em; }
.brand-mark.small { width: 40px; height: 40px; margin: 0; font-size: 13px; }
.sidebar-caption { margin: 12px 0 38px 54px; font-size: 9px; letter-spacing: .18em; color: rgba(255,255,255,.45); }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { width: 100%; text-align: left; border: 0; background: transparent; color: rgba(255,255,255,.67); padding: 13px 14px; border-left: 2px solid transparent; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.05); border-left-color: var(--gold); }
.nav-item.logout { margin-top: auto; }
.dashboard-main { padding: 30px clamp(24px, 4vw, 64px) 70px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: center; padding-bottom: 26px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.topbar h1 { margin: 0; font-size: 32px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.top-actions select { min-width: 220px; background: #fffaf1; }
.user-chip { display: grid; padding: 8px 12px; border-left: 1px solid var(--line); }
.user-chip small { color: var(--muted); font-size: 10px; }
.hero-card { background: linear-gradient(135deg, #3a2f27, #211b17); color: #fff7ea; padding: clamp(28px, 4vw, 46px); display: flex; justify-content: space-between; gap: 24px; box-shadow: var(--shadow); border: 1px solid rgba(219,200,155,.25); }
.hero-card h2 { font-size: clamp(28px, 4vw, 46px); margin: 0 0 12px; }
.hero-card p { color: rgba(255,247,234,.68); max-width: 700px; line-height: 1.8; }
.status-seal { min-width: 110px; min-height: 110px; border: 1px solid var(--gold-soft); border-radius: 50%; display: grid; place-items: center; color: var(--gold-soft); font-family: "Yu Mincho", serif; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 22px 0; }
.metric-card, .panel { background: rgba(255,252,246,.86); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(47,37,29,.05); }
.metric-card { padding: 22px; display: grid; gap: 7px; }
.metric-card span, .metric-card small { color: var(--muted); }
.metric-card strong { font-family: "Yu Mincho", serif; font-size: 24px; font-weight: 500; }
.content-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 20px; }
.content-grid.single-main { grid-template-columns: minmax(0, 1.4fr) minmax(260px, .6fr); }
.panel { padding: clamp(22px, 3vw, 32px); }
.panel h3 { margin: 0 0 14px; font-size: 24px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.action-panel { background: #e9dfcb; }
.subtle-panel { background: rgba(232,223,205,.5); }
.check-list, .plain-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.check-list li { position: relative; padding-left: 28px; }
.check-list li::before { content: "○"; position: absolute; left: 0; color: #b8a996; }
.check-list li.done::before { content: "●"; color: var(--gold); }
.check-list.compact { gap: 9px; }
.plain-list li { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.badge { border: 1px solid var(--line); padding: 6px 10px; font-size: 12px; color: var(--muted); }
.badge.active { color: var(--success); border-color: rgba(73,104,88,.35); background: #f4f8f5; }
.form-grid { display: grid; gap: 20px; margin-top: 24px; }
.button-row { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.summary-box { margin-top: 20px; padding: 17px; border-left: 3px solid var(--gold); background: #fffaf1; line-height: 1.7; }
.audit-list { display: grid; gap: 10px; }
.audit-row { display: grid; grid-template-columns: 160px 1fr 100px; gap: 16px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.audit-row time { color: var(--muted); }
.audit-row .result-success { color: var(--success); }
.audit-row .result-denied, .audit-row .result-failed { color: var(--danger); }

@media (max-width: 960px) {
  .auth-shell { grid-template-columns: 1fr; }
  .brand-panel { min-height: 42vh; padding: 42px 28px; }
  .brand-panel h1 { font-size: 44px; }
  .auth-card { padding: 42px 28px; }
  .dashboard-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; position: static; }
  .sidebar nav { grid-template-columns: repeat(3, 1fr); }
  .nav-item.logout { margin-top: 18px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid, .content-grid.single-main { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; flex-direction: column; align-items: stretch; }
  .metric-grid { grid-template-columns: 1fr; }
  .hero-card { flex-direction: column; }
  .status-seal { min-width: 86px; min-height: 86px; width: 86px; }
  .sidebar nav { grid-template-columns: 1fr; }
  .audit-row { grid-template-columns: 1fr; gap: 4px; }
}

.recovery-codes { padding: 18px; border: 1px solid var(--gold-soft); background: #fffaf0; font-size: 15px; line-height: 1.8; letter-spacing: .08em; user-select: all; }
.compact-metrics { grid-template-columns: repeat(2, minmax(0, 220px)); margin-top: 24px; }
.catalog-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 24px; }
.catalog-title { font-size: 18px !important; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.resource-list { display: grid; gap: 8px; max-height: 360px; overflow: auto; padding-right: 6px; }
.resource-row { padding: 11px 12px; border: 1px solid var(--line); background: rgba(255,255,255,.58); display: grid; gap: 4px; }
.resource-row small { color: var(--muted); word-break: break-all; }
@media (max-width: 760px) {
  .catalog-columns { grid-template-columns: 1fr; }
  .compact-metrics { grid-template-columns: 1fr 1fr; }
}

.mapping-form { margin-top: 24px; }
.mapping-recommendation { background: #f7efdf; border-left-color: var(--gold); }
.mapping-recommendation small { display: inline-block; margin-top: 8px; color: var(--muted); }
.required-mark { color: var(--gold); font-size: 10px; letter-spacing: .1em; margin-left: 5px; }
.optional-settings { border: 1px solid var(--line); background: rgba(255,255,255,.42); }
.optional-settings summary { cursor: pointer; padding: 16px 18px; font-weight: 700; color: var(--espresso); }
.optional-settings[open] summary { border-bottom: 1px solid var(--line); }
.optional-grid { padding: 18px; display: grid; gap: 18px; }

/* STEP 2-3: funnel × LINE route data */
.details-controls {
  display: flex;
  align-items: end;
  gap: 16px;
  margin: 24px 0;
  flex-wrap: wrap;
}
.details-controls label {
  min-width: 190px;
  margin: 0;
}
.route-metrics {
  margin-top: 8px;
}
.data-section {
  margin-top: 34px;
  padding-top: 28px;
  border-top: 1px solid rgba(92, 72, 49, 0.16);
}
.section-heading-row,
.route-card-head,
.route-subrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.section-heading-row h3,
.route-card-head h4 {
  margin: 4px 0 0;
}
.quiet-count {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}
.route-data-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}
.route-data-card {
  border: 1px solid rgba(92, 72, 49, 0.16);
  background: rgba(255, 253, 248, 0.78);
  padding: 20px;
  box-shadow: 0 14px 38px rgba(40, 31, 23, 0.045);
}
.route-index {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--gold-dark);
  text-transform: uppercase;
}
.route-card-head > div:first-child {
  min-width: 220px;
}
.route-card-head small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}
.mini-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.mini-metrics span {
  padding: 7px 10px;
  border: 1px solid rgba(92, 72, 49, 0.13);
  background: rgba(240, 232, 216, 0.38);
  color: var(--muted-dark);
  font-size: 0.78rem;
  white-space: nowrap;
}
.mini-metrics.strong span {
  color: var(--espresso);
}
.route-subrows {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(92, 72, 49, 0.1);
}
.route-subrow {
  padding: 10px 0;
}
.route-subrow strong,
.route-subrow small {
  display: block;
}
.route-subrow small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
}
.route-empty {
  margin: 0;
}
.warning-note {
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 2px solid #b98c43;
  background: rgba(185, 140, 67, 0.08);
}
.message-card .route-card-head {
  align-items: flex-start;
}
@media (max-width: 900px) {
  .section-heading-row,
  .route-card-head,
  .route-subrow {
    align-items: flex-start;
    flex-direction: column;
  }
  .mini-metrics {
    justify-content: flex-start;
  }
  .route-card-head > div:first-child {
    min-width: 0;
  }
}
