:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #14213d;
  --muted: #5d6b85;
  --border: #e1e6f0;
  --primary: #0b3d91;
  --primary-ink: #ffffff;
  --primary-soft: #e7eefb;
  --accent: #0e9f8e;
  --accent-soft: #e0f5f2;
  --accent-ink: #0e9f8e;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #b7791f;
  --warn-soft: #fff6e0;
  --ok: #1e8e4f;
  --ok-soft: #e5f6ec;
  --info: #2563eb;
  --info-soft: #e8f0fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 16px rgba(20, 33, 61, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1.25rem;
  background: var(--primary); color: var(--primary-ink);
  border-bottom: 3px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,.15); }
.nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.nav a, .nav button {
  color: #dbe5f7; text-decoration: none; background: none; border: 0; font: inherit;
  padding: .45rem .75rem; border-radius: 8px; cursor: pointer;
}
.nav a:hover, .nav button:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: var(--accent); }
.nav .who { color: #b7c7e6; font-size: .85rem; padding: 0 .5rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head p { color: var(--muted); margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.stat:hover, .stat.active { border-color: var(--primary); }
.stat .num { font-size: 1.6rem; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: .82rem; }

/* ---------- auth ---------- */
.auth-wrap { display: grid; grid-template-columns: 1.1fr 1fr; gap: 2rem; align-items: center; min-height: calc(100vh - 140px); }
.hero h1 { font-size: 2.1rem; }
.hero .eyebrow { display: inline-block; color: var(--accent-ink); background: var(--accent-soft); font-weight: 700; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; padding: .3rem .7rem; border-radius: 999px; margin-bottom: .75rem; }
.hero p { color: var(--muted); font-size: 1.05rem; }
.hero ul { list-style: none; padding: 0; margin: 1.25rem 0 0; display: grid; gap: .6rem; }
.hero li { display: flex; gap: .6rem; align-items: flex-start; }
.hero li .dot { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: .75rem; font-weight: 700; }
@media (max-width: 820px) { .auth-wrap { grid-template-columns: 1fr; min-height: 0; } .hero h1 { font-size: 1.6rem; } }
.tabs { display: flex; gap: .25rem; background: var(--surface-2); border: 1px solid var(--border); padding: .25rem; border-radius: 10px; margin-bottom: 1rem; }
.tabs button { flex: 1; border: 0; background: none; padding: .55rem; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- forms ---------- */
form { display: grid; gap: .85rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .88rem; }
label .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input, select, textarea {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; padding: .6rem .75rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; border-radius: 9px; padding: .6rem 1.05rem; cursor: pointer;
  border: 1px solid transparent; background: var(--primary); color: var(--primary-ink); text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.ghost { background: none; color: var(--primary); padding: .35rem .6rem; }
.btn.danger { background: none; color: var(--danger); padding: .35rem .6rem; }
.btn.small { padding: .35rem .7rem; font-size: .85rem; }
.btn.block { width: 100%; }

.error { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: .55rem .75rem; font-size: .88rem; }
.notice { background: var(--warn-soft); color: #7a4f0e; border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1rem; }
.notice.info { background: var(--info-soft); color: #1d3f91; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.pad { padding: 2rem 0; }
.spacer { flex: 1; }

/* ---------- status badges ---------- */
.badge { display: inline-block; font-size: .76rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.badge.s-received { background: var(--info-soft); color: var(--info); }
.badge.s-review { background: #efe9fd; color: #6a3fc9; }
.badge.s-required { background: var(--warn-soft); color: var(--warn); }
.badge.s-ready { background: var(--accent-soft); color: var(--accent-ink); }
.badge.s-submitted { background: var(--primary-soft); color: var(--primary); }
.badge.s-approved { background: var(--ok-soft); color: var(--ok); }
.badge.s-rejected { background: var(--danger-soft); color: var(--danger); }

/* ---------- application cards ---------- */
.app-card { display: grid; gap: .6rem; text-decoration: none; color: inherit; }
.app-card:hover { border-color: var(--primary); }
.app-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.app-card .dest { font-size: 1.1rem; font-weight: 700; }
.app-card .meta { color: var(--muted); font-size: .85rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.ref { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: .85rem; color: var(--muted); }
.flag-ready { color: var(--accent-ink); font-weight: 600; font-size: .85rem; }

/* ---------- progress stepper ---------- */
.stepper { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; margin: .5rem 0 0; padding: 0; list-style: none; }
.stepper li { display: grid; gap: .35rem; font-size: .75rem; color: var(--muted); }
.stepper li::before { content: ''; height: 6px; border-radius: 3px; background: var(--border); }
.stepper li.done::before { background: var(--primary); }
.stepper li.current { color: var(--text); font-weight: 700; }
.stepper li.current::before { background: var(--accent); }
.stepper.rejected li.current::before { background: var(--danger); }
@media (max-width: 560px) { .stepper li span { display: none; } .stepper li.current span { display: block; } }

/* ---------- documents ---------- */
.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.doc { display: flex; align-items: center; gap: .75rem; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.doc .icon { flex: none; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: .7rem; font-weight: 700; }
.doc.staff .icon { background: var(--accent-soft); color: var(--accent-ink); }
.doc .info { min-width: 0; flex: 1; }
.doc .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .sub { color: var(--muted); font-size: .8rem; }
.doc .actions { display: flex; gap: .25rem; flex: none; }

.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.checklist li { display: flex; gap: .5rem; align-items: center; font-size: .9rem; }
.checklist .tick { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; border: 2px solid var(--border); color: transparent; flex: none; }
.checklist li.ok .tick { background: var(--ok); border-color: var(--ok); color: #fff; }

.dropzone { border: 2px dashed var(--border); border-radius: 10px; padding: 1rem; text-align: center; color: var(--muted); background: var(--surface-2); cursor: pointer; }
.dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone strong { color: var(--primary); }
.dropzone input { display: none; }
.dropzone .chosen { color: var(--text); font-weight: 600; margin-top: .3rem; word-break: break-all; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.timeline li { position: relative; padding-left: 1.4rem; }
.timeline li::before { content: ''; position: absolute; left: 0; top: .4rem; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline li::after { content: ''; position: absolute; left: 4px; top: 1.1rem; bottom: -1rem; width: 2px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .when { color: var(--muted); font-size: .8rem; }
.timeline .comment { background: var(--surface-2); border-radius: 8px; padding: .45rem .65rem; margin-top: .3rem; font-size: .9rem; white-space: pre-wrap; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input { flex: 1; min-width: 200px; }
.filters select { width: auto; }

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0; font-size: .9rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 500; word-break: break-word; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty h2 { color: var(--text); }

.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; max-width: calc(100% - 2rem);
}
.toast.err { background: var(--danger); }
.back { display: inline-block; margin-bottom: .75rem; text-decoration: none; font-weight: 600; }

.mt-1 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }

/* ---------- branding ---------- */
.brand-logo { height: 48px; width: auto; max-width: 200px; object-fit: contain; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.footer { background: var(--surface); border-top: 1px solid var(--border); padding: 1.5rem 1rem; color: var(--muted); font-size: .88rem; }
.footer:empty { display: none; }
.footer-inner { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.footer strong { color: var(--text); display: block; margin-bottom: .25rem; }
.footer a { color: var(--primary); text-decoration: none; }
.footer .copy { max-width: 1100px; margin: 1rem auto 0; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .8rem; }
.help-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; font-size: .9rem; }
.help-list a { text-decoration: none; font-weight: 600; }