/* ODPRS prototype — shared shell styles
   Visual reference: mock/web reference/mfu register.jpg (maroon accent, warm-white background, left sidebar) */

@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&display=swap');

/* Sarabun — self-hosted (not @import'd from Google Fonts) specifically for
   the printable Request Form / PDF (FR-06). PDF generation runs server-side
   in a headless Chromium with no Thai-capable system font installed at all
   (verified via fc-list — only DejaVu, which has zero Thai glyph coverage),
   so the printed form must not depend on a live Google Fonts fetch at
   render time or on the OS having Thai fonts. Sarabun is the open-source
   metric-compatible sibling of TH Sarabun New, Thailand's mandated official
   document typeface, split by Google into per-script files the same way. */
@font-face {
  font-family: "Sarabun";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/Sarabun-Regular-thai.woff2") format("woff2");
  unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Sarabun";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/Sarabun-Regular-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC;
}
@font-face {
  font-family: "Sarabun";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/Sarabun-SemiBold-thai.woff2") format("woff2");
  unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Sarabun";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/Sarabun-SemiBold-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC;
}
@font-face {
  font-family: "Sarabun";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/Sarabun-Bold-thai.woff2") format("woff2");
  unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Sarabun";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/Sarabun-Bold-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC;
}

/* Smooth cross-fade between full-page navigations (Chrome/Edge — no-op elsewhere). */
@view-transition {
  navigation: auto;
}

:root {
  --font-family: "Kanit", "Noto Sans Thai", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-family-print: "Sarabun", "TH Sarabun New", "Sarabun UI", "Noto Sans Thai", serif;
  --color-primary: #7a2e2e;
  --color-primary-dark: #5e2222;
  --color-primary-tint: #f5e9e5;
  --color-bg: #f7f4f0;
  --color-surface: #ffffff;
  --color-border: #e7e1d9;
  --color-text: #262220;
  --color-muted: #7a716a;
  --color-success: #2f7a4f;
  --color-success-tint: #e6f2ea;
  --color-warning: #b5790a;
  --color-warning-tint: #fbf0dc;
  --color-danger: #a63333;
  --color-danger-tint: #f8e6e6;
  --color-info: #2b5f8a;
  --color-info-tint: #e8f0f6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(38, 34, 32, 0.06), 0 1px 8px rgba(38, 34, 32, 0.04);
}

* { box-sizing: border-box; }

/* ---------- Motion ---------- */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* FOUC guard — see partials/head.ejs (the .i18n-loading class starts on
   <html>) and app.js's final DOMContentLoaded handler (removes it once
   translations/icons are applied). Keeps every full-page nav from
   flashing the server-rendered Thai/icon-less markup before JS catches
   up. visibility (not display) so layout/measurement still works while
   hidden. The animation is a pure-CSS failsafe: if app.js never runs
   (blocked/erroring), the page still reveals itself after 1.5s instead
   of staying blank forever. */
html.i18n-loading body {
  visibility: hidden;
  animation: odprs-i18n-reveal-fallback 0s 1.5s forwards;
}

@keyframes odprs-i18n-reveal-fallback {
  to { visibility: visible; }
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-weight: 400;
  color: var(--color-text);
  background: var(--color-bg);
}

a { color: inherit; text-decoration: none; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  min-height: 100vh;
}

/* ---------- Header ---------- */
.app-header {
  grid-area: header;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-lead { display: flex; align-items: center; gap: 12px; min-width: 0; }

.app-header .crumb {
  font-size: 14px;
  color: var(--color-muted);
  min-width: 0;
}

/* ☰ — only shown once the sidebar turns into a drawer (≤1024px). */
.nav-toggle {
  display: none;
  flex: none;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  cursor: pointer;
}
.nav-toggle-bars { display: flex; flex-direction: column; gap: 4px; width: 18px; }
.nav-toggle-bars span { display: block; height: 2px; border-radius: 2px; background: var(--color-text); transition: transform .2s ease, opacity .2s ease; }
.nav-open .nav-toggle-bars span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-open .nav-toggle-bars span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle-bars span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.nav-backdrop[hidden] { display: none; }

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.app-header .crumb strong {
  color: var(--color-text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-muted);
}

.lang-toggle span {
  padding: 2px 6px;
  border-radius: 6px;
  cursor: default;
  transition: background-color .15s ease, color .15s ease;
}

.lang-toggle span.active {
  background: var(--color-primary-tint);
  color: var(--color-primary);
  font-weight: 600;
}

/* ---------- Notification bell (header.ejs) ---------- */
.notif-wrap { position: relative; }

.notif-bell-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--color-text);
}

.notif-bell-btn:hover { background: var(--color-bg); }
.notif-bell-btn .icon { width: 19px; height: 19px; }

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
}

/* No competing `display` rule above, so [hidden] would already work here —
   kept explicit anyway so this doesn't quietly break the way
   .filter-toolbar's did if a display value is ever added to .notif-dropdown. */
.notif-dropdown[hidden] { display: none; }

.notif-dropdown-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  font-weight: 700;
  font-size: 14px;
}

.notif-mark-all-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-family);
}

.notif-item {
  display: block;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-bg); }
.notif-item.unread { background: var(--color-primary-tint); }

.notif-item-title { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; }
.notif-item-body { font-size: 12.5px; color: var(--color-muted); white-space: pre-line; margin-bottom: 4px; }
.notif-item-time { font-size: 11px; color: var(--color-muted); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}

.user-chip:hover {
  background: var(--color-bg);
  border-color: var(--color-primary-tint);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-chip .who {
  line-height: 1.2;
}

.user-chip .who small {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-muted);
  font-size: 11px;
}

.user-chip .who small .role {
  font-weight: 600;
  color: var(--color-primary);
}

.logout-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--color-muted);
  transition: background-color .15s ease, color .15s ease;
}

.logout-link:hover {
  background: var(--color-danger-tint);
  color: var(--color-danger);
}

.logout-link .icon {
  width: 18px;
  height: 18px;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
  grid-area: sidebar;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  margin: 0 4px 8px;
  border-bottom: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: opacity .15s ease;
}

.brand:hover { opacity: 0.75; }

.brand .mark {
  width: 40px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand .brand-text {
  min-width: 0;
  line-height: 1.25;
}

.brand .name {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 1px;
  color: var(--color-primary);
}

.brand .tagline {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--color-text);
  margin-top: 1px;
}

.brand .sub {
  font-size: 10.5px;
  color: var(--color-muted);
  letter-spacing: 0.3px;
  margin-top: 1px;
}

.nav-section + .nav-section {
  border-top: 1px solid var(--color-border);
  margin-top: 4px;
}

/* Small group titles inside a section (admin: "Accounts & System" / "Reference Data"). */
.nav-subhead {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-muted);
  opacity: .8;
  letter-spacing: 0.3px;
  padding: 10px 12px 4px;
}
.nav-section-items > .nav-subhead:first-child { padding-top: 2px; }

/* Sections fold with a slide + fade (height is animated by setOpen() in
   app.js). visibility:hidden — delayed until the slide ends — keeps the
   folded links out of the Tab order. */
.nav-section-items {
  overflow: hidden;
  transition: height .28s ease, opacity .22s ease, visibility 0s;
}
.nav-section.collapsed .nav-section-items {
  height: 0;
  opacity: 0;
  visibility: hidden;
  transition: height .28s ease, opacity .18s ease, visibility 0s .28s;
}

.app-sidebar > * { flex-shrink: 0; }

.nav-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 14px 10px 6px;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-section-label .chevron {
  width: 14px;
  height: 14px;
  transition: transform .15s ease;
}

.nav-section.collapsed .nav-section-label .chevron {
  transform: rotate(-90deg);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 14px;
  margin-bottom: 2px;
  transition: background-color .15s ease, color .15s ease;
}

/* ---------- Icons (inline SVG, injected via data-icon — see ICONS in app.js) ---------- */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: currentColor;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.nav-item .icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--color-bg);
}

.nav-item.active {
  background: var(--color-primary-tint);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-item.active .icon { color: var(--color-primary); }

.nav-item-divider {
  border-top: 1px solid var(--color-border);
  margin: 6px 10px;
}

/* Floating manuals button (partials/header.ejs). Default bottom-right;
   after a drag, initManualFab() sets left/right + top inline. */
.manual-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  touch-action: none;
}
/* In its default corner, lift it above pages with a sticky save bar
   (a dragged button has inline top/bottom and is unaffected). */
body:has(.savebar) .manual-fab,
body:has(.profile-savebar) .manual-fab,
body:has(.submitted-actions) .manual-fab,
body:has(.rd-mobile-bar:not([hidden])) .manual-fab,
body:has(.loc-form-card:not([hidden])) .manual-fab { bottom: 96px; }
/* New/edit request: the summary card turns into a bottom bar at 900px and
   below (see .request-summary), and the button must not cover "Submit". */
@media (max-width: 900px) { body:has(.request-summary) .manual-fab { bottom: 120px; } }
.manual-fab-btn {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: grab;
  box-shadow: 0 4px 14px rgba(122, 46, 46, .35);
  transition: background .15s ease, box-shadow .15s ease;
}
.manual-fab-btn:hover { background: var(--color-primary-dark); }
.manual-fab-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--color-primary-tint), 0 4px 14px rgba(122, 46, 46, .35); }
.manual-fab-btn .icon { width: 22px; height: 22px; pointer-events: none; }
.manual-fab.is-dragging .manual-fab-btn { cursor: grabbing; box-shadow: 0 10px 26px rgba(122, 46, 46, .45); }
.manual-fab.is-snapping { transition: left .2s ease, right .2s ease, top .2s ease; }

/* The menu opens toward the middle of the screen: above or below the
   button, aligned to whichever side the button sits on. */
.manual-fab-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  min-width: 230px;
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(38, 34, 32, .16);
  animation: fadeSlideIn .18s ease both;
}
.manual-fab-menu[hidden] { display: none; }
.manual-fab.opens-down .manual-fab-menu { bottom: auto; top: calc(100% + 10px); }
.manual-fab.on-left .manual-fab-menu { right: auto; left: 0; }
.manual-fab-title { padding: 6px 10px 4px; font-size: 12px; font-weight: 600; color: var(--color-muted); }
.manual-fab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--color-text);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.manual-fab-item:hover { background: var(--color-primary-tint); color: var(--color-primary-dark); }
.manual-fab-item .icon { width: 16px; height: 16px; color: var(--color-primary); }
.manual-fab-hide {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px 6px;
  border: 0;
  border-top: 1px solid var(--color-border);
  background: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--color-muted);
  text-align: left;
  cursor: pointer;
}
.manual-fab-hide:hover { color: var(--color-text); }

/* Hidden state: the button goes away and the sidebar dock row appears,
   pinned to the bottom of the (flex-column) sidebar. */
.manual-fab-docked .manual-fab { display: none; }
.nav-manual-dock { display: none; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--color-border); }
.manual-fab-docked .nav-manual-dock { display: block; }
/* A <button> styled exactly like the sidebar <a class="nav-item"> rows:
   only reset what browsers add to buttons, and keep .nav-item font size,
   weight and colour (the old "font: inherit" overrode them). */
.nav-manual-dock-btn {
  width: 100%;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: inherit;
  text-align: left;
  color: var(--color-text);
  cursor: pointer;
}
.nav-manual-dock-btn:hover { background: var(--color-bg); }
.nav-manual-dock-btn[aria-expanded="true"] { background: var(--color-primary-tint); color: var(--color-primary); }
/* Popup opened from the dock row; placed beside it by initManualFab(). */
.manual-dock-pop {
  position: fixed;
  z-index: 1000;
  min-width: 230px;
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(38, 34, 32, .16);
  animation: fadeSlideIn .18s ease both;
}
.manual-dock-pop[hidden] { display: none; }
@media (max-width: 600px) {
  .manual-fab { right: 16px; bottom: 16px; }
}

/* ---------- Main content ---------- */
.app-main {
  grid-area: main;
  padding: 28px 32px 60px;
  animation: fadeSlideIn 0.35s ease both;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-subtitle {
  color: var(--color-muted);
  font-size: 14px;
  margin: 0 0 24px;
}

/* ---------- Profile page (profile.ejs) ---------- */
.profile-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.profile-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-header-info .page-title { margin-bottom: 8px; }

.profile-header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge-role { background: var(--color-primary-tint); color: var(--color-primary); }

.profile-header-email {
  font-size: 13px;
  color: var(--color-muted);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
  animation: fadeSlideIn 0.35s ease both;
}

/* .card clips its children (overflow:hidden) — that cut the date picker's
   absolutely-positioned popup in half where it hangs past the card's bottom
   edge. Cards with popups opt out; nothing in them paints outside the
   rounded corners (the header has no background). */
.card.card-overflow-visible { overflow: visible; }

/* Every .card runs the fadeSlideIn animation with `both`, so it keeps a
   transform after it ends and therefore forms its own stacking context: the
   popup's z-index is then trapped inside its card, and the NEXT card paints
   over it (the calendar looked cut off when another card sat below it, as on
   the officer approve/reject panels). Lifting the card itself above its
   later siblings fixes that; 5 stays below the top bar (10) and modals. */
.card.card-overflow-visible { position: relative; z-index: 5; }

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: 20px;
}

/* admin/units.ejs drill-down heading: back button, then the category name
   large with a small "Unit Type" label above and the unit count beside it. */
.units-view-head {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.units-view-heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-left: 16px;
  border-left: 1px solid var(--color-border);
}
.units-view-eyebrow {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-muted);
  line-height: 1.2;
}
.units-view-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}
#units-view-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.25;
}
.units-view-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
}
@media (max-width: 600px) {
  .units-view-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .units-view-heading { padding-left: 0; border-left: 0; }
}

/* Action bar at the bottom of a form card (requester/new-request.ejs): its
   own padded, tinted strip under a rule instead of buttons floating against
   the last field. Stacks full-width on phones with the primary action first. */
.card-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

.card-footer .btn { min-width: 120px; }

/* PDPA note under the last section of the new-request form (links to /privacy). */
.privacy-note { margin: 4px 4px 0; font-size: 13px; line-height: 1.6; color: var(--color-muted); }
.privacy-note a { color: var(--color-primary); white-space: nowrap; }

@media (max-width: 560px) {
  .card-footer { flex-direction: column-reverse; align-items: stretch; }
  .card-footer .btn { width: 100%; }
}

/* ---------- Table ---------- */
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  background: var(--color-primary);
  color: #fff;
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr {
  transition: background-color .15s ease;
  animation: fadeSlideIn 0.3s ease both;
}
.data-table tbody tr:hover { background: var(--color-bg); }

/* ---------- Status badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}

.badge-awaiting { background: var(--color-warning-tint); color: var(--color-warning); }
.badge-printing { background: var(--color-info-tint); color: var(--color-info); }
.badge-ready    { background: #eef0e0; color: #6b7a1f; }
.badge-completed{ background: var(--color-success-tint); color: var(--color-success); }
.badge-rejected { background: var(--color-danger-tint); color: var(--color-danger); }
.badge-cancelled{ background: var(--color-border); color: var(--color-muted); }
.badge-overdue  { background: var(--color-danger); color: #fff; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}

.btn:active:not(:disabled) { transform: scale(0.97); }

/* .btn's own `display: inline-flex` (author, normal) beats the browser's
   built-in `[hidden] { display: none }` (user-agent, normal) — same trap as
   .notif-dropdown[hidden]/.modal-overlay[hidden]/.filter-toolbar[hidden]
   below, so any .btn toggled via the `hidden` attribute/property needs this
   explicit override too, or it silently stays visible. */
.btn[hidden] { display: none; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }

.btn-danger { background: #fff; color: var(--color-danger); border-color: var(--color-danger-tint); }
.btn-danger:hover { background: var(--color-danger-tint); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Compact row-action buttons for admin list tables (locations, units):
   a smaller size than the default .btn, so a row of edit/archive/delete
   doesn't dwarf the table text it sits next to. */
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* Up/down reorder buttons as one joined pill instead of two separate
   buttons with a gap between them. */
.row-move {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.row-move .btn {
  border: none;
  border-radius: 0;
  padding: 5px 12px;
  font-size: 13px;
  background: var(--color-surface);
  color: var(--color-muted);
}
.row-move .btn + .btn { border-left: 1px solid var(--color-border); }
.row-move .btn:hover:not(:disabled) { background: var(--color-bg); color: var(--color-text); }

.row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* App Store "install" style save feedback (admin/settings.ejs) — sits next
   to the Save button (not inside it) as its own status icon: a spinning
   progress ring while the request is in flight, morphing into a drawn-in
   checkmark on success. stroke-dasharray "60 28" on a r=14 circle
   (circumference ~88) gives a visible arc+gap so the spin reads as motion
   rather than a static ring; the checkmark path uses pathLength="24" so
   stroke-dasharray/dashoffset don't need to match the path's real SVG
   coordinate-space length. */
.save-status-icon { flex-shrink: 0; color: var(--color-primary); }

.save-status-ring {
  stroke: currentColor;
  stroke-linecap: round;
  stroke-dasharray: 60 28;
  transform-origin: 18px 18px;
  animation: save-ring-spin 0.85s linear infinite;
}

.save-status-check {
  stroke: var(--color-success);
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
}

.save-status-check.drawn {
  animation: save-check-draw 0.45s cubic-bezier(.65, 0, .35, 1) forwards;
}

@keyframes save-ring-spin {
  to { transform: rotate(360deg); }
}

@keyframes save-check-draw {
  to { stroke-dashoffset: 0; }
}

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
}

.form-grid .span-2 { grid-column: 1 / -1; }

.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
}
.field label .icon {
  width: 15px;
  height: 15px;
  vertical-align: -3px;
  color: var(--color-muted);
  margin-right: 2px;
}

/* Character counter under a capped field (e.g. "45/120"). */
.hint.char-count { display: block; text-align: right; font-size: 12px; margin-top: 4px; }
.hint.char-count.is-full { color: var(--color-warning); font-weight: 600; }

.hint {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-muted);
}

.field .hint {
  display: block;
  margin-top: 5px;
}

.field-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.field-label-row label {
  margin-bottom: 0;
}

.hint-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--color-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.hint-toggle .icon,
.hint-toggle svg {
  width: 15px;
  height: 15px;
}

.hint-toggle:hover,
.hint-toggle[aria-expanded="true"] {
  color: var(--color-primary);
  background: var(--color-primary-tint);
}

.hint-popover {
  margin-top: -2px;
  margin-bottom: 8px;
  padding: 8px 10px;
  background: var(--color-primary-tint);
  border-radius: 8px;
}

.hint-popover .hint {
  margin-top: 0;
  color: var(--color-text);
}

p.hint { margin: 0; }

.field input[type="text"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="date"],
.field input[type="url"],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}

/* Placeholder examples ("เช่น ...") must read as clearly not-yet-filled —
   default browser placeholder color is too close to real input text and
   was getting mistaken for an already-completed field. */
.field input::placeholder,
.field textarea::placeholder {
  color: var(--color-muted);
  font-style: italic;
  opacity: 1;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}

.field input[readonly] {
  background: var(--color-bg);
  color: var(--color-muted);
}

.field textarea { resize: vertical; min-height: 80px; }

.field-error {
  display: none;
  align-items: center;
  gap: 6px;
  color: var(--color-danger);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
  margin-top: 6px;
}

.field-error .icon,
.field-error svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.field.invalid input:not([type="radio"]):not([type="checkbox"]),
.field.invalid select,
.field.invalid textarea,
.field.invalid .date-picker-input {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px var(--color-danger-tint);
}

.field.invalid .radio-option {
  border-color: var(--color-danger);
  background: var(--color-danger-tint);
}

.field.invalid .field-error { display: flex; animation: fadeSlideIn 0.2s ease both; }

/* ---------- Custom date picker (requester/new-request.ejs) ---------- */
/* Sat/Sun and pre-minDate cells are rendered `disabled` directly in the
   grid (see the script at the bottom of new-request.ejs) instead of being
   caught after the fact — a native <input type="date"> can't grey out
   specific weekdays in its own popup, so this replaces it entirely. */
.date-picker { position: relative; }

.date-picker-input {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  cursor: pointer;
}

.date-picker-input.placeholder { color: var(--color-muted); }
.date-picker-input .icon { width: 16px; height: 16px; color: var(--color-muted); flex-shrink: 0; }

/* Flex items default to min-width:auto (their content's width), which
   fights `width:100%` on the button and pushes it past the field's edge
   for a long formatted date — min-width:0 lets it actually shrink. */
.date-picker-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.date-picker-input:focus,
.date-picker-input[aria-expanded="true"] {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}

.date-picker-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  /* Match the toggle button's own width (its containing block, via
     .date-picker's position:relative) instead of a fixed px value, capped
     so it doesn't balloon into an oversized grid on a very wide field. */
  width: 100%;
  /* …but never narrower than a usable month grid: next to the time select
     on admin/settings the field itself can be ~150px wide, which squeezed
     the grid and pushed the day numbers out of the frame. position() in
     app.js shifts it left if this would run off the right edge. */
  min-width: 272px;
  max-width: 320px;
  padding: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
}

.date-picker-panel[hidden] { display: none; }

/* Flipped above the field when there's no room below (set by
   positionCalendar() in new-request.ejs). */
.date-picker-panel.open-up {
  top: auto;
  bottom: calc(100% + 6px);
}

/* Bigger tap targets on touch screens (phones/tablets). */
@media (pointer: coarse) {
  .date-picker-panel { max-width: 360px; }
  .date-picker-nav { width: 40px; height: 40px; font-size: 20px; }
  .date-picker-day { font-size: 15px; }
  .date-picker-weekdays span { font-size: 12px; }
}

.date-picker-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 13.5px;
}

.date-picker-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--color-text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.date-picker-nav:hover { background: var(--color-bg); }
.date-picker-nav:disabled { color: var(--color-border); cursor: default; }
.date-picker-nav:disabled:hover { background: none; }

.date-picker-weekdays,
.date-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}

.date-picker-weekdays span {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  padding: 4px 0;
}

.date-picker-day {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: none;
  border-radius: 8px;
  background: none;
  font-family: var(--font-family);
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
}

.date-picker-day:hover:not(:disabled) { background: var(--color-primary-tint); }

.date-picker-day:disabled {
  color: var(--color-border);
  cursor: not-allowed;
}

.date-picker-day.selected {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
}

.date-picker-day.today:not(.selected) {
  box-shadow: inset 0 0 0 1px var(--color-primary);
}

.date-picker-day.empty { visibility: hidden; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 4px;
}

/* Profile page: the save button stays on screen while the form scrolls
   (same floating bar as the Settings save bar). */
.profile-savebar {
  position: sticky;
  bottom: 16px;
  z-index: 20;
  justify-content: flex-start;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(38, 34, 32, 0.12);
}

/* Hand-over card on the request-submitted page: what to do (title + when),
   where (place / hours / phone as labelled columns), then a one-line note.
   Amber while the originals are still due, green once received. */
.handoff {
  margin-bottom: 20px;
  border: 1px solid var(--handoff-line);
  border-radius: var(--radius);
  background: var(--handoff-tint);
  overflow: hidden;
  animation: fadeSlideIn 0.3s ease both;
}

.handoff-warning { --handoff-color: var(--color-warning); --handoff-tint: var(--color-warning-tint); --handoff-line: #efdcb4; }
.handoff-success { --handoff-color: var(--color-success); --handoff-tint: var(--color-success-tint); --handoff-line: #c6e0d0; }

.handoff-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  color: var(--handoff-color);
}

.handoff-head .icon { width: 24px; height: 24px; flex: 0 0 auto; margin-top: 2px; }
.handoff-title { font-size: 13px; font-weight: 600; }

.handoff-when {
  margin-top: 2px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.handoff-time { font-size: 14px; font-weight: 600; }

.handoff-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 24px;
  margin: 0;
  padding: 14px 20px;
  border-top: 1px solid var(--handoff-line);
  background: var(--color-surface);
}

.handoff-info:not(:has(> div:not([hidden]))) { display: none; }

.handoff-info dt {
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--color-muted);
}

.handoff-info dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.handoff-info a { margin-left: 6px; font-weight: 600; color: var(--color-info); text-decoration: underline; }

.handoff-note {
  margin: 0;
  padding: 10px 20px;
  border-top: 1px solid var(--handoff-line);
  background: var(--color-surface);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--color-muted);
}

@media (max-width: 560px) {
  .handoff-when { font-size: 19px; }
}

/* Request-submitted page footer (requester/request-submitted.ejs): actions
   on this request (edit/cancel) on the left, where-to-next navigation on
   the right. Floats at the bottom of the window (same look as the profile
   save bar) so the buttons are visible without scrolling past the form. */
.submitted-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  position: sticky;
  bottom: 16px;
  z-index: 20;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(38, 34, 32, 0.12);
}

.submitted-actions-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Edit/cancel disappear once the request is no longer awaiting — don't leave
   an empty group behind to add stray spacing. */
.submitted-actions-group:not(:has(.btn:not([hidden]))) { display: none; }

.submitted-actions .btn .icon { width: 18px; height: 18px; }

/* Phones: keep the floating bar short. Each group is one row of two equal
   buttons, navigation on the bottom row. */
@media (max-width: 560px) {
  .submitted-actions { flex-direction: column-reverse; align-items: stretch; gap: 8px; padding: 10px; bottom: 8px; }
  .submitted-actions-group { flex-direction: row; flex-wrap: nowrap; gap: 8px; }
  .submitted-actions-group .btn { flex: 1 1 0; min-width: 0; justify-content: center; padding-left: 8px; padding-right: 8px; }
  /* Two rows of buttons: lift the manual button above both. */
  body:has(.submitted-actions-group:first-child .btn:not([hidden])) .manual-fab { bottom: 140px; }
}

.radio-group,
.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.radio-option,
.check-option {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
  background: var(--color-surface);
  transition: border-color .15s ease, background .15s ease;
}

.radio-option:has(input:checked),
.check-option:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-tint);
  color: var(--color-primary-dark);
  font-weight: 500;
}

.radio-option input,
.check-option input {
  accent-color: var(--color-primary);
  margin: 0;
}

.radio-option.disabled,
.check-option.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--color-bg);
}

.calc-box {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--color-bg);
  font-size: 13.5px;
}

.calc-box .calc-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

.calc-box .calc-value {
  font-weight: 600;
}

.calc-box .calc-responsibility {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
  font-weight: 500;
  color: var(--color-primary-dark);
}

.copy-label-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

.copy-label-fields .field {
  flex: 1 1 200px;
  margin: 0;
}

/* ---------- Evaluation form — star rating ---------- */
.btn-quickfill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px 8px 14px;
  border: 1px solid #f1d27a;
  border-radius: 999px;
  background: linear-gradient(180deg, #fffaeb 0%, #fdf0c7 100%);
  color: #8a5a00;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(138, 90, 0, 0.08);
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.btn-quickfill .icon {
  width: 17px;
  height: 17px;
  color: #eab308;
  transition: color .15s ease, transform .2s ease;
}

/* fill must target the <svg> itself — it carries fill="none" as an
   attribute, which beats a value merely inherited from the span. */
.btn-quickfill .icon svg { fill: #eab308; transition: fill .15s ease; }

.btn-quickfill:hover {
  border-color: #eab308;
  background: linear-gradient(180deg, #fff5d6 0%, #fbe6a6 100%);
  box-shadow: 0 4px 12px rgba(234, 179, 8, 0.22);
  transform: translateY(-1px);
}

.btn-quickfill:hover .icon { transform: rotate(-12deg) scale(1.12); }

/* All rows are currently at 5 stars — the button reads as "on". */
.btn-quickfill.is-applied {
  border-color: #d69e06;
  background: linear-gradient(180deg, #f5c030 0%, #e0a50a 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(214, 158, 6, 0.3);
}

.btn-quickfill.is-applied .icon { color: #fff; }
.btn-quickfill.is-applied .icon svg { fill: #fff; }

/* Requester evaluation form (requester/evaluate.ejs), built from the
   admin's questions: one block per question, sections as cards. */
.eval-section + .eval-section { margin-top: 16px; }
.eval-q { padding: 14px 0; border-bottom: 1px dashed var(--color-border); margin: 0; }
.eval-q:last-child { border-bottom: 0; }
.eval-q .rating-row { margin: 0; padding: 0; border: 0; }
.eval-q-label { font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.eval-q-label .req, .rating-row-label .req { color: var(--color-danger); }
.eval-optional { font-weight: 400; color: var(--color-muted); font-size: 13px; }
.eval-q-hint { display: block; margin-top: 2px; font-weight: 400; font-size: 12.5px; color: var(--color-muted); }
.eval-q textarea { width: 100%; min-height: 90px; }
.eval-q .field-error { display: flex; }
.eval-q.invalid .radio-option, .eval-q.invalid .check-option { border-color: var(--color-danger); }
.eval-q.invalid .rating-row-label { color: var(--color-danger); }

.rating-list {
  display: flex;
  flex-direction: column;
}

.rating-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 -12px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--color-border);
  border-radius: 8px;
  transition: background-color .15s ease;
}

.rating-row:hover { background: var(--color-bg); }

.rating-row:last-child { border-bottom: none; }

.rating-row-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.rating-row-label .icon {
  width: 34px;
  height: 34px;
  padding: 8px;
  border-radius: 50%;
  background: var(--color-primary-tint);
  color: var(--color-primary);
  flex-shrink: 0;
}

.rating-row-control {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.star-rating {
  display: flex;
  flex-direction: row-reverse;
  gap: 2px;
}

/* Visually hidden but still focusable/keyboard-operable — never display:none. */
.star-rating input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.star-rating label {
  cursor: pointer;
  display: inline-flex;
  padding: 3px;
  border-radius: 6px;
}

.star-rating input:focus-visible + label {
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}

.star-rating .icon {
  width: 25px;
  height: 25px;
  color: var(--color-border);
  transition: color .12s ease, transform .12s ease;
}

/* Reversed DOM order (5→1) + general-sibling selector is the classic
   no-JS star-fill trick: checking/hovering star N lights up N and every
   star after it in DOM order, which is visually every star before it. */
.star-rating label:hover .icon,
.star-rating label:hover ~ label .icon,
.star-rating input:checked ~ label .icon {
  color: #eab308;
}

.star-rating label:hover .icon svg,
.star-rating label:hover ~ label .icon svg,
.star-rating input:checked ~ label .icon svg {
  fill: #eab308;
}

.star-rating label:hover .icon { transform: scale(1.15); }

.rating-feedback {
  min-width: 110px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-muted);
}

.rating-feedback.tier-good { color: var(--color-success); }
.rating-feedback.tier-mid  { color: var(--color-warning); }
.rating-feedback.tier-low  { color: var(--color-danger); }

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 20px;
  animation: fadeSlideIn 0.3s ease both;
}

.notice-info { background: var(--color-info-tint); color: var(--color-info); }
.notice-warning { background: var(--color-warning-tint); color: var(--color-warning); }
.notice-success { background: var(--color-success-tint); color: var(--color-success); }
.notice-error { background: var(--color-danger-tint); color: var(--color-danger); }

.notice .icon { width: 20px; height: 20px; margin-top: 1px; }


.summary-list {
  display: grid;
  grid-template-columns: 180px 1fr;
  row-gap: 12px;
  font-size: 14px;
}

.summary-list dt { color: var(--color-muted); }
.summary-list dd { margin: 0; font-weight: 600; }

/* ---------- Officer: counter handover (officer/counter-handover.ejs) ----------
   Claim Code is the one thing step 1 asks for, so give the input more
   visual weight than an ordinary .field row instead of it sitting inside
   a two-column form-grid meant for lists of unrelated fields. */
.claim-search-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 8px;
}

.claim-search {
  display: flex;
  gap: 12px;
}
.claim-search-input {
  flex: 1;
  min-width: 0;
  padding: 13px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 6px;
  text-align: center;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.claim-search-input::placeholder { color: var(--color-border); }
.claim-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}
.claim-search .btn { flex: none; padding-left: 24px; padding-right: 24px; }
@media (max-width: 560px) {
  .claim-search { flex-direction: column; }
  .claim-search .btn { width: 100%; }
}

/* ---------- System settings (admin/settings.ejs) ----------
   One row per setting: title + one-line description on the left, an on/off
   switch on the right. The whole row is a <label>, so it all toggles. */
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.set-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
/* Every card on the Admin pages (settings, officers, locations). Section header clearly above the row titles: bigger, heavier, on a tinted
   strip; the rows underneath stay at body size. */
.admin-card .card-header {
  padding: 16px 20px;
  background: var(--color-bg);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary-dark);
}

.set-row-title { font-size: 14.5px; font-weight: 500; }
.set-row-desc { font-size: 12.5px; color: var(--color-muted); }

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
  margin: 0;
  border-radius: 999px;
  background: var(--color-border);
  cursor: pointer;
  transition: background-color .2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform .2s ease;
}

.switch:checked { background: var(--color-primary); }
.switch-danger:checked { background: var(--color-danger); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.set-divider { height: 1px; margin: 20px 0; background: var(--color-border); }

.set-subtitle {
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-muted);
}

.set-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

/* Date picker + 24h time select (+ clear) on one line. */
.set-datetime { display: flex; align-items: center; gap: 8px; }
.set-datetime .date-picker { flex: 1 1 auto; min-width: 0; }
.set-datetime .time-wheel { flex: 0 0 auto; }


/* ---------- Time wheel (partials/time-wheel.ejs, createTimeWheel()) ----------
   iPhone-alarm style: two scroll-snap columns, 5 rows tall, the centre row
   (under the tinted band) is the value. Row height 40px = ITEM_H in app.js. */
.time-wheel { position: relative; }
.time-wheel-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  font-family: var(--font-family);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  cursor: pointer;
}
.time-wheel-input .icon { width: 16px; height: 16px; color: var(--color-muted); }
.time-wheel-input:focus,
.time-wheel-input[aria-expanded="true"] {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}
.time-wheel-input:disabled { opacity: .5; cursor: not-allowed; }

.time-wheel-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 220px;
  padding: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(38, 34, 32, 0.16);
  z-index: 20;
}
.time-wheel-panel[hidden] { display: none; }
.time-wheel-panel.open-up { top: auto; bottom: calc(100% + 6px); }

.time-wheel-wheels {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 200px;
}
.time-wheel-band {
  position: absolute;
  left: 0;
  right: 0;
  top: 80px;
  height: 40px;
  border-radius: 8px;
  background: var(--color-primary-tint);
  pointer-events: none;
}
.time-wheel-col {
  position: relative;
  width: 72px;
  height: 200px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  padding: 80px 0;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
  border-radius: 8px;
}
.time-wheel-col::-webkit-scrollbar { display: none; }
.time-wheel-col:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.time-wheel-item {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  color: var(--color-muted);
  cursor: pointer;
  user-select: none;
  transition: color .12s ease, font-size .12s ease;
}
.time-wheel-item:hover { color: var(--color-text); }
.time-wheel-item.selected { font-size: 22px; font-weight: 700; color: var(--color-primary-dark); }
.time-wheel-sep { position: relative; font-size: 22px; font-weight: 700; color: var(--color-primary-dark); }

.time-wheel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}
.time-wheel-unit { font-size: 11.5px; color: var(--color-muted); }

@media (pointer: coarse) {
  .time-wheel-panel { width: 240px; }
  .time-wheel-col { width: 84px; }
}
.set-datetime .btn[hidden] { display: none; }

.set-schedule-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 0;
  padding: 8px 8px 8px 14px;
  min-height: 46px;
  border-radius: 8px;
  background: var(--color-bg);
  font-size: 13px;
  color: var(--color-muted);
}
.set-schedule-status-text { min-width: 0; }
/* "Clear dates" sits at the bar's right end: same white secondary button as
   elsewhere, kept on one line so it doesn't squash into a pill. */
.set-schedule-status .btn { flex-shrink: 0; white-space: nowrap; }
@media (max-width: 560px) {
  .set-schedule-status { flex-direction: column; align-items: stretch; padding: 10px 12px; }
  .set-schedule-status .btn { width: 100%; }
}
.set-schedule-status[data-state="closedIndefinitely"],
.set-schedule-status[data-state="closedUntil"] { background: var(--color-danger-tint); color: var(--color-danger); }
.set-schedule-status[data-state="scheduled"],
.set-schedule-status[data-state="scheduledOpenEnded"] { background: var(--color-warning-tint); color: var(--color-warning); }

.set-actions { justify-content: flex-start; align-items: center; gap: 14px; }

/* Maintenance schedule/messages block — slides open with the switch
   (setMaintDetails() in admin/settings.ejs animates the height). Clipped only
   while moving; once settled it's overflow:visible so the calendar can hang
   out of it. visibility waits for the slide so folded fields leave Tab order. */
.set-collapse {
  height: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: height .3s ease, opacity .25s ease, visibility 0s .3s;
}
.set-collapse.is-open {
  height: auto;
  opacity: 1;
  visibility: visible;
  transition: height .3s ease, opacity .25s ease .05s, visibility 0s;
}
.set-collapse.is-open.is-settled { overflow: visible; }

/* This card opts out of clipping (card-overflow-visible, for the calendar),
   so its tinted header has to round its own top corners. */
.admin-card.card-overflow-visible > .card-header { border-radius: var(--radius) var(--radius) 0 0; }

/* ---------- Sticky save bar (admin/settings) ----------
   Stays pinned to the bottom of the viewport while the form scrolls.
   clean = quiet white bar, Save disabled; dirty = amber "unsaved changes"
   bar with a pulsing Save + Discard; saving / saved = progress, then green. */
.savebar {
  position: sticky;
  bottom: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
  padding: 12px 14px 12px 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(38, 34, 32, 0.12);
  transition: background-color .2s ease, border-color .2s ease;
}
.savebar-status { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 14px; color: var(--color-muted); }
.savebar-icon { width: 20px; height: 20px; flex-shrink: 0; }
.savebar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.savebar-save { min-width: 170px; justify-content: center; padding: 11px 22px; font-size: 15px; font-weight: 600; }
.savebar-save:disabled { opacity: .4; }

.savebar[data-state="dirty"] {
  background: var(--color-warning-tint);
  border-color: var(--color-warning);
  animation: savebar-nudge .3s ease;
}
.savebar[data-state="dirty"] .savebar-status { color: var(--color-warning); font-weight: 600; }
.savebar[data-state="dirty"] .savebar-save { animation: savebar-pulse 1.6s ease-out 2; }
.savebar[data-state="saving"] .savebar-status { color: var(--color-primary); }
.savebar[data-state="saved"] { background: var(--color-success-tint); border-color: var(--color-success); }
.savebar[data-state="saved"] .savebar-status { color: var(--color-success); font-weight: 600; }

@keyframes savebar-nudge {
  0% { transform: translateY(6px); }
  100% { transform: translateY(0); }
}
@keyframes savebar-pulse {
  0% { box-shadow: 0 0 0 0 rgba(122, 46, 46, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(122, 46, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(122, 46, 46, 0); }
}

@media (max-width: 560px) {
  .savebar { flex-direction: column; align-items: stretch; gap: 10px; bottom: 10px; padding: 12px; }
  .savebar-status { justify-content: center; text-align: center; }
  .savebar-actions { flex-direction: column-reverse; align-items: stretch; }
  .savebar-actions .btn { width: 100%; justify-content: center; }
  .savebar-actions .save-status-icon { display: none !important; }
}

@media (max-width: 700px) {
  .set-pair { grid-template-columns: 1fr; }
}

/* ---------- Request detail (officer/request-detail.ejs) ----------
   Two columns: the submitted spec on the left (read top-down and compared
   against the physical originals), the Officer's decision on the right in a
   sticky panel so Approve/Reject stays in view while scrolling the spec.
   Stacks to one column below 1000px with the spec first. Values wrap instead
   of truncating so long text is always fully readable. */
.rd-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-muted);
}

.rd-back:hover { color: var(--color-primary); }
.rd-back .icon { width: 14px; height: 14px; transform: rotate(90deg); }

.rd-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 4px;
}

.rd-head .page-title { margin: 0; overflow-wrap: anywhere; }
.rd-head .badge { font-size: 13px; padding: 5px 12px; }

.rd-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.rd-main,
.rd-aside { min-width: 0; }

.rd-aside {
  position: sticky;
  top: 84px;
}

.rd-main .card,
.rd-aside .card { margin-bottom: 16px; }

.rd-card-title {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-muted);
}

/* Overview: item list, then pages × copies = total → sheets as one line of
   arithmetic, so the Officer sees how the paper figure was reached. */
.rd-items {
  padding: 14px 16px;
  border-left: 4px solid var(--color-primary);
  border-radius: 8px;
  background: var(--color-primary-tint);
}

.rd-items-text {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.rd-calc {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 16px;
}

.rd-calc-item {
  flex: 1 1 0;
  min-width: 0;
  padding: 12px 8px;
  text-align: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.rd-calc-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.rd-calc-label {
  margin-top: 2px;
  font-size: 12px;
  color: var(--color-muted);
}

.rd-calc-op {
  align-self: center;
  flex: 0 0 auto;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-muted);
}

.rd-calc-item.is-result {
  background: var(--color-primary-tint);
  border-color: transparent;
}

.rd-calc-item.is-result .rd-calc-value { color: var(--color-primary-dark); }

/* Label / value rows separated by hairlines — no boxes, no bold-on-bold. */
.rd-rows { margin: 0; }

.rd-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}

.rd-row:first-child { padding-top: 0; }
.rd-row:last-child { padding-bottom: 0; border-bottom: none; }

.rd-row dt { color: var(--color-muted); }

.rd-row dd {
  margin: 0;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* Email tucked next to a person's name (requester / officer) so it's there
   to cross-check against a display name — e.g. after a name change — without
   calling attention to itself as a fraud check. */
.identity-email {
  font-weight: 400;
  color: var(--color-muted);
  font-size: 0.88em;
  margin-left: 5px;
}

.rd-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.rd-pair .rd-row { grid-template-columns: 1fr; gap: 2px; }
.rd-pair .rd-row dt { font-size: 12.5px; }

/* Decision panel. */
.rd-due {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--color-warning-tint);
  color: var(--color-warning);
}

.rd-due .icon { width: 20px; height: 20px; flex: 0 0 auto; }
.rd-due-label { font-size: 12px; }
.rd-due-value { font-size: 15px; font-weight: 700; }

.rd-hint {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-muted);
}

.rd-aside .btn-block { width: 100%; }

.rd-approve-actions { margin-top: 16px; }
.rd-approve-actions .rd-note { margin-top: 8px; text-align: center; }

.rd-reject-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 16px;
  padding: 12px 8px 8px;
  border: none;
  border-top: 1px solid var(--color-border);
  background: none;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-danger);
  cursor: pointer;
  border-radius: 0 0 8px 8px;
}

.rd-reject-toggle:hover { background: var(--color-danger-tint); }
.rd-reject-toggle .icon { width: 14px; height: 14px; transition: transform .15s ease; }
.rd-reject-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }

.rd-reject-box {
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.rd-reject-box[hidden] { display: none; }

/* Outcome cards: a tinted band with the result, plain rows underneath. */
.rd-outcome { padding: 0; }

.rd-outcome-band {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.rd-outcome-band .icon { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; }
.rd-outcome-band.tone-success { background: var(--color-success-tint); color: var(--color-success); }
.rd-outcome-band.tone-danger { background: var(--color-danger-tint); color: var(--color-danger); }
.rd-outcome-band.tone-muted { background: var(--color-bg); color: var(--color-muted); }

.rd-outcome-body { padding: 16px 18px; }
.rd-outcome-body .rd-row { grid-template-columns: 1fr; gap: 2px; }
.rd-outcome-body .rd-row dt { font-size: 12.5px; }

.rd-code-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.rd-code {
  padding: 10px 12px;
  border: 1px dashed var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
}

.rd-code-label { font-size: 12px; color: var(--color-muted); }

.rd-code-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rd-code-value .copy-btn { margin-left: 0; flex: 0 0 auto; }

.rd-note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-muted);
}

@media (max-width: 1000px) {
  .rd-layout { grid-template-columns: minmax(0, 1fr); }
  .rd-aside { position: static; }
}

@media (max-width: 560px) {
  .rd-row { grid-template-columns: 1fr; gap: 2px; }
  .rd-row dt { font-size: 12.5px; }
  .rd-pair { grid-template-columns: 1fr; gap: 0; }
  .rd-calc { flex-wrap: wrap; }
  .rd-calc-item { flex: 1 1 40%; }
  .rd-calc-op { display: none; }
  .rd-calc-value { font-size: 22px; }
}

/* On-screen (non-print) look for the Request Form — the @media print block
   below is the "official document" version used when printing/generating
   the PDF. Structure/sizing ported from the reviewed wireframe at
   ref and logos/wireframes/printing-request-form-redesign.html (.ph-*
   classes there, renamed .print-* here); the logo's real source file is
   high-res so it needs an explicit on-screen size too, not just print's. */
.print-doc .print-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1.5px solid var(--color-text);
}
.print-doc .print-logo { width: 44px; height: auto; margin-bottom: 6px; }
.print-doc .print-org-en { font-size: 13.5px; font-weight: 600; letter-spacing: 0.01em; margin-bottom: 8px; }
.print-doc .print-doc-title { font-size: 19px; font-weight: 600; letter-spacing: 0.01em; margin-top: 4px; }
.print-doc .print-salutation { font-size: 12.5px; color: var(--color-muted); margin-top: 6px; }

.print-doc .print-section-label {
  font-size: 13.5px;
  font-weight: 700;
  padding-bottom: 4px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--color-text);
}

.print-doc .print-field-table,
.print-doc .print-item-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 20px;
}
.print-doc .print-field-table { border: 1px solid var(--color-border); }
.print-doc .print-field-table th,
.print-doc .print-field-table td,
.print-doc .print-item-table th,
.print-doc .print-item-table td {
  border: 0.75px solid var(--color-border);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
  font-weight: 400;
}
.print-doc .print-field-table th { background: var(--color-bg); font-weight: 600; width: 19%; white-space: nowrap; }
.print-doc .print-approval-table th { text-align: center; font-weight: 700; width: 50%; white-space: normal; }
.print-doc .print-approval-table td { line-height: 1.5; }
.print-doc .print-approval-table td em { font-style: italic; color: var(--color-muted); }
/* Each Officer/Receiver detail is its own line with a small muted label
 * ahead of the value (.pf-line/.pf-line-label, set by boldLine()/detailLine()
 * in app.js) instead of a run-on paragraph — a 4-5 line cell reads as a
 * scannable list, not a wall of same-weight text. */
/* Sign-off cell: status as a heading, then label | value rows with the
   labels in one aligned column. */
.print-doc .pf-lines {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 14px;
  row-gap: 3px;
  align-items: baseline;
}
.print-doc .pf-lines > .pf-line { display: contents; }
.print-doc .pf-lines > .pf-line-head { display: block; grid-column: 1 / -1; margin-bottom: 4px; }
.print-doc .pf-line-value { overflow-wrap: anywhere; }
.print-doc .print-approval-table .pf-line-label { color: var(--color-muted); font-size: 0.85em; font-weight: 400; }

.print-doc .print-item-table { font-size: 12.5px; }
.print-doc .print-item-table th { font-weight: 700; font-size: 11px; }
.print-doc .print-item-table td.num { font-variant-numeric: tabular-nums; text-align: right; }
.print-doc .print-item-table small { display: block; font-weight: 400; color: var(--color-muted); font-size: 9.5px; }

.print-doc .print-requester-line {
  font-size: 13px;
  padding-top: 12px;
  margin-top: 2px;
  border-top: 0.75px solid var(--color-border);
}
.print-doc .print-requester-line .k { font-weight: 700; }

.print-doc .print-footnote {
  font-size: 10.5px;
  color: var(--color-muted);
  text-align: center;
  padding-top: 10px;
  border-top: 0.75px solid var(--color-border);
}

/* Two faces of the same text (pfNodes() in app.js): one language on
   screen, "Thai (English)" when printed or turned into the PDF. */
.pf-print { display: none; }
@media print {
  .pf-screen { display: none !important; }
  .pf-print { display: inline; }
}

/* Screen only: a lighter, shorter form that uses the full width.
   Print/PDF keep their own official layout. */
@media screen {
  .print-doc.card-body { padding: 20px 24px; }
  .print-doc .print-header { padding-bottom: 10px; margin-bottom: 14px; gap: 0; }
  .print-doc .print-logo { width: 34px; margin-bottom: 4px; }
  .print-doc .print-org-en { font-size: 12.5px; margin-bottom: 2px; }
  .print-doc .print-doc-title { font-size: 17px; margin-top: 2px; }
  .print-doc .print-salutation { font-size: 12px; margin-top: 2px; }
  .print-doc .print-section-label { font-size: 13px; margin-bottom: 6px; }
  .print-doc .print-field-table,
  .print-doc .print-item-table { margin-bottom: 14px; }
  .print-doc .print-field-table th,
  .print-doc .print-field-table td,
  .print-doc .print-item-table th,
  .print-doc .print-item-table td { padding: 5px 10px; }
  .print-doc .print-requester-line { padding-top: 8px; margin-bottom: 12px; }
  .print-doc .print-approval-table td { height: 44px; }
}

/* Wider screens: field tables become a grid of label | value pairs laid
   side by side (2 pairs per row, 4 from 1500px) so the form is short
   and fills the width. Phones keep the one-pair-per-row layout further down. */
@media screen and (min-width: 769px) {
  .print-doc .print-field-table:not(.print-approval-table) {
    display: grid;
    grid-template-columns: repeat(2, max-content minmax(0, 1fr));
    border: none;
    border-top: 1px solid var(--color-border);
    border-left: 1px solid var(--color-border);
  }
  .print-doc .print-field-table:not(.print-approval-table) tbody,
  .print-doc .print-field-table:not(.print-approval-table) tr { display: contents; }
  .print-doc .print-field-table:not(.print-approval-table) th,
  .print-doc .print-field-table:not(.print-approval-table) td {
    display: block;
    width: auto;
    border: none;
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    overflow-wrap: anywhere;
  }
  /* The long paper-source sentence goes last and takes a whole row's
     remaining width (its label + 3 columns). */
  .print-doc th:has(+ #pf-paperresponsibility),
  .print-doc #pf-paperresponsibility { order: 1; }
  .print-doc #pf-paperresponsibility { grid-column: span 3; }
}
@media screen and (min-width: 1500px) {
  .print-doc .print-field-table:not(.print-approval-table) {
    grid-template-columns: repeat(4, max-content minmax(0, 1fr));
  }
}
/* ---------- Copy-to-clipboard button ---------- */
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  vertical-align: middle;
  margin-left: 4px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 6px;
  cursor: pointer;
  color: var(--color-muted);
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.copy-btn:hover { background: var(--color-bg); color: var(--color-primary); border-color: var(--color-primary); }
.copy-btn .icon { width: 13px; height: 13px; }
.copy-btn.copied { color: var(--color-success); border-color: var(--color-success); }

/* ---------- Confirm modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 11, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
  animation: fadeSlideIn 0.15s ease both;
}

.modal-overlay[hidden] { display: none; }

.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(11, 11, 11, 0.28);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  animation: fadeSlideIn 0.2s ease both;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
}

.modal-message {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--color-muted);
  line-height: 1.6;
  white-space: pre-line;
}

.modal-extra {
  margin: 4px 0 18px;
  text-align: left;
}
.modal-extra[hidden] { display: none; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.result-modal-box {
  text-align: center;
}

.result-modal-box .modal-message {
  margin-bottom: 20px;
}

.result-modal-box .modal-actions {
  justify-content: center;
}

.result-modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.result-modal-icon .icon {
  width: 26px;
  height: 26px;
}

.result-modal-success .result-modal-icon { background: var(--color-success-tint); color: var(--color-success); }
.result-modal-danger .result-modal-icon { background: var(--color-danger-tint); color: var(--color-danger); }

/* ---------- Processing overlay ---------- */
.processing-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(11, 11, 11, 0.28);
  padding: 28px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: fadeSlideIn 0.2s ease both;
}

.processing-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.processing-message {
  font-size: 14px;
  font-weight: 600;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-muted);
}

.empty-state .icon {
  font-size: 40px;
  margin-bottom: 12px;
}

/* ---------- Dashboard: stat tiles ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-tile .card-body {
  padding: 18px 20px;
}

.stat-label {
  font-size: 12.5px;
  color: var(--color-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: proportional-nums;
}

/* ---------- Generic in-page tab switcher (Evaluation Results) ---------- */
/* A segmented-control look (boxed, filled active state) rather than an
   underline — an underline read as plain section headings, not something
   clickable, so it wasn't obvious there were two swappable views. */
/* Sits next to the shared year filter on one line (.tab-row) instead of a
   filter bar's worth of its own vertical space above the tabs. */
.tab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.tab-nav {
  position: relative;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

/* A <select> styled to match .field select's look without needing the
   .field wrapper/label — used where a filter sits inline in a toolbar row
   rather than stacked in a labeled form-grid field. */
.toolbar-select {
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 13.5px;
  color: var(--color-text);
  background: var(--color-surface);
}

.toolbar-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}

/* One-row filter bar (search + selects + a checkbox) instead of a labeled
   form-grid — cuts several label lines' worth of height so the page isn't
   all filters before any actual content. Wraps to multiple lines only on
   narrow viewports. */
.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* An author stylesheet rule at the same specificity as the browser's own
   [hidden]{display:none} default wins regardless of the attribute — same
   trap .modal-overlay[hidden] above already works around — so toggling
   .hidden on a .filter-toolbar sub-group (e.g. dashboard.ejs's calendar vs
   custom-range fields) silently did nothing without this override. */
.filter-toolbar[hidden] { display: none; }

.filter-toolbar-search {
  flex: 1 1 240px;
  min-width: 180px;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
}

.filter-toolbar-search:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}

.filter-toolbar-checkbox {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 400;
  white-space: nowrap;
  color: var(--color-text);
}

/* Positioned/sized via JS (offsetLeft/offsetWidth of the active button) so
   it slides and resizes to match whichever label is active, like a
   physical toggle switch — the two tab labels are very different lengths
   so a fixed-width thumb wouldn't line up with the shorter one. */
.tab-nav-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: 0;
  border-radius: 7px;
  background: var(--color-primary);
  box-shadow: var(--shadow);
  transition: left 0.2s ease, width 0.2s ease;
}

.tab-btn {
  position: relative;
  z-index: 1;
  padding: 9px 20px;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-muted);
  background: none;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.tab-btn:hover { color: var(--color-text); }
.tab-btn.active { color: #fff; }

/* ---------- Evaluation Results: per-dimension score cards ---------- */
/* 5 cards, not 4 — the shared .stat-grid's 4-column layout would strand the
   5th card alone on its own row, so this section gets its own column count.
   A class (not an ID) so the .stat-grid responsive overrides further down
   this file — same specificity, later in source order — still win at
   narrower widths. */
.scores-grid { grid-template-columns: repeat(5, 1fr); }

.score-card-header {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-bottom: 8px;
  /* Reserves room for a 2-line label so the value/bar below start at the
     same height on every card, regardless of how long each dimension's
     label is (they range from ~18 to ~32 characters). */
  min-height: 34px;
}

.score-card-header .icon { margin-top: 1px; }

.score-card-header .icon {
  width: 15px;
  height: 15px;
  color: var(--color-muted);
  flex-shrink: 0;
}

.score-card-bar-track {
  height: 7px;
  border-radius: 4px;
  background: var(--color-border);
  overflow: hidden;
  margin-top: 8px;
}

.score-card-bar-fill {
  height: 100%;
  border-radius: 4px;
}

.score-tier-good .score-card-bar-fill { background: var(--color-success); }
.score-tier-mid .score-card-bar-fill { background: var(--color-warning); }
.score-tier-low .score-card-bar-fill { background: var(--color-danger); }

/* ---------- Evaluation Results: written-feedback list ---------- */
/* ---------- Evaluation results: latest-comments feed ----------
   A clean list: avatar, name + when, the comment itself, then the
   reference number and only the sub-scores rated low; the overall score
   sits on the right as a star badge (number + star, never colour alone).
   Tier colours reuse the .score-tier-* good/mid/low thresholds (1-5). */
.feed-card-header { align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.feed-title { font-size: 16px; font-weight: 700; }
.feed-subtitle { margin-top: 3px; font-size: 12.5px; font-weight: 400; color: var(--color-muted); }

.feed-list { padding: 4px 0; }
.feed-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  transition: background-color .15s ease;
  animation: fadeSlideIn 0.3s ease both;
}
.feed-item:last-child { border-bottom: none; }
.feed-item:hover { background: var(--color-bg); }
.feed-item:hover .feed-text { background: var(--color-surface); box-shadow: inset 0 0 0 1px var(--color-border); }

.feed-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-primary-tint);
  color: var(--color-primary);
  font-size: 15px;
  font-weight: 700;
}

.feed-main { min-width: 0; }
/* Name on its own line, the time underneath as a small grey line with a
   clock icon — no separator dot needed. */
.feed-meta { display: flex; flex-direction: column; gap: 1px; }
.feed-name { font-size: 14px; font-weight: 600; color: var(--color-text); line-height: 1.4; }
.feed-when { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--color-muted); }
.feed-when .icon { width: 12px; height: 12px; }
.feed-text {
  margin: 10px 0 0;
  padding: 10px 14px;
  background: var(--color-bg);
  border-radius: 4px 12px 12px 12px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--color-text);
  overflow-wrap: anywhere;
}
.feed-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.feed-ref {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}
.feed-dim { padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.feed-dim strong { font-weight: 700; }
.feed-dim.score-tier-mid { background: var(--color-warning-tint); color: var(--color-warning); }
.feed-dim.score-tier-low { background: var(--color-danger-tint); color: var(--color-danger); }

.feed-score {
  display: inline-flex; align-items: baseline; gap: 2px;
  padding: 5px 11px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.feed-score-star { font-size: 13px; margin-right: 3px; }
.feed-score-num { font-size: 16px; font-weight: 700; }
.feed-score-max { font-size: 12px; opacity: .75; }
.feed-score.score-tier-good { background: var(--color-success-tint); color: var(--color-success); }
.feed-score.score-tier-mid { background: var(--color-warning-tint); color: var(--color-warning); }
.feed-score.score-tier-low { background: var(--color-danger-tint); color: var(--color-danger); }

.feed-footer { border-top: 1px solid var(--color-border); }
.feed-more-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%;
  padding: 13px 20px;
  border: none;
  background: transparent;
  color: var(--color-primary);
  font-family: var(--font-family);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s ease;
}
.feed-more-btn:hover { background: var(--color-primary-tint); }
.feed-more-arrow { font-size: 18px; line-height: 1; transition: transform .15s ease; }
.feed-more-btn:hover .feed-more-arrow { transform: translateX(3px); }

@media (max-width: 560px) {
  .feed-item { grid-template-columns: 34px minmax(0, 1fr); padding: 14px 16px; }
  .feed-avatar { width: 34px; height: 34px; font-size: 13px; }
  .feed-score { grid-column: 2; justify-self: start; margin-top: -4px; }
}

/* ---------- Dashboard: bar charts (validated data color — see file.md / dataviz notes) ---------- */
:root { --viz-bar: #a03d3d; }

.viz-bar-chart { display: flex; flex-direction: column; gap: 10px; }

.viz-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background-color .15s ease;
}

.viz-bar-row:hover { background: var(--color-bg); }

.viz-bar-label {
  width: 200px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viz-bar-track {
  flex: 1;
  height: 22px;
  background: var(--color-bg);
  border-radius: 4px;
  overflow: hidden;
}

.viz-bar-fill {
  height: 100%;
  background: var(--viz-bar);
  border-radius: 0 4px 4px 0;
  width: 0;
  transition: width .5s ease;
}

.viz-bar-value {
  width: 76px;
  flex-shrink: 0;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.viz-bar-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.viz-bar-badge.highest { background: var(--color-success-tint); color: var(--color-success); }
.viz-bar-badge.lowest { background: var(--color-warning-tint); color: var(--color-warning); }

/* ---------- Excel export button (history / dashboard / evaluations) ---------- */
.export-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border: 1px solid #b9d7c3;
  border-radius: 999px;
  background: #f2f9f4;
  color: #1d6b3d;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.export-btn .icon { width: 16px; height: 16px; }
.export-btn:hover { background: #e3f3e8; border-color: #1d6b3d; box-shadow: 0 4px 12px rgba(29, 107, 61, 0.15); }
.export-btn.is-busy { opacity: .7; cursor: progress; }
.export-btn.is-busy .icon { animation: exportPulse 1s ease-in-out infinite; }
@keyframes exportPulse { 50% { transform: translateY(2px); } }
.tab-row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

/* ---------- Filter panel (dashboard, history, queue, evaluations, audit log) ----------
   One shared look for every page's filters: an optional full-width search
   box on top, then labelled groups on one row separated by thin rules,
   on/off options as chips, and at most one short note underneath —
   instead of a loose run of unlabelled selects plus paragraphs of notes. */
.filter-panel .card-body { padding: 18px 20px 16px; }
.filter-panel > .card-header { padding: 14px 20px; }

.filter-search { position: relative; flex: 1 1 280px; min-width: 200px; }
.filter-search-icon {
  position: absolute; left: 12px; top: 50%;
  width: 17px; height: 17px;
  transform: translateY(-50%);
  color: var(--color-muted);
  pointer-events: none;
}
.filter-search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text);
}
.filter-search input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-tint); }
.filter-panel .filter-search + .filter-row { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--color-border); }
.filter-panel .filter-collapse-inner > .filter-row { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--color-border); }
.filter-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 24px; }

/* Collapsible filters (pilot: officer/evaluations.ejs): search + a toggle
   button on one line, the filter row slides open beneath (grid 0fr→1fr). */
.filter-top { display: flex; align-items: center; gap: 10px; }
.filter-top .filter-search { flex: 1 1 auto; }
.filter-top-title { flex: 1 1 auto; font-size: 13.5px; color: var(--color-muted); }
.filter-panel .filter-collapse-inner > .filter-note { margin-top: 14px; }
.filter-toggle { font-family: var(--font-family); display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; white-space: nowrap; }
.filter-toggle-count {
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  background: var(--color-primary); color: #fff;
  font-size: 12px; font-weight: 700; line-height: 20px; text-align: center;
}
.filter-toggle-count[hidden] { display: none; }
.filter-toggle-chevron { width: 16px; height: 16px; transition: transform .2s ease; }
.filter-toggle[aria-expanded="true"] { border-color: var(--color-primary); color: var(--color-primary); }
.filter-toggle[aria-expanded="true"] .filter-toggle-chevron { transform: rotate(180deg); }
.filter-collapse { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s ease; }
.filter-collapse.is-open { grid-template-rows: 1fr; }
.filter-collapse-inner { overflow: hidden; min-height: 0; }
.filter-collapse.is-open .filter-collapse-inner { overflow: visible; }
.filter-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filter-group + .filter-group { padding-left: 24px; border-left: 1px solid var(--color-border); }
.filter-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 22px; }
.filter-label { font-size: 12.5px; font-weight: 600; color: var(--color-muted); }
.filter-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-controls[hidden] { display: none; }
.filter-controls .toolbar-select { min-width: 150px; }
.filter-to { font-size: 13px; color: var(--color-muted); }
.filter-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--color-primary); cursor: pointer; user-select: none; }
.filter-switch input { accent-color: var(--color-primary); margin: 0; }
.filter-clear {
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-primary);
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.filter-clear:hover { background: var(--color-primary-tint); }

/* On/off option as a chip: the whole pill is the click target, and it
   fills in maroon-tint while on. */
/* Checkbox filter: same box as .toolbar-select next to it (8px corners,
   same padding and text size), not a rounded pill. */
.filter-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  font-size: 13.5px;
  line-height: normal;
  color: var(--color-text);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.filter-chip input { accent-color: var(--color-primary); margin: 0; }
.filter-chip:hover { border-color: var(--color-primary); }
.filter-chip:has(input:checked) { background: var(--color-primary-tint); border-color: var(--color-primary); color: var(--color-primary); font-weight: 600; }

.filter-note { display: flex; align-items: center; gap: 6px; margin: 14px 0 0; font-size: 12.5px; color: var(--color-muted); }
.filter-note .icon { width: 15px; height: 15px; }

@media (max-width: 760px) {
  .filter-row { flex-direction: column; align-items: stretch; gap: 14px; }
  .filter-group + .filter-group { padding-left: 0; border-left: none; padding-top: 14px; border-top: 1px solid var(--color-border); }
  .filter-controls .toolbar-select { flex: 1 1 140px; }
}

/* ---------- Dashboard: yearly trend card ----------
   Standard analytics "trend card" layout: header (title + range control),
   a strip of headline numbers, the line chart, then an optional table.
   The SVG is drawn at the container's real pixel width (not a stretched
   viewBox), so text stays crisp and the same size at any width. */
.trend-card-header { align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.trend-heading { min-width: 0; }
.trend-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 16px; font-weight: 700; }
.trend-subtitle { margin-top: 4px; font-size: 12.5px; font-weight: 400; color: var(--color-muted); line-height: 1.5; }

.viz-range {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
}
.viz-range[hidden] { display: none; }
.viz-range-btn {
  padding: 5px 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--color-muted);
  font-family: var(--font-family);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.viz-range-btn:hover { color: var(--color-text); }
.viz-range-btn.active { background: var(--color-surface); color: var(--color-primary); font-weight: 600; box-shadow: 0 1px 3px rgba(38, 34, 32, 0.12); }

.trend-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

.trend-view-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}
.trend-view-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--color-muted);
  font-family: var(--font-family);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.trend-view-btn .icon { width: 15px; height: 15px; }
.trend-view-btn:hover { color: var(--color-text); }
.trend-view-btn.active { background: var(--color-primary); color: #fff; font-weight: 600; }

.trend-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.trend-stat {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}
.trend-stat-icon {
  width: 38px; height: 38px;
  padding: 9px;
  border-radius: 10px;
  background: var(--color-primary-tint);
  color: var(--color-primary);
  flex-shrink: 0;
}
.trend-stat-body { min-width: 0; }
.trend-stat-label { font-size: 12.5px; color: var(--color-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trend-stat-value { margin-top: 2px; font-size: 22px; font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; line-height: 1.25; white-space: nowrap; }
.trend-stat-unit { margin-left: 5px; font-size: 13px; font-weight: 500; color: var(--color-muted); }
.trend-stat-note { margin-top: 2px; font-size: 12px; color: var(--color-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.trend-change { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--color-text); }
.trend-change.up, .trend-change.down { color: var(--color-text); }
.trend-change.flat { color: var(--color-muted); }

.viz-line-chart { position: relative; width: 100%; }
.viz-line-svg { display: block; overflow: visible; font-family: var(--font-family); }
.viz-grid { stroke: var(--color-border); stroke-width: 1; stroke-dasharray: 2 4; }
.viz-baseline { stroke: #b9aea2; stroke-dasharray: none; }
.viz-tick { stroke: #b9aea2; stroke-width: 1; }
.viz-axis-label { fill: var(--color-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.viz-axis-title { fill: var(--color-text); font-size: 12.5px; font-weight: 600; }

.viz-line-area { fill: url(#viz-line-area); }
.viz-line-path { fill: none; stroke: var(--viz-bar); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.viz-line-dot { fill: var(--viz-bar); stroke: var(--color-surface); stroke-width: 2; }
.viz-line-dot-latest { stroke-width: 3; }
.viz-line-dot-active { stroke-width: 3; pointer-events: none; }
.viz-pill rect { fill: var(--viz-bar); }
.viz-pill text { fill: #fff; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-hover-band { fill: var(--viz-bar); fill-opacity: 0.07; pointer-events: none; }
.viz-hit { fill: transparent; cursor: crosshair; touch-action: pan-y; }

.viz-tooltip {
  position: absolute;
  z-index: 2;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(38, 34, 32, 0.16);
  pointer-events: none;
  white-space: nowrap;
}
.viz-tooltip[hidden] { display: none; }
.viz-tooltip-title { font-size: 12.5px; color: var(--color-muted); }
.viz-tooltip-value { font-size: 17px; font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; }
.viz-tooltip-value span { font-size: 12.5px; font-weight: 500; color: var(--color-muted); }
.viz-tooltip-change { margin-top: 2px; font-size: 12.5px; color: var(--color-muted); }
.viz-tooltip-change .trend-change { font-weight: 600; }

.viz-demo-badge { padding: 2px 8px; border-radius: 999px; background: var(--color-warning-tint); color: var(--color-warning); font-size: 11.5px; font-weight: 600; }
.viz-demo-badge[hidden] { display: none; }

/* Table view. Its own light styling (not .data-table's maroon header) since
   it sits inside a card. The header is sticky, and needs a z-index: every
   body row runs the fadeSlideIn animation, whose transform gives each row
   its own stacking layer — without z-index those rows painted over the
   sticky header while scrolling. */
.trend-table-wrap {
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: 12px;
}
.trend-table-wrap[hidden] { display: none; }
.trend-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.trend-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 11px 18px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.trend-table td { padding: 11px 18px; border-bottom: 1px solid var(--color-border); }
.trend-table tbody tr { animation: fadeSlideIn 0.3s ease both; transition: background-color .15s ease; }
.trend-table tbody tr:hover { background: var(--color-bg); }
.trend-table tbody tr:last-child td { border-bottom: none; }
.trend-table .num { text-align: right; }
.trend-td-year { font-weight: 600; white-space: nowrap; }
.trend-peak-badge {
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--color-primary-tint);
  color: var(--color-primary);
  font-size: 11.5px;
  font-weight: 600;
}
.trend-td-sheets { display: flex; align-items: center; gap: 14px; }
.trend-td-value { min-width: 72px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.trend-td-bar { flex: 1; max-width: 260px; height: 8px; border-radius: 999px; background: var(--color-bg); overflow: hidden; }
.trend-td-bar span { display: block; height: 100%; border-radius: 999px; background: var(--viz-bar); opacity: .75; }
.trend-table tr.is-peak .trend-td-bar span { opacity: 1; }

@media (max-width: 1100px) {
  .trend-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .trend-stat { padding: 12px; gap: 10px; }
  .trend-stat-icon { width: 32px; height: 32px; padding: 7px; }
  .trend-stat-value { font-size: 18px; }
  .trend-td-bar { display: none; }
  .trend-table th, .trend-table td { padding: 10px 12px; }
}

/* ---------- Print (Request Form) ----------
   .print-doc wraps the Request Form content in both request-submitted.ejs
   and officer/request-form-view.ejs. Its formal styling only applies under
   @media print / the PDF (page.emulateMediaType("print") in pdf.js) — the
   on-screen app chrome elsewhere keeps the regular Kanit UI look; only this
   one printable document switches to the official Sarabun typeface. */
@media print {
  .app-sidebar, .app-header, .no-print,
  .manual-fab, .manual-dock, .manual-dock-pop { display: none !important; }
  /* !important: the printable width of A4 (~680px) also matches the
     tablet/phone @media (max-width: ...) blocks further down this file,
     which come later and would otherwise put their screen padding back
     (an extra ~60pt of height = the form spilling onto a 2nd page). */
  .app { display: block !important; min-height: 0 !important; }
  .app-main { padding: 0 !important; }
  /* html too: with printBackground (pdf.js) the app's cream page colour
     otherwise shows in the empty space under the form. */
  html, body { background: #fff !important; }

  /* The Request Form's on-screen .card chrome (border/shadow/rounded
     corners/padding) is app UI, not part of the document — strip it so
     the printed page is just the document itself, edge to edge within
     pdf.js's own page margins. */
  .card { border: none; border-radius: 0; box-shadow: none; background: transparent; margin: 0; overflow: visible; }
  .card-body { padding: 0 !important; }

  /* Sizing ported from the reviewed wireframe (ref and logos/wireframes/
     printing-request-form-redesign.html, .ph-* classes there), then scaled
     up ~15% (2026-08-26) to use more of the A4 page now that dropping the
     .card padding above freed up room. Verify against the ~757pt
     A4-minus-15mm-margins budget after editing any row/table — the
     original vertical-list version overflowed to 3 pages once already. */
  /* Same page box for the browser's own Print and for pdf.js, so both lay
     the form out identically. The page margin is 0 so the browser has no
     room for its own header/footer (page title, date, URL like
     "localhost:3000/requester/..."), and the 15mm white border comes from
     body padding instead. clone repeats that padding on every page if some
     other screen is printed across several pages. pdf.js passes margin 0 to
     match. */
  @page { size: A4; margin: 0; }
  body {
    padding: 15mm !important;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
  }

  /* Fill the whole A4 page (267mm tall inside the 15mm margins; 2mm kept
     back for rounding so it never tips onto a 2nd page): the form is a
     column, and whatever height is left is shared out between the tables
     (flex-grow below), so short requests get roomier rows and signature
     boxes instead of blank paper at the bottom. Flex only hands out
     leftover space, so a long request just stays at its natural height. */
  .print-doc {
    display: flex;
    flex-direction: column;
    min-height: 265mm;
    font-family: var(--font-family-print);
    font-size: 11.25pt;
    line-height: 1.3;
    color: #1a1a1a;
  }
  /* iPhone/iPad (Safari, and every iOS browser, which all run on WebKit):
     printing ignores "@page { margin: 0 }" and adds its own page margins on
     top of our 15mm body padding, so the page-filling 265mm form spilled
     onto a 2nd page. There, drop our padding (iOS supplies the margins)
     and let the form take its natural height. -webkit-touch-callout is
     only supported by iOS WebKit, so desktop and Android are unaffected. */
  @supports (-webkit-touch-callout: none) {
    body { padding: 0 !important; }
    .print-doc { min-height: 0; }
  }

  .print-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5pt;
    padding-bottom: 7pt;
    margin-bottom: 10pt;
    border-bottom: 1.5pt solid #1a1a1a;
  }
  .print-header .print-logo { width: 37pt; height: auto; margin-bottom: 4.5pt; }
  .print-header .print-org-en { font-size: 10.5pt; font-weight: 600; letter-spacing: 0.01em; margin-bottom: 6.5pt; }
  .print-header .print-doc-title { font-size: 15pt; font-weight: 600; letter-spacing: 0.01em; margin-top: 3pt; }
  .print-header .print-salutation { font-size: 10pt; color: #4a4a4a; margin-top: 4.5pt; }

  .print-doc .print-section-label {
    font-size: 10.5pt;
    font-weight: 700;
    padding-bottom: 3pt;
    margin-bottom: 5pt;
    border-bottom: 1pt solid #1a1a1a;
  }

  .print-doc .print-field-table,
  .print-doc .print-item-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
    margin-bottom: 9pt;
  }
  .print-doc .print-field-table { border: 1pt solid #6f675c; }
  .print-doc .print-field-table th,
  .print-doc .print-field-table td,
  .print-doc .print-item-table th,
  .print-doc .print-item-table td {
    border: 0.75pt solid #b8b0a6;
    padding: 4pt 7.5pt;
    text-align: left;
    vertical-align: top;
    font-weight: 400;
  }
  .print-doc .print-field-table th { background: #f2efe9; font-weight: 600; width: 19%; white-space: nowrap; }
  /* Leftover-height shares: the two detail tables and the items table get
     most of it, the sign-off table less (it already has a minimum below). */
  .print-doc .print-field-table { flex: 3 0 auto; }
  .print-doc .print-item-table { flex: 2 0 auto; }
  .print-doc .print-approval-table { flex: 2 0 auto; }
  .print-doc .print-item-table thead th { height: 1pt; }
  .print-doc .print-field-table:not(.print-approval-table) th,
  .print-doc .print-field-table:not(.print-approval-table) td,
  .print-doc .print-item-table tbody td { vertical-align: middle; }
  .print-doc .print-approval-table td { height: 70pt; }
  .print-doc .print-approval-table th { text-align: center; font-weight: 700; width: 50%; white-space: normal; height: 1pt; }
  .print-doc .print-approval-table td { line-height: 1.35; }
  .print-doc .print-approval-table td em { font-style: italic; color: #4a4a4a; }
  .print-doc .pf-lines { column-gap: 8pt; row-gap: 1.5pt; }
  .print-doc .pf-lines > .pf-line-head { margin-bottom: 3pt; }
  .print-doc .print-approval-table .pf-line-label { color: #6f675c; font-size: 8pt; font-weight: 400; }

  .print-doc .print-item-table { border: 0.75pt solid #6f675c; font-size: 9.5pt; }
  .print-doc .print-item-table th { font-weight: 700; font-size: 8.5pt; }
  .print-doc .print-item-table td.num { font-variant-numeric: tabular-nums; text-align: right; }
  .print-doc .print-item-table small { display: block; font-weight: 400; color: #6f675c; font-size: 7.5pt; }

  .print-doc .print-requester-line {
    font-size: 10pt;
    padding-top: 9.5pt;
    margin-top: 1.5pt;
    margin-bottom: 8pt;
    border-top: 0.75pt solid #b8b0a6;
  }
  .print-doc .print-requester-line .k { font-weight: 700; }

  .print-doc .print-footnote {
    font-size: 8.5pt;
    color: #4a4a4a;
    text-align: center;
    padding-top: 8pt;
    border-top: 0.75pt solid #b8b0a6;
  }
}

@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
  .viz-bar-label { width: 110px; }
  .rating-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .rating-row-control { align-self: stretch; justify-content: space-between; }
}

/* ---------- Request form steps (requester/new-request.ejs) ----------
   The form is four numbered cards (who / what / how / where+when) so the
   eye has one place to be at a time instead of one long undifferentiated
   grid of fields. */
.step-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

/* Three short choices side by side (paper size / colour / sides). */
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) {
  .form-grid.cols-3 { grid-template-columns: 1fr; }
}

/* Finishing options split into "finishing" and "binding" rows. */
.check-subgroup + .check-subgroup { margin-top: 12px; }
.check-subgroup-caption {
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-muted);
}

/* Optional extras (Copy Label) set off from the required fields above. */
.field-extra {
  padding-top: 18px;
  border-top: 1px dashed var(--color-border);
}

/* Drop-off place when there is only one to show (no <select> needed). */
.location-static {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  font-size: 14px;
  font-weight: 600;
}

.form-fields > .notice { margin-bottom: 18px; }

/* Two-column request form: the step cards on the left, a summary panel that
   stays in view on the right, so the paper totals and the submit button are
   always next to the fields that change them. (Header is 64px tall.) */
.request-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.request-summary {
  position: sticky;
  top: 84px;
}

.request-summary .card { margin-bottom: 0; overflow: hidden; }
.request-summary .calc-box { border: none; background: none; padding: 0; }
.request-summary .calc-row { align-items: baseline; padding: 4px 0; }
.request-summary .calc-value { font-size: 22px; color: var(--color-primary); }
.request-summary .calc-responsibility { line-height: 1.6; }

.summary-mini {
  display: grid;
  gap: 2px;
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
  font-size: 13.5px;
}
.summary-mini dt { color: var(--color-muted); font-weight: 600; font-size: 12.5px; margin-top: 8px; }
.summary-mini dt:first-child { margin-top: 0; }
.summary-mini dd { margin: 0; font-weight: 600; }

.request-summary .card-footer { flex-direction: column-reverse; align-items: stretch; }
.request-summary .card-footer .btn { width: 100%; }

/* Narrow screens: one column, and the summary becomes a slim bar pinned to
   the bottom (totals + submit) so it is still always visible. */
@media (max-width: 900px) {
  .request-layout { grid-template-columns: 1fr; }
  .request-summary { top: auto; bottom: 0; z-index: 8; margin: 0 -4px; }
  .request-summary .card {
    display: flex;
    align-items: center;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
  }
  .request-summary .card-header,
  .request-summary .summary-mini,
  .request-summary .calc-responsibility,
  .request-summary .card-footer .btn-secondary { display: none; }
  .request-summary .card-body { flex: 1; padding: 10px 16px; }
  .request-summary .calc-box { display: flex; gap: 18px; }
  .request-summary .calc-row { flex-direction: column; padding: 0; font-size: 12px; }
  .request-summary .calc-value { font-size: 18px; }
  .request-summary .card-footer { border: none; background: none; padding: 10px 16px 10px 0; }
  .request-summary .card-footer .btn { width: auto; min-width: 110px; }
}

/* Drop-off place details under the location field: one icon + fact per item. */
.location-meta {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 13.5px;
  color: var(--color-text);
}
.location-meta li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.location-meta .icon {
  width: 16px;
  height: 16px;
  color: var(--color-primary);
}
.location-meta a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- Admin: locations page (admin/locations.ejs) ---------- */
.loc-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-weight: 600;
  animation: fadeSlideIn 0.25s ease both;
}
.loc-banner[hidden] { display: none; }

.loc-form-grid {
  display: grid;
  grid-template-columns: 170px 1fr 1fr;
  gap: 12px 16px;
  align-items: center;
}
.loc-col-head {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-muted);
}
.loc-form-grid > label { font-weight: 600; font-size: 13.5px; }

.loc-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--color-border);
}
.loc-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 14px;
}

.field-box {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px;
  background: var(--color-bg);
}

/* Location form, kept short: hours on one wrapping line, uses as two
   checkboxes, defaults as one small line underneath. */
.hours-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.hours-line .field { width: 140px; margin: 0; }
.hours-line .sep { color: var(--color-muted); font-size: 13.5px; }
.hours-line .hours-gap { width: 8px; }
.hours-line .time-wheel-input { min-width: 104px; }
.hours-line .time-wheel-panel { left: 0; right: auto; }

/* Step 4: one bordered row per use; the star on the right marks this place
   as the default for that use and is hidden while the use is unticked. */
.usage-box { padding: 4px 16px; }
/* Required mark, and the red outline when "What is this place for?" has
   neither box ticked on save. */
.loc-section-title .req, .field label .req { color: var(--color-danger); }
/* .field-error is display:none unless inside .field.invalid; these are
   only ever added for an invalid field, so always show them. */
.loc-field-msg { display: flex; animation: fadeSlideIn 0.2s ease both; }
.usage-box.invalid { border-color: var(--color-danger); box-shadow: 0 0 0 3px var(--color-danger-tint); }
.usage-rows { display: flex; flex-direction: column; }
.usage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding: 10px 0;
}
.usage-row + .usage-row { border-top: 1px dashed var(--color-border); }
.usage-row-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.usage-row-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--color-primary); }
.star-toggle {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  background: var(--color-surface);
  cursor: pointer;
  white-space: nowrap;
  min-width: 168px;
  justify-content: center;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.star-toggle:hover { border-color: var(--color-warning); color: var(--color-warning); }
.star-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.star-toggle .star-on { display: none; }
.star-toggle:has(input:checked) { border-color: var(--color-warning); background: var(--color-warning-tint); color: var(--color-warning); font-weight: 600; }
.star-toggle:has(input:checked) .star-on { display: inline; }
.star-toggle:has(input:checked) .star-off { display: none; }
.star-toggle:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--color-primary-tint); }
.star-toggle.disabled { visibility: hidden; }

/* Save / Cancel: the card's own footer strip (full width, a hairline on
   top, no separate box), kept on screen while the form scrolls. Needs the
   card's card-overflow-visible class for sticky to work. */
.loc-actions {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px -20px -20px;
  padding: 14px 20px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius) var(--radius);
}

@keyframes loc-row-flash {
  from { background: var(--color-success-tint); }
  to { background: transparent; }
}
tr.row-flash td { animation: loc-row-flash 3s ease-out both; }

/* admin/locations.ejs "Used for" cell: stacked lines instead of one run of
   pills, a separate outlined "Default" tag, and the pending count as text. */
.loc-usage { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.loc-usage-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.loc-default-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--color-primary);
  border-radius: 999px;
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.loc-pending {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-info);
}
/* "Hours / phone" cell: one line each with a small muted icon; the number
   is formatted and the contact name after it is muted. */
.loc-contact { display: flex; flex-direction: column; gap: 6px; }
.loc-contact-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 14px;
  line-height: 1.35;
}
.loc-contact-line .icon { width: 16px; height: 16px; color: var(--color-muted); }
.loc-phone-number { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.loc-phone-note { color: var(--color-muted); font-size: 13px; }
.loc-pending-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* Admin add/edit form cards: land below the sticky 64px header, and pulse
   a maroon ring when opened so the eye finds the form after the scroll. */
#category-form-card, #unit-form-card, #location-form-card { scroll-margin-top: 80px; }
@keyframes form-card-flash {
  0%, 30% { box-shadow: 0 0 0 3px var(--color-primary-tint), 0 0 0 4px var(--color-primary); }
  100% { box-shadow: var(--shadow); }
}
.form-card-flash { animation: form-card-flash 1.6s ease-out; }

@media (max-width: 900px) {
  .loc-form-grid { grid-template-columns: 1fr; }
  .loc-col-head { display: none; }
}

.loc-section .hint { display: block; margin-top: 8px; }
.loc-section .hint[hidden] { display: none; }

/* .notice's own `display: flex` beats the built-in [hidden] rule (same trap
   as .btn[hidden] above), so a notice toggled with `hidden` stayed visible. */
.notice[hidden] { display: none; }

.modal-extra .field + .field { margin-top: 14px; }
/* ---------- "Mark ready" dialog (officer/printing-jobs.ejs) ----------
   Sized to fit a normal laptop screen without F11: a short job summary on
   top, a compact calendar on the left, place and time on the right. */
.modal-box:has(.ready-layout) { max-width: 640px; max-height: calc(100vh - 24px); overflow-y: auto; padding: 20px 22px; }
.modal-box:has(.ready-layout) .modal-message:empty { display: none; }
.modal-box:has(.ready-layout) .modal-title { margin-bottom: 14px; }
.modal-box:has(.ready-layout) .modal-extra { margin-bottom: 16px; }
.ready-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  grid-template-areas: "job job" "date place" "date time";
  grid-template-rows: auto auto 1fr;
  gap: 14px 20px;
  align-items: start;
}
.ready-layout .field { margin: 0; }
.ready-layout .field + .field { margin-top: 0; }
.ready-layout .field > label { margin-bottom: 6px; }
.ready-layout .ready-date-field { grid-area: date; }
.ready-layout .ready-place-field { grid-area: place; }
.ready-layout .ready-time-field { grid-area: time; }
.ready-layout .ready-place-field select { width: 100%; }

/* Job summary */
.ready-job {
  grid-area: job;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}
.ready-job-main { flex: 1 1 auto; min-width: 0; }
.ready-job-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.ready-job-run { font-weight: 700; font-size: 15px; color: var(--color-primary-dark); font-variant-numeric: tabular-nums; }
.ready-job-name { font-size: 14px; color: var(--color-text); }
.ready-job-item { margin-top: 2px; font-size: 13px; color: var(--color-muted); overflow-wrap: anywhere; }
.ready-job-pages {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  column-gap: 4px;
  padding-left: 16px;
  border-left: 1px solid var(--color-border);
  text-align: right;
  white-space: nowrap;
}
.ready-job-total { font-size: 22px; font-weight: 700; line-height: 1.1; color: var(--color-text); }
.ready-job-unit { font-size: 13px; color: var(--color-muted); }
.ready-job-break { grid-column: 1 / -1; font-size: 12px; color: var(--color-muted); }

/* Compact inline calendar */
.date-picker.is-inline .date-picker-panel {
  position: static;
  width: auto;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 8px 10px 6px;
  box-shadow: none;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  animation: none;
}
.date-picker.is-inline .date-picker-panel-header { margin-bottom: 4px; font-size: 14px; font-weight: 700; color: var(--color-text); }
.date-picker.is-inline .date-picker-nav {
  width: 28px; height: 28px;
  border: 1px solid var(--color-border);
  font-size: 16px;
  color: var(--color-primary);
}
.date-picker.is-inline .date-picker-nav:hover:not(:disabled) { background: var(--color-primary-tint); border-color: var(--color-primary); }
.date-picker.is-inline .date-picker-nav:disabled { border-color: transparent; }
.date-picker.is-inline .date-picker-weekdays span { padding: 3px 0; font-size: 11.5px; }
.date-picker.is-inline .date-picker-grid { gap: 2px 0; }
.date-picker.is-inline .date-picker-day {
  position: relative;
  aspect-ratio: auto;
  width: 30px;
  height: 30px;
  margin: 0 auto;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 500;
}
.date-picker.is-inline .date-picker-day:disabled { color: var(--color-muted); opacity: .35; font-weight: 400; }
.date-picker.is-inline .date-picker-day.today:not(.selected) { box-shadow: none; color: var(--color-primary); font-weight: 700; }
.date-picker.is-inline .date-picker-day.today::after {
  content: "";
  position: absolute;
  bottom: 3px; left: 50%;
  width: 4px; height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: currentColor;
}
.date-picker.is-inline .date-picker-day.selected { box-shadow: 0 2px 6px rgba(122, 46, 46, .3); }

/* Time: "available now" or a set time (hour : minute) */
.ready-time { display: flex; flex-direction: column; gap: 10px; }
.ready-time .radio-group { gap: 8px; }
.ready-time .radio-option[hidden] { display: none; }
/* Inline clock wheel: 3 rows (120px) instead of the popup's 5, in a box
   like the calendar's. ITEM_H stays 40px, so the padding is (120-40)/2. */
.time-wheel.is-inline { align-self: flex-start; transition: opacity .15s ease; }
/* The button and "done" row set their own display, so the hidden attribute alone
   would not hide them; inline pickers never show either. */
.time-wheel.is-inline .time-wheel-input,
.time-wheel.is-inline .time-wheel-foot,
.date-picker.is-inline .date-picker-input { display: none; }
.time-wheel.is-inline .time-wheel-panel {
  position: static;
  width: auto;
  padding: 6px 14px;
  box-shadow: none;
  border: 1px solid var(--color-border);
  border-radius: 10px;
}
.time-wheel.is-inline .time-wheel-wheels { height: 120px; }
.time-wheel.is-inline .time-wheel-col { height: 120px; padding: 40px 0; }
.time-wheel.is-inline .time-wheel-band { top: 40px; }
.time-wheel.is-inline.is-disabled { opacity: .4; }
.time-wheel.is-inline.is-disabled .time-wheel-col { pointer-events: none; }
.ready-hint { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--color-muted); }

@media (max-width: 640px) {
  .ready-layout { grid-template-columns: 1fr; grid-template-areas: "job" "place" "date" "time"; grid-template-rows: none; }
}

/* =====================================================================
   Responsive — phone / tablet / desktop / TV
   ---------------------------------------------------------------------
   ≥ 1920px  TV & large monitors: the whole UI scales up (zoom) so text
             stays readable from a distance; 100vh-based heights are
             divided by the same factor so nothing overflows the screen.
   ≤ 1024px  tablet: sidebar becomes an off-canvas drawer (☰ in the
             header, see initNavDrawer() in app.js), single-column shell.
   ≤ 768px   small tablet / large phone: tighter spacing, wrapping headers.
   ≤ 560px   phone: compact header, stacked cards, full-width buttons.
   Page-specific breakpoints elsewhere in this file still apply on top.
   ===================================================================== */

/* ---------- TV & large screens ---------- */
@media (min-width: 1920px) { :root { --screen-zoom: 1.12; } }
@media (min-width: 2560px) { :root { --screen-zoom: 1.35; } }
@media (min-width: 3400px) { :root { --screen-zoom: 1.75; } }
@media (min-width: 1920px) {
  html { zoom: var(--screen-zoom); }
  /* Zoom scales vh too — divide it back out, or every "full screen"
     layout would be taller than the screen. `html body` / `html .x`
     out-rank the per-page <style> blocks that also set these. */
  html body { min-height: calc(100vh / var(--screen-zoom)); }
  .app, html .login-page, html .closed-page { min-height: calc(100vh / var(--screen-zoom)); }
  .app-sidebar { height: calc(100vh / var(--screen-zoom)); }
  /* Keep lines a readable length on very wide screens. */
  .app-main { max-width: 1760px; width: 100%; }
}

/* ---------- Desktop: collapsible sidebar (icon rail) ----------
   The ☰ button folds the sidebar to a 76px icon-only rail and back; the
   grid column animates between the two widths. Labels become tooltips
   (title attributes, set in initNavDrawer()). Desktop widths only — below
   1025px the sidebar is the drawer instead. */
@media (min-width: 1025px) {
  .nav-toggle { display: inline-flex; }
  .app { grid-template-columns: var(--sidebar-w, 240px) minmax(0, 1fr); transition: grid-template-columns .25s ease; }
  html.sidebar-collapsed .app { --sidebar-w: 76px; }
  .app-sidebar { overflow-x: hidden; transition: padding .25s ease; }

  html.sidebar-collapsed .app-sidebar { padding: 18px 10px; }
  html.sidebar-collapsed .brand { justify-content: center; padding: 4px 0 16px; margin: 0 0 8px; }
  html.sidebar-collapsed .brand > div:not(.mark) { display: none; }
  html.sidebar-collapsed .nav-section-label { display: none; }
  html.sidebar-collapsed .nav-subhead { display: none; }
  /* Section folding doesn't apply in the rail — always show every icon. */
  html.sidebar-collapsed .nav-section-items { height: auto !important; opacity: 1 !important; visibility: visible !important; }
  html.sidebar-collapsed .nav-section + .nav-section { margin-top: 8px; padding-top: 8px; }
  html.sidebar-collapsed .nav-item { justify-content: center; gap: 0; padding: 11px 0; }
  html.sidebar-collapsed .nav-item > span:not(.icon) { display: none; }
  html.sidebar-collapsed .nav-item .icon { width: 21px; height: 21px; }
  html.sidebar-collapsed .nav-item-divider { margin: 6px 8px; }

  /* While the column animates (class set by setCollapsed() in app.js) the
     labels are visible before there's room for them — without nowrap they
     wrap onto several lines and re-wrap every frame. Keep them on one line
     (clipped by overflow-x) and fade them in on expand. */
  html.sidebar-animating .brand > div:not(.mark),
  html.sidebar-animating .nav-section-label,
  html.sidebar-animating .nav-item > span:not(.icon) { white-space: nowrap; }
  html.sidebar-animating:not(.sidebar-collapsed) .brand > div:not(.mark),
  html.sidebar-animating:not(.sidebar-collapsed) .nav-section-label,
  html.sidebar-animating:not(.sidebar-collapsed) .nav-item > span:not(.icon) { animation: sidebar-label-in .25s ease; }
}

@keyframes sidebar-label-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Tablet: drawer navigation ---------- */
@media (max-width: 1024px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "header"
      "main";
  }
  .nav-toggle { display: inline-flex; }

  .app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 60;
    width: 280px;
    max-width: 86vw;
    height: auto;
    box-shadow: 0 0 40px rgba(38, 34, 32, 0.25);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform .25s ease, visibility 0s linear .25s;
  }
  .nav-open .app-sidebar {
    transform: none;
    visibility: visible;
    transition: transform .25s ease;
  }
  .nav-backdrop {
    position: fixed; inset: 0;
    z-index: 55;
    background: rgba(38, 34, 32, 0.45);
    animation: navBackdropIn .2s ease both;
  }
  .nav-open { overflow: hidden; }

  .app-header { padding: 0 20px; gap: 12px; }
  .app-main { padding: 24px 24px 56px; min-width: 0; }

  /* Tables keep a sensible minimum width and scroll sideways instead. */
  .table-scroll > table.data-table { min-width: 760px; }

  .scores-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@keyframes navBackdropIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Small tablet / large phone ---------- */
@media (max-width: 768px) {
  .app-main { padding: 20px 18px 48px; }
  .page-title { font-size: 24px; }
  .page-subtitle { margin-bottom: 18px; }

  .card-header { flex-wrap: wrap; gap: 10px; }
  .card-body { padding: 18px; }

  .user-chip .who { display: none; }
  .header-actions { gap: 10px; }

  .tab-row { align-items: stretch; }
  .tab-nav { max-width: 100%; overflow-x: auto; }
  .tab-row-actions { width: 100%; justify-content: space-between; }

  .scores-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions { flex-wrap: wrap; }
}

/* ---------- Phone ---------- */
@media (max-width: 560px) {
  .app-header { height: 56px; padding: 0 12px; }
  .app { grid-template-rows: 56px 1fr; }
  .app-header .crumb {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .app-header .crumb strong { font-weight: 600; }
  .header-actions { gap: 6px; }
  .lang-toggle { font-size: 12px; gap: 2px; }
  .logout-link { width: 32px; height: 32px; }

  .notif-dropdown {
    position: fixed;
    top: 64px; left: 10px; right: 10px;
    width: auto;
    max-height: 70vh;
  }

  .app-main { padding: 16px 14px 40px; }
  .page-title { font-size: 21px; }
  .page-subtitle { font-size: 13px; }
  .card { border-radius: 12px; }
  .card-header { padding: 14px 16px; }
  .card-body { padding: 16px; }

  .scores-grid { grid-template-columns: minmax(0, 1fr); }
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions .btn { width: 100%; justify-content: center; }
  .export-btn { flex: 1 1 auto; justify-content: center; }

  .data-table th, .data-table td { padding: 10px 12px; }
}

/* ---------- My Requests (requester/my-requests.ejs): rows -> cards ----------
   A 5-column table is hard to read on a phone even when it scrolls, so
   below 1025px each row becomes a tappable card: status + item name up
   top, the reference number under it, the two dates as labelled columns.
   Two cards per row on tablets, one on phones. */
.mr-chevron { display: none; }
@media (max-width: 1024px) {
  .table-scroll > table.mr-table { min-width: 0; }
  .mr-table thead { display: none; }
  .mr-table, .mr-table tbody { display: block; width: 100%; }
  .mr-table tbody {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px;
  }
  .mr-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "status status"
      "item   item"
      "ref    ref"
      "sub    appt";
    gap: 6px 14px;
    padding: 14px 16px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-surface);
    box-shadow: 0 1px 2px rgba(38, 34, 32, 0.05);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
  }
  .mr-table tbody tr:hover, .mr-table tbody tr:focus-visible {
    border-color: var(--color-primary);
    box-shadow: 0 6px 16px rgba(122, 46, 46, 0.12);
    outline: none;
  }
  .mr-table tbody tr:active { transform: scale(0.99); }
  .mr-table td { display: block; padding: 0; border: none; min-width: 0; }

  .mr-table .mr-status { grid-area: status; display: flex; align-items: center; justify-content: space-between; }
  .mr-table .mr-chevron { display: inline; font-size: 22px; line-height: 1; color: var(--color-muted); }
  .mr-table .mr-item {
    grid-area: item;
    font-size: 15.5px;
    font-weight: 600;
    line-height: 1.45;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .mr-table .mr-ref { grid-area: ref; font-size: 12.5px; color: var(--color-muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
  .mr-table .mr-date { grid-area: sub; margin-top: 6px; padding-top: 10px; border-top: 1px dashed var(--color-border); font-size: 13px; }
  .mr-table .mr-appt { grid-area: appt; }
  .mr-table .mr-date::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 11.5px;
    color: var(--color-muted);
  }
  .mr-table .mr-appt { font-weight: 600; color: var(--color-primary); }

  /* The empty-state row spans the whole grid. */
  .mr-table tbody tr:has(.empty-state) { grid-column: 1 / -1; display: block; border: none; box-shadow: none; }
}
@media (max-width: 640px) {
  .mr-table tbody { grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 10px; }
}

/* ---------- Request form on screen (request-submitted / request-form-view) ----------
   The printable form's 4-column field tables and 6-column item table
   overflow a phone. On small SCREENS only (never print/PDF — those keep
   the official layout) each table becomes label/value rows. */
.submitted-form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@media screen and (max-width: 768px) {
  #request-form-card > .card-header { flex-direction: column; align-items: stretch; }
  .submitted-form-actions .btn { flex: 1 1 0; justify-content: center; }
  .print-doc.card-body { padding: 16px; }
  .print-doc .print-doc-title { font-size: 17px; }

  /* Field tables: every th/td pair becomes one row — label | value. */
  .print-doc .print-field-table:not(.print-approval-table),
  .print-doc .print-field-table:not(.print-approval-table) tbody { display: block; width: 100%; }
  .print-doc .print-field-table:not(.print-approval-table) tr {
    display: grid;
    grid-template-columns: minmax(110px, 38%) minmax(0, 1fr);
  }
  .print-doc .print-field-table:not(.print-approval-table) th,
  .print-doc .print-field-table:not(.print-approval-table) td {
    display: block;
    width: auto;
    white-space: normal;
    border: none;
    border-bottom: 1px solid var(--color-border);
    overflow-wrap: anywhere;
  }
  .print-doc .print-field-table:not(.print-approval-table) th { font-size: 12px; color: var(--color-muted); }
  .print-doc .print-field-table:not(.print-approval-table) tr:last-child > :nth-last-child(-n+2) { border-bottom: none; }

  /* Item table: header row hidden, the one item becomes a labelled block;
     the four numbers sit in a 2×2 grid. */
  .print-doc .print-item-table,
  .print-doc .print-item-table tbody { display: block; width: 100%; border: 1px solid var(--color-border); }
  .print-doc .print-item-table tbody { border: none; }
  .print-doc .print-item-table thead { display: none; }
  .print-doc .print-item-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .print-doc .print-item-table td {
    display: block;
    border: none;
    border-bottom: 1px solid var(--color-border);
    padding: 9px 12px;
    font-size: 13.5px;
    overflow-wrap: anywhere;
  }
  .print-doc .print-item-table td.pf-cell-ref,
  .print-doc .print-item-table td.pf-cell-items { grid-column: 1 / -1; }
  .print-doc .print-item-table td.num { text-align: left; font-weight: 700; font-size: 16px; }
  .print-doc .print-item-table td.num:nth-child(odd) { border-left: 1px solid var(--color-border); }
  .print-doc .print-item-table td:nth-last-child(-n+2) { border-bottom: none; }
  .print-doc .print-item-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 11.5px;
    font-weight: 400;
    color: var(--color-muted);
  }
  .print-doc .print-item-table small { font-size: 11.5px; }

  /* Requester / submitted / received: one per line, no "·" separators. */
  .print-doc .print-requester-line .pf-sep { display: none; }
  .print-doc .print-requester-line .pf-meta { display: block; }
  .print-doc .print-requester-line .pf-meta + .pf-meta,
  .print-doc .print-requester-line #pf-received-wrap .pf-meta { margin-top: 4px; }

  /* Officer / Receiver sign-off: stacked instead of side by side, each
     heading directly above its own box. */
  .print-doc .print-approval-table,
  .print-doc .print-approval-table tbody { display: block; width: 100%; }
  .print-doc .print-approval-table tbody { display: grid; grid-template-columns: minmax(0, 1fr); }
  .print-doc .print-approval-table tr { display: contents; }
  .print-doc .print-approval-table th,
  .print-doc .print-approval-table td { display: block; width: auto; }
  /* The 44px from the screen rule above is only a minimum inside a table;
     on a block it is a fixed height, and the sign-off lines spilled over
     the Receiver box. Grow with the content instead. */
  .print-doc .print-approval-table td { height: auto; }
  .print-doc .print-approval-table tr:first-child > :nth-child(1) { order: 1; }
  .print-doc .print-approval-table tr:last-child > :nth-child(1) { order: 2; margin-bottom: 10px; }
  .print-doc .print-approval-table tr:first-child > :nth-child(2) { order: 3; }
  .print-doc .print-approval-table tr:last-child > :nth-child(2) { order: 4; }
  .print-doc .print-approval-table td:empty { min-height: 44px; }
}

/* Phones in landscape: short screens — don't let the drawer's own content
   hide behind the fold. */
@media (max-height: 480px) and (max-width: 1024px) {
  .app-sidebar { overflow-y: auto; }
}

/* ---------- Officer evaluation report (officer/evaluations.ejs) ----------
   Row 1: headline card (core question score + 5→1 spread) and a counts card.
   Row 2: results per section as aligned label | bar | score rows. */
.er-top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.er-top .card { margin: 0; }
.er-hero-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 24px; align-items: center; }
.er-hero-label { font-size: 13.5px; font-weight: 600; color: var(--color-muted); }
.er-hero-num { font-size: 52px; font-weight: 700; line-height: 1.1; margin-top: 6px; color: var(--color-text); }
.er-hero-of { font-size: 18px; font-weight: 500; color: var(--color-muted); margin-left: 6px; }
.er-stars { display: inline-flex; gap: 2px; margin-top: 6px; font-size: 20px; line-height: 1; }
.er-star { position: relative; color: var(--color-border); }
.er-star-fill { position: absolute; inset: 0 auto 0 0; overflow: hidden; color: var(--color-warning); }
.er-hero-tier { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--color-muted); }
.er-tier-pill { padding: 2px 10px; border-radius: 999px; font-weight: 600; background: var(--color-bg); color: var(--color-text); }
.er-hero-score.score-tier-good .er-tier-pill { background: var(--color-success-tint); color: var(--color-success); }
.er-hero-score.score-tier-mid .er-tier-pill { background: var(--color-warning-tint); color: var(--color-warning); }
.er-hero-score.score-tier-low .er-tier-pill { background: var(--color-danger-tint); color: var(--color-danger); }
.er-block-head .er-block-meta { display: inline-flex; align-items: center; gap: 8px; }
.er-type-pill { padding: 1px 8px; border-radius: 999px; border: 1px solid var(--color-border); font-size: 12px; }
.pf-sep { display: inline-block; width: 24px; }
.er-hero-score.score-tier-good .er-hero-num { color: var(--color-success); }
.er-hero-score.score-tier-mid .er-hero-num { color: var(--color-warning); }
.er-hero-score.score-tier-low .er-hero-num { color: var(--color-danger); }
.er-hero-empty .empty-state { padding: 16px 0 0; }
.er-dist { display: flex; flex-direction: column; gap: 8px; }
.er-dist-row { display: grid; grid-template-columns: 36px 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }
.er-dist-n { color: var(--color-muted); white-space: nowrap; }
.er-dist-track { height: 10px; border-radius: 999px; background: var(--color-bg); overflow: hidden; }
.er-dist-fill { display: block; height: 100%; border-radius: 999px; }
.er-dist-1 { background: var(--lk-1); }
.er-dist-2 { background: var(--lk-2); }
.er-dist-3 { background: var(--lk-3); }
.er-dist-4 { background: var(--lk-4); }
.er-dist-5 { background: var(--lk-5); }
.er-dist-num { text-align: right; color: var(--color-muted); font-variant-numeric: tabular-nums; }
.er-kpis { display: flex; flex-direction: column; justify-content: center; padding: 6px 20px; }
.er-kpi { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 0; }
.er-kpi + .er-kpi { border-top: 1px solid var(--color-border); }
.er-kpi-label { font-size: 13.5px; color: var(--color-muted); }
.er-kpi-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

.er-section + .er-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--color-border); }
.er-section-title { margin: 0 0 14px; font-size: 15px; font-weight: 700; color: var(--color-primary-dark); }
.er-rows { display: flex; flex-direction: column; gap: 14px; }
.er-row { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(0, 3fr) 48px; gap: 20px; align-items: center; }
.er-row-label { font-size: 14px; }
.er-row-count { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 2px; font-size: 12px; color: var(--color-muted); }
.er-change { color: var(--color-warning); font-weight: 500; }
/* Likert colours: diverging red (1-2), gray (3), blue (4-5). Adjacent
   steps checked with the dataviz validator (normal vision and CVD both
   >= 15); the gray midpoint is meant to read as neutral. */
.er-results, .er-hero { --lk-1: #b8322c; --lk-2: #e2766b; --lk-3: #dad6cf; --lk-4: #6c9fe0; --lk-5: #2563b5; }
.er-likert {
  display: flex;
  gap: 2px;
  height: 16px;
  border-radius: 4px;
  overflow: hidden;
}
.lk { display: block; height: 100%; flex: 1 1 0; min-width: 3px; cursor: default; transition: filter .15s ease; }
.lk:hover { filter: brightness(.9); }
.lk-1 { background: var(--lk-1); }
.lk-2 { background: var(--lk-2); }
.lk-3 { background: var(--lk-3); }
.lk-4 { background: var(--lk-4); }
.lk-5 { background: var(--lk-5); }
.er-likert-head { margin-bottom: 16px; }
.er-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--color-muted); margin-bottom: 12px; }
.er-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.lk-swatch { width: 12px; height: 12px; border-radius: 3px; }
.er-row-captions { font-size: 12px; color: var(--color-muted); }
/* "dissatisfied ← … → satisfied" under the legend, at the bar's two ends */
.er-likert-captions { display: flex; justify-content: space-between; }
.er-row-score-cap { text-align: right; }
.er-row-score { text-align: right; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--color-text); }

.er-block { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--color-border); border-radius: 10px; }
.er-block-head { display: flex; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 12px; }
.er-block-title { font-weight: 600; font-size: 14px; }
.er-block-meta { display: block; font-size: 12.5px; color: var(--color-muted); }
.er-block-head .er-block-meta { display: inline; }
.er-block-text { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.er-opt { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) 96px; gap: 16px; align-items: center; font-size: 13.5px; }
.er-opt + .er-opt { margin-top: 8px; }
.er-opt-track { height: 8px; border-radius: 999px; background: var(--color-bg); overflow: hidden; }
.er-opt-fill { display: block; height: 100%; border-radius: 999px; background: var(--color-primary); }
.er-opt-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.er-opt-num small { color: var(--color-muted); font-size: 12px; }
.er-removed { color: var(--color-muted); font-size: 12px; }
.er-read-btn { padding: 0; border: 0; background: none; font: inherit; font-size: 13px; color: var(--color-primary); cursor: pointer; }
.er-read-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.er-removed-group { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--color-border); }
.er-removed-group > summary { cursor: pointer; font-size: 13.5px; color: var(--color-muted); }
.er-removed-group .er-section { margin-top: 14px; padding-top: 0; border-top: 0; }
.er-cell-score { font-weight: 700; }
.er-cell-score.score-tier-good { color: var(--color-success); }
.er-cell-score.score-tier-mid { color: var(--color-warning); }
.er-cell-score.score-tier-low { color: var(--color-danger); }

@media (max-width: 900px) {
  .er-top { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .er-hero-body { grid-template-columns: 1fr; }
  .er-row, .er-opt { grid-template-columns: 1fr 48px; }
  .er-likert, .er-opt-track { grid-column: 1 / -1; grid-row: 2; }
  .er-row-captions { display: none; }
  .er-opt { grid-template-columns: 1fr auto; }
}

/* ---------- Admin: evaluation form (/admin/evaluation-form) ---------- */
.ef-page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 20px; flex-wrap: wrap; }
.ef-preview-btn { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.ef-preview-btn .icon { width: 17px; height: 17px; }
/* Officer "full request form" page: title left, PDF/Print right; stacked on phones. */
.rfv-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.rfv-head h1 { overflow-wrap: anywhere; }
.rfv-actions { display: flex; gap: 10px; }
@media (max-width: 640px) {
  .rfv-head { flex-direction: column; align-items: stretch; }
  .rfv-actions .btn { flex: 1 1 0; justify-content: center; }
}
.ef-preview-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.ef-preview-banner > div { flex: 1; min-width: 0; }
.ef-preview-banner .btn { white-space: nowrap; }
@media (max-width: 640px) {
  .ef-preview-banner { flex-wrap: wrap; }
  .ef-preview-banner > div { flex-basis: calc(100% - 40px); }
  .ef-preview-banner .btn { flex: 1 1 100%; }
}
/* "Time to evaluate" card: choice → amount → plain-words example → hint,
   with Save in the card's footer like the other admin forms. */
.ef-window { display: flex; flex-direction: column; gap: 16px; }
.ef-window-mode { gap: 10px; }
.ef-window-amount { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; font-size: 14px; transition: opacity .15s ease; }
.ef-window-amount.is-off { opacity: .45; }
.ef-window-text { color: var(--color-text); }
.ef-window-field { margin: 0; }
.ef-window-field .loc-field-msg { margin-top: 6px; }
/* number and unit: two separate boxes with a gap between them */
.ef-input-group { display: inline-flex; align-items: center; gap: 10px; }
.ef-input-group input { width: 90px; text-align: center; font-variant-numeric: tabular-nums; }
.ef-input-group select { width: auto; min-width: 120px; }
.ef-window-example {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--color-primary-tint);
  color: var(--color-primary-dark);
  font-size: 13.5px;
}
.ef-window-example:empty { display: none; }
.ef-window-hint { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: 12.5px; color: var(--color-muted); }
.ef-window-hint .icon { width: 15px; height: 15px; flex-shrink: 0; margin-top: 2px; }
.ef-card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--color-border); }
.ef-card-foot .btn:disabled { opacity: .4; }
/* "Unsaved changes" next to Save, in the warning colour. */
.ef-unsaved { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--color-warning); }
.ef-unsaved[hidden] { display: none; }
.ef-unsaved .icon { width: 18px; height: 18px; }

.ef-section { margin-top: 16px; }
.ef-section-header { gap: 12px; flex-wrap: wrap; }
.ef-section-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.ef-section-count { font-size: 12.5px; font-weight: 500; color: var(--color-muted); }
.ef-section-actions { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; }
.ef-move { padding: 3px 9px; font-size: 13px; }

.ef-questions { padding: 0 20px; }
.ef-q {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px dashed var(--color-border);
}
.ef-q:last-child { border-bottom: 0; }
.ef-q-move { display: flex; gap: 4px; }
.ef-q-text { font-weight: 500; font-size: 14px; }
.ef-q-text .req { color: var(--color-danger); }
.ef-optional { font-weight: 400; font-size: 12.5px; color: var(--color-muted); }
.ef-q-meta { margin-top: 4px; }
.ef-type {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--color-bg);
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}
.ef-guide {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 13px;
  color: var(--color-muted);
}
.ef-guide .icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.ef-guide strong { display: block; color: var(--color-text); margin-bottom: 2px; }
.ef-q-options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ef-opt { font-size: 12.5px; padding: 2px 8px; border-radius: 6px; background: var(--color-bg); color: var(--color-text); }
.ef-q-actions { display: flex; gap: 14px; padding-top: 2px; }
.ef-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--color-primary);
  cursor: pointer;
}
.ef-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.ef-link:disabled { color: var(--color-muted); cursor: not-allowed; text-decoration: none; }
.ef-link-danger { color: var(--color-muted); }
.ef-link-danger:hover:not(:disabled) { color: var(--color-danger); }
.ef-empty { padding: 16px 0; color: var(--color-muted); font-size: 13.5px; }
.ef-section-foot { padding: 12px 20px 16px; border-top: 1px solid var(--color-border); }
.ef-add-q { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; font-size: 13.5px; }
.ef-add-q .icon { width: 16px; height: 16px; }
.ef-add-section-row { margin-top: 16px; }
.ef-add-section-row .btn { display: inline-flex; align-items: center; gap: 8px; }

/* Editor that opens in place of the row being edited. */
.ef-editor {
  margin: 12px 0;
  padding: 16px;
  border: 1px solid var(--color-primary);
  border-radius: 10px;
  background: var(--color-bg);
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}
.ef-editor-wrap { padding: 4px 20px; }
.ef-editor-title { font-weight: 700; font-size: 14.5px; color: var(--color-primary-dark); margin-bottom: 12px; }
.ef-editor .field { margin-bottom: 12px; }
.ef-editor-actions { display: flex; gap: 10px; margin-top: 4px; }
.ef-q-settings .field select { width: 100%; }
.ef-required-opt { display: inline-flex; width: auto; }
.ef-options .ef-link { margin-top: 4px; }
.ef-option-row { display: grid; grid-template-columns: 24px 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.ef-option-num { color: var(--color-muted); font-size: 13px; text-align: right; }
.ef-option-row.invalid input { border-color: var(--color-danger); }
.ef-options.invalid .ef-option-row input:placeholder-shown { border-color: var(--color-danger); }

@keyframes ef-flash { from { background: var(--color-success-tint); } to { background: transparent; } }
.ef-q.ef-flash, .ef-section.ef-flash .ef-section-header { animation: ef-flash 2.5s ease-out; }

@media (max-width: 640px) {
  .ef-q { grid-template-columns: 1fr; }
  .ef-q-move { order: 3; }
  .ef-option-row { grid-template-columns: 1fr; }
  .ef-option-num { display: none; }
}

/* ---------- Admin: user manuals (/admin/manuals) ----------
   One table: a row per audience, a column per language. */
.mn-table { table-layout: fixed; }
.mn-table thead th:first-child { width: 200px; }
.mn-table td { vertical-align: top; }
.mn-audience {
  background: var(--color-bg);
  color: var(--color-primary-dark);
  font-weight: 600;
  text-align: left;
  vertical-align: top;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}
.mn-table tbody tr:last-child .mn-audience { border-bottom: none; }
.mn-cell { display: flex; flex-direction: column; gap: 10px; }
.mn-file { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-height: 22px; }
.mn-file-link { display: inline-flex; align-items: center; gap: 6px; color: var(--color-primary); font-weight: 500; text-decoration: none; min-width: 0; }
.mn-file-link:hover .mn-file-name { text-decoration: underline; }
.mn-file-link .icon { width: 16px; height: 16px; flex-shrink: 0; }
.mn-file-name { word-break: break-word; }
.mn-file-size { color: var(--color-muted); font-size: 12.5px; }
.mn-empty { color: var(--color-muted); font-size: 13.5px; }
.mn-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mn-btn { padding: 6px 12px; font-size: 13px; cursor: pointer; }
.mn-upload.is-busy { opacity: .6; pointer-events: none; }
/* Plain dark text in the body, and text links for replace/delete (red
   only on hover). */
/* .mn-table .mn-audience (not just .mn-audience): the row headers are <th>,
   and the global .data-table th (maroon fill, white text) outranks a single
   class — that is what kept this column solid red. */
/* Header row keeps the standard maroon .data-table look (same as the
   Locations/Units tables); the body, row headers included, stays white. */
.mn-table .mn-audience { background: transparent; color: var(--color-text); font-weight: 600; }
/* Vertical rule after the "Manual" column, down the header and every row. */
.mn-table .mn-audience { border-right: 1px solid var(--color-border); }
.data-table.mn-table thead th:first-child { border-right: 1px solid rgba(255, 255, 255, .25); }
/* ...and between the Thai and English columns. */
.mn-table tbody td:nth-of-type(1) { border-right: 1px solid var(--color-border); }
.data-table.mn-table thead th:nth-child(2) { border-right: 1px solid rgba(255, 255, 255, .25); }
@media (max-width: 760px) { .mn-table .mn-audience, .mn-table tbody td:nth-of-type(1) { border-right: 0; } }
.mn-file-link { color: var(--color-text); }
.mn-file-link .icon { color: var(--color-muted); }
.mn-actions { gap: 4px 14px; align-items: center; }
.mn-btn { display: inline-flex; align-items: center; gap: 6px; }
.mn-btn .icon { width: 15px; height: 15px; }
.mn-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--color-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.mn-link:hover { color: var(--color-text); }
.mn-link-danger:hover { color: var(--color-danger); }
.mn-hint { margin: 12px 2px 0; color: var(--color-muted); font-size: 12.5px; }
@media (max-width: 760px) {
  .mn-table, .mn-table tbody, .mn-table tr, .mn-table th, .mn-table td { display: block; width: auto; }
  .mn-table thead { display: none; }
  .mn-table td { padding: 10px 16px; }
  .mn-table td::before { content: attr(data-label); display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--color-muted); }
}

/* ---------- Admin: officers — roles ---------- */
.of-admin-check { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; cursor: pointer; }
.of-role { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; background: var(--color-bg); color: var(--color-muted); border: 1px solid var(--color-border); white-space: nowrap; }
.of-role.is-admin { background: var(--color-primary-tint); color: var(--color-primary); border-color: transparent; font-weight: 600; }
.of-grant { margin-top: 4px; font-size: 12px; color: var(--color-muted); line-height: 1.4; overflow-wrap: anywhere; }
.of-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.of-btn { padding: 6px 12px; font-size: 13px; }
.of-self { color: var(--color-muted); font-size: 13px; font-style: italic; }
.of-env-note { margin-top: 16px; }
.of-env-list { margin-top: 4px; font-weight: 600; word-break: break-all; }

/* ---------- Audit log: category chip ---------- */
.audit-type { display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-muted); white-space: nowrap; }


/* ---------- Officer dashboard (one period at a time) ---------- */
.db-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.db-head .page-subtitle { margin-bottom: 0; }
.db-filter-card { margin-bottom: 16px; overflow: visible; position: relative; z-index: 30; }
.db-filter-card .card-body, .db-filter-card .filter-row, .db-filter-card .filter-group, .db-filter-card .filter-controls { overflow: visible; }
.db-filter-card .filter-row { flex-wrap: nowrap; }
.db-filter-card .filter-group { flex: 1 1 0; }
.db-filter-card .filter-controls { flex-wrap: nowrap; }
.db-filter-card .filter-controls .toolbar-select { flex: 1 1 0; min-width: 0; }
.db-filter-card .toolbar-select { height: 40px; box-sizing: border-box; font-family: var(--font-family); font-size: 14px; }
@media (max-width: 1100px) { .db-filter-card .filter-row, .db-filter-card .filter-controls { flex-wrap: wrap; } .db-filter-card .filter-group + .filter-group { padding-left: 0; border-left: 0; } .db-filter-card .filter-group { flex-basis: 100%; } }
.db-combo { position: relative; flex: 1.4 1 0; min-width: 0; }
.db-combo-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #fff; cursor: pointer; text-align: left; color: var(--color-text); }
.db-combo-value { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-combo-value.is-placeholder { color: var(--color-text); }
.db-combo-chevron { flex: 0 0 auto; width: 16px; height: 16px; color: var(--color-muted); transition: transform .15s ease; }
.db-combo-btn[aria-expanded="true"] { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-tint); }
.db-combo-btn[aria-expanded="true"] .db-combo-chevron { transform: rotate(180deg); }
.db-combo-panel { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: max(100%, 360px); background: #fff; border: 1px solid var(--color-border); border-radius: 10px; box-shadow: 0 10px 28px rgba(38, 34, 32, .14); padding: 8px; }
.db-combo-panel[hidden] { display: none; }
.db-combo-search { width: 100%; box-sizing: border-box; height: 38px; padding: 0 12px; border: 1px solid var(--color-border); border-radius: 8px; font-family: var(--font-family); font-size: 14px; }
.db-combo-search:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-tint); }
.db-combo-list { max-height: 300px; overflow-y: auto; margin-top: 6px; }
.db-combo-group { padding: 8px 10px 4px; font-size: 12px; font-weight: 600; color: var(--color-muted); }
.db-combo-option { padding: 8px 10px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.db-combo-option.is-active { background: var(--color-bg); }
.db-combo-option.is-selected { color: var(--color-primary); font-weight: 600; }
.db-combo-empty { padding: 16px 10px; text-align: center; font-size: 13.5px; color: var(--color-muted); }
.db-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.db-grid > .db-card { margin-bottom: 0; }
.db-span-4 { grid-column: span 4; } .db-span-8 { grid-column: span 8; } .db-span-12 { grid-column: span 12; }
.db-share { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.db-donut { width: 160px; height: 160px; }
.db-arc.is-click, .db-share-row:not(.is-static) { cursor: pointer; }
.db-arc.is-click:hover { filter: brightness(.94); }
.db-share-legend { width: 100%; display: flex; flex-direction: column; gap: 2px; }
.db-share-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 6px; border: 0; border-radius: 6px; background: none; font: inherit; font-size: 13.5px; color: var(--color-text); text-align: left; }
.db-share-row:not(.is-static):hover { background: var(--color-bg); }
.db-share-name { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-share-row b { font-weight: 600; }
.db-split + .db-split { margin-top: 20px; }
.db-split-title { font-size: 13px; color: var(--color-muted); margin-bottom: 6px; }
.db-split-bar { display: flex; gap: 2px; height: 30px; border-radius: 6px; overflow: hidden; background: var(--color-bg); }
.db-split-seg { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12.5px; font-weight: 600; cursor: pointer; min-width: 4px; }
.db-split-seg:hover { filter: brightness(.94); }
.db-split-legend { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; font-size: 13.5px; }
.db-split-legend > span { display: flex; align-items: center; gap: 6px; }
.db-split-legend b { margin-left: auto; font-weight: 600; }
@media (max-width: 1100px) { .db-span-4, .db-span-8 { grid-column: span 12; } .db-top { grid-template-columns: 1fr; } }
.db-active { position: sticky; top: 72px; z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 16px; margin-bottom: 14px; background: var(--color-primary-tint); border: 1px solid var(--color-primary); border-radius: 12px; box-shadow: 0 4px 14px rgba(38, 34, 32, .08); }
.db-active[hidden] { display: none; }
.db-active-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.db-active-label { font-size: 14px; font-weight: 600; color: var(--color-primary); white-space: nowrap; }
.db-active-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.db-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 6px 4px 12px; background: #fff; border: 1px solid var(--color-border); border-radius: 8px; font-size: 13.5px; color: var(--color-text); }
.db-chip-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.db-chip button { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border: 0; border-radius: 6px; background: none; color: var(--color-muted); font-size: 12px; cursor: pointer; }
.db-chip button:hover { background: var(--color-bg); color: var(--color-text); }
.db-active-reset { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-family); white-space: nowrap; }
.db-active-reset .icon { width: 16px; height: 16px; }
.db-back-link { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 0; border-radius: 6px; background: none; color: var(--color-primary); font-family: var(--font-family); font-size: 13px; font-weight: 600; cursor: pointer; }
.db-back-link[hidden] { display: none; }
.db-back-link:hover { background: var(--color-primary-tint); }
.db-back-link .icon { width: 14px; height: 14px; }
@media (max-width: 640px) { .db-active { flex-direction: column; align-items: stretch; } }
/* period row: mode buttons, then the picker for that mode */
.db-filter-card .db-period-row + .db-who-row { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--color-border); }
.db-filter-card .db-period-controls { flex-wrap: wrap; gap: 10px 16px; }
.db-seg { display: inline-flex; flex: 0 0 auto; height: 40px; border: 1px solid var(--color-border); border-radius: 8px; overflow: hidden; background: #fff; }
.db-seg button { padding: 0 18px; border: 0; border-left: 1px solid var(--color-border); background: none; font-family: var(--font-family); font-size: 14px; color: var(--color-text); cursor: pointer; white-space: nowrap; }
.db-seg button:first-child { border-left: 0; }
.db-seg button:hover { background: var(--color-bg); }
.db-seg button.is-active { background: var(--color-primary); color: #fff; font-weight: 600; }
.db-pick { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; }
.db-pick[hidden], .db-pick .toolbar-select[hidden] { display: none; }
.db-filter-card .db-pick .toolbar-select { flex: 0 0 auto; min-width: 120px; }
.db-filter-card .db-pick input[type="date"] { min-width: 150px; }
.db-step { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: 0 0 auto; border: 1px solid var(--color-border); border-radius: 8px; background: #fff; color: var(--color-text); cursor: pointer; }
.db-step:hover:not(:disabled) { background: var(--color-bg); }
.db-step:disabled { opacity: .4; cursor: default; }
.db-step .icon { width: 18px; height: 18px; }
.db-step.is-prev .icon { transform: rotate(90deg); } .db-step.is-next .icon { transform: rotate(-90deg); }
.db-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.db-side > .db-card { margin-bottom: 0; }
.db-grid { margin-bottom: 16px; }
.db-active-period { font-size: 14px; font-weight: 600; color: var(--color-text); }
.db-col.is-click { cursor: pointer; }
.db-table td.db-name { width: 100%; max-width: 0; } .db-table td.db-name .db-unit-link, .db-table td.db-name .db-bars { max-width: 100%; }
.db-kpis { margin-bottom: 16px; } .db-kpis .db-card { margin-bottom: 0 !important; }
@media (max-width: 640px) { .db-who-row .filter-controls > * { flex: 1 1 100% !important; } .db-table td.db-name { min-width: 150px; } }
.db-col:hover path { filter: brightness(.92); }
@media (max-width: 640px) { .db-seg { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); width: 100%; height: auto; gap: 1px; background: var(--color-border); } .db-seg button { grid-column: span 2; height: 40px; padding: 0 6px; border-left: 0; background: #fff; } .db-seg button:nth-child(n+4) { grid-column: span 3; } .db-seg button.is-active { background: var(--color-primary); } .db-pick { width: 100%; } .db-filter-card .db-pick .toolbar-select, .db-filter-card .db-pick input[type="date"] { flex: 1 1 0; min-width: 0; } }
/* Dropdown (.dd): a button that opens a tidy panel, a list with a check on
   the chosen row, or a grid of equal tiles (years, months). Used on the
   dashboard; written generic so other pages can take it up. */
.dd { position: relative; min-width: 0; }
.dd[hidden] { display: none; }
.dd-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #fff; cursor: pointer; text-align: left; color: var(--color-text); }
.dd-value { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-chevron { flex: 0 0 auto; width: 16px; height: 16px; color: var(--color-muted); transition: transform .15s ease; }
.dd-btn[aria-expanded="true"] { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-tint); }
.dd-btn[aria-expanded="true"] .dd-chevron { transform: rotate(180deg); }
.dd-panel { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; min-width: 100%; width: max-content; max-width: min(420px, calc(100vw - 32px)); box-sizing: border-box; background: #fff; border: 1px solid var(--color-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(38, 34, 32, .16); padding: 8px; }
.dd-panel[hidden] { display: none; }
.dd-panel.is-grid { width: 300px; }
.dd-title { padding: 4px 6px 10px; font-size: 12.5px; font-weight: 600; color: var(--color-muted); }
.dd-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.dd-grid { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: 6px; max-height: 300px; overflow-y: auto; padding: 2px; }
.dd-opt { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none; font-family: var(--font-family); font-size: 14px; color: var(--color-text); text-align: left; cursor: pointer; white-space: nowrap; }
.dd-opt:hover:not(:disabled), .dd-opt:focus-visible { background: var(--color-bg); outline: none; }
.dd-opt:disabled { color: #c9c2ba; cursor: default; }
.dd-check { flex: 0 0 16px; color: var(--color-primary); font-weight: 700; visibility: hidden; }
.dd-opt.is-selected { color: var(--color-primary); font-weight: 600; }
.dd-opt.is-selected .dd-check { visibility: visible; }
.dd-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dd-sep { height: 1px; margin: 4px 6px; background: var(--color-border); }
.dd-grid .dd-opt { justify-content: center; padding: 10px 4px; border: 1px solid var(--color-border); text-align: center; font-variant-numeric: tabular-nums; }
.dd-grid .dd-opt:hover:not(:disabled), .dd-grid .dd-opt:focus-visible { border-color: var(--color-primary); background: var(--color-primary-tint); }
.dd-grid .dd-opt.is-now:not(.is-selected) { border-color: var(--color-primary); color: var(--color-primary); }
.dd-grid .dd-opt.is-selected { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.dd-grid .dd-opt:disabled { border-style: dashed; background: none; }
.db-filter-card .filter-controls > .dd { flex: 1 1 0; }
.db-filter-card .db-pick .dd { flex: 0 0 auto; min-width: 170px; }
.db-filter-card .db-pick #db-month { min-width: 110px; }
@media (max-width: 640px) { .db-filter-card .db-pick .dd { flex: 1 1 0; min-width: 0; } .dd-panel.is-grid { width: min(300px, calc(100vw - 32px)); } }
/* every other <select> in the app, upgraded by app.js (.dd-auto) */
.dd-auto { display: block; }
.dd-auto[hidden] { display: none; }
.dd-native { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; pointer-events: none; }
.dd-btn.dd-field { padding: 10px 12px; border: 1px solid var(--color-border); border-radius: 8px; font-size: 14px; background: var(--color-surface); min-height: 42px; transition: border-color .15s ease, box-shadow .15s ease; }
.dd-btn { font-family: var(--font-family); line-height: 1.4; }
.dd-btn:focus-visible { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-tint); }
.dd-btn:disabled { background: var(--color-bg); color: var(--color-muted); cursor: not-allowed; }
.dd-btn.is-placeholder .dd-value { color: var(--color-muted); }
.field.invalid .dd-btn, .dd-btn.is-invalid { border-color: var(--color-danger); box-shadow: 0 0 0 3px var(--color-danger-tint); }
.dd-fixed { position: fixed; z-index: 2100; overflow: hidden; display: flex; flex-direction: column; }
.dd-fixed[hidden] { display: none; }
.dd-fixed .dd-body { overflow-y: auto; min-height: 0; }
.dd-fixed .dd-list, .dd-fixed .dd-grid { max-height: none; overflow: visible; }
.dd-fixed.is-grid { width: 300px; }
.dd-fixed .dd-opt { white-space: normal; line-height: 1.4; }
.dd-grid .dd-opt.is-wide { grid-column: 1 / -1; }
.dd-group { padding: 10px 10px 4px; font-size: 12px; font-weight: 600; color: var(--color-muted); }
.dd-search { flex: 0 0 auto; width: 100%; box-sizing: border-box; height: 38px; margin-bottom: 6px; padding: 0 12px; border: 1px solid var(--color-border); border-radius: 8px; font-family: var(--font-family); font-size: 14px; }
.dd-search:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-tint); }
.dd-empty { padding: 16px 10px; text-align: center; font-size: 13.5px; color: var(--color-muted); }
.filter-controls > .dd-auto { min-width: 150px; }
.filter-controls > .dd-auto .dd-btn { width: 100%; }
.ef-input-group .dd-auto { min-width: 120px; }
@media (max-width: 760px) { .filter-controls > .dd-auto { flex: 1 1 140px; } }
.db-card .table-wrap { overflow-x: auto; }
@media (max-width: 640px) { .db-table .db-col-req { display: none; } .db-table td.db-name { min-width: 120px; } .db-table td, .db-table th { padding: 8px 6px; } }
/* dashboard panels placed by placePanel(): fixed, sized to the screen */
.dd-panel.is-placed, .db-combo-panel.is-placed { position: fixed; z-index: 2100; box-sizing: border-box; display: flex; flex-direction: column; min-width: 0; max-width: none; overflow: hidden; }
.dd-panel.is-placed[hidden], .db-combo-panel.is-placed[hidden] { display: none; }
.is-placed > .dd-list, .is-placed > .dd-grid, .is-placed > .db-combo-list { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; }
.is-placed > .dd-title, .is-placed > .db-combo-search { flex: 0 0 auto; }
.dd-panel.is-placed .dd-opt { white-space: normal; line-height: 1.4; }
.db-combo-panel.is-placed { border-radius: 12px; box-shadow: 0 12px 32px rgba(38, 34, 32, .16); }
.db-legend i.is-bar { width: 10px; height: 10px; border-radius: 2px; }
.db-val.is-in { fill: #fff; stroke: #2a78d6; }
.db-val { font-size: 11.5px; font-weight: 600; fill: #262220; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; paint-order: stroke; pointer-events: none; }
/* request-detail: floating shortcut to the approve card on narrow screens */
.rd-mobile-bar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 30; display: flex; gap: 8px; padding: 10px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; box-shadow: 0 6px 24px rgba(38, 34, 32, .14); }
.rd-mobile-bar[hidden] { display: none; }
.rd-mobile-bar .btn { flex: 1 1 0; justify-content: center; font-family: var(--font-family); }
.rd-mobile-bar .btn-primary { flex-grow: 2; }
@keyframes rd-flash { 0% { box-shadow: 0 0 0 0 rgba(122, 46, 46, .45); } 100% { box-shadow: 0 0 0 14px rgba(122, 46, 46, 0); } }
.rd-flash { animation: rd-flash 1.1s ease-out 2; }
@media (min-width: 1001px) { .rd-mobile-bar { display: none !important; } }
@media (max-width: 1000px) { body:has(.rd-mobile-bar:not([hidden])) .app-main { padding-bottom: 96px; } }
#db-body[hidden] { display: none; }
.db-tip-hint { opacity: .7; font-size: 11.5px; }
.db-card { background: #fff; border: 1px solid var(--color-border); border-radius: 12px; padding: 16px 18px; min-width: 0; margin-bottom: 16px; }
.db-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.db-card-head h2 { font-size: 15.5px; font-weight: 600; margin: 0; }
.db-hint { font-size: 12.5px; color: var(--color-muted); margin-top: 2px; }
.db-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 12.5px; color: var(--color-muted); }
.db-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.db-legend i { display: inline-block; width: 16px; height: 3px; border-radius: 2px; }
.db-legend i.is-dash { background: repeating-linear-gradient(90deg, #8f8780 0 5px, transparent 5px 8px); }
.db-swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }
#db-body.is-busy { opacity: .6; transition: opacity .15s; pointer-events: none; }
.db-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.db-kpis .db-card { margin-bottom: 16px; }
.db-kpi-label { font-size: 13px; color: var(--color-muted); }
.db-kpi-value { font-size: 28px; font-weight: 700; line-height: 1.15; margin: 6px 0 6px; color: var(--color-text); }
.db-kpi-value small { font-size: 15px; font-weight: 400; color: var(--color-muted); }
.db-kpi-cmp { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; font-size: 13px; color: var(--color-muted); padding-top: 8px; border-top: 1px solid var(--color-border); }
.db-kpi-cmp small { font-size: 12px; }
.db-kpi-muted { color: var(--color-muted); font-weight: 400; }
.is-up { color: #2563b5; } .is-down { color: #b8322c; }
.db-kpi-cmp b { font-weight: 600; }
.db-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.db-table th { text-align: left; font-weight: 600; font-size: 13px; color: var(--color-muted); padding: 8px 10px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.db-table td { padding: 8px 10px; border-bottom: 1px solid #f1ede7; vertical-align: middle; }
.db-table tr.is-selected td { background: #eef4fc; }
.db-table .db-num { text-align: right; white-space: nowrap; }
.db-table th.db-num .db-sort { margin-left: auto; }
.db-table td.db-num small { display: block; font-size: 12px; color: var(--color-muted); }
.db-col-n { width: 36px; color: var(--color-muted); text-align: right; }
.db-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.db-sort:hover, .db-sort.is-active { color: var(--color-text); }
.db-unit-link { background: none; border: 0; padding: 0; font: inherit; color: var(--color-text); cursor: pointer; text-align: left; max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.db-unit-link:hover { color: var(--color-primary); text-decoration: underline; }
.db-bars { display: flex; flex-direction: column; gap: 2px; margin-top: 5px; max-width: 420px; }
.db-bars span { display: block; height: 5px; border-radius: 0 3px 3px 0; min-width: 1px; }
.db-bar-a { background: #2a78d6; } .db-bar-b { background: #9ec5f4; }
.db-table-more { text-align: center; margin-top: 12px; }
.db-table-more:empty { display: none; }
.db-table-more .btn { font-family: var(--font-family); }
.db-empty { padding: 32px 0; text-align: center; color: var(--color-muted); font-size: 14px; }
.db-loading { padding: 40px 0; text-align: center; color: var(--color-muted); }
.db-loading[hidden] { display: none; }
.db-tip { position: fixed; z-index: 1000; display: none; pointer-events: none; max-width: 280px; padding: 8px 10px; background: #262220; color: #fff; border-radius: 8px; font-size: 12.5px; line-height: 1.5; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
@media (max-width: 1100px) { .db-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .db-head { flex-direction: column; }
  .db-kpis { grid-template-columns: minmax(0, 1fr); }
}
