/* ═══════════════════════════════════════════════════
   system.css — MIS application layer
   Barangay Conde Labak, Batangas City

   Rebuilt 2026-07. Replaces the previous file, which had
   grown a "MODERN REFRESH" appendix that re-declared the
   same selectors at the bottom to override the top —
   every value had to be read twice to know what applied.
   Each component is now declared once.

   Load order: tokens.css → shared.css → system.css → gis.css
   The GIS map engine's styles were moved to gis.css
   untouched; nothing here targets a .gis-* selector.

   Contents
     1  Base
     2  Shell layout
     3  Sidebar
     4  Topbar
     5  Module launcher
     6  User menu
     7  Page header
     8  Cards
     9  KPIs & stats
    10  Tables
    11  Toolbars & filters
    12  Tabs
    13  Timeline
    14  Status & severity
    15  Empty & loading states
    16  Charts
    17  Service cards & portal
    18  Module-specific blocks
    19  Account-claim wizard
    20  Sysmodal & toast
    21  Utilities
    22  Responsive
    23  Print
═══════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════
   1 · BASE
═══════════════════════════════════════════════════ */

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  background: var(--surface);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Locks the page behind the mobile nav drawer. */
body.drawer-open {
  overflow: hidden;
}

/* One focus treatment for the whole application. Keyboard users get a clear
   ring; pointer users get none, because :focus-visible already excludes them. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* #page-content takes focus on navigation for screen readers; it must not
   draw a ring for that. */
#page-content:focus {
  outline: none;
}

/* ═══════════════════════════════════════════════════
   2 · SHELL LAYOUT

   Previously three stacked bars ate 124px before any
   content: a navy public-site navbar (64px) that only
   duplicated the sidebar's brand and module list, plus a
   white topbar (60px). The navbar is gone; one 60px
   topbar remains, and the sidebar now runs the full
   height of the viewport.
═══════════════════════════════════════════════════ */

/* Hidden until shell.js validates the session, at which point it sets an
   inline display:flex. #main is written to survive either box type — it fills
   the row as a flex item and still spans the width if #app is ever a block. */
#app {
  display: none;
  min-height: 100vh;
}

#app.visible {
  display: flex;
}

#main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--duration-base) var(--ease-out);
}

#main.with-sidebar {
  margin-left: var(--sidebar-w);
}

.sidebar-collapsed #main.with-sidebar {
  margin-left: var(--sidebar-w-collapsed);
}

#page-content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--page-pad);
  animation: page-in var(--duration-slow) var(--ease-out);
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Scrim behind the mobile drawer. */
.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-scrim);
  background: rgba(6, 14, 27, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fade-in var(--duration-base) var(--ease-out);
}

.sidebar-scrim[hidden] {
  display: none;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ═══════════════════════════════════════════════════
   3 · SIDEBAR

   Stays dark in both themes. A light sidebar would drop
   the navy that identifies this as the same system as
   the public portal.
═══════════════════════════════════════════════════ */

#sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  transition:
    width var(--duration-base) var(--ease-out),
    transform var(--duration-base) var(--ease-out);
}

#sidebar.hidden {
  transform: translateX(-100%);
}

.sidebar-collapsed #sidebar {
  width: var(--sidebar-w-collapsed);
}

/* ── Brand ─────────────────────────────────────────── */
.sidebar-head {
  flex-shrink: 0;
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out);
}

.sidebar-brand:hover {
  background: var(--sidebar-item-hover);
}

.brand-seal {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--gold-600);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.25);
}

.brand-seal img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.brand-name {
  min-width: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-extrabold);
  letter-spacing: 0.06em;
  line-height: var(--leading-tight);
  color: var(--sidebar-text-strong);
  white-space: nowrap;
}

.brand-name span {
  display: block;
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--sidebar-text);
}

/* ── Nav ───────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: var(--space-2) 0 var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  /* A thin, dark scrollbar — the default light one is a bright stripe down
     an otherwise navy panel. */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-full);
}

.sidebar-section + .sidebar-section {
  margin-top: var(--space-4);
}

.sidebar-section-label {
  padding: var(--space-3) var(--space-5) var(--space-2);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.34);
  white-space: nowrap;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: calc(100% - var(--space-4));
  margin: 1px var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--sidebar-text);
  text-align: left;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.nav-item:hover {
  background: var(--sidebar-item-hover);
  color: var(--sidebar-text-strong);
}

.nav-item.active {
  background: var(--sidebar-item-active);
  color: var(--sidebar-item-active-text);
  font-weight: var(--weight-semibold);
}

/* The active marker is a rail on the left edge rather than a full border, so
   collapsing the sidebar to icons keeps the same cue. */
.nav-item.active::before {
  content: "";
  position: absolute;
  left: calc(var(--space-2) * -1);
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  background: var(--gold-400);
}

.nav-item:focus-visible {
  outline-offset: -2px;
}

.nav-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 20px;
  font-size: 1.15rem;
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-badge {
  flex-shrink: 0;
  min-width: 20px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  text-align: center;
}

.nav-badge:empty {
  display: none;
}

/* Tooltip shown only while collapsed — see the collapsed block below. */
.nav-tip {
  display: none;
}

/* ── Collapsed rail ──────────────────────────────────
   Desktop only. Below 1025px the sidebar is an overlay drawer, which always
   opens at full width — there is nothing to collapse, and a collapsed state
   left over from a wider window would render an icon-only drawer.

   Gating on min-width is why there is no "undo" block in the mobile media
   query further down: these rules simply never apply there. */
@media (min-width: 1025px) {
  .sidebar-collapsed #sidebar .brand-name,
  .sidebar-collapsed #sidebar .nav-label,
  .sidebar-collapsed #sidebar .nav-badge,
  .sidebar-collapsed #sidebar .user-meta {
    display: none;
  }

  .sidebar-collapsed #sidebar .sidebar-brand,
  .sidebar-collapsed #sidebar .user-pill {
    justify-content: center;
  }

  .sidebar-collapsed #sidebar .nav-item {
    justify-content: center;
    padding-inline: 0;
  }

  .sidebar-collapsed #sidebar .sidebar-section-label {
    /* Keeps the section rhythm without a label that can't fit. */
    height: 1px;
    margin: var(--space-3) var(--space-4);
    padding: 0;
    overflow: hidden;
    background: var(--sidebar-border);
    color: transparent;
  }

  .sidebar-collapsed #sidebar .nav-tip {
    position: absolute;
    left: calc(100% + var(--space-2));
    top: 50%;
    z-index: var(--z-dropdown);
    display: block;
    transform: translateY(-50%) translateX(-4px);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--navy-900);
    box-shadow: var(--shadow-lg);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition:
      opacity var(--duration-fast) var(--ease-out),
      transform var(--duration-fast) var(--ease-out);
  }

  .sidebar-collapsed #sidebar .nav-item:hover .nav-tip,
  .sidebar-collapsed #sidebar .nav-item:focus-visible .nav-tip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
}

/* ── Footer ────────────────────────────────────────── */
.sidebar-footer {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-3);
  border-top: 1px solid var(--sidebar-border);
}

/* "Guide Videos" (js/app-shell.js): a .nav-item, but inside the footer's own
   padding rather than the nav's, so it drops the nav's side margins. */
.sidebar-footer .nav-item-guides {
  width: 100%;
  margin: 0 0 var(--space-2);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
}

.user-avatar {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--gold-600);
  color: var(--navy-900);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

.user-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--sidebar-text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--sidebar-text);
}

.logout-btn {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 1rem;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
}

/* ═══════════════════════════════════════════════════
   4 · TOPBAR
═══════════════════════════════════════════════════ */

#topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-h);
  /* The bar is full-bleed, but its contents track the same centred column as
     #page-content — otherwise on a very wide monitor the page title sits at
     the far left of the screen while the content it labels is centred.
     Below --content-max the calc goes negative and max() falls back to the
     plain gutter. */
  padding-inline: max(
    var(--page-pad),
    calc((100% - var(--content-max)) / 2 + var(--page-pad))
  );
  background: color-mix(in srgb, var(--surface-raised) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--border);
}

.topbar-heading {
  min-width: 0;
  flex: 1;
}

.topbar-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--text-brand);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-subtitle {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.topbar-date {
  padding: 6px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* One icon button used by every topbar control — launcher, appearance,
   notifications, sidebar toggle. */
.topbar-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 1.05rem;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.topbar-icon-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.topbar-kbd {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* Hidden unless there is something unread (js/shell.js renderNotifDot). A dot
   that is always lit is not a signal, and this one was previously painted on
   every page load whatever the account's actual feed said. */
.topbar-notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--gold-500);
  box-shadow: 0 0 0 2px var(--surface-raised);
}
.topbar-notif-dot.is-on {
  display: block;
}

/* ── Notification panel ───────────────────────────────
   Hangs off the bell, mirroring .nav-user-menu-dropdown beside it so the two
   topbar panels behave identically. */
.notif-menu {
  position: relative;
}

.notif-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: var(--z-dropdown);
  display: none;
  flex-direction: column;
  width: 340px;
  max-width: calc(100vw - var(--space-4) * 2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: menu-in var(--duration-base) var(--ease-out);
}
.notif-panel.open {
  display: flex;
}

.notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.notif-panel-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
}

/* Capped so a long feed scrolls inside the panel rather than running off the
   bottom of the viewport. */
.notif-panel-list {
  max-height: 380px;
  overflow-y: auto;
}

.notif-empty {
  padding: var(--space-5) var(--space-4);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
  text-align: center;
}

.notif-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}
.notif-item:last-child {
  border-bottom: none;
}
.notif-item:hover {
  background: var(--surface);
}

/* Unread carries a left rule rather than a background tint: the tint would
   fight the urgent styling below, and both states have to be readable at once
   (an unread urgent alert is the exact case this panel exists for). */
.notif-item.is-unread {
  box-shadow: inset 3px 0 0 var(--gold-500);
}
.notif-item.is-urgent {
  box-shadow: inset 3px 0 0 #ef4444;
}

.notif-item-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--accent-bg);
  color: var(--text-secondary);
}
.notif-item.is-urgent .notif-item-icon {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}
[data-theme="dark"] .notif-item.is-urgent .notif-item-icon {
  color: #f87171;
}

.notif-item-body {
  min-width: 0;
  flex: 1;
}

.notif-item-title {
  font-size: 12.5px;
  font-weight: var(--weight-semibold);
  color: var(--text);
  overflow-wrap: anywhere;
}
.notif-item.is-unread .notif-item-title {
  font-weight: 700;
}

.notif-item-text {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.notif-item-when {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--text-muted);
}

/* On a phone the panel spans the bar instead of hanging off one button. */
@media (max-width: 480px) {
  .notif-panel {
    position: fixed;
    top: 60px;
    right: var(--space-3);
    left: var(--space-3);
    width: auto;
  }
}

/* ── Sign-in briefing ─────────────────────────────────
   The window an officer meets when they sign in (js/staff-briefing.js): what
   arrived while they were away on top, what they left unfinished underneath.

   The two halves are deliberately NOT styled alike. The top one is news and
   reads as news; the bottom one is a debt, so it is tinted and its rows carry
   an amber rule. An officer should be able to tell which list they are looking
   at from across the desk, without reading either heading. */
.brf-group + .brf-group {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.brf-group-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brf-group-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-brand);
}

/* The count is the first thing read, so it is a chip rather than a number in
   a sentence — and it is grey at zero: "0" in a loud badge says there is
   something to look at when there is not. */
.brf-group-count {
  min-width: 24px;
  padding: 1px var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}
.brf-group-count.is-on {
  border-color: var(--accent-border);
  background: var(--accent-bg);
  color: var(--text-brand);
}
.brf-group-waiting .brf-group-count.is-on {
  border-color: rgba(212, 160, 23, 0.45);
  background: rgba(212, 160, 23, 0.14);
  color: #92610a;
}
[data-theme="dark"] .brf-group-waiting .brf-group-count.is-on {
  color: var(--gold-500);
}

.brf-group-sub {
  margin: var(--space-2) 0 var(--space-4);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

/* "Nothing new came in" is good news and should look like it, not like an
   empty table. */
.brf-group-empty {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-3) 0 0;
  padding: var(--space-4);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-md);
  background: var(--success-bg);
  font-size: var(--text-xs);
  color: var(--success);
}

.brf-queue + .brf-queue {
  margin-top: var(--space-4);
}

.brf-queue-head {
  margin-bottom: var(--space-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Every row is a button: a briefing that only tells you is half a briefing, so
   pressing one closes the window and opens the page it is worked on. */
.brf-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}
.brf-item + .brf-item {
  margin-top: var(--space-2);
}
.brf-item:hover {
  border-color: var(--accent-border);
  background: var(--surface);
}
.brf-item:active {
  transform: scale(0.995);
}

.brf-group-waiting .brf-item {
  box-shadow: inset 3px 0 0 var(--gold-500);
}
.brf-item.is-urgent {
  box-shadow: inset 3px 0 0 var(--danger-solid);
}

.brf-item-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--accent-bg);
  color: var(--text-secondary);
}
.brf-item.is-urgent .brf-item-icon {
  background: var(--danger-bg);
  color: var(--danger);
}

.brf-item-main {
  display: block;
  min-width: 0;
  flex: 1;
}

.brf-item-title {
  display: block;
  font-size: 12.5px;
  font-weight: var(--weight-semibold);
  color: var(--text);
  overflow-wrap: anywhere;
}

.brf-item-sub {
  display: block;
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

/* How long it has been sitting, not a date — "waiting 12 days" is the part
   that should make somebody act. */
.brf-item-when {
  flex-shrink: 0;
  font-size: 10.5px;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

.brf-more {
  display: block;
  width: 100%;
  margin-top: var(--space-2);
  padding: var(--space-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: none;
  font: inherit;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}
.brf-more:hover {
  background: var(--surface);
  color: var(--text);
}

/* On a phone the age moves under the title rather than squeezing it. */
@media (max-width: 480px) {
  .brf-item {
    align-items: flex-start;
  }
  .brf-item-when {
    align-self: flex-start;
  }
}

/* ── Sidebar toggle ───────────────────────────────── */
.sidebar-toggle-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 16px;
}

.sidebar-toggle-bars span {
  display: block;
  height: 2px;
  border-radius: var(--radius-full);
  background: currentColor;
  transition: width var(--duration-base) var(--ease-out);
}

.sidebar-toggle-bars span:nth-child(1) {
  width: 100%;
}
.sidebar-toggle-bars span:nth-child(2) {
  width: 70%;
}
.sidebar-toggle-bars span:nth-child(3) {
  width: 100%;
}

.sidebar-collapsed .sidebar-toggle-bars span:nth-child(2) {
  width: 100%;
}

/* ═══════════════════════════════════════════════════
   5 · MODULE LAUNCHER

   Twelve modules is more than a sidebar scan handles
   comfortably. Ctrl/⌘K opens a filterable list.
═══════════════════════════════════════════════════ */

.topbar-modules-menu {
  position: relative;
}

.topbar-modules-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: var(--z-dropdown);
  display: none;
  flex-direction: column;
  width: 300px;
  max-height: min(70vh, 520px);
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-xl);
  animation: menu-in var(--duration-base) var(--ease-out);
}

.topbar-modules-dropdown.open {
  display: flex;
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.topbar-modules-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  margin-bottom: var(--space-2);
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
}

.topbar-modules-search:focus-within {
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-ring) 18%, transparent);
}

.topbar-modules-search input {
  flex: 1;
  min-width: 0;
  height: 36px;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
}

.topbar-modules-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.topbar-modules-group[hidden] {
  display: none;
}

.topbar-modules-section {
  padding: var(--space-3) var(--space-3) var(--space-1);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.topbar-module-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.topbar-module-item[hidden] {
  display: none;
}

.topbar-module-item:hover,
.topbar-module-item:focus-visible {
  background: var(--surface-hover);
}

.topbar-module-item.is-current {
  background: var(--accent-bg);
  color: var(--accent-fg);
  font-weight: var(--weight-semibold);
}

.topbar-module-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 18px;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.topbar-module-item.is-current .topbar-module-icon {
  color: var(--accent-fg);
}

.topbar-modules-empty {
  padding: var(--space-6) var(--space-3);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.topbar-modules-empty[hidden] {
  display: none;
}

/* ═══════════════════════════════════════════════════
   6 · USER MENU
═══════════════════════════════════════════════════ */

.nav-user-menu {
  position: relative;
}

.nav-user-menu.is-hidden {
  display: none;
}

.nav-user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-2) 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-raised);
  font-family: inherit;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.nav-user-menu-trigger:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.nav-user-menu-trigger .nav-user-avatar {
  width: 28px;
  height: 28px;
  font-size: var(--text-2xs);
}

.nav-user-menu-trigger .nav-user-name {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.nav-user-caret {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: transform var(--duration-fast) var(--ease-out);
}

.nav-user-menu-trigger[aria-expanded="true"] .nav-user-caret {
  transform: rotate(180deg);
}

.nav-user-menu-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: var(--z-dropdown);
  display: none;
  flex-direction: column;
  gap: 2px;
  min-width: 244px;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-xl);
  animation: menu-in var(--duration-base) var(--ease-out);
}

.nav-user-menu-dropdown.open {
  display: flex;
}

.nav-user-menu-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  padding: var(--space-2) var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--border);
}

.nav-user-menu-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.nav-user-name-full {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-user-role {
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-user-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.nav-user-menu-item i[data-icon] {
  color: var(--text-muted);
  font-size: 1.05rem;
}

.nav-user-menu-item:hover {
  background: var(--surface-hover);
}

.nav-user-menu-item-danger:hover,
.nav-user-menu-item-danger:hover i[data-icon] {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ═══════════════════════════════════════════════════
   7 · PAGE HEADER
═══════════════════════════════════════════════════ */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.page-title {
  margin: 0 0 2px;
  font-size: var(--text-2xl);
  font-weight: var(--weight-extrabold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--text-brand);
}

.page-desc {
  margin: 0;
  max-width: 68ch;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════
   8 · CARDS
═══════════════════════════════════════════════════ */

.card,
.notice-card {
  padding: var(--card-pad);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.card {
  margin-bottom: var(--stack);
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.card-title,
.notice-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-brand);
}

.notice-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

/* Was referenced by dashboard.js and content.js but never defined — every
   .card-body rendered as an unstyled div. */
.card-body {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.card-body > * + * {
  margin-top: var(--space-3);
}

.card-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.card-action {
  border: 0;
  background: none;
  padding: 0;
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--accent-fg);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--duration-fast) var(--ease-out);
}

.card-action:hover {
  color: var(--text-brand);
}

/* AI summary panel — referenced by dashboard.js, previously unstyled. */
.ai-card {
  position: relative;
  overflow: hidden;
  border-color: var(--accent-border);
}

.ai-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--gold-600),
    var(--blue-500),
    transparent
  );
}

.ai-summary-text {
  margin: 0;
  padding: var(--space-4);
  border: 1px dashed var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--accent-bg);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════
   9 · KPIs & STATS
═══════════════════════════════════════════════════ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.kpi-card {
  position: relative;
  overflow: hidden;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Accent rail, tinted per tone. `warning` was used by residency.js against a
   variant that did not exist — it silently fell back to gold. */
.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

.kpi-card.success::before {
  background: linear-gradient(90deg, var(--success-solid), transparent);
}
.kpi-card.danger::before {
  background: linear-gradient(90deg, var(--danger-solid), transparent);
}
.kpi-card.warning::before {
  background: linear-gradient(90deg, var(--warning-solid), transparent);
}
.kpi-card.info::before {
  background: linear-gradient(90deg, var(--info-solid), transparent);
}

.kpi-label {
  margin-bottom: var(--space-2);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}

.kpi-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-extrabold);
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text-brand);
  font-variant-numeric: tabular-nums;
}

.kpi-trend {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* A trend line that is reporting a fault rather than a figure — "no official
   is receiving report texts". Empty most of the time, and it should be
   impossible to read past when it is not. */
.kpi-trend.kpi-trend-alarm {
  color: var(--danger);
  font-weight: var(--weight-semibold);
}

.kpi-trend .up,
.kpi-trend .dn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  margin-right: 4px;
  border-radius: var(--radius-full);
  font-weight: var(--weight-bold);
}

.kpi-trend .up {
  background: var(--success-bg);
  color: var(--success);
}

.kpi-trend .dn {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Down-trend arrow: the markup reuses the trend-up glyph for both. */
.kpi-trend .dn i[data-icon] {
  transform: scaleY(-1);
}

/* ── Stat rows ─────────────────────────────────────── */
.stat-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row-label {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.stat-row-bar {
  flex: 2;
}

.stat-row-value {
  min-width: 52px;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-brand);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Health tiles ──────────────────────────────────── */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
}

.health-card {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.health-value {
  margin-top: var(--space-1);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-brand);
  font-variant-numeric: tabular-nums;
}

/* ── Insight cards ─────────────────────────────────── */
.insight-card {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.insight-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.insight-icon {
  display: inline-flex;
  color: var(--accent-fg);
  font-size: 1.25rem;
}

.insight-title {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-brand);
}

.insight-badge {
  display: inline-flex;
  margin-top: var(--space-1);
}

.insight-desc {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

/* ── Layout grids ──────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--stack);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--stack);
}

/* ═══════════════════════════════════════════════════
   10 · TABLES
═══════════════════════════════════════════════════ */

.table-wrap {
  overflow-x: auto;
  /* Pulls the scroller to the card's edges so a wide table can use the full
     width instead of scrolling inside the padding. */
  margin: 0 calc(var(--card-pad) * -1);
  padding: 0 var(--card-pad);
  overscroll-behavior-x: contain;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table th {
  padding: var(--space-3) var(--space-4);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: background var(--duration-fast) var(--ease-out);
}

.data-table tbody tr:hover td {
  background: var(--surface);
}

/* Numeric columns line up when the digits are tabular. Kept as its own rule —
   grouping it with a :has() selector would take the whole list down with it on
   a browser that doesn't support :has(). */
.table-mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.table-name {
  font-weight: var(--weight-semibold);
}

.table-muted {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.table-text-sm {
  font-size: var(--text-sm);
}

.table-text-md {
  font-size: var(--text-xs);
}

.table-nowrap {
  white-space: nowrap;
}

.table-action-code {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-secondary);
}

/* ── Permission matrix ─────────────────────────────── */
.perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.perm-table th,
.perm-table td {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  text-align: center;
}

.perm-table th {
  background: var(--surface);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
}

.perm-table td:first-child,
.perm-table th:first-child {
  text-align: left;
  background: var(--surface);
  font-weight: var(--weight-medium);
}

/* A heading row inside the matrix. The SMS rows are a group of their own
   because they are not module access — they decide who a 2 AM text goes to
   and who may spend the barangay's credits — and a reader scanning fourteen
   module rows needs to be told where that list stops. */
.perm-table .perm-group td {
  background: var(--surface-sunken);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* The matrix is laid out like the sidebar: a heading per section, a row per
   screen, and under a screen the things done inside it. The indent and the
   tick mark are what say "this one lives in the row above" — without them an
   action row reads as another module and the grouping is lost. */
.perm-table .perm-sub > td:first-child {
  padding-left: var(--space-8);
  position: relative;
}
.perm-table .perm-sub > td:first-child::before {
  content: "";
  position: absolute;
  left: var(--space-5);
  top: 1.05em;
  width: 8px;
  height: 8px;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.perm-row-label {
  font-weight: var(--weight-semibold, 600);
}
.perm-table .perm-sub .perm-row-label {
  font-weight: var(--weight-regular, 400);
}
/* Every row explains itself now, so the description is a real part of the row
   rather than an afterthought: readable, and capped so a long one does not
   stretch the table past the ticks. */
.perm-row-desc {
  margin-top: 2px;
  max-width: 62ch;
  font-size: var(--text-xs);
  font-weight: var(--weight-regular, 400);
  line-height: 1.5;
  color: var(--text-muted);
}

.perm-check {
  color: var(--success-solid);
  font-size: 1rem;
}

.perm-x {
  color: var(--danger-solid);
  font-size: 1rem;
}

/* ── Pagination ────────────────────────────────────── */
.feedback-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.feedback-page-info {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.feedback-page-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

.fb-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.fb-page-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.fb-page-btn.active {
  background: var(--navy-800);
  border-color: var(--navy-800);
  color: var(--on-brand);
}

.fb-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Prev/next arrows — icon-only, so they don't need the numeric button's
   horizontal padding. */
.fb-page-nav {
  padding: 0;
  color: var(--text-muted);
}

/* The "…" standing in for the page numbers the window skipped. Not a button:
   a long audit trail would otherwise render hundreds of them. */
.fb-page-gap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 34px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  user-select: none;
}

/* A paginated card puts its controls straight under the list it belongs to,
   whatever wrapper that list lives in. */
.card > .feedback-pagination:last-child {
  margin-bottom: 0;
}

/* ═══════════════════════════════════════════════════
   11 · TOOLBARS & FILTERS
═══════════════════════════════════════════════════ */

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.filter-row .form-control {
  height: 38px;
  background: var(--surface-raised);
}

.filter-input {
  flex: 1 1 240px;
  max-width: 340px;
}

.filter-select {
  flex: 0 1 200px;
  max-width: 220px;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Checkbox / radio rows — used by residency.js and the incident modal but
   never styled, so they inherited raw UA checkboxes with no hit area. */
.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.checkbox-row label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.checkbox-row label:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.checkbox-row label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-fg);
  font-weight: var(--weight-semibold);
}

.checkbox-row input[type="checkbox"],
.checkbox-row input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--gold-600);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════
   12 · TABS
═══════════════════════════════════════════════════ */

.tab-bar {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-5);
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  padding: var(--space-3) var(--space-4);
  border: 0;
  background: none;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out);
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--text-brand);
}

.tab.active::after {
  content: "";
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: -3px;
  height: 2px;
  border-radius: var(--radius-full);
  background: var(--gold-600);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: page-in var(--duration-base) var(--ease-out);
}

/* ═══════════════════════════════════════════════════
   13 · TIMELINE
═══════════════════════════════════════════════════ */

.timeline {
  padding-left: var(--space-1);
}

.timeline-item {
  position: relative;
  display: flex;
  gap: var(--space-4);
  padding-bottom: var(--space-5);
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 18px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-dot {
  position: relative;
  z-index: var(--z-base);
  flex-shrink: 0;
  width: 11px;
  height: 11px;
  margin-top: 5px;
  border-radius: var(--radius-full);
  background: var(--gold-600);
  box-shadow: 0 0 0 3px var(--surface-raised), 0 0 0 4px var(--gold-600);
}

.timeline-dot.gray {
  background: var(--text-muted);
  box-shadow: 0 0 0 3px var(--surface-raised), 0 0 0 4px var(--text-muted);
}

.timeline-dot.red {
  background: var(--danger-solid);
  box-shadow: 0 0 0 3px var(--surface-raised), 0 0 0 4px var(--danger-solid);
}

.timeline-dot.green {
  background: var(--success-solid);
  box-shadow: 0 0 0 3px var(--surface-raised), 0 0 0 4px var(--success-solid);
}

/* Warning-level audit entries on the dashboard's Recent Activity — between
   an ordinary action (green) and a critical one (red). */
.timeline-dot.gold {
  background: var(--warning-solid);
  box-shadow: 0 0 0 3px var(--surface-raised), 0 0 0 4px var(--warning-solid);
}

.timeline-body {
  flex: 1;
  min-width: 0;
}

.timeline-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.timeline-meta {
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════
   14 · STATUS & SEVERITY
═══════════════════════════════════════════════════ */

.sev-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  border-radius: var(--radius-full);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Solid fills: severity has to survive being skimmed in a dense table. */
.sev-critical {
  background: var(--red-700);
  color: #fff;
}
.sev-high {
  background: var(--red-500);
  color: #fff;
}
.sev-medium {
  background: var(--amber-500);
  color: var(--n-900);
}
.sev-low {
  background: var(--blue-500);
  color: #fff;
}

/* ═══════════════════════════════════════════════════
   15 · EMPTY & LOADING STATES

   New. Every list in the system previously rendered
   "Loading…" or "No results" as bare centred text with
   an inline style, which read as a broken page rather
   than a state.
═══════════════════════════════════════════════════ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-10) var(--space-5);
  text-align: center;
}

.empty-state-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: 1.5rem;
}

.empty-state-title {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.empty-state-desc {
  max-width: 44ch;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Legacy hooks kept so existing "no results" markup picks up the new look. */
.resident-empty,
.announcements-empty {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.resident-summary {
  margin-bottom: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Skeletons — a shimmering block sized like the content it stands in for. */
.skeleton {
  border-radius: var(--radius-xs);
  background: linear-gradient(
    90deg,
    var(--surface-sunken) 25%,
    var(--surface-hover) 37%,
    var(--surface-sunken) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-text {
  height: 12px;
  margin: 6px 0;
}

.skeleton-title {
  height: 20px;
  width: 40%;
  margin: 6px 0 12px;
}

.skeleton-row {
  height: 44px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-sm);
}

.skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2) 0;
}

.skeleton-panel {
  padding: var(--space-4);
}

/* Sized like the number it stands in for, so the card does not resize under
   the reader when the real figure arrives. */
.skeleton-kpi {
  display: inline-block;
  width: 72px;
  height: 26px;
  vertical-align: -4px;
}

/* One of the map's filter dropdowns, before the engine puts the real ones in. */
.skeleton-pill {
  width: 116px;
  height: 32px;
  border-radius: 100px;
}

@keyframes shimmer {
  from {
    background-position: 100% 50%;
  }
  to {
    background-position: 0 50%;
  }
}

/* ═══════════════════════════════════════════════════
   16 · CHARTS
═══════════════════════════════════════════════════ */

.chart-box {
  position: relative;
  width: 100%;
}

.chart-box-lg {
  height: 240px;
}
.chart-box-md {
  height: 210px;
}
.chart-box-sm {
  height: 190px;
}

/* ═══════════════════════════════════════════════════
   17 · SERVICE CARDS & RESIDENT PORTAL
═══════════════════════════════════════════════════ */

.resident-portal {
  max-width: 1100px;
  margin: 0 auto;
}

.portal-welcome {
  position: relative;
  overflow: hidden;
  margin-bottom: var(--space-8);
  padding: var(--space-8) var(--space-10);
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--navy-800), var(--navy-700));
  color: var(--on-brand);
}

.portal-welcome::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(245, 197, 24, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245, 197, 24, 0.045) 1px, transparent 1px);
  background-size: 40px 40px;
}

.portal-welcome-content {
  position: relative;
}

.portal-welcome h2 {
  margin-bottom: var(--space-2);
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: var(--weight-extrabold);
  letter-spacing: var(--tracking-tight);
  color: var(--on-brand);
}

.portal-welcome h2 .gold {
  color: var(--gold-400);
}

.portal-welcome p {
  max-width: 60ch;
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  color: rgba(255, 255, 255, 0.7);
}

.services-title {
  margin-bottom: var(--space-1);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-brand);
}

.services-subtitle {
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-10);
}

.service-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow: hidden;
  padding: var(--space-6) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  text-align: left;
  cursor: pointer;
  transition:
    transform var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out);
}

.service-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--tone, var(--gold-600));
  transition: height var(--duration-base) var(--ease-out);
}

.service-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--tone, var(--gold-600)) 45%, var(--border));
}

.service-card:hover::before {
  height: 5px;
}

/* Each tone sets one custom property; rail, icon tint and arrow all read it. */
.sc-blue {
  --tone: var(--blue-600);
}
.sc-red {
  --tone: var(--red-500);
}
.sc-green {
  --tone: var(--green-600);
}
.sc-purple {
  --tone: var(--violet-500);
}
.sc-teal {
  --tone: var(--teal-600);
}
.sc-gold {
  --tone: var(--gold-600);
}

.service-icon-wrap {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--tone, var(--gold-600)) 12%, transparent);
  color: var(--tone, var(--gold-600));
  font-size: 1.4rem;
}

.service-title {
  margin-bottom: var(--space-1);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-brand);
}

.service-desc {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--text-muted);
}

.service-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: auto;
  align-self: flex-start;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.03em;
  color: var(--tone, var(--gold-600));
  transition: gap var(--duration-base) var(--ease-out);
}

.service-card:hover .service-arrow {
  gap: var(--space-2);
}

/* The .quick-access-* block that was here styled the dashboard's "Services
   Quick Access" tile grid. That card and the "Quick Actions" button row were
   both removed — every destination they offered is one click away in the
   sidebar, and they were pushing the charts below the fold. Nothing else in
   the app used these classes. */

/* ═══════════════════════════════════════════════════
   18 · MODULE-SPECIFIC BLOCKS
═══════════════════════════════════════════════════ */

/* ── Resident search results ───────────────────────── */
.resident-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.resident-card:hover {
  background: var(--accent-bg);
  border-color: var(--accent-border);
}

.resident-avatar-sm {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--navy-800);
  color: var(--gold-400);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}

.resident-info {
  min-width: 0;
}

.resident-info h4 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.resident-info p {
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Certificate picker ────────────────────────────── */
.cert-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.cert-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  text-align: center;
  cursor: pointer;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out);
}

.cert-type-card:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.cert-type-card.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.cert-type-card .cert-icon {
  color: var(--accent-fg);
  font-size: 1.4rem;
}

.cert-type-card .cert-name {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  color: var(--text-primary);
}

.cert-selected-badge {
  margin-bottom: var(--space-5);
}

/* ── Certificate queue actions ─────────────────────── */
/* Workflow buttons on the left, the fixed Message / Delete / Export cluster
   pushed to the right edge. Neither side wraps: a wrapped row would drop the
   fixed cluster onto a second line and out of line with the rows around it —
   the table scrolls sideways instead. */
.cert-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cert-actions > .btn-group {
  flex-wrap: nowrap;
}

.cert-actions-fixed {
  margin-left: auto;
}

/* Holds the width of a Message or Export a row doesn't have. */
.cert-action-placeholder {
  visibility: hidden;
}

/* ── Certificate Processing tabs ───────────────────── */
.cert-page-tabs {
  display: inline-flex;
  margin-bottom: var(--space-5);
}

/* ── Certificate forms editor (js/certificate-forms.js) ─
   A word-processor page: a bar with the certificate picker and Save, a
   toolbar that stays in view, the A4 sheet itself, and a side panel for the
   fill-in fields and the certificate's details. */
.cfw-readonly {
  margin-bottom: var(--space-4);
}

.cfw {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cfw-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}

.cfw-bar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.cfw-bar-label {
  font-size: 11px;
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cfw-select {
  width: auto;
  min-width: 240px;
  max-width: 420px;
}

.cfw-state {
  font-size: 12px;
  color: var(--text-muted);
}

.cfw-state[data-state="dirty"] {
  font-weight: var(--weight-semibold);
  color: var(--warning);
}

.cfw-overflow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: var(--weight-semibold);
  color: var(--danger);
}

.cfw-overflow[hidden] {
  display: none;
}

.cfw-overflow svg {
  width: 14px;
  height: 14px;
}

.cfw .btn.is-on {
  border-color: var(--accent);
  background: var(--accent-bg);
}

/* ── Toolbar ── */
.cfw-ribbon {
  position: sticky;
  top: calc(var(--topbar-h) + var(--space-2));
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-2);
}

.cfw-ribbon-set {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.cfw-ribbon-set:disabled {
  opacity: 0.5;
}

.cfw-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  border-right: 1px solid var(--border);
}

.cfw-ribbon-set > .cfw-group:last-child,
.cfw-zoom-group {
  border-right: 0;
}

.cfw-table-tools[hidden] {
  display: none;
}

.cfw-rbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  font: inherit;
  font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
}

.cfw-rbtn span {
  font-size: 12.5px;
  font-weight: var(--weight-semibold);
}

.cfw-rbtn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.cfw-rbtn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--text-primary);
}

/* The one button this page is about. Gold, like the rest of the MIS's
   "do the thing" buttons. */
.cfw-rbtn-field,
.cfw-rbtn-field:hover:not(:disabled) {
  background: var(--gold-400);
  color: var(--navy-800);
}

.cfw-rbtn-field:hover:not(:disabled) {
  background: var(--gold-500);
}

.cfw-svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.cfw-rsel {
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font: inherit;
  font-size: 12.5px;
  color: var(--text-primary);
  cursor: pointer;
}

.cfw-rsel-style {
  width: 124px;
}

.cfw-rsel-font {
  width: 140px;
}

.cfw-rsel-size {
  width: 62px;
}

.cfw-rsel-letter {
  width: 96px;
}

.cfw-rsel-num {
  width: 78px;
}

.cfw-rsel-zoom {
  width: 70px;
}

.cfw-colw {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.cfw-colw input {
  width: 56px;
  height: 28px;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font: inherit;
  color: var(--text-primary);
}

/* ── The page ── */
.cfw-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--space-3);
  align-items: start;
}

.cfw-canvas {
  display: flex;
  justify-content: center;
  overflow: auto;
  padding: 16px;
  border-radius: var(--radius-md);
  background: #8a8a8a;
}

.cfw-zoom {
  flex: none;
}

.cfw-page {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.cfw-heading {
  cursor: not-allowed;
  user-select: none;
}

.cfw-body {
  min-height: 40mm;
  outline: none;
  cursor: text;
}

.cfw-body[hidden],
.cfw-preview-body[hidden] {
  display: none;
}

/* Table cells get faint guides while editing, so a borderless table can be
   found and clicked into. They never print — the print window has no
   .cfw-body. */
.cfw-body td {
  min-width: 6mm;
  outline: 1px dashed rgba(0, 0, 0, 0.2);
  outline-offset: -1px;
}

/* A fill-in field on the page: tinted, labelled with what it holds, and as
   wide as the blank it prints. */
.cfw-field {
  display: inline-block;
  min-height: 1.2em;
  padding: 0 4px;
  border-bottom: 1px dashed #b38600;
  border-radius: 2px 2px 0 0;
  background: rgba(245, 197, 24, 0.22);
  line-height: 1.2;
  text-align: center;
  text-indent: 0;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.cfw-field-line {
  border-bottom: 1px solid #000;
}

.cfw-field:hover {
  background: rgba(245, 197, 24, 0.45);
}

.cfw-field-label {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8pt;
  font-style: normal;
  font-weight: normal;
  letter-spacing: 0;
  color: #7a5a00;
}

.cfw-field-flash {
  animation: cfw-flash 1.2s ease;
}

@keyframes cfw-flash {
  0%,
  60% {
    background: rgba(245, 197, 24, 0.9);
    box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.55);
  }
}

/* Where the printable area ends — 297mm less the bottom margin. Red when the
   wording runs past it. */
.cfw-page-end {
  position: absolute;
  top: calc(297mm - 18mm);
  right: 0;
  left: 0;
  border-top: 1px dashed rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

.cfw-page-end span {
  position: absolute;
  top: -15px;
  right: 4mm;
  font: 9px Arial, Helvetica, sans-serif;
  color: rgba(0, 0, 0, 0.35);
}

.cfw-page-end.is-over {
  border-top: 2px solid #dc2626;
}

.cfw-page-end.is-over span {
  color: #dc2626;
}

/* ── Side panel ── */
.cfw-side {
  position: sticky;
  top: calc(var(--topbar-h) + 64px);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: calc(100vh - var(--topbar-h) - 80px);
  overflow-y: auto;
  padding: var(--space-3);
}

.cfw-side-tabs .sc-tab {
  flex: 1;
  justify-content: center;
  padding: 6px 10px;
  font-size: 12.5px;
}

.cfw-side-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cfw-side .form-group {
  margin-bottom: 0;
}

.cfw-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

.cfw-hint[hidden] {
  display: none;
}

.cfw-side-insert {
  justify-content: center;
}

.cfw-side-insert .cfw-svg {
  width: 16px;
  height: 16px;
}

.cfw-field-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cfw-field-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font: inherit;
  text-align: left;
  color: var(--text-primary);
  cursor: pointer;
}

.cfw-field-item:hover {
  border-color: var(--accent);
}

.cfw-field-item-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.cfw-field-item-meta {
  font-size: 11.5px;
  color: var(--text-muted);
}

.cfw-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-sm);
  line-height: 1.4;
  cursor: pointer;
}

.cfw-check input {
  margin-top: 3px;
}

.cfw-side-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.cfw-req {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.cfw-req-head {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cfw-req-checks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.cfw-icon-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.cfw-icon-btn svg {
  width: 15px;
  height: 15px;
}

.cfw-icon-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.cfw-more .btn {
  justify-content: flex-start;
}

.cfw-slug code {
  font-family: var(--font-mono);
}

/* ── Fill-in field dialog ── */
.cfw-dialog {
  width: min(560px, 94vw);
}

.cfw-dialog .modal-title-icon .cfw-svg {
  width: 18px;
  height: 18px;
}

.cfw-fd-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: 70vh;
  overflow-y: auto;
}

.cfw-fd-body .form-group {
  margin-bottom: 0;
}

.cfw-fd-body .form-group .cfw-hint {
  margin-top: 4px;
}

.cfw-fd-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.cfw-fd-section.is-off {
  opacity: 0.5;
}

.cfw-fd-width {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.cfw-fd-width input {
  width: 90px;
}

.cfw-fd-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cfw-chip {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  font: inherit;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.cfw-chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

/* The width the field is set to. Gold like the other chosen controls, so it
   reads from across the dialog — including "Fit to text". */
.cfw-chip[aria-pressed="true"],
.cfw-chip[aria-pressed="true"]:hover {
  border-color: var(--gold-500);
  background: var(--gold-400);
  font-weight: var(--weight-bold);
  color: var(--navy-800);
}

/* A 170mm line of text, and the part of it the blank will take. */
.cfw-fd-ruler {
  position: relative;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, var(--border) 0 1px, transparent 1px 10%);
}

.cfw-fd-bar {
  position: absolute;
  bottom: 3px;
  left: 0;
  width: 0;
  border-bottom: 3px solid var(--gold-500);
  transition: width 0.12s ease;
}

.cfw-fd-bar.is-fit {
  width: 18px;
  border-bottom-style: dashed;
}

.cfw-fd-shared[hidden],
.cfw-fd-error[hidden],
#cfw-fd-remove[hidden] {
  display: none;
}

.cfw-fd-error {
  margin: 0;
  font-size: 12.5px;
  color: var(--danger);
}

.cfw-fd-footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cfw-fd-spacer {
  flex: 1;
}

/* Not enough room beside the page: the panel moves underneath it. */
@media (max-width: 1200px) {
  .cfw-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .cfw-side {
    position: static;
    max-height: none;
  }
}

/* ── Star rating ───────────────────────────────────── */
.star-rating {
  display: flex;
  gap: var(--space-1);
  margin: var(--space-2) 0;
}

.star {
  border: 0;
  background: none;
  padding: 2px;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--border-strong);
  cursor: pointer;
  transition:
    color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-spring);
}

.star:hover {
  transform: scale(1.12);
}

.star.active,
.star:hover {
  color: var(--gold-400);
}

/* Submitted with no rating. The row is a div, so it gets the shake from the
   bare .m-shake rule but none of .form-control.m-empty's amber halo — draw
   that here instead, on the stars themselves, since a box around them would
   read as a field they had failed to type in. Outlives the shake so scrolling
   back still shows what is missing. */
.star-rating.m-empty .star {
  color: var(--warning-solid);
}

.star-rating:focus {
  outline: none;
}

.rating-label {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* The prompt before anything is chosen carries a little more weight than the
   verdict that replaces it — it is an instruction, not a caption. */
.star-rating.m-empty + .rating-label {
  color: var(--warning);
  font-weight: var(--weight-semibold);
}

/* ── Feedback list ─────────────────────────────────── */
.feedback-item {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}

.feedback-item:last-child {
  border-bottom: none;
}

.feedback-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.feedback-stars {
  color: var(--gold-400);
  font-size: var(--text-base);
}

.feedback-date {
  margin-left: auto;
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

/* Per-entry Delete, at the far right of the meta row. Empty for roles without
   the "Delete Records" permission, so it must not reserve space of its own. */
.feedback-item-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.feedback-msg {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

/* ── Archive list ──────────────────────────────────── */
.archive-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.archive-card:last-child {
  border-bottom: none;
}

.archive-icon {
  flex-shrink: 0;
  display: inline-flex;
  color: var(--accent-fg);
  font-size: 1.3rem;
}

.archive-meta {
  flex: 1;
  min-width: 0;
}

.archive-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.archive-info {
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Countdown to automatic permanent deletion. Only snapshots with a schedule
   show one (cleared audit entries), so it has to read as a deadline rather
   than as one more grey metadata line — it is the only thing on the card that
   will change without anybody touching it. */
.archive-timer {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.6;
}

.archive-timer i {
  display: inline-flex;
  font-size: 0.9em;
}

.archive-timer-ok {
  background: var(--info-bg, rgba(29, 78, 216, 0.1));
  color: var(--info, #1d4ed8);
}

.archive-timer-soon {
  background: var(--warning-bg, rgba(245, 158, 11, 0.12));
  color: var(--warning, #b45309);
}

.archive-timer-due {
  background: var(--danger-bg, rgba(239, 68, 68, 0.12));
  color: var(--danger, #dc2626);
}

.archive-actions {
  display: flex;
  flex-shrink: 0;
  gap: var(--space-1);
}

/* The backups taken, under the "last backup" line on the Archive page. */
.backup-list {
  margin-top: var(--space-2);
}

/* Permanent delete sat in the row looking exactly like Restore beside it.
   It now reads destructive on hover, before the confirm dialog. */
.btn-archive-purge {
  color: var(--text-muted);
}

.btn-archive-purge:hover:not(:disabled) {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

/* Stands where the permanent-delete button would be, for archived audit
   entries — which have no manual delete at all. Deliberately not a disabled
   button: a greyed-out control invites hunting for the permission that would
   enable it, and there isn't one. */
.archive-locked {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--text-muted);
  opacity: 0.55;
  cursor: help;
}

/* ── Incident report modal helpers ─────────────────── */
.inc-pick-status {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.inc-pick-status.picked {
  color: var(--success);
  font-weight: var(--weight-semibold);
}

/* Logged calls only (js/incident-report.js): file without a pin when the
   caller could not say where they are. Hidden on the public form — a resident
   filing their own report is standing in it. */
.inc-nopin {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

.inc-nopin input {
  width: 16px;
  height: 16px;
  accent-color: var(--gold-600);
  cursor: pointer;
}

.inc-field-hint {
  margin-top: var(--space-1);
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════
   19 · ACCOUNT-CLAIM WIZARD
═══════════════════════════════════════════════════ */

.acc-steps {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.acc-step {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  transition:
    background var(--duration-base) var(--ease-out),
    color var(--duration-base) var(--ease-out);
}

.acc-step-line {
  flex: 1;
  height: 2px;
  border-radius: var(--radius-full);
  background: var(--border);
  transition: background var(--duration-base) var(--ease-out);
}

.acc-step-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
}

.acc-step-help {
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.acc-step-complete {
  padding: var(--space-5) 0;
  text-align: center;
}

.acc-success-icon {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto var(--space-5);
  border-radius: var(--radius-full);
  background: var(--success-bg);
  color: var(--success);
  font-size: 2.2rem;
}

.acc-success-title {
  margin-bottom: var(--space-2);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-brand);
}

.acc-success-copy {
  max-width: 42ch;
  margin: 0 auto var(--space-5);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.acc-ref-box {
  display: inline-block;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: left;
}

.acc-ref-label {
  margin-bottom: var(--space-1);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}

.acc-ref-number {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-brand);
}

/* The ID photo pickers (js/account-application.js): three tap targets that
   become their own preview once a photo is chosen. */
.acc-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
@media (max-width: 560px) {
  .acc-photo-grid {
    grid-template-columns: 1fr;
  }
}
.acc-photo-label {
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
}
.acc-photo-drop {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1.5px dashed var(--border-strong, var(--border));
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  cursor: pointer;
  transition: border-color var(--duration-base) var(--ease-out);
}
.acc-photo-drop:hover {
  border-color: var(--gold);
}
.acc-photo-empty {
  display: grid;
  justify-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  font-size: var(--text-2xs);
  text-align: center;
  color: var(--text-muted);
}
.acc-photo-empty svg {
  width: 22px;
  height: 22px;
}
.acc-photo-drop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.acc-consent {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  cursor: pointer;
}
.acc-consent input {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--gold-600);
}

/* The optional "confirm your number" step (js/account-application.js): the
   button that asks for a code, and the line that says it worked. Hidden
   entirely unless the server says a text would really arrive. */
.acc-code-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.acc-confirmed {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--success-border, var(--border));
  border-radius: var(--radius-md);
  background: var(--success-bg, var(--surface-sunken));
  color: var(--success, var(--text-secondary));
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
/* The review modal on Account Claiming (js/pages/accounts.js): the applicant's
   details beside their ID photos, then the candidate records below. */
.app-review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-5);
}
@media (max-width: 760px) {
  .app-review-grid {
    grid-template-columns: 1fr;
  }
}
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.detail-table th,
.detail-table td {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.detail-table th {
  padding-right: var(--space-3);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
}
.app-photos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.app-photo {
  margin: 0;
}
.app-photo figcaption {
  margin-top: 4px;
  font-size: var(--text-2xs);
  color: var(--text-muted);
}
.app-photo-frame {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}
.app-photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}
/* One click shows a photo whole, across the three columns. */
.app-photo.app-photo-zoom {
  grid-column: 1 / -1;
  order: -1;
}
.app-photo.app-photo-zoom .app-photo-frame {
  aspect-ratio: auto;
}
.app-photo.app-photo-zoom .app-photo-frame img {
  height: auto;
  object-fit: contain;
  cursor: zoom-out;
}
.app-candidates {
  display: grid;
  gap: var(--space-2);
}
.app-candidate {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.app-candidate-photo {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  color: var(--text-muted);
}
.app-candidate-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.app-candidate-main {
  flex: 1;
  min-width: 0;
}
.app-candidate-actions {
  flex: none;
}
@media (max-width: 560px) {
  .app-candidate {
    flex-wrap: wrap;
  }
}

/* In the portal modal the wizard supplies .modal-body and .modal-footer
   itself; its own box must not get between them and .modal-box's layout. */
.modal-box > .acc-wizard {
  display: contents;
}
/* Buttons and grids set their own display, which beats the UA's [hidden]
   rule — restate it for everything the wizard shows and hides. */
.acc-wizard [hidden] {
  display: none !important;
}

/* ═══════════════════════════════════════════════════
   20 · SYSMODAL & TOAST
═══════════════════════════════════════════════════ */

.sysmodal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: rgba(6, 14, 27, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sysmodal-backdrop.open {
  display: flex;
}

.sysmodal {
  width: 560px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface-raised);
  box-shadow: var(--shadow-xl);
  animation: modalIn var(--duration-slow) var(--ease-out);
}

.sysmodal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.sysmodal-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-brand);
}

.sysmodal-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.sysmodal-close:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.sysmodal-body {
  padding: var(--space-6);
}

.sysmodal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ── Toast ─────────────────────────────────────────── */
.toast {
  position: fixed;
  right: var(--space-6);
  bottom: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: min(420px, calc(100vw - var(--space-8)));
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--navy-800);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  box-shadow:
    var(--shadow-xl),
    inset 0 0 0 1px rgba(245, 197, 24, 0.32);
  opacity: 0;
  transform: translateY(120%);
  transition:
    opacity var(--duration-slow) var(--ease-out),
    transform var(--duration-slow) var(--ease-out);
}

.toast > span:first-child {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--gold-400);
  font-size: 1.1rem;
}

/* ═══════════════════════════════════════════════════
   20b · SIGN-IN SCREEN  (system.html)

   The one full-screen surface in the MIS. It stays dark
   in both themes — it is the handoff from the public
   portal's navy hero into the application.
═══════════════════════════════════════════════════ */

#login-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background:
    radial-gradient(900px 480px at 82% -10%, rgba(37, 99, 235, 0.22), transparent 60%),
    radial-gradient(760px 420px at -10% 110%, rgba(201, 162, 39, 0.16), transparent 55%),
    linear-gradient(150deg, var(--navy-900) 0%, var(--navy-800) 55%, var(--navy-700) 100%);
  transition:
    opacity var(--duration-slow) var(--ease-out),
    visibility var(--duration-slow) var(--ease-out);
}

#login-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Two faint rings echoing the seal, kept behind the card. */
.login-bg-pattern {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.login-bg-pattern::before,
.login-bg-pattern::after {
  content: "";
  position: absolute;
  border-radius: var(--radius-full);
  border: 1px solid rgba(201, 162, 39, 0.12);
}

.login-bg-pattern::before {
  top: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
}

.login-bg-pattern::after {
  bottom: -150px;
  left: -150px;
  width: 500px;
  height: 500px;
  border-color: rgba(201, 162, 39, 0.08);
}

.login-card {
  position: relative;
  width: 420px;
  max-width: 100%;
  padding: var(--space-10) var(--space-8);
  border: 1px solid rgba(201, 162, 39, 0.22);
  border-radius: var(--radius-2xl);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 32px 80px -24px rgba(0, 0, 0, 0.6);
}

.login-seal {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto var(--space-6);
  border-radius: var(--radius-full);
  background: var(--gold-600);
  box-shadow:
    0 0 0 6px rgba(201, 162, 39, 0.18),
    0 0 0 12px rgba(201, 162, 39, 0.07);
}

.login-seal img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.login-title {
  margin-bottom: var(--space-1);
  font-size: var(--text-2xl);
  font-weight: var(--weight-extrabold);
  letter-spacing: var(--tracking-tight);
  text-align: center;
  color: #fff;
}

.login-subtitle {
  margin-bottom: var(--space-8);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  text-align: center;
  color: rgba(255, 255, 255, 0.48);
}

.login-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.login-input {
  width: 100%;
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid rgba(201, 162, 39, 0.25);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: inherit;
  font-size: var(--text-base);
  outline: none;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.login-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.login-input:focus {
  border-color: var(--gold-600);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}

/* The password box and its show/hide button (js/password-reveal.js). The gap
   below moves from the box to the wrapper, so the button centres on the box
   alone; the colours are the dark card's, not the light form's. */
.login-pass-field {
  margin-bottom: var(--space-5);
}

.login-pass-field .login-input {
  margin-bottom: 0;
  padding-right: 48px;
}

.login-pass-field .cp-eye {
  color: rgba(255, 255, 255, 0.55);
}

.login-pass-field .cp-eye:hover,
.login-pass-field .cp-eye:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.login-pass-field .cp-eye:focus-visible {
  outline: 2px solid var(--gold-600);
  outline-offset: 1px;
}

.login-error {
  min-height: 18px;
  margin: 6px 0;
  font-size: 13px;
  color: #fca5a5;
}

.login-btn {
  width: 100%;
  margin-top: var(--space-1);
  padding: var(--space-4);
  border: 0;
  border-radius: var(--radius-md);
  background: var(--gold-400);
  color: var(--navy-900);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.login-btn:hover:not(:disabled) {
  background: var(--gold-300);
  box-shadow: 0 10px 24px -8px rgba(201, 162, 39, 0.6);
  transform: translateY(-1px);
}

.login-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.99);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* Role chips are no longer rendered — the account's own role decides access —
   but the styles stay for any cached markup still carrying them. */
.login-roles {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.role-chip {
  flex: 1;
  padding: var(--space-2);
  border: 1px solid rgba(201, 162, 39, 0.2);
  border-radius: var(--radius-md);
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-family: inherit;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.role-chip.active {
  background: rgba(201, 162, 39, 0.15);
  border-color: var(--gold-600);
  color: var(--gold-300);
}

.login-claim {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid rgba(201, 162, 39, 0.15);
  font-size: var(--text-sm);
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
}

.login-claim a {
  margin-left: var(--space-1);
  color: var(--gold-300);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

.login-claim a:hover {
  color: var(--gold-400);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.login-back-link {
  display: block;
  margin-top: var(--space-5);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-align: center;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.4);
  transition: color var(--duration-fast) var(--ease-out);
}

.login-back-link:hover {
  color: var(--gold-400);
}

@media (max-width: 480px) {
  .login-card {
    padding: var(--space-7) var(--space-5);
  }
}

/* ═══════════════════════════════════════════════════
   21 · UTILITIES
═══════════════════════════════════════════════════ */

/* No !important: several elements are revealed by JS setting an inline
   display, and an important declaration here would outrank it. */
.is-hidden {
  display: none;
}

.text-left {
  text-align: left;
}
.text-center {
  text-align: center;
}

.table-wrap + .feedback-pagination {
  margin-top: 0;
}

/* Spacing helpers the page templates already reference. */
.alert-mb {
  margin-bottom: var(--space-5);
}
.alert-spacing-top {
  margin-top: var(--space-4);
}
.form-row-tight {
  margin-bottom: var(--space-4);
}
.form-row-roomy {
  margin-bottom: var(--space-5);
}
.form-group-flat {
  margin: 0;
}
.textarea-tall {
  min-height: 130px;
}
.textarea-medium {
  min-height: 110px;
}
.badge-align-right {
  margin-left: auto;
}
.modal-help-text {
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.modal-help-text-lg {
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════
   22 · RESPONSIVE
═══════════════════════════════════════════════════ */

/* Tablet: the sidebar becomes an overlay drawer so content keeps full width. */
@media (max-width: 1024px) {
  #main.with-sidebar,
  .sidebar-collapsed #main.with-sidebar {
    margin-left: 0;
  }

  /* The collapsed rail is a desktop affordance; as a drawer the sidebar always
     opens at full width. The rail's rules are gated behind min-width: 1025px,
     so only the width itself needs resetting here. */
  .sidebar-collapsed #sidebar {
    width: var(--sidebar-w);
  }

  /* Off-canvas until toggled, and above the scrim that dims the page. */
  #sidebar {
    z-index: var(--z-drawer);
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }

  #sidebar.mobile-open {
    transform: translateX(0);
  }

  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .portal-welcome {
    padding: var(--space-6) var(--space-5);
  }
}

@media (max-width: 768px) {
  .topbar-date,
  .topbar-kbd {
    display: none;
  }

  .nav-user-menu-trigger .nav-user-name {
    display: none;
  }

  .nav-user-menu-trigger {
    padding-right: 4px;
  }

  .nav-user-caret {
    display: none;
  }

  .topbar-modules-dropdown {
    position: fixed;
    top: calc(var(--topbar-h) + var(--space-2));
    right: var(--space-3);
    left: var(--space-3);
    width: auto;
  }

  /* Comfortable touch targets on the controls people actually poke at. */
  .topbar-icon-btn,
  .fb-page-btn {
    min-width: 40px;
    height: 40px;
  }

  .nav-item {
    padding-block: var(--space-3);
  }
}

@media (max-width: 600px) {
  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-3);
  }

  .kpi-card {
    padding: var(--space-4);
  }

  .kpi-value {
    font-size: var(--text-2xl);
  }

  .page-title {
    font-size: var(--text-xl);
  }

  .cert-type-grid,
  .services-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .card-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-input,
  .filter-select {
    flex-basis: 100%;
    max-width: none;
  }

  .toast {
    right: var(--space-3);
    left: var(--space-3);
    bottom: var(--space-3);
    max-width: none;
  }
}

/* ═══════════════════════════════════════════════════
   23 · PRINT
   Certificates, blotter entries and audit extracts get
   printed at the barangay hall — chrome should not.
═══════════════════════════════════════════════════ */

@media print {
  #sidebar,
  #topbar,
  .sidebar-scrim,
  .toast,
  .btn-group,
  .filter-row,
  .card-action,
  .gis-heat-controls {
    display: none !important;
  }

  #main.with-sidebar {
    margin-left: 0;
  }

  #page-content {
    padding: 0;
  }

  .card,
  .kpi-card,
  .notice-card {
    break-inside: avoid;
    border-color: #ccc;
    box-shadow: none;
  }

  body {
    background: #fff;
  }
}

/* ═══════════════════════════════════════════════════
   AI SURFACES — Feedback page (js/pages/feedback.js)
   Filled by Gemini via /api/ai/feedback/*. Every rule here styles
   something that is absent when the server has no Gemini key, so the
   page simply renders without them.
   ═══════════════════════════════════════════════════ */

.fb-ai-note {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  color: var(--text-muted);
}

.fb-ai-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.35);
  color: #7c3aed;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* A theme is a group of the phrases residents' comments were actually read
   as, so it names them underneath itself. Without this the merge is invisible
   and staff have no way to tell that "Document Processing · 8" is three
   different wordings — or to notice when the AI has merged two things that
   should not have been. Kept to one line: it is evidence, not a heading. */
.fb-theme-row .stat-row-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  /* More room than the default 1:2 label:bar split. The phrase line is the
     part that gets cut first, and it is the part that earns the theme's
     trust — the bar only has to be comparable to the ones above it. */
  flex: 1.6;
}

.fb-theme-merged {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Per-item alert chip, beside the stars in Recent Feedback. */
.fb-chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: capitalize;
  border: 1px solid transparent;
  cursor: help;
}
.fb-chip-urgent {
  background: rgba(239, 68, 68, 0.9);
  border-color: rgba(239, 68, 68, 0.9);
  color: #fff;
}

/* An alert somebody has dealt with. Deliberately quiet — the row is history,
   not a queue item, and it must not compete with the open flags in the same
   list. Hover gives who resolved it and when. */
.fb-chip-resolved {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.35);
  color: #15803d;
}
[data-theme="dark"] .fb-chip-resolved {
  color: #4ade80;
}

/* The AI was wrong. Grey, not red and not green: nothing happened, and the
   chip is a note about the FLAG rather than a judgement on the feedback —
   which is still in the list and still counted like every other comment. */
.fb-chip-dismissed {
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.4);
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* A still-open flag marks its whole row, so scanning Recent Feedback shows
   where the unhandled ones are without reading every chip. */
.feedback-item.is-flagged {
  border-left: 3px solid #ef4444;
  padding-left: var(--space-3);
}

/* What staff sent back to the resident when they resolved it. Indented under
   the comment like a reply in a thread, because that is what it is — the row
   now holds both halves of an exchange. */
.fb-reply {
  margin: var(--space-2) 0 0 var(--space-4);
  padding: var(--space-2) var(--space-3);
  border-left: 2px solid rgba(34, 197, 94, 0.5);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: rgba(34, 197, 94, 0.06);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.fb-reply-tag {
  display: block;
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #15803d;
}
[data-theme="dark"] .fb-reply-tag {
  color: #4ade80;
}

/* Landing here from the dashboard's View button. The entry is scrolled to and
   flashed, then settles — a permanent marker would still be lit the next time
   the page is opened and would stop meaning "this is the one you asked for".

   The target is the Needs Attention entry: that is the one carrying the full
   comment and the Dismiss/Resolve pair, which is the whole reason View brings
   an officer here rather than letting them close an alert off a one-line
   summary. The Recent Feedback rule below is the fallback for an alert that has
   already been closed and so has left the queue.

   Two flashes over ~2s: one pulse is easy to miss at the end of a smooth
   scroll, since the scroll is still moving while the animation plays. */
.fb-attention-item.is-highlighted,
.feedback-item.is-highlighted {
  animation: fb-highlight 2.2s var(--ease-out);
  border-radius: var(--radius-md);
  /* Inset the band from the text without moving the text: the padding it gains
     is cancelled by an equal negative margin, so nothing shifts when the
     highlight ends. */
  margin-left: calc(var(--space-3) * -1);
  margin-right: calc(var(--space-3) * -1);
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}
@keyframes fb-highlight {
  0%,
  20% {
    background: rgba(201, 162, 39, 0.26);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.45);
  }
  40% {
    background: rgba(201, 162, 39, 0.06);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.1);
  }
  60% {
    background: rgba(201, 162, 39, 0.26);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.45);
  }
  100% {
    background: transparent;
    box-shadow: 0 0 0 3px transparent;
  }
}
/* Respect a reduced-motion preference: still mark the entry, just do not flash
   it. The scroll is already instant under this setting. */
@media (prefers-reduced-motion: reduce) {
  .fb-attention-item.is-highlighted,
  .feedback-item.is-highlighted {
    animation: none;
    background: rgba(201, 162, 39, 0.16);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.3);
    border-radius: var(--radius-md);
  }
}

/* Dismiss and Resolve as a pair at the end of the badge row. */
.fb-attention-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.fb-attention-card {
  border-left: 3px solid #ef4444;
}
.fb-attention-item {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.fb-attention-item:last-child {
  border-bottom: none;
}
.fb-attention-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}


/* The resident's own words under the AI's summary of them. Quieter than the
   line above, because that line is the claim and this is the evidence for it —
   but present, because a summary nobody can check is a summary nobody should
   trust. The dashboard drops this to stay thin and puts it on the tooltip; here
   there is room to simply show it. */
.fb-attention-quote {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-3);
  border-left: 2px solid var(--border);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

/* Dark palette is driven by data-theme="dark" on <html> (js/theme.js), not by
   the media query — a manual toggle has to win over the OS preference. */
[data-theme="dark"] .fb-ai-badge {
  color: #a78bfa;
}

/* ═══════════════════════════════════════════════════
   INCIDENT DETAIL MODAL  (js/pages/incidents.js)
   The blotter table can only carry five columns, so narration, respondent,
   witnesses and contact had nowhere to be read. This is that view.
   ═══════════════════════════════════════════════════ */
.incident-detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

/* ── What the officials were texted about this report ────────────────────
   Sits under the badges in the detail modal, above the report itself: the
   first thing someone opening a report at 2 AM wants to know is whether
   anybody else has been told. */
.incident-sms {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  font-size: var(--text-sm);
}

.incident-sms-ok {
  color: var(--text-secondary);
}

.incident-sms-warn {
  color: var(--warning);
  font-weight: var(--weight-semibold);
}

.incident-sms-muted {
  color: var(--text-muted);
}

/* "Reports go to N officials", in the blotter's card header. Red when the
   answer is nobody — that is a fault in the system, not a statistic. */
.incident-recipients {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.incident-recipients.is-warning {
  color: var(--danger);
}
.incident-detail-row {
  display: grid;
  grid-template-columns: minmax(110px, 150px) 1fr;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.incident-detail-row:last-child {
  border-bottom: none;
}
.incident-detail-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.incident-detail-value {
  font-size: 13px;
  line-height: 1.55;
  min-width: 0;
  overflow-wrap: anywhere;
}
/* Narration is free text and can be long — let it breathe. */
.incident-detail-block {
  white-space: pre-wrap;
}
/* The blotter row a map pin's "View in Blotter" arrived for
   (openIncidentFromHandoff) — tinted so it is still easy to find once its
   detail modal is closed. It stays for as long as the page is open. */
.data-table tr.incident-row-focus > td {
  background: rgba(201, 162, 39, 0.16);
}
.data-table tr.incident-row-focus > td:first-child {
  box-shadow: inset 3px 0 0 var(--gold, #c9a227);
}
@media (max-width: 640px) {
  .incident-detail-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* ═══════════════════════════════════════════════════
   AI BRIEFING STRIP  (dashboard, js/shell.js renderAiSummary)
   Full-width card at the top of the dashboard. The four sections lay out as a
   horizontal strip so the whole briefing is one glance, rather than a tall
   column of prose squeezed beside another card.
   ═══════════════════════════════════════════════════ */
.ai-briefing {
  margin-bottom: var(--space-5);
}

/* Only applied once real sections exist — the placeholder and any error
   message stay as plain centred text inside the same dashed box. */
.ai-summary-text.ai-summary-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.ai-summary-section {
  min-width: 0;
  padding-left: var(--space-3);
  border-left: 3px solid var(--border);
}
/* Same colour language as the GIS briefing: what is waiting, what is slipping,
   how residents feel, what to do first. */
.ai-summary-section-1 {
  border-left-color: #3b82f6;
}
.ai-summary-section-2 {
  border-left-color: #ef4444;
}
.ai-summary-section-3 {
  border-left-color: #f59e0b;
}
.ai-summary-section-4 {
  border-left-color: #22c55e;
}

.ai-summary-head {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.ai-summary-body {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.ai-summary-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ai-summary-list li {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-secondary);
  padding-left: 11px;
  position: relative;
}
.ai-summary-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

/* Below the strip's natural break point the columns stack, and the left rules
   read as a vertical list instead — still scannable, just taller. */
@media (max-width: 640px) {
  .ai-summary-text.ai-summary-sections {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
}

/* ═══════════════════════════════════════════════════
   AI URGENT ALERTS  (inside the dashboard briefing, js/shell.js renderAiAlerts)

   Lives under the briefing's four summary columns: the summary says three items
   are flagged, and these are those three, each with the button that clears it.
   One thin line per alert, each in its own box — a run of them has to read as a
   list of things to do, not as a second wall of text under the first.

   Red is spent here and nowhere else on the dashboard. The whole block is
   absent, not empty, when nothing is flagged.
   ═══════════════════════════════════════════════════ */
.ai-alerts {
  margin-top: var(--space-4);
}

.ai-alerts-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #b91c1c;
}
[data-theme="dark"] .ai-alerts-head {
  color: #f87171;
}
.ai-alerts-head i {
  width: 14px;
  height: 14px;
}

/* How many are waiting. Reads as a count, not as decoration, so it carries the
   same weight as the sidebar pills. */
.ai-alert-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: #ef4444;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
}

/* One alert: a single row, boxed. Vertical padding is deliberately tight —
   four alerts should cost about as much height as one paragraph, or the
   briefing stops being a strip you can take in at a glance. */
.ai-alert {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 6px var(--space-3);
  margin-bottom: 6px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-left: 3px solid #ef4444;
  border-radius: var(--radius-md);
  background: rgba(239, 68, 68, 0.05);
}
.ai-alert:last-child {
  margin-bottom: 0;
}

/* Safety risk vs service failure, in one word. Both are urgent; which one it is
   decides who gets sent. */
.ai-alert-kind {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.ai-alert-kind-safety {
  background: #ef4444;
  color: #fff;
}
.ai-alert-kind-service {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #b45309;
}
[data-theme="dark"] .ai-alert-kind-service {
  color: #fbbf24;
}

/* The model's action line. Truncated to keep the row one line high; the full
   text and the resident's own words are on the row's tooltip. */
.ai-alert-text {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-alert-age {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.ai-alert-resolve {
  flex-shrink: 0;
  white-space: nowrap;
}

/* Narrow screens: the row wraps to two lines rather than crushing the reason
   into a two-word column. The age moves under the text with it. */
@media (max-width: 720px) {
  .ai-alert {
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }
  .ai-alert-text {
    white-space: normal;
    overflow: visible;
    flex-basis: 100%;
    order: 3;
  }
  .ai-alert-age {
    margin-left: auto;
  }
}

/* ═══════════════════════════════════════════════════
   EDIT REQUESTS  (Barangay Residency → Edit Requests tab)
   The staff review queue for profile changes residents propose from
   Settings → My Account. Cards rather than table rows: each request is a
   before/after diff plus a free-text reason, which a row of <td>s cannot
   hold legibly.
═══════════════════════════════════════════════════ */

/* Pending count on the tab itself. Hidden when zero via :empty, same rule the
   sidebar badges follow — a permanent "0" stops meaning anything. */
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--gold-600);
  color: var(--navy-900);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  line-height: 1;
}

.tab-count:empty {
  display: none;
}

.er-card {
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
}

/* A gold spine on the ones still waiting for a decision, so a mixed list
   reads at a glance instead of by badge colour alone. */
.er-card.is-pending {
  border-left: 3px solid var(--gold-600);
}

.er-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.er-name {
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.er-meta {
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Before → after. Auto width so the arrow column stays hairline-thin and the
   two value columns take what they need. */
.er-diff {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.er-diff th {
  padding: 0 var(--space-2) var(--space-1);
  text-align: left;
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.er-diff td {
  padding: var(--space-2);
  border-top: 1px solid var(--border);
  vertical-align: top;
}

.er-field {
  width: 26%;
  color: var(--text-secondary);
  font-weight: var(--weight-semibold);
}

/* The outgoing value is struck through: what makes a diff readable is seeing
   which side is being replaced without reading the column header. */
.er-old {
  width: 30%;
  color: var(--text-muted);
  text-decoration: line-through;
}

.er-arrow {
  width: 24px;
  color: var(--gold-600);
  text-align: center;
}

.er-new {
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
}

.er-reason {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  color: var(--text-secondary);
}

.er-reason-label {
  display: block;
  margin-bottom: 3px;
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.er-decision {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.er-remarks {
  margin-top: 2px;
  font-style: italic;
}

.er-actions {
  margin-top: var(--space-3);
}

/* Below ~640px the four diff columns cannot hold two values side by side —
   stack each change as label / old / new instead of letting the table
   scroll sideways inside a card. */
@media (max-width: 640px) {
  .er-diff thead {
    display: none;
  }

  .er-diff,
  .er-diff tbody,
  .er-diff tr,
  .er-diff td {
    display: block;
    width: auto;
  }

  .er-diff tr {
    padding: var(--space-2) 0;
    border-top: 1px solid var(--border);
  }

  .er-diff td {
    padding: 1px 0;
    border: 0;
  }

  .er-arrow {
    display: none !important;
  }
}

/* Photo changes are the one field whose value cannot be printed as text — a
   base64 data URI would run to hundreds of kilobytes and bury the rest of the
   diff. The thumbnail is also the only form in which a photo can be reviewed
   at all. The struck-through styling on .er-old must not reach it. */
.er-photo {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: cover;
}

.er-old .er-photo {
  opacity: 0.6;
}

/* Visually hidden but read by screen readers. The resident directory's photo
   column has no visible header (a caption over a 40px avatar column is noise),
   but the column still needs a name in the table's accessible structure. */
.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;
}

/* ── Resident directory: photo column ──────────────────────────────────────
   Residents with an uploaded photo show it; the rest show their initials in
   the same circle, so the column is a consistent rail down the table rather
   than a scatter of images among empty cells. */
.res-photo-col {
  width: 52px;
  padding-right: 0 !important;
}

.resident-avatar-img {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  /* cover, not contain: portraits are rarely square, and letterboxing them
     into the circle leaves grey wedges that read as a rendering fault. */
  object-fit: cover;
  background: var(--surface-hover);
}

/* The shared initials circle is sized for the profile modal (40px); inside a
   table row it matches the photo. */
.res-photo-col .resident-avatar-sm {
  width: 36px;
  height: 36px;
  font-size: var(--text-xs);
}

/* The profile modal's header keeps the larger size for both forms. */
.modal-body > div > .resident-avatar-img {
  width: 40px;
  height: 40px;
}

/* ═══════════════════════════════════════════════════
   SITE CONTENT — js/pages/content.js

   This module was the one page that shipped its own
   ~290-line <style> block inside pages/content.html, which
   is why it drifted furthest from the rest of the MIS:
   hard-coded light-mode chip colours, a second copy of
   .btn-danger-outline, and a replica of the public
   officials card sitting in the editor. It lives here now,
   on the tokens, like every other module.

   The layout answers two specific complaints about the old
   page. Save sat at the bottom, so a long list put the
   commonest action several screens away — it is now in a bar
   that sticks under the topbar. And every row was a
   permanently open form, so the page was mostly white space
   between fields — a row is now a single line until opened,
   and its fields sit in a 12-column grid.
   ═══════════════════════════════════════════════════ */

/* ── Sticky command bar ──────────────────────────────────────────────────
   Full-bleed inside the page gutter (hence the negative margins) so list
   rows pass cleanly underneath it instead of clipping at a rounded corner. */
.sc-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: var(--z-sticky);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: calc(var(--page-pad) * -1) calc(var(--page-pad) * -1) var(--stack);
  padding: var(--space-3) var(--page-pad);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--border);
}

.sc-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
}

.sc-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px var(--space-4);
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.sc-tab:hover:not(.is-active) {
  color: var(--text-primary);
}

.sc-tab.is-active {
  background: var(--surface-raised);
  color: var(--text-brand);
  box-shadow: var(--shadow-xs);
}

.sc-tab-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--surface-active);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  color: var(--text-secondary);
}

.sc-tab.is-active .sc-tab-count {
  background: var(--navy-800);
  color: var(--gold-300);
}

/* The other tab has unsaved edits. Without this, switching tabs hides the
   fact that anything is pending on the one you left. */
.sc-tab-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--warning-solid);
}

.sc-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sc-dirty {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  white-space: nowrap;
}

.sc-dirty[data-state="dirty"] {
  color: var(--warning);
}

/* Only one section is on screen at a time — the whole point of the tabs is
   that you are never scrolling both lists at once. */
.sc-panel[hidden] {
  display: none;
}

/* ── Toolbar row, on top of the shared .gis-filter-row pill bar ────────── */
.sc-toolbar {
  align-items: center;
}

.sc-search-icon {
  font-size: 14px;
  color: var(--text-muted);
}

.sc-toolbar-spacer {
  flex: 1 1 auto;
}

.sc-toolbar-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── The list ────────────────────────────────────────────────────────────
   Rows share one card rather than each being a floating card of its own:
   twelve shadowed boxes down a page is noise, and a hairline between rows
   reads as a list, which is what this is. */
.sc-list {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.sc-item {
  border-top: 1px solid var(--border);
  /* Clears the topbar AND the sticky command bar when a row is scrolled to. */
  scroll-margin-top: calc(var(--topbar-h) + 84px);
}

.sc-item:first-child {
  border-top: 0;
}

.sc-item.is-open {
  background: var(--surface);
}

/* Status rail. A post that has expired or is about to come down is what a
   reader scans this list for, and a chip alone does not carry down a long
   page the way a coloured edge does. */
.sc-item[data-status="expired"],
.sc-item[data-status="soon"],
.sc-item[data-status="new"] {
  box-shadow: inset 3px 0 0 var(--status-rail, transparent);
}

.sc-item[data-status="expired"] {
  --status-rail: var(--text-muted);
}

.sc-item[data-status="soon"] {
  --status-rail: var(--warning-solid);
}

.sc-item[data-status="new"] {
  --status-rail: var(--accent);
}

.sc-item-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-right: var(--space-3);
}

.sc-item-head {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 0;
  background: none;
  font-family: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}

.sc-item-head:hover {
  background: var(--surface-hover);
}

.sc-item-caret {
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  color: var(--text-muted);
  font-size: 15px;
  transition: transform var(--duration-fast) var(--ease-out);
}

.sc-item.is-open .sc-item-caret {
  transform: rotate(90deg);
  color: var(--accent-fg);
}

.sc-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sc-item-title {
  overflow: hidden;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-item-title.is-untitled {
  font-style: italic;
  font-weight: var(--weight-medium);
  color: var(--text-muted);
}

.sc-item-sub {
  overflow: hidden;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-item.is-expired .sc-item-title,
.sc-item.is-expired .sc-avatar {
  opacity: 0.65;
}

.sc-flags {
  flex: none;
  display: flex;
  gap: var(--space-2);
}

.sc-chip {
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
}

.sc-chip-new {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-fg);
}

.sc-chip-edited {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning);
}

.sc-chip-expired {
  background: var(--surface-sunken);
  border-color: var(--border);
  color: var(--text-muted);
}

/* The history is showing on the homepage. */
.sc-chip-live {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

/* The hand-ordered lists (officials, hotlines): display order and the
   reorder controls. */
.sc-rank {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-left: var(--space-4);
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.sc-item-tools {
  flex: none;
  display: flex;
  gap: var(--space-1);
}

.sc-icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.sc-icon-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.sc-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* The save that rides on a COLLAPSED row. Present only while that row is
   dirty, so it needs to read as the one thing to press rather than as another
   grey tool beside the reorder arrows — it carries the accent, and the row's
   own "Edited" chip sits immediately to its left saying why it is there. */
.sc-icon-save {
  border-color: var(--accent-border);
  background: var(--accent-bg);
  color: var(--accent-fg);
}

/* Resolves to the same pair .btn-gold uses, so the hover of the small save and
   the hover of the full one are the same colour in both themes — gold-400 is
   light enough for navy text whichever theme is on, which var(--accent) is
   not (it flips from gold-600 to gold-300). */
.sc-icon-save:hover:not(:disabled) {
  background: var(--gold-400);
  border-color: var(--gold-400);
  color: var(--navy-800);
}

/* In flight. Not a spinner — one 30px button pulsing is enough to say "this
   one is going", and it degrades to simply looking disabled without motion. */
.sc-icon-save:disabled {
  opacity: 1;
  cursor: progress;
  animation: sc-save-pulse 1s ease-in-out infinite;
}

@keyframes sc-save-pulse {
  50% {
    opacity: 0.45;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sc-icon-save:disabled {
    animation: none;
    opacity: 0.6;
  }
}

/* ── Open row: the editor ────────────────────────────────────────────────
   A 12-column grid, so a short field (Tag, Honorific) sits beside the long
   one it belongs with instead of claiming a full-width line and leaving two
   thirds of it empty — the "so much empty space" the old single-column
   stack produced. */
.sc-item-body {
  padding: var(--space-2) var(--space-5) var(--space-5) var(--space-8);
  border-top: 1px dashed var(--border);
  animation: page-in var(--duration-base) var(--ease-out);
}

.sc-fields {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--space-4);
}

/* The grid's gap already provides the rhythm. */
.sc-fields .form-group {
  margin-bottom: 0;
}

.sc-col-2 {
  grid-column: span 2;
}

.sc-col-3 {
  grid-column: span 3;
}

/* Added with the Hotlines tab: three even columns, which is what a row of
   short fields (a number, a category, the hours) actually wants. */
.sc-col-4 {
  grid-column: span 4;
}

.sc-col-5 {
  grid-column: span 5;
}

.sc-col-9 {
  grid-column: span 9;
}

.sc-col-12 {
  grid-column: span 12;
}

/* Tighter than the shared 90px default — the element selector is needed to
   beat `textarea.form-control`. Three lines is the length of an actual
   announcement; the taller box only added empty space to every open row. */
textarea.sc-textarea {
  min-height: 82px;
}

.sc-item-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* Remove and Save at the end of an open row. Save sits last, on the outside:
   it is the action this row is normally finished with, and putting the
   destructive one further from the corner the thumb lands in is deliberate. */
.sc-foot-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

/* Disabled here means "already saved", not "not allowed" — it reads as a
   confirmation, so it keeps its shape instead of dimming to the usual 0.4. */
.sc-foot-save:disabled {
  opacity: 0.55;
  cursor: default;
}

.sc-expiry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.sc-inline-label {
  font-size: 11.5px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.sc-date,
.sc-time {
  width: auto;
  padding: var(--space-2) var(--space-3);
}

/* The optional time of day, shown only once a date is set. Kept on one line
   with its "at" so it reads as a phrase — "Take down after 14 Aug at 5:00 PM"
   — rather than as a second, equal-weight field. */
.sc-expiry-time {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.sc-expiry-time.is-hidden {
  display: none;
}

.sc-inline-label-sub {
  text-transform: none;
  letter-spacing: 0;
  font-weight: var(--weight-medium);
  color: var(--text-muted);
}

/* Chrome/Edge draw the clock and calendar pickers with a near-black glyph,
   which all but disappears on a dark surface. */
[data-theme="dark"] .sc-date::-webkit-calendar-picker-indicator,
[data-theme="dark"] .sc-time::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(0.75);
}

.sc-expiry-note {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.sc-item.is-expired .sc-expiry-note {
  font-weight: var(--weight-semibold);
  color: var(--warning);
}

.sc-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── "Also send as a text message" (js/pages/content.js) ─────────────────
   Inside an open announcement row, below the fields. Deliberately a panel
   and not a button: it is the only action in the system that spends money on
   everybody at once, so picking the audience, seeing the cost and confirming
   it are three separate moments. */
.sc-sms {
  margin: var(--space-4) 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

.sc-sms.is-open {
  border-color: var(--accent-border);
}

.sc-sms-toggle {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
}

.sc-sms-toggle input {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--gold-600);
  cursor: pointer;
}

.sc-sms-toggle span {
  display: grid;
  gap: 2px;
  font-size: var(--text-sm);
}

.sc-sms-body {
  padding: 0 var(--space-4) var(--space-4);
  display: grid;
  gap: var(--space-3);
}

.sc-sms-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-3);
}

.sc-sms-label {
  flex: none;
  width: 54px;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}

.sc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* A chip that is a checkbox. The box itself is hidden: at this size the
   label IS the control, and a row of twelve tiny boxes reads as noise. */
.sc-chip-pick {
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.sc-chip-pick input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.sc-chip-pick:hover {
  border-color: var(--border-strong);
}

.sc-chip-pick.is-on {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-fg);
  font-weight: var(--weight-semibold);
}

/* "Everyone" sits at the head of the purok chips and is the state the panel
   starts in, so it is marked off from the puroks that narrow it. */
.sc-chip-pick.sc-chip-all {
  margin-right: var(--space-2);
  border-style: dashed;
}

.sc-chip-pick.sc-chip-all.is-on {
  border-style: solid;
}

.sc-sms-scope {
  margin: 0;
}

.sc-sms-emergency {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--danger-border, var(--border));
  border-radius: var(--radius-sm);
  background: var(--danger-bg, var(--surface));
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  color: var(--text-secondary);
  cursor: pointer;
}

.sc-sms-emergency input {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--red-600);
}

/* The message exactly as it will arrive, in the width of a phone. Reading it
   back is the last check before it goes. */
.sc-sms-preview {
  display: grid;
  gap: var(--space-2);
}

.sc-sms-body-text {
  max-width: 44ch;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  white-space: pre-wrap;
}

.sc-sms-cost {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
}

.sc-sms-cost.is-warning {
  color: var(--warning);
}

.sc-sms-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* The suggested dial string, offered inside a hint rather than written into
   the field: what a phone rings is not something to guess on the operator's
   behalf. Looks like the sentence it sits in, acts like a button. */
.sc-link-btn {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-family: var(--font-mono);
  color: var(--accent-fg);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.sc-link-btn:hover {
  color: var(--text-brand);
}

/* ── Hotlines editor ─────────────────────────────────────────────────────
   The category chip reuses the announcement chip, on two hues only: the
   numbers on the public emergency card, and the rest of the directory. Eight
   invented colours would say less than that one distinction does. */
.hot-cat {
  --tag: var(--text-muted);
}
.hot-cat.is-emergency {
  --tag: var(--red-600);
}
[data-theme="dark"] .hot-cat.is-emergency {
  --tag: var(--red-300);
}

/* The primary barangay line — the number every text message quotes, and the
   one entry that cannot be deleted. */
.sc-chip-primary {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-fg);
}

/* ── Officials editor: avatar column + fields ────────────────────────────
   96px of avatar and two buttons, in place of the 250px replica of the
   public card the old editor carried beside every single official. */
.sc-official-body {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

.sc-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

/* min-width:0, or a long unbroken description in the textarea below pushes
   this grid column wider than its track and the row overflows sideways. */
.sc-official-fields {
  min-width: 0;
}

.sc-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border: 2px solid var(--accent-border);
  border-radius: var(--radius-full);
  background: var(--navy-800);
  color: var(--gold-300);
  font-size: var(--text-2xs);
  font-weight: var(--weight-extrabold);
  letter-spacing: 0.02em;
}

.sc-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sc-avatar-lg {
  width: 96px;
  height: 96px;
  margin-top: var(--space-2);
  border-width: 3px;
  font-size: var(--text-xl);
}

/* A <label> styled as a button, covering a transparent file input. */
.sc-photo-btn {
  position: relative;
  width: 100%;
  overflow: hidden;
  cursor: pointer;
}

.sc-photo-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.sc-photo-remove {
  color: var(--danger);
}

.sc-photo-remove:hover:not(:disabled) {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ── History: one document, not a list ───────────────────────────────────
   The same card as the lists, holding a single always-open form. The head
   reads like a collapsed row — title, where it shows, chips — but there is
   nothing to collapse, so it is not a button. */
.sc-doc-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
}

/* A row's body is indented to clear its caret; this one has none. */
.sc-doc-body {
  padding-left: var(--space-5);
  animation: none;
}

/* Long enough to read the story while editing it — the 82px announcement
   box would show two lines of it. */
textarea.sc-doc-text {
  min-height: 340px;
  line-height: 1.7;
  resize: vertical;
}

/* ── Announcement tag chips ──────────────────────────────────────────────
   The landing page's chips, rebuilt on one --tag hue per chip instead of a
   hard-coded pale background per tag, so they survive dark mode — the
   copies ported into the old page rendered pale-on-pale with the lights
   off. */
.announcement-tag {
  --tag: var(--gold-700);
  display: inline-block;
  flex: none;
  padding: 4px 11px;
  border: 1px solid color-mix(in srgb, var(--tag) 34%, transparent);
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--tag) 12%, transparent);
  color: var(--tag);
  font-size: var(--text-2xs);
  font-weight: var(--weight-extrabold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.ann-tag-advisory {
  --tag: var(--gold-700);
}

.ann-tag-health {
  --tag: var(--green-600);
}

.ann-tag-community {
  --tag: var(--blue-600);
}

.ann-tag-event {
  --tag: var(--violet-500);
}

.ann-tag-emergency {
  --tag: var(--red-600);
}

[data-theme="dark"] .ann-tag-advisory {
  --tag: var(--gold-300);
}

[data-theme="dark"] .ann-tag-health {
  --tag: var(--green-300);
}

[data-theme="dark"] .ann-tag-community {
  --tag: var(--blue-300);
}

[data-theme="dark"] .ann-tag-event {
  --tag: #c4b5fd;
}

[data-theme="dark"] .ann-tag-emergency {
  --tag: var(--red-300);
}

/* The chip in a collapsed row is a fixed-width column, so every title starts
   on the same x whatever its tag is called. Wide enough for the longest of
   them — EMERGENCY — at this size and letter-spacing. */
.sc-tag {
  width: 110px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Responsive ──────────────────────────────────────────────────────────
   Below ~1000px the 12-column grid stops helping: a 2-of-12 Honorific field
   is 40px wide on a tablet. */
@media (max-width: 1000px) {
  .sc-col-2,
  .sc-col-3 {
    grid-column: span 4;
  }

  .sc-col-4 {
    grid-column: span 6;
  }

  .sc-col-5 {
    grid-column: span 8;
  }

  .sc-col-9 {
    grid-column: span 12;
  }
}

@media (max-width: 760px) {
  .sc-bar {
    gap: var(--space-2);
  }

  .sc-bar-actions {
    flex: 1;
    justify-content: flex-end;
  }

  /* "All changes saved" is the state that needs no words — a disabled Save
     button already says it, and at this width the pill collapses to a lone
     tick that reads as a stray glyph. The count stays when there IS one. */
  .sc-dirty[data-state="clean"] {
    display: none;
  }

  .sc-official-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .sc-photo {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .sc-photo-btn {
    width: auto;
  }

  .sc-item-body {
    padding-left: var(--space-4);
  }

  .sc-tag {
    width: auto;
  }

  /* One field per line — anything narrower than this is unusable. */
  .sc-col-2,
  .sc-col-3,
  .sc-col-4,
  .sc-col-5,
  .sc-col-9 {
    grid-column: span 12;
  }
}

@media (max-width: 560px) {
  /* The subtitle and the tag lose to the title for the little width there
     is; both are still in the open row. */
  .sc-item-sub,
  .sc-tag {
    display: none;
  }

  .sc-rank {
    margin-left: var(--space-3);
  }

  .sc-item-foot {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ─── HOUSEHOLD RESIDENTS PANEL ─────────────────────────────────────────────
   The roster that opens when a tagged house is clicked on the GIS map
   (js/household-panel.js). It is a reading screen before it is a working one:
   an officer standing at a house wants to see, in one pass, how many people
   live there, which of them are seniors, PWDs, solo parents or minors, and who
   can be phoned. So the counts come first as tiles, then one row per resident
   with the facts that decide what happens next, and the connect box last. */
.hh-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.hh-name {
  font-size: 1.15rem;
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}
.hh-sub {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.hh-sub span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.hh-sub svg,
.hh-row-lines svg,
.hh-row-flag svg,
.hh-flag svg,
.hh-empty svg {
  width: 14px;
  height: 14px;
}
.hh-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.hh-notes {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-sunken, rgba(27, 42, 74, 0.04));
  font-size: 0.85rem;
  color: var(--text-secondary);
}
/* Eight small counts, four to a row on a desktop modal and two on a phone.
   auto-fit rather than a fixed count so the row never leaves a ragged gap. */
/* Eight counts, four to a row: a fixed four keeps them in two even rows of
   related things (people, then vulnerabilities) instead of the ragged 6 + 2 an
   auto-fit produced at this width. */
.hh-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  margin: var(--space-4) 0;
}
@media (max-width: 560px) {
  .hh-tiles {
    grid-template-columns: repeat(2, 1fr);
  }
}
.hh-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.hh-tile-value {
  font-size: 1.25rem;
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1.1;
}
.hh-tile-label {
  font-size: 0.68rem;
  letter-spacing: var(--tracking-wide, 0.04em);
  text-transform: uppercase;
  color: var(--text-muted);
}
/* "Nobody here can be reached by phone" is a fact worth a colour: it decides
   whether an advisory about this house can be sent at all. */
.hh-tile-warn {
  border-color: rgba(217, 119, 6, 0.45);
  background: rgba(217, 119, 6, 0.08);
}
.hh-flag {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid rgba(217, 119, 6, 0.4);
  background: rgba(217, 119, 6, 0.08);
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.hh-section-title {
  font-size: 0.72rem;
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}
.hh-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.hh-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.hh-avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--navy, #0d1b3e);
  color: #fff;
  font-size: 0.8rem;
  font-weight: var(--weight-bold);
}
.hh-avatar-sm {
  width: 30px;
  height: 30px;
  font-size: 0.7rem;
}
.hh-row-main {
  flex: 1 1 auto;
  min-width: 0;
}
.hh-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.hh-row-name {
  font-weight: var(--weight-semibold, 600);
  color: var(--text-primary);
}
.hh-row-facts {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.hh-row-lines {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.hh-row-lines span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.hh-muted {
  color: var(--text-muted);
}
.hh-ok {
  color: #0d9488;
  font-weight: var(--weight-semibold, 600);
}
.hh-warn,
.hh-row-flag {
  color: #b45309;
}
.hh-row-flag {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  font-size: 0.76rem;
}
.hh-row-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  flex: 0 0 auto;
}
.hh-remove {
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.35);
}
.hh-empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: var(--space-6) var(--space-4);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}
.hh-empty svg {
  width: 26px;
  height: 26px;
  color: var(--text-muted);
}
.hh-empty p {
  margin: 0;
  font-size: 0.85rem;
  max-width: 44ch;
}
.hh-connect {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}
.hh-search-wrap {
  position: relative;
}
.hh-search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}
.hh-search-wrap .form-control {
  padding-left: 34px;
}
.hh-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: var(--space-3);
}
.hh-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.hh-result-main {
  flex: 1 1 auto;
  min-width: 0;
}
.hh-no-match,
.hh-hint {
  font-size: 0.8rem;
  margin: var(--space-3) 0 0;
}
.hh-readonly {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}

@media (max-width: 560px) {
  .hh-row {
    flex-wrap: wrap;
  }
  .hh-row-actions {
    flex-direction: row;
    width: 100%;
  }
  .hh-row-actions .btn {
    flex: 1 1 0;
  }
}

/* The "View on map" button beside a resident's Household, in their profile.
   Small and inline: it belongs to that row's value, not to the dialog. */
.resident-household-map {
  margin-left: var(--space-2);
  vertical-align: middle;
}
.resident-household-map svg {
  width: 13px;
  height: 13px;
}
