/* cfpl admin UI. One typeface (Public Sans, self-hosted), four themes: light, dark, gruvbox dark, gruvbox light.
   Themes are CSS variables on <html data-theme="...">; with no choice made the OS preference decides (light or dark). */
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/fonts/public-sans-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/fonts/public-sans-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root, :root[data-theme="light"] {
  --bg: #ffffff; --surface: #f6f7f9; --surface-2: #eceef2; --fg: #1a1d23; --muted: #5d6572; --line: #dcdfe5; --accent: #1b5fb4; --accent-fg: #ffffff; --accent-soft: #e3eefc;
  --ok: #067647; --ok-bg: #d1fadf; --warn: #b42318; --warn-bg: #fee4e2; --caution: #b54708; --caution-bg: #fef0c7; --shadow: 0 1px 2px rgba(16,24,40,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #14161a; --surface: #1b1e24; --surface-2: #252932; --fg: #e8eaee; --muted: #9aa3b0; --line: #2f343e; --accent: #6aa7ff; --accent-fg: #0b1220; --accent-soft: #1d2b44;
    --ok: #4ade80; --ok-bg: #12351f; --warn: #f87171; --warn-bg: #3b1818; --caution: #fbbf24; --caution-bg: #3a2c0c; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161a; --surface: #1b1e24; --surface-2: #252932; --fg: #e8eaee; --muted: #9aa3b0; --line: #2f343e; --accent: #6aa7ff; --accent-fg: #0b1220; --accent-soft: #1d2b44;
  --ok: #4ade80; --ok-bg: #12351f; --warn: #f87171; --warn-bg: #3b1818; --caution: #fbbf24; --caution-bg: #3a2c0c; --shadow: none; color-scheme: dark;
}
:root[data-theme="gruvbox-dark"] {
  --bg: #282828; --surface: #32302f; --surface-2: #3c3836; --fg: #ebdbb2; --muted: #a89984; --line: #504945; --accent: #83a598; --accent-fg: #282828; --accent-soft: #3c3836;
  --ok: #b8bb26; --ok-bg: #3a3b17; --warn: #fb4934; --warn-bg: #4a2420; --caution: #fabd2f; --caution-bg: #483a14; --shadow: none; color-scheme: dark;
}
:root[data-theme="gruvbox-light"] {
  --bg: #fbf1c7; --surface: #f2e5bc; --surface-2: #ebdbb2; --fg: #3c3836; --muted: #5f5448; --line: #d5c4a1; --accent: #076678; --accent-fg: #fbf1c7; --accent-soft: #ebdbb2;
  --ok: #79740e; --ok-bg: #e4e1a8; --warn: #9d0006; --warn-bg: #f2c9b8; --caution: #b57614; --caution-bg: #f3dca0; --shadow: none; color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
/* Public Sans is the only typeface, everywhere (inputs, tables, code). */
html, body, button, input, select, textarea, code, pre, kbd, samp, table, th, td { font-family: "Public Sans", sans-serif; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-size: 15px; line-height: 1.55; background: var(--bg); color: var(--fg); font-variant-numeric: tabular-nums; }
code, pre, kbd, samp { font-size: .92em; background: var(--surface-2); padding: .05em .35em; border-radius: 4px; }
pre { padding: .7rem .9rem; overflow: auto; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: .2rem 0 1rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 1.8rem 0 .6rem; font-weight: 650; } h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; z-index: 50; background: var(--bg); padding: 6px 10px; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* layout: fixed left menu + content */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 1rem .75rem; gap: .25rem; }
.side .brand { display: block; padding: .25rem .5rem .6rem; }
.brand-logo { display: block; width: 92px; height: 30px; background: var(--accent); -webkit-mask: url(/logo.svg) no-repeat left center / contain; mask: url(/logo.svg) no-repeat left center / contain; }
.env-badge { align-self: flex-start; margin: 0 .5rem .6rem; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 2px 9px; border-radius: 999px; background: var(--ok); color: var(--bg); }
.env-staging .env-badge { background: var(--caution); } .env-development .env-badge { background: var(--muted); }
.side nav { display: flex; flex-direction: column; gap: .1rem; }
.nav-group { margin: .9rem .5rem .25rem; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.side nav a { display: block; padding: .42rem .65rem; border-radius: 7px; color: var(--fg); text-decoration: none; font-weight: 500; }
.side nav a:hover { background: var(--surface-2); }
.side nav a[aria-current="page"] { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.side-foot { margin-top: auto; padding-top: 1rem; display: flex; flex-direction: column; gap: .6rem; border-top: 1px solid var(--line); }
.side-foot label { display: flex; flex-direction: column; gap: .2rem; font-size: 12px; color: var(--muted); margin: 0; }
.side-foot select { width: 100%; }
.who { font-size: 13px; color: var(--muted); padding: 0 .25rem; } .who strong { color: var(--fg); font-weight: 600; }
.side-foot form { margin: 0; } .side-foot button { width: 100%; }
.content { min-width: 0; display: flex; flex-direction: column; }
.menu-toggle { display: none; }
main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.4rem 2rem 2rem; flex: 1; }
.foot { color: var(--muted); text-align: center; padding: 1rem; font-size: 13px; }
.banner { padding: .6rem 1.5rem; color: #fff; font-weight: 500; } .banner-kill { background: #b42318; } .banner-throttle { background: #b54708; }

/* components */
table.data { border-collapse: collapse; width: 100%; background: var(--bg); }
.data th, .data td { border-bottom: 1px solid var(--line); padding: .5rem .7rem; text-align: left; vertical-align: top; }
.data th { font-size: 12px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); background: var(--surface); position: sticky; top: 0; }
.data tbody tr:hover { background: var(--surface); }
caption { text-align: left; color: var(--muted); font-size: 13px; padding: .3rem 0; }
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; background: var(--surface-2); color: var(--fg); font-size: 12px; font-weight: 600; }
.badge-approved, .badge-verified, .badge-submitted, .badge-replied { background: var(--ok-bg); color: var(--ok); }
.badge-submit_failed, .badge-qa_failed, .badge-rejected, .badge-suppressed { background: var(--warn-bg); color: var(--warn); }
.flash { padding: .6rem .9rem; border-radius: 8px; margin: 0 0 1rem; } .flash-notice { background: var(--ok-bg); color: var(--ok); } .flash-error { background: var(--warn-bg); color: var(--warn); }
.empty, .muted, .note { color: var(--muted); } .note { font-size: 14px; } .muted { opacity: .8; }
.pager { display: flex; gap: 1rem; margin-top: 1rem; }
form label { display: block; margin: .5rem 0; font-weight: 500; }
input, select, textarea, button { font-size: inherit; color: var(--fg); }
input:not([type=checkbox]):not([type=radio]), select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: .38rem .6rem; max-width: 100%; }
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus { border-color: var(--accent); }
button, .button { cursor: pointer; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: .38rem .85rem; font-weight: 600; }
button:hover { border-color: var(--accent); }
.side form button.secondary { background: transparent; font-weight: 500; color: var(--muted); }
form.filter { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: end; margin: 1rem 0; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
form.filter label { display: flex; flex-direction: column; gap: .2rem; font-size: 13px; margin: 0; color: var(--muted); }
ul.stats { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .75rem; }
ul.stats li { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; box-shadow: var(--shadow); }
meter { width: 8rem; vertical-align: middle; accent-color: var(--accent); }
details.usermenu summary { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* small screens: the menu slides in */
@media (max-width: 860px) {
  .shell { display: block; }
  .menu-toggle { display: inline-flex; position: sticky; top: 0; z-index: 30; width: 100%; justify-content: flex-start; border-radius: 0; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); padding: .7rem 1rem; }
  /* closed: offscreen AND removed from tab order and the accessibility tree (visibility is delayed so the slide-out still animates) */
  .side { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: 270px; transform: translateX(-102%); visibility: hidden; transition: transform .18s ease, visibility 0s linear .18s; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  body.menu-open .side { transform: none; visibility: visible; transition: transform .18s ease, visibility 0s; }
  main { padding: 1rem; }
  /* scrim behind the open menu, and no background scrolling while it is open */
  body.menu-open::after { content: ''; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.45); }
  body.menu-open { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { .side, body.menu-open .side { transition: none; } }
@media print { .side, .menu-toggle { display: none; } .shell { display: block; } }

/* keyboard shortcuts, command palette, help */
kbd { display: inline-block; min-width: 1.4em; text-align: center; padding: .05em .4em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); font-size: .8em; line-height: 1.5; }
.side nav a { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.side nav a kbd.hint { opacity: .55; font-size: .7em; }
.side nav a:hover kbd.hint, .side nav a:focus kbd.hint { opacity: 1; }
button.linklike { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; cursor: pointer; text-decoration: underline; }
tr.kb-row { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.kb-armed { outline: 3px solid var(--caution); outline-offset: 2px; }
#kb-toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 90; background: var(--fg); color: var(--bg); padding: .5rem .9rem; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .15s; max-width: 90vw; }
#kb-toast.show { opacity: .95; }
dialog.kb-dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--fg); padding: 1.1rem 1.3rem; max-width: min(40rem, 94vw); max-height: 85vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog.kb-dialog::backdrop { background: rgba(0,0,0,.45); }
dialog.kb-dialog h2 { margin: 0 0 .5rem; } dialog.kb-dialog h3 { margin: 1rem 0 .3rem; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kb-table { width: 100%; border-collapse: collapse; } .kb-table td { padding: .2rem .4rem; border: 0; vertical-align: top; } .kb-table td:first-child { white-space: nowrap; width: 9rem; }
.kb-pref { display: block; margin: 1rem 0 .6rem; }
#kb-palette { width: min(36rem, 94vw); padding: .6rem; position: fixed; top: 12vh; margin: 0 auto; }
#kb-palette input { width: 100%; font-size: 16px; padding: .6rem .7rem; }
#kb-list { list-style: none; margin: .5rem 0 0; padding: 0; max-height: 50vh; overflow: auto; }
#kb-list li { display: flex; gap: .6rem; align-items: baseline; padding: .4rem .6rem; border-radius: 7px; cursor: pointer; }
#kb-list li[aria-selected=true] { background: var(--accent-soft); outline: 1px solid var(--accent); }
#kb-list .kb-group { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); min-width: 5.5rem; }
#kb-list .kb-label { flex: 1; } #kb-list .kb-detail { color: var(--muted); font-size: 13px; } #kb-list .kb-empty { color: var(--muted); cursor: default; }
@media print { #kb-toast, dialog.kb-dialog { display: none; } }
@media (prefers-reduced-motion: reduce) { #kb-toast { transition: none; } }
.side nav a[aria-current="page"] kbd.hint { background: transparent; color: inherit; border-color: currentColor; opacity: .8; }

/* saved views */
details.views { margin: .4rem 0 .8rem; }
details.views summary { cursor: pointer; font-weight: 600; }
ul.view-list { list-style: none; padding: 0; margin: .4rem 0; }
ul.view-list li { padding: .15rem 0; }
form.inline { display: inline; margin-left: .5rem; }
.muted { color: var(--muted); font-size: 13px; }
form.view-save { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: end; margin: .5rem 0; }

/* review screen */
.review-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(16rem, 1.4fr); gap: 1.5rem; align-items: start; }
.review-facts { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; position: sticky; top: 1rem; }
.review-facts h2 { margin-top: 0; font-size: 1rem; } .review-facts dt { font-weight: 600; margin-top: .6rem; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; } .review-facts dd { margin: .1rem 0 0; }
@media (max-width: 960px) { .review-grid { grid-template-columns: 1fr; } .review-facts { position: static; } }
p.diff { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; }
p.diff ins { background: var(--ok-bg); color: var(--ok); text-decoration: none; border-radius: 3px; } p.diff del { background: var(--warn-bg); color: var(--warn); border-radius: 3px; }
#live-qa { margin: .4rem 0; } #live-qa.live-ok strong { color: var(--ok); } #live-qa.live-bad strong { color: var(--warn); }
#queue-pos { margin: -.4rem 0 .8rem; } .advance-pref { white-space: nowrap; }
