/* ═══════════════════════════════════════════════════════════
   MigrationProvision — Portal (logged-in app)
   Sidebar, dashboard, wizard, case detail.
═══════════════════════════════════════════════════════════ */

/* ── Layout shell ────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  background: var(--bg-page);
}
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  background: var(--c-ink);
  color: var(--text-on-dark);
  padding: var(--space-6) 0;
  display: flex; flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
}
@media (max-width: 980px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: var(--z-drawer); transform: translateX(-100%); transition: transform var(--t-base); }
  .sidebar.is-open { transform: translateX(0); }
}
.sidebar__brand {
  padding: 0 var(--space-6) var(--space-7);
  border-bottom: 1px solid var(--border-dark);
  margin-bottom: var(--space-6);
}
.sidebar__brand .brand__mark { background: rgba(255,255,255,.08); }
.sidebar__brand .brand__mark span { color: #fff; }
.sidebar__brand .brand__name { color: #fff; font-size: var(--fs-17); }
.sidebar__brand .brand__sub { color: var(--text-on-dark-m); }
.sidebar__nav {
  display: flex; flex-direction: column; gap: 2px;
  padding: 0 var(--space-4);
  flex: 1;
}
.sidebar__label {
  font-size: var(--fs-11);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-on-dark-m);
  padding: var(--space-5) var(--space-3) var(--space-2);
  font-weight: 600;
}
.side-link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-3);
  font-size: var(--fs-14);
  color: var(--text-on-dark-m);
  border-radius: var(--r-8);
  transition: all var(--t-fast);
}
.side-link svg {
  width: 18px; height: 18px;
  stroke: currentColor; stroke-width: 1.6; fill: none;
  flex-shrink: 0;
}
.side-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-link.is-active { background: rgba(255,255,255,.1); color: #fff; }
.side-link.is-active::before {
  content: ""; width: 3px; height: 18px;
  background: var(--c-authority);
  border-radius: 3px;
  margin-left: -12px; margin-right: 9px;
}
.side-link__counter {
  margin-left: auto;
  font-size: var(--fs-11);
  background: rgba(255,255,255,.1);
  color: #fff;
  padding: 2px 8px;
  border-radius: var(--r-pill);
}

.sidebar__user {
  margin-top: auto;
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--border-dark);
  display: flex; align-items: center; gap: var(--space-3);
}
.sidebar__user .avatar { background: rgba(255,255,255,.08); color: #fff; border-color: var(--border-dark); }
.sidebar__user-info { flex: 1; min-width: 0; }
.sidebar__user-name { color: #fff; font-size: var(--fs-14); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__user-email { color: var(--text-on-dark-m); font-size: var(--fs-12); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Main canvas ─────────────────────────────────── */
.canvas {
  padding: var(--space-7);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
@media (max-width: 640px) { .canvas { padding: var(--space-5); } }

.canvas__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-7);
  flex-wrap: wrap;
}
.canvas__title-block { flex: 1; min-width: 0; }
.canvas__title {
  font-family: var(--font-serif);
  font-size: var(--fs-28);
  color: var(--text-strong);
  line-height: var(--lh-snug);
}
.canvas__sub {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: var(--fs-14);
}
.canvas__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* ── Dashboard stat tiles ────────────────────────── */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-7);
}
@media (max-width: 900px) { .tile-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .tile-grid { grid-template-columns: 1fr; } }
.tile {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-10);
  padding: var(--space-5);
}
.tile__label {
  font-size: var(--fs-12);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.tile__value {
  font-family: var(--font-serif);
  font-size: var(--fs-28);
  color: var(--text-strong);
  font-weight: 600;
  line-height: 1;
  margin-bottom: 6px;
}
.tile__sub {
  font-size: var(--fs-13);
  color: var(--text-muted);
}
.tile__sub--success { color: var(--c-success); }
.tile__sub--warning { color: var(--c-warning); }
.tile__sub--danger { color: var(--c-danger); }

/* ── Empty state ─────────────────────────────────── */
.empty {
  text-align: center;
  padding: var(--space-12) var(--space-7);
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-12);
}
.empty__icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--c-paper-2);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-5);
}
.empty__icon svg { width: 28px; height: 28px; stroke: var(--c-ink); stroke-width: 1.5; fill: none; }
.empty__title {
  font-family: var(--font-serif);
  font-size: var(--fs-24);
  color: var(--text-strong);
  margin-bottom: var(--space-3);
}
.empty__body {
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto var(--space-6);
}

/* ── Case list ───────────────────────────────────── */
.case-list { display: flex; flex-direction: column; gap: var(--space-3); }
.case-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: var(--space-5);
  align-items: center;
  padding: var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-10);
  transition: all var(--t-fast);
}
.case-row:hover { border-color: var(--border-strong); box-shadow: var(--sh-2); }
.case-row__id {
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wide);
}
.case-row__title {
  font-weight: 600;
  color: var(--text-strong);
  font-size: var(--fs-15);
  line-height: var(--lh-snug);
  margin-bottom: 2px;
}
.case-row__meta {
  font-size: var(--fs-13);
  color: var(--text-muted);
}
.case-row__authority {
  font-size: var(--fs-13);
  color: var(--text-strong);
  font-weight: 500;
}
.case-row__date {
  font-size: var(--fs-13);
  color: var(--text-muted);
  white-space: nowrap;
}
@media (max-width: 720px) {
  .case-row { grid-template-columns: 1fr; gap: var(--space-2); }
  .case-row__date { display: none; }
}

/* ── Case detail ─────────────────────────────────── */
.case-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-7);
}
@media (max-width: 1024px) { .case-grid { grid-template-columns: 1fr; } }

.case-section { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-12); padding: var(--space-7); }
.case-section + .case-section { margin-top: var(--space-5); }
.case-section__title { font-family: var(--font-serif); font-size: var(--fs-20); color: var(--text-strong); margin-bottom: var(--space-5); }

/* Timeline */
.timeline { position: relative; padding-left: var(--space-7); }
.timeline::before {
  content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px;
  width: 1px; background: var(--border-strong);
}
.tl-item { position: relative; padding-bottom: var(--space-6); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -23px; top: 8px;
  width: 13px; height: 13px;
  background: var(--bg-surface);
  border: 2px solid var(--c-authority);
  border-radius: 50%;
}
.tl-item.is-done::before { background: var(--c-success); border-color: var(--c-success); }
.tl-item.is-active::before { background: var(--c-authority); border-color: var(--c-authority); box-shadow: 0 0 0 4px rgba(183,138,74,.15); }
.tl-item.is-blocked::before { background: var(--c-danger); border-color: var(--c-danger); }
.tl-item__title { font-weight: 600; color: var(--text-strong); margin-bottom: 4px; }
.tl-item__meta { font-size: var(--fs-13); color: var(--text-muted); }
.tl-item__body { margin-top: var(--space-3); font-size: var(--fs-14); line-height: var(--lh-relaxed); color: var(--text-body); }

/* Side panel (key facts) */
.fact-list { display: flex; flex-direction: column; gap: var(--space-4); }
.fact {
  display: flex; flex-direction: column;
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.fact:last-child { border-bottom: 0; padding-bottom: 0; }
.fact__label {
  font-size: var(--fs-12); text-transform: uppercase;
  letter-spacing: var(--tracking-wide); color: var(--text-muted);
  margin-bottom: 4px;
}
.fact__value { font-size: var(--fs-15); color: var(--text-strong); font-weight: 500; }

/* Document chips */
.doc-list { display: flex; flex-direction: column; gap: var(--space-3); }
.doc-item {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--r-8);
  background: var(--bg-surface);
  transition: all var(--t-fast);
}
.doc-item:hover { border-color: var(--border-strong); }
.doc-item__icon {
  width: 40px; height: 40px;
  background: var(--c-paper-2);
  border-radius: var(--r-6);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.doc-item__icon svg { width: 20px; height: 20px; stroke: var(--c-ink); stroke-width: 1.5; fill: none; }
.doc-item__body { flex: 1; min-width: 0; }
.doc-item__name { font-weight: 600; color: var(--text-strong); font-size: var(--fs-14); }
.doc-item__meta { font-size: var(--fs-12); color: var(--text-muted); }
.doc-item__actions { display: flex; gap: var(--space-2); }
.doc-item__action {
  font-size: var(--fs-13);
  color: var(--c-ink);
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--r-6);
}
.doc-item__action:hover { background: var(--c-paper-2); }

/* ── Wizard (case intake) ────────────────────────── */
.wizard {
  max-width: 720px;
  margin: 0 auto;
}
.wizard__progress {
  margin-bottom: var(--space-9);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}
.wizard__progress-bar {
  height: 4px;
  background: var(--c-slate-100);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-bottom: var(--space-3);
}
.wizard__progress-fill {
  height: 100%;
  background: var(--c-authority);
  transition: width var(--t-slow);
}
.wizard__progress-meta {
  display: flex; justify-content: space-between;
  font-size: var(--fs-13);
  color: var(--text-muted);
}
.wizard__step h2 {
  font-family: var(--font-serif);
  font-size: var(--fs-28);
  color: var(--text-strong);
  margin-bottom: var(--space-3);
}
.wizard__step .lead { margin-bottom: var(--space-7); font-size: var(--fs-17); }
.wizard__nav {
  margin-top: var(--space-9);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.wizard__nav .btn--ghost { color: var(--text-muted); }

/* Wizard option-card group */
.wizard__options { display: flex; flex-direction: column; gap: var(--space-3); }
.wizard__options .option-card {
  position: relative;
  padding-left: var(--space-9);
}
.wizard__options .option-card::before {
  content: "";
  position: absolute; left: var(--space-5); top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: #fff;
}
.wizard__options .option-card.is-selected::before {
  border-color: var(--c-ink);
  background: var(--c-ink);
  box-shadow: inset 0 0 0 4px #fff;
}

/* Assessment result screen */
.result {
  text-align: center;
  padding: var(--space-12) var(--space-7);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-12);
}
.result__seal {
  width: 96px; height: 96px;
  margin: 0 auto var(--space-7);
  border: 2px solid var(--c-authority);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-paper-2);
  font-family: var(--font-serif);
  font-size: var(--fs-13); font-weight: 700;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--c-authority-d);
  text-align: center;
  line-height: 1.05;
  padding: 8px;
}
.result__seal--eligible {}
.result__seal--premature { border-color: var(--c-warning); color: var(--c-warning); }
.result__seal--referral { border-color: var(--c-info); color: var(--c-info); }
.result h2 { font-family: var(--font-serif); font-size: var(--fs-32); margin-bottom: var(--space-3); color: var(--text-strong); }
.result .lead { margin: 0 auto var(--space-7); }

/* ── Messaging panel ─────────────────────────────── */
.thread {
  display: flex; flex-direction: column; gap: var(--space-4);
  max-height: 480px; overflow-y: auto;
  padding-right: var(--space-3);
}
.msg {
  display: flex; gap: var(--space-3);
}
.msg__bubble {
  padding: var(--space-4) var(--space-5);
  background: var(--c-slate-100);
  border-radius: var(--r-10);
  font-size: var(--fs-14);
  line-height: var(--lh-relaxed);
  max-width: 80%;
}
.msg__meta { font-size: var(--fs-12); color: var(--text-muted); margin-top: 4px; }
.msg--me { flex-direction: row-reverse; }
.msg--me .msg__bubble { background: var(--c-ink); color: #fff; }
.msg--me .msg__meta { text-align: right; }

.compose {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
  display: flex; gap: var(--space-3);
}
.compose .input { flex: 1; }

/* Upload zone */
.upload {
  padding: var(--space-9);
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-12);
  text-align: center;
  background: var(--c-paper);
  cursor: pointer;
  transition: all var(--t-fast);
}
.upload:hover { border-color: var(--c-ink); background: var(--c-paper-2); }
.upload__icon {
  width: 48px; height: 48px;
  margin: 0 auto var(--space-4);
  background: var(--c-paper-2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.upload__icon svg { width: 24px; height: 24px; stroke: var(--c-ink); stroke-width: 1.5; fill: none; }
.upload__title { font-weight: 600; color: var(--text-strong); margin-bottom: 4px; }
.upload__hint { font-size: var(--fs-13); color: var(--text-muted); }

/* ── Auth pages ──────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-page);
}
@media (max-width: 900px) { .auth-page { grid-template-columns: 1fr; } }
.auth-page__panel {
  background: var(--c-ink);
  color: var(--text-on-dark);
  padding: var(--space-12) var(--space-9);
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-page__panel::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 90% 10%, rgba(183,138,74,.18), transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(28,63,109,.5), transparent 65%);
  pointer-events: none;
}
.auth-page__panel > * { position: relative; }
@media (max-width: 900px) { .auth-page__panel { display: none; } }
.auth-page__hero {
  font-family: var(--font-serif);
  font-size: var(--fs-32);
  color: #fff;
  line-height: var(--lh-snug);
  margin-bottom: var(--space-5);
  max-width: 480px;
}
.auth-page__hero em { color: var(--c-authority-l); font-style: italic; font-weight: 500; }
.auth-page__quote {
  margin-top: var(--space-9);
  padding-top: var(--space-7);
  border-top: 1px solid var(--border-dark);
  font-style: italic;
  color: var(--text-on-dark-m);
}
.auth-page__form-wrap {
  padding: var(--space-12) var(--space-9);
  display: flex; flex-direction: column; justify-content: center;
}
.auth-page__form { max-width: 380px; width: 100%; margin: 0 auto; }
.auth-page__form .brand { margin-bottom: var(--space-9); }
.auth-page__form h1 { font-family: var(--font-serif); font-size: var(--fs-28); margin-bottom: var(--space-3); color: var(--text-strong); }
.auth-page__form .lead { margin-bottom: var(--space-7); font-size: var(--fs-15); }
.auth-page__alt {
  text-align: center;
  margin-top: var(--space-7);
  font-size: var(--fs-14);
  color: var(--text-muted);
}
.auth-page__alt a { color: var(--c-ink); font-weight: 600; }
.auth-page__alt a:hover { color: var(--c-authority-d); }
