*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--hl-ink);
  background: var(--hl-bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; letter-spacing: -.005em; color: var(--hl-navy-900); margin: 0; line-height: 1.2; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--hl-navy-700); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--hl-navy-300); outline-offset: 2px; }
.muted { color: var(--hl-ink-2); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; color: var(--hl-ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1.1rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; font-weight: 500;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--hl-navy-900); color: #fff; }
.btn-primary:hover { background: var(--hl-navy-950); }
.btn-accent { background: #fff; color: var(--hl-navy-900); font-weight: 600; }
.btn-accent:hover { background: var(--hl-navy-100); }
.btn-ghost { background: transparent; border-color: var(--hl-line); color: var(--hl-ink); }
.btn-ghost:hover { background: var(--hl-white); border-color: var(--hl-ink-3); }
.btn-danger { background: var(--bad-bg); color: var(--bad); }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: none; padding: 0; color: var(--hl-navy-700); cursor: pointer; text-decoration: underline; }

/* ---------- Forms ---------- */
.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field label { font-weight: 500; font-size: .9rem; }
.input, .select, .textarea {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--hl-line);
  border-radius: var(--radius-sm); background: var(--hl-white);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--hl-navy-700); box-shadow: 0 0 0 3px var(--hl-navy-100); }
.textarea { min-height: 90px; resize: vertical; }
.field-error { color: var(--bad); font-size: .85rem; }
.otp { display: flex; gap: .5rem; justify-content: center; }
.otp input { width: 3rem; height: 3.4rem; text-align: center; font-size: 1.4rem; border: 1px solid var(--hl-line); border-radius: var(--radius-sm); background: #fff; }
.otp input:focus { outline: none; border-color: var(--hl-navy-700); box-shadow: 0 0 0 3px var(--hl-navy-100); }

/* ---------- Cards & layout ---------- */
.card { background: var(--hl-white); border: 1px solid var(--hl-line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 1.25rem 1.4rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.4rem; border-bottom: 1px solid var(--hl-line); flex-wrap: wrap; }
.stack { display: grid; gap: 1.25rem; }
.stack > *, .grid-2 > *, .card { min-width: 0; }
.activity, .kv dd, .check-title { overflow-wrap: anywhere; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 960px) { .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--hl-navy-900); color: #D9DDF0; padding: 1.25rem 1rem;
  display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh;
}
.brand { display: block; text-decoration: none; padding: .25rem .25rem 0; }
.brand img { display: block; width: 100%; max-width: 200px; height: auto; }
.nav { display: grid; gap: .2rem; }
.nav a {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: var(--radius-sm);
  color: #D9DDF0; text-decoration: none; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 3px 0 0 var(--hl-navy-300); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; background: #fff; color: var(--hl-navy-900); font-size: .72rem; font-weight: 600; border-radius: 99px; padding: 0 .45rem; }
.sidebar-foot { margin-top: auto; font-size: .78rem; color: #A3A9C8; display: grid; gap: .6rem; }
.sidebar-foot .lock { display: flex; gap: .5rem; align-items: flex-start; }
.sidebar-foot svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--hl-navy-300); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem 2rem; background: var(--hl-white); border-bottom: 1px solid var(--hl-line);
  position: sticky; top: 0; z-index: 5;
}
.topbar .who { display: flex; align-items: center; gap: .75rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--hl-navy-100); color: var(--hl-navy-700); display: grid; place-items: center; font-weight: 600; font-size: .85rem; }
.content { padding: 2rem; max-width: 1200px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head p { margin-top: .3rem; }
.role-pill { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; padding: .2rem .55rem; border-radius: 99px; background: var(--hl-navy-100); color: var(--hl-navy-900); font-weight: 600; }

.menu-toggle { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: .75rem 1rem; }
  .topbar > .row, .topbar .who > .small, .topbar [data-logout] span { display: none; }
  .content { padding: 1.25rem 1rem; }
}

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  background: var(--hl-navy-900); color: #E3E6F5; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-art .watermark { position: absolute; right: -12%; bottom: -14%; width: 62%; max-width: 520px; opacity: .045; pointer-events: none; }
.auth-art .brand img { max-width: 300px; }
.auth-art > div:first-child { margin-bottom: 2.5rem; }
.auth-logo-mobile { display: none; }
.auth-art h1 { color: #fff; font-size: 2.3rem; max-width: 18ch; }
.auth-art p { color: #C3C9E6; max-width: 42ch; margin-top: 1rem; }
.trust { display: grid; gap: .8rem; margin-top: 2rem; position: relative; z-index: 1; }
.trust div { display: flex; gap: .7rem; align-items: center; color: #E3E6F5; font-size: .92rem; }
.trust svg { width: 20px; height: 20px; color: var(--hl-navy-300); flex: none; }
.auth-form { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h2 { font-size: 1.6rem; margin-bottom: .35rem; }
.auth-box > p { margin-bottom: 1.5rem; }
.demo-hint { margin-top: 1.5rem; padding: .85rem 1rem; border-radius: var(--radius-sm); background: var(--hl-navy-100); font-size: .85rem; color: var(--hl-ink-2); }
.demo-hint code { background: rgba(255,255,255,.7); padding: 0 .3rem; border-radius: 4px; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-art { padding: 2rem 1.25rem 2.5rem; } .auth-art .brand img { max-width: 230px; } .auth-art h1 { font-size: 1.7rem; } }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; padding: .15rem .55rem; border-radius: 99px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-bad { color: var(--bad); background: var(--bad-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-neutral { color: var(--hl-ink-2); background: #ECEDF3; }

/* ---------- Status tracker ---------- */
.tracker { display: grid; grid-template-columns: repeat(var(--steps), 1fr); position: relative; counter-reset: step; }
.tracker-step { display: grid; justify-items: center; text-align: center; gap: .5rem; position: relative; padding: 0 .25rem; }
.tracker-step::before {
  content: ""; position: absolute; top: 15px; left: -50%; width: 100%; height: 3px; background: var(--hl-line); z-index: 0;
}
.tracker-step:first-child::before { display: none; }
.tracker-step.done::before, .tracker-step.current::before { background: var(--hl-navy-700); }
.tracker-dot {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; z-index: 1;
  background: var(--hl-white); border: 2px solid var(--hl-line); color: var(--hl-ink-3); font-weight: 600; font-size: .85rem;
}
.tracker-step.done .tracker-dot { background: var(--hl-navy-700); border-color: var(--hl-navy-700); color: #fff; }
.tracker-step.current .tracker-dot { border-color: var(--hl-navy-500); background: var(--hl-navy-100); color: var(--hl-navy-700); box-shadow: 0 0 0 5px rgba(82,99,184,.15); }
.tracker-label { font-size: .8rem; color: var(--hl-ink-2); max-width: 12ch; }
.tracker-step.current .tracker-label { color: var(--hl-ink); font-weight: 600; }
@media (max-width: 640px) {
  .tracker { grid-template-columns: 1fr; gap: .9rem; }
  .tracker-step { grid-template-columns: 32px 1fr; justify-items: start; text-align: left; align-items: center; }
  .tracker-step::before { left: 15px; top: -22px; width: 3px; height: 22px; }
  .tracker-label { max-width: none; }
}

/* ---------- Checklist ---------- */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: grid; grid-template-columns: 28px 1fr auto; gap: .8rem; align-items: center; padding: .85rem 1.4rem; border-bottom: 1px solid var(--hl-line); }
.checklist li:last-child { border-bottom: none; }
.check-ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; }
.check-ico svg { width: 15px; height: 15px; }
.check-ico.needed { border: 2px dashed var(--hl-ink-3); }
.check-ico.uploaded { background: var(--info-bg); color: var(--info); }
.check-ico.accepted { background: var(--ok); color: #fff; }
.check-ico.attention { background: var(--bad-bg); color: var(--bad); }
.check-title { font-weight: 500; }
.check-note { font-size: .82rem; color: var(--hl-ink-2); }
.check-note.bad { color: var(--bad); }

/* ---------- Progress meter ---------- */
.meter { height: 8px; background: #ECEDF3; border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--hl-navy-700), var(--hl-navy-500)); border-radius: 99px; transition: width .3s; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed #C3C8DA; border-radius: var(--radius-lg); background: #FAFBFD;
  padding: 2.5rem 1.5rem; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--hl-navy-700); background: var(--hl-navy-100); }
.dropzone svg { width: 44px; height: 44px; color: var(--hl-navy-700); }
.dropzone strong { display: block; font-size: 1.05rem; margin: .6rem 0 .25rem; color: var(--hl-navy-900); }
.upload-list { display: grid; gap: .75rem; margin-top: 1.25rem; }
.upload-item {
  display: grid; grid-template-columns: 40px minmax(0,1fr) auto; grid-template-areas: "ico info act" "sel sel sel";
  gap: .7rem .9rem; align-items: center; padding: .85rem 1rem; border: 1px solid var(--hl-line); border-radius: var(--radius); background: #fff;
}
.upload-item > :nth-child(1) { grid-area: ico; }
.upload-item > :nth-child(2) { grid-area: info; }
.upload-item > :nth-child(3) { grid-area: sel; }
.upload-item > :nth-child(3):empty { display: none; }
.upload-item > :nth-child(4) { grid-area: act; }
.btn svg { width: 16px; height: 16px; flex: none; }
.upload-item .fname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-ico { width: 40px; height: 40px; border-radius: 8px; background: var(--hl-navy-100); color: var(--hl-navy-700); display: grid; place-items: center; font-size: .65rem; font-weight: 700; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; position: relative; }
.review-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .55rem; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--hl-ink-3); padding: .7rem 1.4rem; border-bottom: 1px solid var(--hl-line); background: var(--hl-navy-50); white-space: nowrap; }
.table td { padding: .8rem 1.4rem; border-bottom: 1px solid var(--hl-line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--hl-navy-50); }
.doc-name { display: flex; align-items: center; gap: .7rem; font-weight: 500; }
.doc-name .file-ico { width: 32px; height: 32px; font-size: .58rem; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--hl-ink-2); }

/* ---------- Stats ---------- */
.stat { padding: 1.1rem 1.25rem; }
.stat .label { font-size: .8rem; color: var(--hl-ink-2); }
.stat .value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; color: var(--hl-navy-900); line-height: 1.1; margin-top: .2rem; }

/* ---------- Messages ---------- */
.thread { display: flex; flex-direction: column; gap: 1rem; padding: 1.25rem 1.4rem; max-height: 520px; overflow-y: auto; }
.msg { max-width: 75%; display: grid; gap: .25rem; }
.msg .bubble { padding: .75rem 1rem; border-radius: 14px; background: #EEF0F6; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; }
.msg.mine .bubble { background: var(--hl-navy-900); color: #fff; border-bottom-right-radius: 4px; }
.msg:not(.mine) .bubble { border-bottom-left-radius: 4px; }
.msg.mine .meta { text-align: right; }
.msg .meta { font-size: .75rem; color: var(--hl-ink-3); }
.composer { display: flex; gap: .75rem; padding: 1rem 1.4rem; border-top: 1px solid var(--hl-line); align-items: flex-end; }
.composer textarea { min-height: 46px; height: 46px; }

/* ---------- Callouts ---------- */
.callout { display: flex; gap: .9rem; padding: 1rem 1.2rem; border-radius: var(--radius); align-items: flex-start; }
.callout svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.callout-accent { background: var(--warn-bg); border: 1px solid #F0DDB0; }
.callout-accent svg { color: var(--warn); }
.callout-info { background: var(--info-bg); }
.callout-info svg { color: var(--info); }
.callout-ok { background: var(--ok-bg); }
.callout-ok svg { color: var(--ok); }
.hero-action { background: linear-gradient(120deg, var(--hl-navy-900), var(--hl-navy-700)); color: #fff; border: none; }
.hero-action h2 { color: #fff; }
.hero-action p { color: #D5DAF2; }

.contact { display: flex; gap: .9rem; align-items: center; }
.contact .avatar { width: 46px; height: 46px; font-size: 1rem; background: var(--hl-navy-100); color: var(--hl-navy-900); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1rem; font-size: .9rem; }
.kv dt { color: var(--hl-ink-2); }
.kv dd { margin: 0; font-weight: 500; }

.activity { list-style: none; margin: 0; padding: 0 1.4rem; }
.activity li { padding: .75rem 0; border-bottom: 1px solid var(--hl-line); display: grid; gap: .1rem; font-size: .9rem; }
.activity li:last-child { border-bottom: none; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--hl-line); padding: 0 1rem; overflow-x: auto; }
.tabs button { background: none; border: none; padding: .85rem .8rem; cursor: pointer; color: var(--hl-ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--hl-navy-900); border-bottom-color: var(--hl-navy-500); }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--hl-line); background: #fff; border-radius: 99px; padding: .3rem .8rem; font-size: .85rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--hl-navy-900); color: #fff; border-color: var(--hl-navy-900); }

/* ---------- Toasts & modal ---------- */
.toasts { position: fixed; bottom: 1.25rem; right: 1.25rem; display: grid; gap: .5rem; z-index: 100; }
.toast { background: var(--hl-navy-900); color: #fff; padding: .8rem 1.1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .9rem; max-width: 360px; animation: rise .2s ease-out; }
.toast.bad { background: var(--bad); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 30, 25, .45); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; }
.modal-head { padding: 1.25rem 1.5rem .5rem; }
.modal-body { padding: .5rem 1.5rem 1rem; }
.modal-foot { padding: 1rem 1.5rem 1.25rem; display: flex; justify-content: flex-end; gap: .6rem; }
