@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2-variations'); }

:root {
  --navy: #102747; --blue: #154F8C; --azure: #1688DB; --green: #16A085; --green-text: #0b6e5b;
  --bg: #ffffff; --surface: #ffffff; --tint: #eef5fc; --border: #d3e0ee; --text: #1c2733; --muted: #52606d;
  --primary: #154F8C; --primary-hover: #0f3d6f; --on-primary: #ffffff; --link: #154F8C; --focus: #1688DB;
  --danger: #b42318; --danger-bg: #fdecea; --ok-bg: #e3f6f1; --info-bg: #eaf3fb; --warn: #8a5a00; --warn-bg: #fff4d6;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 39, 71, .06), 0 4px 14px rgba(21, 79, 140, .07);
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}
:root[data-theme='dark'] {
  --bg: #0a1730; --surface: #11233f; --tint: #16304f; --border: #2a4468; --text: #e7eef7; --muted: #a9b9cb;
  --primary: #3aa0ee; --primary-hover: #5db3f3; --on-primary: #04162c; --link: #7cc0f7;
  --danger: #ff8a80; --danger-bg: #3a1a1c; --ok-bg: #0f3a33; --info-bg: #16304f; --green-text: #5fd9bf; --warn: #f0c56a; --warn-bg: #3a2e10;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 16px/1.55 var(--font); color: var(--text); background: var(--bg); }
.auth-main { background: linear-gradient(180deg, #ffffff, #f3f8fd); }
h1, h2, h3 { color: var(--text); line-height: 1.25; margin: 0 0 .4em; font-weight: 700; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
:root[data-theme='dark'] h1, :root[data-theme='dark'] h2, :root[data-theme='dark'] h3 { color: #fff; }
p { margin: 0 0 .75em; }
a { color: var(--link); }
small, .muted { color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.eyebrow { font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: .25rem; }
.lead { color: var(--muted); font-size: 1.02rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 8px; border: 1px solid transparent; font: 600 1rem var(--font); cursor: pointer; text-decoration: none; transition: background .15s; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--link); border-color: var(--border); }
.btn-secondary:hover { background: var(--tint); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--tint); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-block { width: 100%; }
.btn-small { min-height: 44px; padding: 0 14px; font-size: .9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.link-btn { background: none; border: 0; padding: 0; color: var(--link); font: inherit; text-decoration: underline; cursor: pointer; min-height: 44px; }
.inline-form { display: inline; }

/* Forms */
.form { display: grid; gap: 16px; }
.field label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 6px; }
.input-wrap { position: relative; }
input, select { width: 100%; min-height: 44px; padding: 0 14px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
input[type='password'] { padding-right: 76px; }
input::placeholder { color: var(--muted); }
.pw-toggle { position: absolute; right: 4px; top: 2px; min-height: 40px; min-width: 56px; background: none; border: 0; color: var(--link); font: 600 .85rem var(--font); cursor: pointer; border-radius: 6px; }
.has-error input, .has-error select { border-color: var(--danger); }
.field-msg { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.field-error { color: var(--danger); font-weight: 500; }
.field-error::before { content: 'Error: '; font-weight: 700; }
.strength { font-size: .85rem; margin: -8px 0 0; min-height: 1.2em; color: var(--muted); }
.strength.weak { color: var(--danger); } .strength.strong { color: var(--green-text); }
.row-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.link-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; font-size: .95rem; }
.link-row a { display: inline-flex; align-items: center; min-height: 44px; }

/* Alerts and badges */
.alert { border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; border-left: 4px solid; font-size: .95rem; }
.alert-error { background: var(--danger-bg); border-color: var(--danger); }
.alert-info { background: var(--info-bg); border-color: var(--azure); }
.alert-success { background: var(--ok-bg); border-color: var(--green); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; text-transform: capitalize; background: var(--tint); color: var(--text); }
.badge-ok { background: var(--ok-bg); color: var(--green-text); }
.badge-bad { background: var(--danger-bg); color: var(--danger); }

/* Auth layout (login is the first page: no splash screen) */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.brand-panel { display: none; }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 28px 24px; }
.auth-card-wide { max-width: 520px; }
.auth-mobile-logo { display: block; width: 200px; height: auto; margin: -8px auto 12px; border-radius: 10px; }
.auth-foot { max-width: 420px; text-align: center; font-size: .8rem; color: var(--muted); margin-top: 16px; }
.steps { padding-left: 20px; color: var(--muted); }
.qr-box { display: flex; justify-content: center; margin: 12px 0; }
.qr-box img { border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: #fff; }
.manual-key { margin-bottom: 16px; font-size: .9rem; } .manual-key summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--link); }
.manual-key code { display: block; padding: 10px; background: var(--tint); border-radius: 8px; word-break: break-all; letter-spacing: .08em; }
.codes { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.codes li { background: var(--tint); border-radius: 8px; padding: 8px 10px; text-align: center; }
@media (min-width: 960px) {
  .auth-shell { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
  .brand-panel { display: flex; align-items: center; justify-content: center; padding: 48px; color: #fff;
    background: radial-gradient(1200px 700px at 30% 40%, #05306e 0%, #021f50 45%, #021332 100%); }
  .brand-inner { max-width: 520px; }
  .brand-logo { width: 100%; height: auto; margin: 0 0 24px -8px; }
  .brand-panel h2 { color: #fff; font-size: 1.5rem; }
  .brand-purpose { font-size: 1.05rem; line-height: 1.6; color: #d7e6f7; }
  .brand-points { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 10px; }
  .brand-points li { padding-left: 28px; position: relative; color: #e8f1fb; }
  .brand-points li::before { content: ''; position: absolute; left: 0; top: .35em; width: 14px; height: 14px; border-radius: 50%; background: var(--azure); box-shadow: 0 0 0 4px rgba(22, 136, 219, .25); }
  .auth-mobile-logo { display: none; }
  .auth-card { padding: 36px 32px; }
}

/* App layout */
.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--navy); color: #dbe7f5; padding: 16px 12px; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand-logo, .sidebar-brand img { mix-blend-mode: lighten; }
.sidebar-brand img { width: 100%; max-width: 190px; height: auto; display: block; margin: 0 auto 12px; }
.nav-group { display: grid; gap: 2px; }
.nav-label { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: #9db3cc; margin: 16px 10px 4px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 8px; color: #dbe7f5; text-decoration: none; font-weight: 500; }
.nav-link:hover { background: rgba(255, 255, 255, .08); }
.nav-link.is-active { background: var(--blue); color: #fff; box-shadow: inset 3px 0 0 var(--azure); }
.nav-link.is-soon { color: #9db3cc; cursor: default; }
.nav-link.is-soon:hover { background: none; }
.nav-link small { margin-left: auto; white-space: nowrap; font-size: .7rem; color: #9db3cc; }
.icon { flex: none; }
.app-content { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar-spacer { flex: 1; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; border-radius: 8px; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--tint); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; } .user-meta small { font-size: .75rem; }
.page { padding: 24px 20px 48px; max-width: 1200px; width: 100%; }
.page-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
body.sidebar-closed .app-shell { grid-template-columns: 0 minmax(0, 1fr); }
body.sidebar-closed .sidebar { display: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-link { text-decoration: none; color: inherit; display: block; }
.card-link:hover { border-color: var(--azure); }
.card-attn { border-left: 4px solid var(--azure); }
.card-kicker { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.card p:last-child { margin-bottom: 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.kvs { margin: 0 0 12px; } .kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; text-align: right; }
.badge-soft { background: var(--tint); }
.stack { display: grid; gap: 16px; margin-bottom: 28px; }
.pending { display: grid; gap: 12px; }
.pending p { margin: 0; }
.empty-card { margin-bottom: 28px; }
section + section { margin-top: 28px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters input { max-width: 320px; } .filters select { max-width: 220px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--tint); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.center-msg { max-width: 520px; margin: 48px auto; text-align: center; }
dialog { border: 0; border-radius: 12px; padding: 24px; max-width: 420px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(8, 20, 40, .6); }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 16px; }

@media (max-width: 859px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 20; transform: translateX(-100%); height: 100vh; transition: transform .2s; }
  body:not(.sidebar-closed) .sidebar { transform: translateX(0); }
  body.sidebar-closed .app-shell { grid-template-columns: minmax(0, 1fr); }
  body.sidebar-closed .sidebar { display: flex; transform: translateX(-100%); }
  .user-meta { display: none; }
  .btn-ghost span { display: none; }
}

/* Phase 2: library and onboarding */
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.alert-warn { background: var(--warn-bg); border-color: #d99a00; }
progress { width: 100%; height: 10px; border: 0; border-radius: 99px; overflow: hidden; background: var(--tint); accent-color: var(--green); }
progress::-webkit-progress-bar { background: var(--tint); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--green); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--green); border-radius: 99px; }
.ms { border-left: 3px solid var(--border); margin: 0 0 20px 8px; padding-left: 18px; }
.ms.is-done { border-color: var(--green); } .ms.is-cur { border-color: var(--azure); }
.task { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task-main { flex: 1 1 260px; min-width: 0; }
.task-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.task-actions .field { margin: 0; min-width: 110px; }
.task-actions .field input, .task-actions .field select { min-height: 40px; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 6px 0; }
.checks label { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; min-height: 36px; }
.checks input { width: auto; min-height: 0; }
.drop-note { border: 2px dashed var(--border); border-radius: 10px; padding: 14px; background: var(--tint); }
input[type='file'] { padding: 8px 10px; }
textarea { width: 100%; min-height: 84px; padding: 10px 14px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; resize: vertical; }
.btn-row form { margin: 0; }
.plain { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.plain legend { padding: 0; font-size: .88rem; font-weight: 600; margin-bottom: 4px; }
.mb { margin-bottom: 18px; } .center { align-items: center; } .flush { margin: 0; } .flush-top { margin: 4px 0 0; }
.wide-cell { min-width: 150px; }
.form .btn:not(.btn-block) { justify-self: start; }
.card .table-wrap { margin-bottom: 16px; }
.badge { text-transform: none; }
.badge::first-letter { text-transform: uppercase; }
.row { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.row > * { flex: 1 1 200px; min-width: 0; }
.row .field { margin-bottom: 12px; }
.form .row .field { margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; margin-bottom: 20px; }
.page h2 { margin-top: 26px; }
.page .card h2, .page .page-head h2 { margin-top: 0; }
.field > .field-msg { margin-bottom: 0; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.answer-text p { margin: 0 0 .7em; }
.sources { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
mark { background: #cfe6fb; color: inherit; padding: 0 2px; border-radius: 3px; }
:root[data-theme='dark'] mark { background: #1d4f80; }
.btn-row .btn-small { white-space: normal; text-align: left; }
