/* PrivacyOps console. System fonts only (no third-party fonts or trackers). */
:root {
  --paper: #f4f6f5; --surface: #ffffff; --ink: #14202a; --ink-2: #44525c; --ink-3: #6b7780; --rule: #d8dedb; --rule-2: #e8ecea;
  --nav: #0d3b44; --nav-ink: #d7e6e4; --nav-active: #ffffff; --nav-hover: #135059;
  --accent: #0d5f6b; --accent-ink: #ffffff; --attention: #b7791f; --attention-bg: #fbf3e4;
  --granted: #1e7a4c; --granted-bg: #e5f3eb; --withdrawn: #a8321f; --withdrawn-bg: #fbe9e5; --pending: #946200; --pending-bg: #fdf3d9;
  --neutral-bg: #eef1f0; --focus: #e0a526;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", "Sitka Text", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", "Noto Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f171c; --surface: #162128; --ink: #e6ecea; --ink-2: #b6c2c0; --ink-3: #8b9897; --rule: #2c3a41; --rule-2: #223038;
    --nav: #0a2a31; --nav-hover: #10404a; --accent: #5fb3bd; --accent-ink: #0b1c20; --attention: #e0a84f; --attention-bg: #33270f;
    --granted: #6fcf97; --granted-bg: #15301f; --withdrawn: #f08a77; --withdrawn-bg: #3a1d17; --pending: #e7c15a; --pending-bg: #3a2f10; --neutral-bg: #1d2a31;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); font-variant-numeric: tabular-nums; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.005em; color: var(--ink); }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 4px; }
h2 { font-size: 1.25rem; margin: 28px 0 10px; }
h3 { font-size: 1.05rem; margin: 18px 0 6px; }
p { margin: 6px 0; }
.muted { color: var(--ink-3); }
.small { font-size: .86rem; }
.mono { font-family: var(--mono); font-size: .85em; word-break: break-all; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--nav); color: var(--nav-ink); display: flex; flex-direction: column; padding: 18px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .org { padding: 0 18px 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.side .org strong { display: block; font-family: var(--serif); font-size: 1.1rem; color: #fff; }
.side .org select { width: 100%; margin-top: 8px; background: transparent; color: var(--nav-ink); border: 1px solid rgba(255,255,255,.25); border-radius: 4px; padding: 4px; font: inherit; font-size: .85rem; }
.side .org select option { color: #000; }
.side nav { padding: 10px 0; flex: 1; }
.side .group { margin: 14px 0 4px; padding: 0 18px; font-size: .8rem; color: #93b6b3; }
.side a { display: flex; justify-content: space-between; align-items: center; padding: 6px 18px; color: var(--nav-ink); text-decoration: none; border-left: 3px solid transparent; }
.side a:hover { background: var(--nav-hover); color: #fff; }
.side a.active { border-left-color: var(--attention); background: var(--nav-hover); color: var(--nav-active); font-weight: 600; }
.side .count { background: var(--attention); color: #1b1300; border-radius: 9px; padding: 0 7px; font-size: .75rem; font-weight: 700; }
.side .me { padding: 12px 18px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: .85rem; }
.side .me button { background: none; border: 0; color: #9fd0cc; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.menu-toggle { display: none; }
main.content { padding: 26px 34px 60px; max-width: 1240px; width: 100%; }
main.content:focus { outline: none; }
.side .me a { padding: 0; border: 0; display: inline; color: #9fd0cc; text-decoration: underline; }
.side .me a:hover { background: none; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); z-index: 20; transition: transform .2s; }
  .side.open { transform: none; }
  .menu-toggle { display: inline-block; position: fixed; top: 10px; left: 10px; z-index: 21; }
  main.content { padding: 56px 16px 40px; }
}

/* ---------- integrity strip: the one bold element ---------- */
.ledger { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--rule); border-left: 6px solid var(--granted); padding: 12px 16px; margin: 0 0 20px; border-radius: 3px; }
.ledger.bad { border-left-color: var(--withdrawn); }
.ledger .seal { width: 34px; height: 34px; flex: none; border-radius: 50%; border: 2px solid var(--granted); display: grid; place-items: center; color: var(--granted); font-weight: 800; font-family: var(--serif); }
.ledger.bad .seal { border-color: var(--withdrawn); color: var(--withdrawn); }
.ledger strong { font-family: var(--serif); font-size: 1.05rem; }

/* ---------- obligations ---------- */
.obligations { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 3px; }
.obligation { padding: 14px 18px; border-right: 1px solid var(--rule-2); }
.obligation:last-child { border-right: 0; }
.obligation .n { font-family: var(--serif); font-size: 2rem; line-height: 1.1; }
.obligation.hot .n { color: var(--withdrawn); }
.obligation.ok .n { color: var(--granted); }
.obligation a { font-size: .86rem; }

/* ---------- panels, tables ---------- */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 3px; padding: 16px 18px; margin: 14px 0; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 3px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
thead th { font-weight: 600; color: var(--ink-2); font-size: .85rem; background: var(--neutral-bg); }
tbody tr:hover { background: color-mix(in srgb, var(--neutral-bg) 55%, transparent); }
tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; }
.empty { padding: 28px; text-align: center; color: var(--ink-3); background: var(--surface); border: 1px dashed var(--rule); border-radius: 3px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.kv dt { color: var(--ink-3); }
dl.kv dd { margin: 0; }

/* ---------- state marks ---------- */
.state { display: inline-block; padding: 1px 9px; border-radius: 2px; font-size: .82rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.s-granted, .s-fulfilled, .s-acknowledged, .s-verified, .s-published, .s-approved, .s-active, .s-sent { color: var(--granted); background: var(--granted-bg); }
.s-withdrawn, .s-denied, .s-rejected, .s-dead, .s-failed, .s-critical, .s-overdue, .s-retired { color: var(--withdrawn); background: var(--withdrawn-bg); }
.s-pending, .s-verifying, .s-in_review, .s-machine_draft, .s-awaiting_principal, .s-delivered, .s-warning, .s-received, .s-queued, .s-logged, .s-human_reviewed, .s-partially_fulfilled, .s-draft, .s-open { color: var(--pending); background: var(--pending-bg); }
.s-expired, .s-superseded, .s-closed, .s-in_progress, .s-info, .s-unverified, .s-cancelled, .s-done, .s-none { color: var(--ink-2); background: var(--neutral-bg); }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 6px 14px 6px 0; }
.hint { color: var(--ink-3); font-size: .85rem; font-weight: 400; margin: 2px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], input[type=datetime-local], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #9aa6a3; border-radius: 3px; padding: 7px 9px;
}
textarea { min-height: 90px; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: .85rem; min-height: 220px; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; }
.row > .shrink { flex: 0 0 auto; }
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 3px; padding: 7px 14px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); text-decoration: none; display: inline-block; line-height: 1.3;
}
button.ghost, .btn.ghost { background: transparent; color: var(--accent); }
button.danger { background: var(--withdrawn); border-color: var(--withdrawn); color: #fff; }
button.ghost.danger { background: transparent; color: var(--withdrawn); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-weight: 500; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.small, .btn.small { padding: 3px 10px; font-size: .85rem; }
.stack > * + * { margin-top: 8px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin: 8px 0 14px; flex-wrap: wrap; }
.tabs button { background: none; color: var(--ink-2); border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: 8px 12px; font-weight: 600; }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--attention); }

/* ---------- notice editor ---------- */
.section-edit { border: 1px solid var(--rule); border-radius: 3px; padding: 10px 12px; margin: 10px 0; background: var(--surface); }
.section-edit.required { border-left: 4px solid var(--accent); }
.flag { background: var(--attention-bg); border-left: 4px solid var(--attention); padding: 10px 12px; margin: 8px 0; border-radius: 2px; }
.flag q { font-style: italic; }
.trans-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule-2); }
.trans-row .src { color: var(--ink-2); white-space: pre-wrap; }
@media (max-width: 760px) { .trans-row { grid-template-columns: 1fr; } }
.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.lang-grid .lang { border: 1px solid var(--rule-2); border-radius: 3px; padding: 6px 9px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; background: var(--surface); }
.lang-grid .lang label { margin: 0; }

/* ---------- timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--rule); }
.timeline li { position: relative; padding: 4px 0 12px 16px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink-3); }
.timeline li.visible::before { border-color: var(--accent); background: var(--accent); }
.timeline .when { color: var(--ink-3); font-size: .82rem; }
.timeline .body { white-space: pre-wrap; margin-top: 2px; }

/* ---------- bars (simple charts) ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 6px; }
.bars .bar { flex: 1; display: flex; flex-direction: column-reverse; min-width: 10px; }
.bars .seg { width: 100%; }
.bars .seg.granted { background: var(--granted); }
.bars .seg.withdrawn { background: var(--withdrawn); }
.bars .seg.denied { background: var(--attention); }
.bars .seg.expired { background: var(--ink-3); }
.bar-labels { display: flex; gap: 6px; font-size: .72rem; color: var(--ink-3); }
.bar-labels span { flex: 1; text-align: center; min-width: 10px; overflow: hidden; }
.legend { display: flex; gap: 14px; font-size: .82rem; color: var(--ink-2); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; }
.legend .granted { background: var(--granted); } .legend .withdrawn { background: var(--withdrawn); } .legend .denied { background: var(--attention); } .legend .expired { background: var(--ink-3); }
.meter { height: 8px; background: var(--neutral-bg); border-radius: 4px; overflow: hidden; min-width: 80px; }
.meter > span { display: block; height: 100%; background: var(--granted); }
.meter.warn > span { background: var(--pending); }
.meter.hot > span { background: var(--withdrawn); }

/* ---------- auth screen ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 460px) 1fr; }
.auth .formside { background: var(--surface); padding: 48px 40px; border-right: 1px solid var(--rule); }
.auth .story { background: var(--nav); color: var(--nav-ink); padding: 64px 56px; display: flex; flex-direction: column; justify-content: center; }
.auth .story h2 { color: #fff; font-size: 2rem; line-height: 1.2; max-width: 22ch; margin: 0 0 16px; }
.auth .story p { max-width: 52ch; color: #b8d3d0; }
.auth .story ul { padding-left: 18px; color: #d7e6e4; max-width: 52ch; }
.auth .story li { margin: 6px 0; }
@media (max-width: 820px) { .auth { grid-template-columns: 1fr; } .auth .story { padding: 32px 24px; } .auth .formside { padding: 32px 20px; } }

/* ---------- toasts, dialogs ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 3px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--withdrawn); color: #fff; }
dialog { border: 1px solid var(--rule); border-radius: 4px; padding: 0; max-width: min(640px, calc(100vw - 32px)); width: 100%; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(10, 20, 25, .5); }
dialog .dhead { padding: 14px 18px; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; align-items: center; }
dialog .dhead h2 { margin: 0; }
dialog .dbody { padding: 6px 18px 16px; max-height: 70vh; overflow-y: auto; }
dialog .dfoot { padding: 12px 18px; border-top: 1px solid var(--rule); display: flex; justify-content: flex-end; gap: 8px; }
.secret { background: var(--attention-bg); border: 1px solid var(--attention); padding: 10px; border-radius: 3px; }
pre.snippet { background: var(--neutral-bg); border: 1px solid var(--rule); padding: 12px; border-radius: 3px; overflow-x: auto; font-size: .82rem; font-family: var(--mono); }
.callout { border-left: 4px solid var(--attention); background: var(--attention-bg); padding: 10px 14px; margin: 10px 0; border-radius: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.trans-row textarea { min-height: 0; }
/* filter rows: buttons and selects in a paragraph */
p:has(> .btn.small), p:has(> select) { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
p > select { width: auto; min-width: 200px; }
button.small, .btn.small { white-space: nowrap; }
