/* MPA Client Portal — design tokens and components.
   Source of truth for the look: the "Client Portal" design canvas. */

:root {
  --ink: #13202A;
  --ink-2: #24323D;
  --ink-line: #33424E;
  --text: #13202A;
  --text-2: #33404A;
  --muted: #55606A;
  --muted-on-ink: #A9B4BC;
  --soft-on-ink: #C9D1D6;
  --paper: #F3F4F1;
  --paper-2: #F8F9F6;
  --surface: #FFFFFF;
  --line: #DADDD6;
  --line-soft: #ECEEE9;
  --field: #C7CCC4;
  --accent: #1D4F63;
  --accent-tint: #E3ECEF;
  --accent-wash: #F1F6F7;
  --accent-light: #7FB3C4;
  --ok: #1F8A5E;
  --ok-text: #0F4A3A;
  --ok-bg: #D9EEE6;
  --warn: #C2410C;
  --warn-text: #7A410C;
  --warn-bg: #F6E7D6;
  --danger: #8A2A1F;
  --danger-line: #E2C3BE;
  --neutral: #5C666E;

  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 4px;
  --radius-lg: 6px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--paper); line-height: 1.4; }
a { color: var(--accent); }
a:hover { color: var(--ink); }
h1, h2, h3, p { margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* ---------- Brand mark ---------- */
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; font-size: 15px; font-weight: 600; }
.brand svg { flex: none; }
.brand-sub { font-family: var(--mono); font-size: 11px; color: var(--muted-on-ink); letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; font-weight: 400; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label, .label { font-size: 14px; font-weight: 500; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; }
.input, .select {
  height: 48px; padding: 0 14px; font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--field); border-radius: var(--radius); width: 100%;
}
.input-sm, .select-sm { height: 44px; font-size: 14px; padding: 0 12px; }
.input:focus, .select:focus, .btn:focus-visible, a:focus-visible, .choice:focus-within {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search .input { padding-left: 40px; height: 44px; font-size: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px;
  font: inherit; font-size: 14px; font-weight: 600; border-radius: var(--radius); border: 1px solid transparent;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #163E4E; color: #fff; }
.btn:disabled { opacity: .7; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--field); font-weight: 500; }
.btn-secondary:hover { background: var(--paper-2); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger-line); font-weight: 500; }
.btn-ghost { background: none; color: var(--muted); font-weight: 500; }
.btn-block { width: 100%; height: 48px; font-size: 15px; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 14px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; font-size: 14px; color: var(--muted); text-decoration: underline; cursor: pointer; }

/* ---------- Cards / panels ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.card-pad { padding: 28px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.note { display: flex; gap: 12px; align-items: flex-start; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; line-height: 1.5; color: var(--muted); }
.note svg { flex: none; margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 14px; }
.count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.table th { text-align: left; padding: 14px 16px; font-weight: 500; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); }
.table td { padding: 18px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 24px; }
.table th:last-child, .table td:last-child { padding-right: 24px; }
.table .num { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.table .right { text-align: right; }
.cell-file { display: flex; align-items: center; gap: 14px; }
.cell-title { font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cell-sub { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 3px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

/* ---------- Tags / pills ---------- */
.tag { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--warn-text); background: var(--warn-bg); padding: 3px 7px; border-radius: 3px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 12px; }
.pill-active { color: var(--ok-text); background: var(--ok-bg); }
.pill-invited { color: var(--warn-text); background: var(--warn-bg); }
.pill-disabled { color: #fff; background: var(--neutral); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-info { background: #8C969E; }

/* ---------- Chips (filters) ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; font-size: 14px; font-weight: 500; color: var(--text); background: var(--surface); border: 1px solid var(--field); border-radius: 20px; text-decoration: none; }
.chip[aria-current="true"] { color: #fff; background: var(--ink); border-color: var(--ink); font-weight: 600; }

/* ---------- Auth: split sign-in ---------- */
.split { min-height: 100vh; display: flex; flex-wrap: wrap; }
.split-brand {
  flex: 1 1 480px; min-width: 0; min-height: 420px; background: var(--ink); color: var(--paper);
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 48px 56px;
}
.split-brand .rings { position: absolute; right: -260px; bottom: -280px; }
.split-brand > *:not(.rings) { position: relative; }
.split-brand .pitch { max-width: 460px; padding: 64px 0; }
.split-brand .eyebrow { color: var(--muted-on-ink); margin-bottom: 20px; }
.split-brand h2 { font-size: 44px; line-height: 1.08; font-weight: 600; letter-spacing: -.02em; }
.split-brand .pitch p { margin-top: 20px; font-size: 17px; line-height: 1.55; color: var(--soft-on-ink); }
.split-brand .facts { display: flex; flex-wrap: wrap; gap: 8px 24px; font-family: var(--mono); font-size: 12px; color: var(--muted-on-ink); }
.split-form { flex: 1 1 480px; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h1 { font-size: 30px; font-weight: 600; letter-spacing: -.015em; }
.auth-box .lede { margin: 8px 0 32px; font-size: 15px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 20px; }
.auth-foot { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.55; color: var(--muted); }
.auth-foot .mono { color: var(--text); }

/* ---------- Auth: verify ---------- */
.centered { min-height: 100vh; display: flex; flex-direction: column; }
.centered header { padding: 28px 24px; display: flex; justify-content: center; }
.centered main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 24px 80px; }
.verify-card { width: 100%; max-width: 440px; padding: 40px 36px; }
.icon-badge { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-tint); display: flex; align-items: center; justify-content: center; margin-bottom: 24px; }
.verify-card h1 { font-size: 26px; font-weight: 600; letter-spacing: -.015em; }
.verify-card .lede { margin: 10px 0 28px; font-size: 15px; line-height: 1.5; color: var(--muted); }
.code-input { height: 56px; text-align: center; font-family: var(--mono); font-size: 24px; letter-spacing: .5em; padding-left: .5em; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.card-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line-soft); font-size: 14px; }

/* ---------- Client app shell ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1160px; margin: 0 auto; padding: 0 24px; min-height: 68px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 32px; }
.topbar-left { display: flex; align-items: center; gap: 40px; flex-wrap: wrap; }
.topnav { display: flex; gap: 4px; }
.topnav a { padding: 10px 14px; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; border-radius: var(--radius); }
.topnav a[aria-current="page"] { color: var(--text); font-weight: 600; background: var(--paper); }
.user { display: flex; align-items: center; gap: 16px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: var(--paper); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.user-name { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.page { max-width: 1160px; margin: 0 auto; padding: 56px 24px 80px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 40px; }
.page-head h1 { font-size: 40px; font-weight: 600; letter-spacing: -.02em; margin-top: 12px; }
.stats { display: flex; gap: 40px; }
.stat-value { font-family: var(--mono); font-size: 26px; font-weight: 500; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 2px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.toolbar .search { flex: 0 1 320px; min-width: 220px; }
.card-head .search { flex: 0 1 300px; min-width: 200px; }
.page-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 32px; font-size: 14px; color: var(--muted); }
.page-foot .mono { color: var(--text); }

/* ---------- Admin shell ---------- */
.admin { min-height: 100vh; display: flex; flex-wrap: wrap; }
.sidebar { flex: 1 1 240px; max-width: 100%; background: var(--ink); color: var(--paper); padding: 28px 16px; display: flex; flex-direction: column; gap: 32px; }
.sidebar .brand { padding: 0 8px; font-size: 14px; }
.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius); color: var(--soft-on-ink); font-size: 14px; text-decoration: none; }
.sidenav a:hover { background: var(--ink-2); color: #fff; }
.sidenav a[aria-current="page"] { background: var(--ink-2); color: #fff; font-weight: 600; }
.drive-status { margin-top: auto; display: block; padding: 14px; border: 1px solid var(--ink-line); border-radius: var(--radius-lg); color: var(--paper); text-decoration: none; }
.drive-status:hover { color: #fff; border-color: var(--muted); }
.drive-status-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.drive-status-title .dot { width: 8px; height: 8px; background: #5FC9A0; }
.drive-status .mono { display: block; font-size: 11px; color: var(--muted-on-ink); margin-top: 4px; overflow-wrap: anywhere; }
.admin-main { flex: 999 1 560px; min-width: 0; padding: 40px 40px 64px; }
.admin-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 28px; }
.admin-head h1 { font-size: 32px; font-weight: 600; letter-spacing: -.02em; }
.admin-head p { margin-top: 6px; font-size: 15px; color: var(--muted); max-width: 640px; line-height: 1.5; }
.cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.col-main { flex: 999 1 520px; min-width: 0; }
.col-side { flex: 1 1 320px; min-width: 0; }
.panel-title { font-size: 18px; font-weight: 600; }
.panel-lede { margin: 4px 0 20px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.dest { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; white-space: nowrap; padding: 10px 12px; background: var(--paper); border-radius: var(--radius); font-size: 13px; color: var(--muted); }
.dest .mono { font-size: 12px; color: var(--text); white-space: normal; overflow-wrap: anywhere; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 16px; border: 1.5px dashed #AEB5AB; border-radius: var(--radius-lg); background: var(--paper-2); text-align: center; cursor: pointer; }
.dropzone strong { font-size: 14px; }
.dropzone .mono { font-size: 12px; color: var(--muted); }
.panel-note { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-soft); font-size: 13px; line-height: 1.5; color: var(--muted); }
.folder { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; color: var(--text-2); white-space: nowrap; }
.client-link { font-weight: 600; color: var(--text); text-decoration: none; }

/* Invite: folder choices */
.step { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.choices { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); cursor: pointer; }
.choice:has(input:checked) { border: 1.5px solid var(--accent); background: var(--accent-wash); }
.choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
.choice-body { flex: 1; min-width: 0; }
.choice-body .mono { display: block; font-size: 13px; }
.choice-body small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.match { font-size: 12px; font-weight: 600; color: var(--ok-text); background: var(--ok-bg); padding: 3px 8px; border-radius: 10px; white-space: nowrap; }
.email-preview { padding: 20px; font-size: 14px; line-height: 1.55; color: var(--text-2); }
.email-preview p + p { margin-top: 12px; }
.email-preview .fake-btn { display: inline-block; margin: 12px 0; padding: 10px 16px; background: var(--accent); color: #fff; font-weight: 600; border-radius: var(--radius); }

/* Drive page */
.conn { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 24px; }
.conn-id { display: flex; align-items: center; gap: 14px; }
.tile-icon { width: 44px; height: 44px; border-radius: var(--radius-lg); background: var(--accent-tint); display: flex; align-items: center; justify-content: center; }
.conn-state { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.conn-state .dot { width: 8px; height: 8px; background: var(--ok); }
.facts-grid { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); border-top: 1px solid var(--line-soft); }
.facts-grid > div { padding: 18px 24px; border-right: 1px solid var(--line-soft); }
.facts-grid > div:last-child { border-right: 0; }
.facts-grid dt { font-size: 13px; color: var(--muted); }
.facts-grid dd { margin: 6px 0 0; font-family: var(--mono); font-size: 14px; }
.check-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 16px 24px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.check-row:last-child { border-bottom: 0; }
.check-row .label-text { flex: 1 1 260px; }
.steps { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.steps li { padding: 20px; }
.steps strong { display: block; font-size: 15px; margin-top: 8px; }
.steps p { margin-top: 6px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.section-gap { margin-top: 24px; }
.section-title { font-size: 17px; font-weight: 600; margin-bottom: 14px; }

/* Facilities & departments */
.user-org { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.access-line { margin-top: 14px; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.dept-pill { display: inline-block; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-tint); padding: 3px 9px; border-radius: 10px; white-space: nowrap; }
.dept-pill.off { color: var(--muted); background: transparent; border: 1px dashed var(--field); font-weight: 500; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.dept-list { list-style: none; margin: 0; padding: 0; }
.dept-list li { padding: 14px 20px; border-bottom: 1px solid var(--line-soft); }
.dept-list li:last-child { border-bottom: 0; }
.dept-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.dept-head strong { font-size: 15px; }
.dept-meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.dept-warn { color: var(--warn-text); }
.checks { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.facility-link { font-weight: 600; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.facility-link:hover { color: var(--accent); }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.meta-row .mono { color: var(--text-2); font-size: 12px; }

/* Sign-in feedback */
.form-error { margin: 0; padding: 12px 14px; border-radius: var(--radius); background: #FBEAE7; color: var(--danger); font-size: 14px; line-height: 1.45; border: 1px solid var(--danger-line); }
.signed-in { margin-top: -20px; padding: 0 8px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.signed-in-name { color: var(--paper); font-weight: 600; overflow-wrap: anywhere; }
.linklike.on-ink { color: var(--soft-on-ink); font-size: 13px; text-align: left; }

/* Admin feedback and forms */
.flash { margin: 0 0 20px; padding: 12px 14px; border-radius: var(--radius); font-size: 14px; line-height: 1.45; border: 1px solid var(--line); background: var(--surface); }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.flash-error { background: #FBEAE7; color: var(--danger); border-color: var(--danger-line); }
.flash-notice { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.drive-status-title .dot-off { background: transparent; border: 1.5px solid var(--muted-on-ink); }
.add-inline { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-soft); }
.add-inline .input { flex: 1; min-width: 0; }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { flex: 1; min-width: 0; font-size: 13px; }
.textarea { height: auto; padding: 12px; font-size: 14px; line-height: 1.5; resize: vertical; width: 100%; }
.next-steps, .setup-steps { margin: 12px 0 0; padding-left: 20px; font-size: 14px; line-height: 1.5; color: var(--text-2); }
.next-steps li + li, .setup-steps li + li { margin-top: 6px; }
.hint { margin: 6px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }

/* Account setup */
.setup-steps { margin: 0 0 20px; }
.qr { display: flex; justify-content: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; }
.qr img { display: block; width: 200px; height: 200px; }
.manual-key { margin-top: 14px; font-size: 14px; color: var(--muted); }
.manual-key summary { cursor: pointer; color: var(--accent); }
.manual-key p { margin-top: 8px; }
.manual-key .key { font-size: 15px; color: var(--text); letter-spacing: .04em; overflow-wrap: anywhere; }

/* Demo banner */
.demo-banner { background: var(--warn-bg); color: var(--warn-text); font-size: 13px; text-align: center; padding: 8px 16px; }

/* Error page */
.error-page { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.error-page h1 { font-size: 32px; }

@media (max-width: 640px) {
  .split-brand { padding: 32px 24px; min-height: 0; }
  .split-brand h2 { font-size: 32px; }
  .split-brand .pitch { padding: 40px 0; }
  .admin-main { padding: 28px 16px 48px; }
  .page { padding: 32px 16px 56px; }
  .page-head h1 { font-size: 32px; }
  .card-pad { padding: 20px; }
}
