/* ==========================================================================
   eNotice staff UI -- the one shared stylesheet for every authenticated page
   (and the sign-in / password pages). Loaded by templates/base.html.

   Rules for this file:
   - Every colour comes from a token below. Pages don't define their own
     palettes any more (that's how the app ended up with three different
     purple gradients).
   - Brand = the default department colour (#0f4c81), so the staff app and
     the public boards read as one product.
   - Pin orange means "needs someone's attention" (pending review, unsaved
     changes). Don't use it decoratively.
   - Fonts are self-hosted (static/fonts/plex, SIL OFL) so kiosks and staff
     on locked-down campus networks never wait on a font CDN.
   ========================================================================== */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/plex/ibm-plex-sans-latin-400-normal.0ceb759015a6.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/plex/ibm-plex-sans-latin-500-normal.767677e47513.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/plex/ibm-plex-sans-latin-600-normal.e78568807d10.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/plex/ibm-plex-sans-latin-700-normal.f9b6356e32a9.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/plex/ibm-plex-sans-condensed-latin-600-normal.9a955d233e3f.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans Condensed"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/plex/ibm-plex-sans-condensed-latin-700-normal.bc65f4c9d8ef.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/plex/ibm-plex-mono-latin-400-normal.4cc7b4398540.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/plex/ibm-plex-mono-latin-500-normal.bc5ccab82723.woff2") format("woff2"); }

:root {
  --paper: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #17202e;
  --ink-soft: #5b6676;
  --ink-faint: #8a94a3;
  --rule: #e2e7ee;
  --rule-strong: #cfd8e3;

  --brand: #0f4c81;
  --brand-hover: #0c3d68;
  --brand-soft: #e6eef7;
  --night: #0e2236;
  --night-2: #1b3a5a;
  --night-line: #1d3550;
  --night-ink: #c9d6e4;
  --night-faint: #7f96ad;

  --pin: #c2410c;  --pin-soft: #fff1ea;  --pin-line: #f6c7ad;
  --ok: #15803d;   --ok-soft: #e8f6ee;
  --warn: #a16207; --warn-soft: #fef6dd;
  --bad: #b91c1c;  --bad-soft: #fdecec;  --bad-line: #f1c4c4;
  --muted-pill: #eef1f5;
  --pill-ink: #4b5563;
  --seg-bg: #e9edf3;
  --toast-bg: #1f2430;
  --on-solid: #ffffff;           /* text on brand/ok/bad/pin filled buttons and badges */
  --nb-warn-ink: #713f12; --nb-warn-line: #f3dc9a;
  --nb-bad-ink: #7f1d1d;
  --nb-info-ink: #0c3d68; --nb-info-line: #c6d8ec;

  --f-display: "IBM Plex Sans Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  --r-sm: 6px; --r: 9px; --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 4px 14px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 18px 50px rgba(15, 30, 60, 0.22);
  --sidebar-w: 236px;
  --focus: 0 0 0 3px rgba(15, 76, 129, 0.22);
}

/* Staff dark mode (Phase 3). Opt-in from the sidebar's theme switch,
   which sets <html data-theme="light|dark|system"> (saved per browser).
   "system" follows the OS. The sidebar and auth panel are already dark
   and keep their colours; the public boards are never affected. */
:root[data-theme="dark"] {
  --paper: #0f141c; --surface: #161d28; --surface-2: #1b2431;
  --ink: #e6ebf2; --ink-soft: #a3aebd; --ink-faint: #738094;
  --rule: #273141; --rule-strong: #35425a;
  --brand: #6aa6e0; --brand-hover: #8bbbe8; --brand-soft: #1a2a3d;
  --night: #0a1520; --night-2: #1b3a5a;
  --pin: #f08a5d; --pin-soft: #3a2218; --pin-line: #6b3720;
  --ok: #4ade80; --ok-soft: #14301f;
  --warn: #facc15; --warn-soft: #3a3010;
  --bad: #f87171; --bad-soft: #3a1a1a; --bad-line: #6b2a2a;
  --muted-pill: #232c3a; --pill-ink: #c3cbd6; --seg-bg: #1f2836; --toast-bg: #26303f;
  --on-solid: #0b1220;
  --nb-warn-ink: #fde68a; --nb-warn-line: #5c4a12;
  --nb-bad-ink: #fecaca;
  --nb-info-ink: #bfdbfe; --nb-info-line: #2a4466;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow: 0 4px 14px rgba(0, 0, 0, 0.35); --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
  --focus: 0 0 0 3px rgba(106, 166, 224, 0.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --paper: #0f141c; --surface: #161d28; --surface-2: #1b2431;
    --ink: #e6ebf2; --ink-soft: #a3aebd; --ink-faint: #738094;
    --rule: #273141; --rule-strong: #35425a;
    --brand: #6aa6e0; --brand-hover: #8bbbe8; --brand-soft: #1a2a3d;
    --night: #0a1520; --night-2: #1b3a5a;
    --pin: #f08a5d; --pin-soft: #3a2218; --pin-line: #6b3720;
    --ok: #4ade80; --ok-soft: #14301f;
    --warn: #facc15; --warn-soft: #3a3010;
    --bad: #f87171; --bad-soft: #3a1a1a; --bad-line: #6b2a2a;
    --muted-pill: #232c3a; --pill-ink: #c3cbd6; --seg-bg: #1f2836; --toast-bg: #26303f;
    --on-solid: #0b1220;
    --nb-warn-ink: #fde68a; --nb-warn-line: #5c4a12;
    --nb-bad-ink: #fecaca;
    --nb-info-ink: #bfdbfe; --nb-info-line: #2a4466;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow: 0 4px 14px rgba(0, 0, 0, 0.35); --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
    --focus: 0 0 0 3px rgba(106, 166, 224, 0.35);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--f-body); font-size: 14.5px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-hover); }
img { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--f-display); line-height: 1.15; margin: 0; text-wrap: balance; color: var(--ink); }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 0.8rem; }
code, kbd, .mono { font-family: var(--f-mono); font-size: 0.86em; }
kbd {
  background: var(--surface); border: 1px solid var(--rule-strong); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 0.35em; color: var(--ink-soft);
}
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.label {
  font-family: var(--f-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-soft); font-weight: 500;
}
.nums { font-variant-numeric: tabular-nums; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--night); color: var(--night-ink);
  display: flex; flex-direction: column; padding: 16px 12px 12px; gap: 2px;
}
/* Sidebar items never shrink: when the menu is taller than the screen it
   scrolls instead. Shrinking squashed the logo row and pushed the collapse
   button underneath the first nav link, where it couldn't be seen or clicked. */
.sidebar > * { flex-shrink: 0; }
.brand {
  display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none;
  font-family: var(--f-display); font-weight: 700; font-size: 1.2rem; line-height: 1; padding: 0;
}
.brand .nav-text { display: block; line-height: 1; padding-top: 1px; } /* optical centring of the condensed caps against the mark */
.brand:hover { color: #fff; }
.brand-mark { width: 26px; height: 26px; flex: 0 0 auto; display: block; border-radius: 6px; }
.sidebar-dept {
  font-size: 0.78rem; color: var(--night-faint); padding: 0 8px 12px; margin-bottom: 8px;
  border-bottom: 1px solid var(--night-line); line-height: 1.35;
}
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--night-ink); text-decoration: none; font-weight: 500; font-size: 0.92rem;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-link[aria-current="page"] { background: var(--night-2); color: #fff; }
.nav-link svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: 0.85; }
.nav-link .count {
  margin-left: auto; font-size: 0.72rem; font-weight: 700; background: var(--pin); color: var(--on-solid);
  border-radius: 999px; padding: 0 7px; line-height: 1.6;
}
.nav-sep {
  font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--night-faint); padding: 14px 10px 4px;
}
.sidebar-foot {
  margin-top: auto; padding: 12px 6px 2px; border-top: 1px solid var(--night-line);
  display: flex; align-items: center; gap: 10px; font-size: 0.85rem;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #3b6a96; color: #fff; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
}
.sidebar-user { min-width: 0; flex: 1; }
.sidebar-user b { display: block; color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user span { color: var(--night-faint); font-size: 0.75rem; }
.sidebar-foot form { margin: 0; }
.icon-btn-dark {
  background: transparent; border: 0; color: var(--night-faint); cursor: pointer; padding: 6px; border-radius: 6px;
  display: grid; place-items: center;
}
.icon-btn-dark:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.icon-btn-dark svg { width: 17px; height: 17px; }

.main { min-width: 0; display: flex; flex-direction: column; grid-column: 2; grid-row: 1; }
/* The phone-menu backdrop is a sibling of the sidebar inside the .app grid.
   It must never take a grid cell on desktop, or it pushes .main into a new
   row under the sidebar (the page then looks empty). */
.nav-scrim { display: none; }
.topbar { display: none; }
.content { padding: 28px 32px 48px; width: 100%; max-width: 1180px; }
.content--wide { max-width: none; }
.content--narrow { max-width: 760px; }

/* ---------- sidebar header, profile link, collapsed rail ---------- */
/* Logo row: logo + name on the left, collapse button on the right, all on
   one centre line. The logo sits in the same column as the nav icons below
   (left padding 5px: the 26px mark centres on the 17px icons, which sit 10px in). */
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 32px; padding: 0 0 12px 5px; }
.sidebar-top .brand { min-width: 0; }
.sidebar-top .sidebar-collapse { flex: 0 0 auto; width: 30px; height: 30px; padding: 0; }
.sidebar-profile {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: inherit; text-decoration: none;
  border-radius: var(--r-sm); padding: 4px; margin: -4px;
}
.sidebar-profile:hover, .sidebar-profile[aria-current="page"] { background: rgba(255, 255, 255, 0.06); color: inherit; }
.sidebar-foot { margin-top: 10px; }
.nav-link .nav-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Collapsed (desktop only): icon rail. Set on <html data-sidebar> before
   first paint from localStorage, toggled by [data-sidebar-toggle]. */
@media (min-width: 901px) {
  :root[data-sidebar="collapsed"] { --sidebar-w: 68px; }
  :root[data-sidebar="collapsed"] .sidebar { padding-inline: 10px; align-items: stretch; }
  :root[data-sidebar="collapsed"] .sidebar .nav-text { display: none !important; }
  :root[data-sidebar="collapsed"] .sidebar-top { flex-direction: column; justify-content: flex-start; gap: 10px; padding: 0 0 10px; }
  :root[data-sidebar="collapsed"] .sidebar .brand { justify-content: center; width: 100%; }
  :root[data-sidebar="collapsed"] .nav-link { justify-content: center; padding: 9px 0; position: relative; }
  :root[data-sidebar="collapsed"] .nav-link .count {
    position: absolute; top: 2px; right: 2px; margin: 0; font-size: 0.6rem; padding: 0 5px; min-width: 16px; text-align: center;
  }
  :root[data-sidebar="collapsed"] .sidebar-foot { flex-direction: column; justify-content: center; gap: 6px; margin-top: auto; }
  :root[data-sidebar="collapsed"] .sidebar-profile { flex: 0 0 auto; margin: 0; }
  :root[data-sidebar="collapsed"] .sidebar-collapse svg { transform: scaleX(-1); }
  .app { transition: grid-template-columns 0.18s ease; }
}
@media (max-width: 900px) { .sidebar-collapse { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .app { transition: none; } }

/* Phones/tablets: sidebar slides in over the page */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .main { grid-column: 1; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, 290px); z-index: 60; height: 100%;
    transform: translateX(-102%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg);
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }
  .app.nav-open .sidebar { transform: none; }
  .nav-scrim { position: fixed; inset: 0; background: rgba(9, 18, 30, 0.45); z-index: 55; display: none; }
  .app.nav-open .nav-scrim { display: block; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40;
    background: var(--night); color: #fff;
    padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px));
  }
  .topbar .brand { padding: 0; font-size: 1.05rem; }
  .topbar .count {
    margin-left: auto; font-size: 0.72rem; font-weight: 700; background: var(--pin); color: #fff;
    border-radius: 999px; padding: 1px 8px; text-decoration: none;
  }
  .content { padding: 18px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--ink-soft); font-size: 0.88rem; margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 0.85rem; color: var(--ink-soft); text-decoration: none; margin-bottom: 6px; }
.back:hover { color: var(--brand); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 0.88rem; line-height: 1.2; white-space: nowrap;
  padding: 0.55rem 0.95rem; min-height: 38px; border-radius: var(--r-sm); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  background: var(--surface); color: var(--ink); border-color: var(--rule-strong);
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-solid); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--on-solid); }
.btn-success { background: var(--ok); border-color: var(--ok); color: var(--on-solid); }
.btn-success:hover { filter: brightness(0.92); color: var(--on-solid); }
.btn-danger { color: var(--bad); border-color: var(--bad-line); }
.btn-danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: var(--on-solid); }
.btn-danger-solid:hover { filter: brightness(0.9); color: var(--on-solid); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); padding-inline: 0.5rem; }
.btn-ghost:hover { background: var(--brand-soft); color: var(--brand); }
.btn-sm { min-height: 30px; padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 34px; min-height: 34px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards & stats ---------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--rule); font-weight: 600;
}
.card-head .label { font-weight: 500; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  display: block; padding: 14px 16px; text-decoration: none; color: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
a.stat:hover { border-color: var(--rule-strong); box-shadow: var(--shadow); color: inherit; }
.stat b { display: block; font-family: var(--f-display); font-size: 1.85rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.82rem; color: var(--ink-soft); }
.stat.attention { border-color: var(--pin-line); background: var(--pin-soft); }
.stat.attention b { color: var(--pin); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 0.74rem; font-weight: 600; line-height: 1.5;
  border-radius: 999px; padding: 0 9px; white-space: nowrap; background: var(--muted-pill); color: var(--pill-ink);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--draft { background: var(--muted-pill); color: var(--pill-ink); }
.pill--pending_review, .pill--pending { background: var(--warn-soft); color: var(--warn); }
.pill--live { background: var(--ok-soft); color: var(--ok); }
.pill--scheduled { background: var(--brand-soft); color: var(--brand); }
.pill--rejected { background: var(--bad-soft); color: var(--bad); }
.pill--expired { background: var(--muted-pill); color: var(--ink-faint); }
.pill--plain::before { display: none; }
.kind { font-family: var(--f-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }

/* ---------- toolbar: search + segmented tabs ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search { flex: 1 1 240px; position: relative; min-width: 0; }
.search input { padding-left: 34px !important; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--ink-faint); pointer-events: none; }
.seg {
  display: flex; background: var(--seg-bg); border-radius: var(--r-sm); padding: 3px; gap: 2px;
  overflow-x: auto; max-width: 100%; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg a {
  flex: 0 0 auto; padding: 5px 11px; border-radius: 5px; font-size: 0.82rem; font-weight: 500;
  color: var(--ink-soft); text-decoration: none; white-space: nowrap;
}
.seg a:hover { color: var(--ink); }
.seg a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.seg small { font-family: var(--f-mono); font-size: 0.72rem; margin-left: 4px; opacity: 0.8; }

/* ---------- tables (stack into cards on phones) ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-family: var(--f-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-soft); font-weight: 500; padding: 10px 14px; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.cell-title { font-weight: 600; color: var(--ink); text-decoration: none; display: block; overflow-wrap: anywhere; }
a.cell-title:hover { color: var(--brand); }
.cell-sub { font-size: 0.8rem; color: var(--ink-soft); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.reason { font-size: 0.78rem; color: var(--bad); margin-top: 3px; max-width: 260px; }
@media (max-width: 760px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { padding: 12px 14px; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; }
  .table--stack tr:last-child { border-bottom: 0; }
  .table--stack td { padding: 0; border: 0; }
  .table--stack td.col-thumb { grid-row: span 3; }
  .table--stack td.col-hide-sm { display: none; }
  .table--stack td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-faint); font-size: 0.78rem; }
  .table--stack .cell-actions { justify-content: flex-start; margin-top: 6px; }
}

.thumb {
  width: 40px; height: 40px; border-radius: var(--r-sm); object-fit: cover; display: block;
  background: linear-gradient(135deg, #d5dfeb, #edf1f6);
}
.thumb--pdf { background: var(--surface); border: 1px solid var(--rule); position: relative; display: grid; place-items: end center; padding-bottom: 4px; font-size: 0.55rem; font-weight: 700; color: var(--bad); }
.thumb--empty { display: grid; place-items: center; color: var(--ink-faint); }
.thumb--empty svg { width: 16px; height: 16px; }

/* ---------- forms ---------- */
.form-stack > div, .field { margin-bottom: 16px; }
.form-stack label, .field > label, .field-label {
  display: block; font-weight: 600; font-size: 0.86rem; margin-bottom: 5px; color: var(--ink);
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"],
input[type="url"], input[type="date"], input[type="datetime-local"], input[type="tel"], select, textarea {
  width: 100%; font: inherit; font-size: 0.93rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule-strong); border-radius: var(--r-sm); padding: 0.55rem 0.75rem; min-height: 40px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
textarea { line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--brand); }
.helptext, .form-stack .helptext { display: block; font-size: 0.78rem; color: var(--ink-soft); margin-top: 4px; }
.field .helptext { margin-top: 6px; line-height: 1.45; }
.field .helptext ul { margin: 0; padding-left: 1.1em; }
.field .helptext li { margin: 1px 0; }
.field .errorlist { margin-top: 6px; }
.field--check { margin-bottom: 14px; }
/* Space between the last field and the form's buttons. */
.field + .btn-row, .form-stack > .btn-row, .form-stack > button, .form-stack > .btn { margin-top: 22px; }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--bad); font-size: 0.82rem; }
.errorlist.nonfield { background: var(--bad-soft); border: 1px solid var(--bad-line); border-radius: var(--r-sm); padding: 8px 12px; margin-bottom: 14px; }
.field--error input, .field--error select, .field--error textarea { border-color: var(--bad); }
.check { display: flex; align-items: flex-start; gap: 9px; font-weight: 500; font-size: 0.9rem; cursor: pointer; }
.check input { margin-top: 2px; }
.input-lg { font-size: 1.15rem !important; font-weight: 600; min-height: 48px !important; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative;
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule-strong); border-radius: 999px;
  padding: 4px 12px; font-size: 0.82rem; background: var(--surface); cursor: pointer; color: var(--ink); font-weight: 500;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--brand); border-color: var(--brand); color: var(--on-solid); }
.chip:has(input:focus-visible) { box-shadow: var(--focus); }

.dropzone {
  position: relative; border: 1.5px dashed var(--rule-strong); border-radius: var(--r); background: var(--surface-2);
  padding: 16px; text-align: center; color: var(--ink-soft); font-size: 0.84rem; transition: border-color 0.12s, background 0.12s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone b { color: var(--brand); }
.dropzone .file-name { margin-top: 6px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.dropzone img { max-height: 140px; border-radius: var(--r-sm); margin: 0 auto 8px; display: block; }
.dropzone .current { font-size: 0.78rem; margin-top: 6px; }
.dropzone .current a { position: relative; z-index: 2; }
.dropzone .clear { position: relative; z-index: 2; display: inline-flex; gap: 5px; align-items: center; margin-top: 6px; font-size: 0.78rem; }

/* ---------- side panels inside forms ---------- */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 14px 16px; margin-bottom: 14px; }
.panel > .label { display: block; margin-bottom: 10px; }
.panel .field:last-child { margin-bottom: 0; }

/* ---------- menus (··· built on <details>) ---------- */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 200px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--shadow-lg);
  padding: 5px; display: flex; flex-direction: column;
}
.menu-list a, .menu-list button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0;
  font: inherit; font-size: 0.86rem; color: var(--ink); padding: 7px 10px; border-radius: 5px; cursor: pointer; text-decoration: none;
}
.menu-list a:hover, .menu-list button:hover { background: var(--surface-2); color: var(--ink); }
.menu-list .danger { color: var(--bad); }
.menu-list .danger:hover { background: var(--bad-soft); color: var(--bad); }
.menu-list hr { border: 0; border-top: 1px solid var(--rule); margin: 4px 0; }
.menu-list form { margin: 0; }

/* ---------- dialog (in-page confirm, replaces window.confirm) ---------- */
dialog.confirm {
  border: 0; border-radius: var(--r-lg); padding: 0; width: min(420px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg); color: var(--ink); background: var(--surface);
}
dialog.confirm::backdrop { background: rgba(9, 18, 30, 0.45); }
dialog.confirm .dlg-body { padding: 22px 22px 8px; }
dialog.confirm h3 { margin-bottom: 6px; }
dialog.confirm .dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; }

/* ---------- messages / toasts ---------- */
.toasts {
  position: fixed; z-index: 80; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; gap: 10px; align-items: flex-start; background: var(--toast-bg); color: #fff; border-radius: var(--r);
  padding: 11px 14px; box-shadow: var(--shadow-lg); font-size: 0.88rem; animation: toast-in 0.2s ease;
}
.toast--success { background: #14532d; }
.toast--error { background: #7f1d1d; }
.toast--warning { background: #78350f; }
.toast button { margin-left: auto; background: none; border: 0; color: rgba(255, 255, 255, 0.7); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 0 0 6px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

.notice-bar {
  display: flex; gap: 10px; align-items: flex-start; border-radius: var(--r); padding: 10px 14px; margin-bottom: 16px;
  font-size: 0.88rem; border: 1px solid var(--rule); background: var(--surface-2);
}
.notice-bar--warn { background: var(--warn-soft); border-color: var(--nb-warn-line); color: var(--nb-warn-ink); }
.notice-bar--bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--nb-bad-ink); }
.notice-bar--info { background: var(--brand-soft); border-color: var(--nb-info-line); color: var(--nb-info-ink); }

/* ---------- lists of rows ---------- */
.rows { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--rule);
  text-decoration: none; color: inherit; min-width: 0;
}
.row-item:last-child { border-bottom: 0; }
a.row-item:hover { background: var(--surface-2); color: inherit; }
.row-item .t { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .d { color: var(--ink-soft); font-size: 0.8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- empty states ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--ink-soft); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty p { max-width: 420px; margin: 0 auto 14px; }
.empty svg { width: 36px; height: 36px; color: var(--ink-faint); margin-bottom: 8px; }

/* ---------- action tiles (dashboard) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tile {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; text-decoration: none; color: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.tile:hover { border-color: var(--rule-strong); box-shadow: var(--shadow); color: inherit; }
.tile svg { width: 20px; height: 20px; color: var(--brand); flex: 0 0 auto; margin-top: 1px; }
.tile b { display: block; font-weight: 600; }
.tile span { font-size: 0.82rem; color: var(--ink-soft); }

/* ---------- layout thumbnails (rendered from layout_json) ---------- */
.lt-thumb {
  position: relative; aspect-ratio: 16 / 9; background: #0b1b2b; border-radius: var(--r-sm); overflow: hidden;
  display: flex; flex-direction: column; padding: 5px; gap: 3px;
}
.lt-thumb--portrait { aspect-ratio: 9 / 16; max-height: 220px; margin: 0 auto; }
.lt-thumb .b-band { flex: 0 0 auto; border-radius: 2px; }
.lt-thumb .b-grid { position: relative; flex: 1; min-height: 0; }
.lt-thumb .b-block { position: absolute; border-radius: 2px; background: #e6ecf3; }
.lt-thumb .b-block--content_zone, .lt-thumb .b-block--pagination_container, .lt-thumb .b-block--events_agenda { background: #f4f7fb; }
.lt-thumb .b-block--image_poster, .lt-thumb .b-block--image_carousel, .lt-thumb .b-block--spotlight { background: linear-gradient(160deg, #bccbdd, #dfe7f0); }
.lt-thumb .b-block--marquee { background: #b91c1c; }
.lt-thumb .b-block--text_banner { background: #fef3c7; }
.lt-thumb .b-block--clock, .lt-thumb .b-block--countdown { background: #cdd9e6; }
.lt-thumb .b-block--qr { background: #fff; }
.lt-thumb .b-block--rich_text, .lt-thumb .b-block--contacts { background: #eef2f6; }
.lt-thumb .b-block--date_day { background: #fff; }
.lt-thumb .b-block--video_loop { background: #000; box-shadow: inset 0 0 0 1px #3b4a5e; }

/* theme switch (sidebar footer) */
.theme-switch { margin-top: auto !important; display: flex; gap: 2px; background: rgba(255,255,255,0.06); border-radius: 7px; padding: 2px; margin: 10px 6px 0; }
.theme-switch button { flex: 1; border: 0; background: transparent; color: var(--night-faint); font: inherit; font-size: 0.72rem; padding: 4px 0; border-radius: 5px; cursor: pointer; }
.theme-switch button:hover { color: #fff; }
.theme-switch button[aria-pressed="true"] { background: var(--night-2); color: #fff; }
.lt-thumb-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #6f87a0; font-size: 0.72rem; }

.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.lib-card { overflow: visible; display: flex; flex-direction: column; transition: border-color 0.12s ease, box-shadow 0.12s ease; }
.lib-card:hover { border-color: var(--rule-strong); box-shadow: var(--shadow); }
.lib-card .lt-link { display: block; padding: 10px 10px 0; text-decoration: none; border-radius: var(--r) var(--r) 0 0; }
.lib-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px 12px; }
.lib-meta b { display: block; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.lib-meta span { font-size: 0.78rem; color: var(--ink-soft); }
.lib-card--blank { border-style: dashed; display: grid; place-items: center; text-align: center; min-height: 180px; text-decoration: none; color: var(--ink-soft); }
.lib-card--blank:hover { color: var(--brand); border-color: var(--brand); }
.lib-card--blank svg { width: 26px; height: 26px; margin-bottom: 6px; }

/* ---------- auth pages (sign in, reset, invite accept) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-art {
  background: var(--night); color: #fff; padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
}
.auth-art .brand { padding: 0; font-size: 1.35rem; }
.auth-art h2 { color: #fff; font-size: clamp(1.8rem, 3.2vw, 2.6rem); max-width: 14ch; }
.auth-art p { color: #9fb6cc; max-width: 40ch; margin-top: 10px; }
.mini-board { background: #13304d; border-radius: 10px; padding: 14px; display: grid; gap: 8px; max-width: 360px; }
.mini-board i { display: block; height: 10px; border-radius: 4px; background: #2c5680; }
.mini-board i:first-child { width: 55%; background: #fff; }
.mini-board i:nth-child(3) { width: 80%; }
.mini-board .tick { height: 14px; background: #b91c1c; border-radius: 4px; }
.auth-main { display: grid; place-items: center; padding: 40px max(20px, env(safe-area-inset-right, 0px)) 40px max(20px, env(safe-area-inset-left, 0px)); background: var(--surface); }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { margin-bottom: 6px; }
.auth-box .lede { color: var(--ink-soft); margin-bottom: 22px; }
.auth-links { margin-top: 16px; font-size: 0.88rem; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
@media (max-width: 820px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { padding: calc(22px + env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) 22px max(20px, env(safe-area-inset-left, 0px)); gap: 14px; }
  .auth-art h2 { font-size: 1.5rem; max-width: none; }
  .auth-art .mini-board, .auth-art p { display: none; }
  .auth-main { place-items: start center; }
}

/* ---------- error pages ---------- */
.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.error-page .code { font-family: var(--f-display); font-size: 4.5rem; font-weight: 700; color: var(--brand); line-height: 1; }
.error-page p { color: var(--ink-soft); max-width: 420px; margin: 10px auto 18px; }

/* ---------- review queue (list + detail) ---------- */
.review { display: grid; grid-template-columns: 300px minmax(0, 1fr); overflow: hidden; }
.review-list { border-right: 1px solid var(--rule); max-height: calc(100vh - 180px); overflow-y: auto; }
.review-item { display: block; padding: 12px 16px; border-bottom: 1px solid var(--rule); text-decoration: none; color: inherit; }
.review-item:hover { background: var(--surface-2); color: inherit; }
.review-item[aria-current="true"] { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.review-item b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.review-item span { font-size: 0.78rem; color: var(--ink-soft); }
.review-detail { padding: 20px 24px 24px; min-width: 0; }
.review-detail h2 { font-size: 1.5rem; margin: 6px 0 4px; overflow-wrap: anywhere; }
.review-body { margin: 14px 0; line-height: 1.65; overflow-wrap: anywhere; }
.review-media { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.review-media img { max-height: 220px; border-radius: var(--r-sm); border: 1px solid var(--rule); }
.review-actions { border-top: 1px solid var(--rule); padding-top: 16px; display: grid; gap: 12px; }
.reject-form { display: flex; gap: 8px; flex-wrap: wrap; }
.reject-form input { flex: 1 1 220px; }
@media (max-width: 860px) {
  .review { grid-template-columns: minmax(0, 1fr); }
  .review-list { border-right: 0; border-bottom: 1px solid var(--rule); max-height: 240px; }
}

/* ---------- formatted notice text (apps/core/markup.py output) ---------- */
.prose p { margin: 0 0 0.8em; }
.prose h4 { font-family: var(--f-display); font-size: 1.1rem; margin: 1em 0 0.4em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 0.8em; }
.prose li { margin-bottom: 0.25em; }
.prose > :last-child { margin-bottom: 0; }

/* ---------- notice editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
@media (max-width: 980px) { .editor { grid-template-columns: minmax(0, 1fr); } }
.rte-bar {
  display: flex; gap: 2px; flex-wrap: wrap; border: 1px solid var(--rule-strong); border-bottom: 0;
  border-radius: var(--r-sm) var(--r-sm) 0 0; background: var(--surface-2); padding: 4px;
}
.rte-bar button {
  min-width: 30px; height: 28px; border: 0; background: transparent; border-radius: 4px; cursor: pointer;
  font: inherit; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); padding: 0 7px;
}
.rte-bar button:hover { background: var(--surface); color: var(--ink); }
.rte-bar .hint { margin-left: auto; font-size: 0.72rem; color: var(--ink-faint); align-self: center; padding-right: 6px; }
.rte-bar + textarea { border-top-left-radius: 0; border-top-right-radius: 0; min-height: 220px; }
.savebar {
  position: sticky; bottom: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 18px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to top, var(--paper) 75%, transparent);
}
.dirty { color: var(--pin); font-size: 0.84rem; font-weight: 600; visibility: hidden; }
.dirty.is-dirty { visibility: visible; }
.phone-preview { width: 200px; margin: 0 auto; border: 7px solid #111827; border-radius: 24px; background: #f4f5f8; overflow: hidden; }
.phone-preview .pp-top { background: var(--brand); color: #fff; font-size: 0.6rem; font-weight: 600; padding: 7px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phone-preview .pp-card { background: #fff; margin: 7px; border-radius: 8px; padding: 8px; min-height: 200px; }
.phone-preview .pp-kind { font-size: 0.5rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--brand); }
.phone-preview .pp-title { font-weight: 700; font-size: 0.72rem; line-height: 1.25; margin: 3px 0 5px; overflow-wrap: anywhere; }
.phone-preview .pp-body { font-size: 0.56rem; line-height: 1.5; color: #374151; overflow-wrap: anywhere; max-height: 170px; overflow: hidden; }
.phone-preview .pp-body p { margin: 0 0 4px; }
.phone-preview .pp-img { width: 100%; border-radius: 4px; margin-bottom: 5px; display: none; }
