/* ===== Veritas — design tokens ===== */
:root {
  --navy-900: #0e1b2c;
  --navy-800: #14273d;
  --navy-700: #1c3350;
  --navy-600: #274566;
  --ink: #1a2432;
  --slate: #55637a;
  --mute: #8a96aa;
  --line: #e4e8f0;
  --line-soft: #eef1f7;
  --bg: #f5f7fb;
  --card: #ffffff;
  --gold: #b8893b;
  --gold-soft: #f4ead6;
  --green: #2f7d5b;
  --green-soft: #e3f2ea;
  --red: #b3402f;
  --red-soft: #fbe7e2;
  --amber: #b8813b;
  --amber-soft: #f8eed6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,27,44,.04), 0 8px 24px rgba(16,27,44,.06);
  --shadow-lg: 0 12px 40px rgba(16,27,44,.12);
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Sidebar ===== */
.sidebar {
  background: linear-gradient(180deg, var(--navy-900), var(--navy-800));
  color: #c8d3e4;
  display: flex;
  flex-direction: column;
  padding: 14px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 16px; }
.brand-mark {
  width: 54px; height: 54px; border-radius: 12px;
  background: white;
  color: #fff; font-family: 'Fraunces', serif; font-weight: 700;
  font-size: 28px; display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  overflow: hidden;
  flex-shrink: 0;
}
.brand-mark img {
  width: 95%;
  height: 95%;
  object-fit: contain;
}
.brand-mark-fallback {
  font-size: 22px;
  color: #b8893b;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: 'Trajan Pro', 'Times New Roman', serif; font-weight: 700; font-size: 18px; color: #fff; letter-spacing: 2px; text-transform: uppercase; }
.brand-sub { font-family: 'Trajan Pro', 'Times New Roman', serif; font-size: 10px; color: #b8a080; letter-spacing: 1.5px; text-transform: uppercase; font-weight: 600; }

.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; }
.nav-group-label {
  font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase;
  color: #64748e; margin: 10px 10px 5px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 6px 12px; border-radius: 9px;
  color: #b7c3d6; text-decoration: none; font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: var(--navy-600); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav-ico { width: 16px; text-align: center; opacity: .85; font-size: 13px; }

.sidebar-foot { padding-top: 14px; border-top: 1px solid rgba(255,255,255,.07); }
.plan-chip {
  font-size: 12px; color: #9fb0c8; background: rgba(255,255,255,.05);
  padding: 8px 12px; border-radius: 9px; text-align: center;
}

/* ===== Main ===== */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.matter-label { display: block; font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--mute); margin-bottom: 3px; }
.matter-btn {
  display: inline-flex; align-items: baseline; gap: 10px;
  background: none; border: none; cursor: pointer; text-align: left; color: var(--ink);
}
.matter-btn strong { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 600; }
.case-no { font-size: 12.5px; color: var(--slate); }
.chev { color: var(--mute); font-size: 12px; }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; width: 340px;
}
.search input { border: none; background: none; outline: none; flex: 1; font-size: 13px; color: var(--ink); }
.search input::placeholder { color: var(--mute); }
.search-ico { color: var(--mute); }
.kbd { font-size: 11px; color: var(--mute); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }

.icon-btn { position: relative; background: none; border: none; font-size: 16px; cursor: pointer; }
.icon-btn .dot { position: absolute; top: 0; right: 0; width: 8px; height: 8px; background: var(--red); border-radius: 50%; border: 2px solid #fff; }

.user { display: flex; align-items: center; gap: 10px; padding-left: 8px; border-left: 1px solid var(--line); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-600), var(--navy-800));
  color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-name { font-size: 13.5px; font-weight: 600; }
.user-role { font-size: 11.5px; color: var(--mute); }

/* ===== Content ===== */
.content { padding: 28px; max-width: 1500px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.page-head h1 { font-family: 'Fraunces', serif; font-size: 28px; font-weight: 600; letter-spacing: -.3px; }
.page-head .sub { color: var(--slate); margin-top: 5px; font-size: 14px; }
.head-actions { display: flex; gap: 10px; }

.btn { font-family: inherit; font-size: 13.5px; font-weight: 600; border-radius: 10px; padding: 10px 16px; cursor: pointer; border: 1px solid transparent; transition: transform .06s, box-shadow .15s, background .15s; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--navy-800); color: #fff; }
.btn.primary:hover { background: var(--navy-700); box-shadow: var(--shadow); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--slate); }
.btn.ghost.flagged { background: #e8f5e9; border-color: #4caf50; color: #2e7d32; font-weight: 700; }
.btn.ghost.flagged:hover { background: #c8e6c9; border-color: #388e3c; }
.btn.subtle { background: var(--bg); color: var(--navy-700); border-color: var(--line); }
.btn.subtle:hover { background: #eef1f7; }
.btn.wide { width: 100%; margin-top: 12px; }

/* KPI */
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; color: var(--slate); text-transform: uppercase; letter-spacing: .5px; }
.kpi-value { display: block; font-family: 'Fraunces', serif; font-size: 30px; font-weight: 600; margin: 8px 0 6px; color: var(--navy-900); }
.kpi-value .unit { font-size: 15px; color: var(--mute); font-family: 'Inter'; font-weight: 500; }
.kpi-value.danger { color: var(--red); }
.kpi-value.warn { color: var(--amber); }
.kpi-delta { font-size: 12.5px; color: var(--mute); }
.kpi-delta.up { color: var(--green); }
.kpi-delta.warn { color: var(--amber); }
.kpi-missing { cursor: pointer; border-color: #e6d3ac; background: linear-gradient(180deg,#fffdf8,var(--card)); transition: transform .12s, box-shadow .15s, border-color .15s; }
.kpi-missing:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: #d9c084; }

/* Grid */
.grid { display: grid; grid-template-columns: 1fr 360px; gap: 22px; }
.col-main { min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.col-rail { display: flex; flex-direction: column; gap: 18px; }

.section-title { display: flex; align-items: baseline; gap: 12px; margin-bottom: -4px; }
.section-title h2 { font-family: 'Fraunces', serif; font-size: 19px; font-weight: 600; }
.hint { font-size: 12.5px; color: var(--mute); }

/* Module cards */
.modules { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.mod-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .12s, box-shadow .15s, border-color .15s;
  position: relative; overflow: hidden;
}
.mod-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: #d3dae7; }
.mod-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.mod-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; }
.mod-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.mod-card h4 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.mod-card p { font-size: 12.5px; color: var(--slate); line-height: 1.5; margin-bottom: 12px; }
.mod-stat { display: flex; align-items: baseline; gap: 6px; }
.mod-stat b { font-family: 'Fraunces', serif; font-size: 20px; color: var(--navy-900); }
.mod-stat span { font-size: 12px; color: var(--mute); }
.mod-card.has-missing { border-top: 2px solid #e6d3ac; }
.mod-missing {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 11px;
  font-size: 11.5px; font-weight: 600; color: #8a6528;
  background: #f4ead6; border: 1px solid #e6d3ac; border-radius: 20px; padding: 4px 10px;
}
.mod-missing .mm-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); flex: none; }
.mod-missing.has-high { color: #a33224; background: #fbe7e2; border-color: #f2cfc7; }
.mod-missing.has-high .mm-dot { background: var(--red); animation: mmPulse 1.8s ease-in-out infinite; }
@keyframes mmPulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* Panels */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h3 { font-size: 15px; font-weight: 600; }
.tag { font-size: 11px; font-weight: 600; color: var(--slate); background: var(--bg); border: 1px solid var(--line); padding: 3px 9px; border-radius: 20px; }
.danger-tag { color: var(--red); background: var(--red-soft); border-color: #f2cfc7; }

/* Scenario bar */
.scenario-bar { display: flex; height: 66px; border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
.seg { display: grid; place-items: center; color: #fff; font-size: 12px; text-align: center; padding: 0 6px; }
.seg b { font-family: 'Fraunces', serif; font-size: 16px; }
.seg-you { background: var(--navy-700); }
.seg-gap { background: repeating-linear-gradient(45deg, #c9a15a, #c9a15a 8px, #bd9349 8px, #bd9349 16px); }
.seg-them { background: #6b7688; }
.scenario-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.note { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.note-k { color: var(--slate); }
.note-v { font-weight: 600; color: var(--ink); }

/* Red flags */
.danger-panel { border-color: #f0d2ca; }
.flag-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.flag { display: flex; gap: 11px; padding: 10px; border-radius: 10px; background: var(--bg); }
.flag .sev { width: 6px; border-radius: 4px; flex-shrink: 0; }
.flag.high .sev { background: var(--red); }
.flag.med .sev { background: var(--amber); }
.flag.low .sev { background: var(--slate); }
.flag-body h5 { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.flag-body p { font-size: 12px; color: var(--slate); line-height: 1.45; }
.flag-body .ref { font-size: 11px; color: var(--mute); margin-top: 3px; }

/* Open items — missing documents */
.missing-panel { border-color: #e6d3ac; }
.missing-panel.pulse { animation: panelPulse 1.6s ease-out; }
@keyframes panelPulse {
  0% { box-shadow: 0 0 0 0 rgba(184,137,59,.5); border-color: #d9c084; }
  100% { box-shadow: 0 0 0 14px rgba(184,137,59,0); border-color: #e6d3ac; }
}
.missing-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.miss { display: flex; gap: 11px; padding: 11px; border-radius: 10px; background: var(--bg); }
.miss-sev { width: 6px; border-radius: 4px; flex-shrink: 0; }
.miss.high .miss-sev { background: var(--red); }
.miss.med .miss-sev { background: var(--amber); }
.miss.low .miss-sev { background: var(--slate); }
.miss-body { flex: 1; min-width: 0; }
.miss-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.miss-top h5 { font-size: 13px; font-weight: 600; }
.miss-area { font-size: 10.5px; color: var(--mute); white-space: nowrap; text-transform: uppercase; letter-spacing: .4px; }
.miss-body p { font-size: 12px; color: var(--slate); line-height: 1.45; margin: 3px 0 8px; }
.miss-ask {
  font-size: 11.5px; font-weight: 600; color: var(--navy-800); cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 4px 11px;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.miss-ask:hover { background: var(--bg); border-color: #c9b891; }
.miss-ask.done { color: var(--green); border-color: #c6e2d2; background: #f2f9f5; cursor: default; }

/* Progress */
.progress-block { display: flex; flex-direction: column; gap: 10px; }
.progress-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--slate); }
.progress-row strong { color: var(--ink); }
.bar { height: 8px; background: var(--line-soft); border-radius: 20px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--green), #3c9b71); border-radius: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.chip { font-size: 11.5px; color: var(--slate); background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; }
.chip.warn { color: var(--amber); background: var(--amber-soft); border-color: #ecd9ad; }

/* Activity */
.activity { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.act { display: flex; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.act:last-child { border-bottom: none; }
.act-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; background: var(--navy-600); }
.act-body { font-size: 12.5px; color: var(--slate); line-height: 1.4; }
.act-body b { color: var(--ink); font-weight: 600; }
.act-time { font-size: 11px; color: var(--mute); }

.foot { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--slate); }
.foot-dim { color: var(--mute); }

/* ===== Logo & Branding ===== */
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.brand-mark-fallback {
  display: none;
  font-family: 'Fraunces', serif;
  font-weight: 700;
  color: #fff;
}

.brand-mark.loading img {
  opacity: 0.5;
}

.brand-mark.error .brand-mark-fallback {
  display: block;
}

.brand-mark.error img {
  display: none;
}

/* Auth page logo styling */
.auth-logo {
  width: 70px;
  height: 70px;
  margin: 0 auto 16px;
  background: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(184,137,59,.2);
  border: 2px solid var(--gold-soft);
  overflow: hidden;
}

.auth-logo img {
  width: 90%;
  height: 90%;
  object-fit: contain;
}

.auth-logo-fallback {
  display: none;
  font-family: 'Fraunces', serif;
  font-weight: 700;
  color: var(--gold);
  font-size: 24px;
}

.auth-logo.error img {
  display: none;
}

.auth-logo.error .auth-logo-fallback {
  display: block;
}

@media (max-width: 1180px) {
  .grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  body { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .modules { grid-template-columns: 1fr; }
}
