/* Parvchakra admin panel.
   Uses the same palette as the mobile design language: ivory, saffron, maroon,
   sage, amber. Light mode only, high contrast, keyboard friendly. */

:root {
  --ivory: #FFF9F0;
  --white: #FFFFFF;
  --saffron: #D9720B;
  --saffron-soft: #FBE3C7;
  --maroon: #6B2737;
  /* A table header is a surface, not a call to action. In dark mode --maroon
     turns into a light tone that is right for text and wrong for a header bar,
     so the header keeps its own pair. */
  --th-bg: #6B2737;
  --th-fg: #FFF9F0;
  --sage: #4B7B4E;
  --sage-soft: #E1EEE0;
  --red: #B23A3A;
  --red-soft: #F6DEDE;
  --amber: #B8860B;
  --amber-soft: #F3E6C4;
  --ink: #2B231C;
  /* Raised from #8A7A68: the old value sat just under 4.5:1 on white, and
     .muted carries real information ("never run", "not measured") at 11-12px,
     which is exactly the text that must not be hard to read. */
  --muted: #6E6152;
  --border: #EAD9C0;
  --sidebar: #3A1F2A;
  /* Design-system additions (doc 07). --bg is the page background, --dark-bg is
     the sidebar's near-black maroon; both are named in the design doc so a
     template never has to hardcode a hex value. */
  --bg: #F5EDE0;
  --dark-bg: #1A1219;
  --green: #2E7D32;
  /* Spacing / radius / type scale. Named so component CSS reads as intent
     rather than as a run of magic numbers. */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 40px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-size-sm: 11.5px;
  --font-size-base: 13px;
  --font-size-lg: 15px;
  --font-display: "Yatra One", "Noto Sans", system-ui, sans-serif;
  --font-body: "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* The topbar has its own tokens because --maroon is reused as a *text accent*
     in dark mode; letting the bar inherit it turns the header light pink. */
  --topbar-bg: var(--maroon);
  --topbar-fg: var(--ivory);
}

/* Dark mode for late shifts (doc 07 §10, low priority but the tokens already
   support it). Toggled by admin.js writing data-theme on <html>; every value
   below reuses or overrides a token rather than re-styling a component. */
html[data-theme="dark"] {
  --ivory: #241C1F;
  --white: #2A2124;
  --ink: #F3E6C4;
  --muted: #B6A794;
  --border: #46323A;
  --bg: #1A1219;
  --sidebar: #120C11;
  --dark-bg: #120C11;
  --maroon: #E8B4C1;
  --th-bg: #3A1F2A;
  --th-fg: #FFF9F0;
  --topbar-bg: #3A1F2A;
  --topbar-fg: #FFF9F0;
  --saffron-soft: #4A3218;
  --sage-soft: #22331F;
  --amber-soft: #40331A;
  --red-soft: #40201F;
}

* { box-sizing: border-box; }

/* Present for screen readers, absent for everybody else. Used where a table
   header already reads as the label to a sighted user but not to a screen
   reader. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 var(--font-body);
}

/* Display face for page and section titles: the same "Yatra One" the design
   doc specifies, so the panel reads as part of the app rather than a separate
   internal tool. */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: .2px;
}

a { color: var(--maroon); }

/* Keyboard-only affordance: present for screen readers and keyboard users,
   invisible until it is focused. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--maroon);
  color: #fff;
  padding: 8px 14px;
  border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }
main:focus { outline: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--saffron);
  outline-offset: 1px;
}

.layout { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--dark-bg);
  color: #FBF3E7;
  padding: 18px 0;
  overflow-y: auto;
  max-height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar .brand {
  padding: 16px 18px;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: .3px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: 8px;
}
.sidebar .brand a { color: inherit; text-decoration: none; }
.sidebar .brand small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 11px; opacity: .65; margin-top: 3px; }
/* Sidebar navigation, following the reference theme's sidebar-nav: each group
   is either a plain heading with flat links (Main) or a collapsible section.
   The header toggles and its children slide open; only the section holding the
   current page starts open, because forty expanded links is a wall of text. */
.sidebar .nav-heading { padding: 16px 18px 5px; font-size: 10px; letter-spacing: .09em; text-transform: uppercase; opacity: .45; font-weight: 700; }
.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 18px;
  background: none;
  border: 0;
  font: inherit;
  font-size: 13px;
  text-align: left;
  color: rgba(255,255,255,.75);
  cursor: pointer;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-item.open > .nav-link { color: #fff; }
.sidebar .nav-caret { margin-left: auto; font-size: 11px; opacity: .6; transition: transform .2s ease; }
.sidebar .nav-item.open > .nav-link .nav-caret { transform: rotate(180deg); }
/* 0fr -> 1fr animates to whatever height the inner list actually has, so a
   long section is never clipped the way a fixed max-height would clip it. */
/* `visibility` is what keeps a shut section out of the tab order and the
   accessibility tree; it flips at the end of the collapse, so the slide still
   animates while the links stop being reachable the moment they are hidden. */
.sidebar .nav-content {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows .22s ease, visibility .22s ease;
}
.sidebar .nav-item.open > .nav-content { grid-template-rows: 1fr; visibility: visible; }
.sidebar .nav-content-inner { overflow: hidden; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 13px;
}
.sidebar nav a .nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; line-height: 1; }
.sidebar .nav-content a { padding: 7px 18px 7px 42px; font-size: 12.5px; }
.sidebar .nav-dot { font-size: 6px; opacity: .5; flex-shrink: 0; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active {
  background: rgba(217,114,11,.15);
  color: var(--saffron);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--saffron);
}
.sidebar .nav-content a.active .nav-dot { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .sidebar .nav-content, .sidebar .nav-caret { transition: none; }
}
/* Collapsed rail on tablets: icon-only, expands on hover/focus. Sections stay
   shut in the rail — there is no room for a nested list under a 60px bar. */
.layout.rail .sidebar { width: 60px; flex-basis: 60px; }
.layout.rail .sidebar .brand,
.layout.rail .sidebar .nav-heading,
.layout.rail .sidebar .nav-label,
.layout.rail .sidebar .nav-caret,
.layout.rail .sidebar .nav-content { display: none; }
.layout.rail .sidebar .nav-link,
.layout.rail .sidebar nav a { justify-content: center; padding: 10px 0; }
.layout.rail .sidebar:hover, .layout.rail .sidebar:focus-within { width: 240px; flex-basis: 240px; }
.layout.rail .sidebar:hover .brand,
.layout.rail .sidebar:focus-within .brand,
.layout.rail .sidebar:hover .nav-heading,
.layout.rail .sidebar:focus-within .nav-heading,
.layout.rail .sidebar:hover .nav-label,
.layout.rail .sidebar:focus-within .nav-label,
.layout.rail .sidebar:hover .nav-caret,
.layout.rail .sidebar:focus-within .nav-caret { display: revert; }
.layout.rail .sidebar:hover .nav-item.open > .nav-content,
.layout.rail .sidebar:focus-within .nav-item.open > .nav-content { display: grid; }
.layout.rail .sidebar:hover .nav-link,
.layout.rail .sidebar:focus-within .nav-link,
.layout.rail .sidebar:hover nav a,
.layout.rail .sidebar:focus-within nav a { justify-content: flex-start; padding: 9px 18px; }
.layout.rail .sidebar:hover .nav-content a,
.layout.rail .sidebar:focus-within .nav-content a { padding: 7px 18px 7px 42px; }

/* ---------- main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--topbar-bg); color: var(--topbar-fg);
  border-bottom: 1px solid rgba(0,0,0,.2);
  padding: 0 18px;
  position: sticky; top: 0; z-index: 20;
  /* A minimum, not a fixed height: on a narrow window the badges and the user
     menu wrap, and a fixed 56px box let the second line spill out over the
     page below it. */
  min-height: 56px;
  height: auto;
  flex-wrap: wrap;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}

/* Below this width the env tag is the first thing to drop: it is ambient
   information, and keeping it forces the whole bar onto two lines. */
@media (max-width: 820px) {
  .topbar { padding: 6px 14px; }
  .topbar .env-tag { display: none; }
  .topbar .who { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar .who { font-size: 12.5px; color: rgba(255,255,255,.85); }
.topbar a { color: var(--topbar-fg); }
.topbar .brand-mini { font-family: var(--font-display); font-size: 17px; letter-spacing: .3px; }
.topbar .brand-mini a { text-decoration: none; display: flex; align-items: center; gap: 7px; }
.topbar .topbar-badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar .tb-badge { background: rgba(255,255,255,.18); color: var(--topbar-fg); padding: 3px 10px; border-radius: 10px; font-size: 11px; text-decoration: none; white-space: nowrap; }
.topbar .tb-badge:hover { background: rgba(255,255,255,.28); }
.topbar .env-tag { text-transform: uppercase; font-size: 10px; font-weight: 700; letter-spacing: .08em; padding: 3px 9px; border-radius: 8px; background: rgba(255,255,255,.16); }
.topbar .env-tag.prod { background: var(--red); }
.topbar .topbar-user { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.topbar .topbar-menu { position: relative; }
.topbar .topbar-menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 8px; }
.topbar .topbar-menu > summary:hover { background: rgba(255,255,255,.1); }
.topbar .topbar-menu > summary::-webkit-details-marker { display: none; }
.topbar .topbar-menu[open] > summary { background: rgba(255,255,255,.12); }
.topbar .topbar-menu .menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--white); color: var(--ink); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.2); min-width: 220px; padding: 8px; z-index: 30; }
.topbar .topbar-menu .menu-pop .menu-meta { font-size: 11.5px; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.topbar .topbar-menu .menu-pop a, .topbar .topbar-menu .menu-pop button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: none; color: var(--ink); padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 13px; text-decoration: none; cursor: pointer; }
.topbar .topbar-menu .menu-pop a:hover, .topbar .topbar-menu .menu-pop button:hover { background: var(--ivory); }
.sidebar-toggle { display: none; background: rgba(255,255,255,.14); color: var(--topbar-fg); border: none; border-radius: 8px; padding: 7px 10px; font-size: 18px; cursor: pointer; align-items: center; }
.sidebar-toggle:hover { background: rgba(255,255,255,.24); }
.theme-toggle { background: rgba(255,255,255,.14); color: var(--topbar-fg); border: none; border-radius: 8px; padding: 7px 10px; font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; }
.theme-toggle:hover { background: rgba(255,255,255,.24); }
.content { padding: 24px 28px; width: 100%; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1, .page-head h2 { margin: 0; font-size: 20px; color: var(--maroon); flex: 1; }
.page-head .page-actions { flex-shrink: 0; }

/* ---------- cards & stats ---------- */
.card { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(107,39,55,0.06); }
.card h3 { margin: 0 0 10px; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: 0 2px 8px rgba(107,39,55,0.06); }
.stat .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 5px; }
.stat .value { font-size: 24px; font-weight: 700; color: var(--maroon); }
.stat .sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.stat a { font-size: 11.5px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; background: var(--white); }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 13px; }
th { font-size: 12px; font-weight: 600; color: var(--th-fg); background: var(--th-bg); }
tbody tr:nth-child(even) td { background: var(--ivory); }
tbody tr:hover td { background: var(--saffron-soft); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* S.No. — the first column of every record table, so a page says how many rows
   it is showing and a row can be pointed at by number. Narrow and quiet: it is
   a counter, not data, and must never compete with the first real column. */
th.sno, td.sno { width: 54px; }
td.sno { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--sage-soft); color: var(--sage); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.info { background: var(--saffron-soft); color: var(--maroon); }
.badge.mute { background: #EDEAE3; color: var(--muted); }

/* ---------- forms ---------- */
label { display: block; font-size: 11.5px; font-weight: 600; color: var(--maroon); margin: 12px 0 4px; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 9px 11px; border: 1.5px solid var(--border); border-radius: 9px;
  background: var(--white); color: var(--ink); font: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus { border-color: var(--saffron); }
.hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.inline-form { display: inline; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
/* A form that owns the whole cell (the translation worklist). Inputs are
   width:100%, so without this the save button drops onto its own line and every
   row becomes three lines tall. */
.cell-form { display: flex; gap: 8px; align-items: center; }
.cell-form input[type=text] { flex: 1 1 auto; width: auto; min-width: 200px; }

button, .btn {
  display: inline-block; padding: 9px 15px; border: none; border-radius: 9px;
  background: var(--maroon); color: var(--ivory); font: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--saffron-soft); color: var(--maroon); }
.btn.ghost { background: transparent; color: var(--maroon); border: 1.5px solid var(--border); }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { padding: 5px 11px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- messages ---------- */
.alert { border-radius: 10px; padding: 11px 13px; margin-bottom: 14px; font-size: 13px; }
.alert.error { background: var(--red-soft); color: var(--red); border: 1px solid #E7BFBF; }
.alert.ok { background: var(--sage-soft); color: var(--sage); border: 1px solid #BED8BD; }
.alert.warn { background: var(--amber-soft); color: var(--amber); border: 1px solid #E3D3A4; }
.alert.info { background: var(--saffron-soft); color: var(--maroon); border: 1px solid #F0CFA6; }

/* ---------- health list ---------- */
.check { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--border); }
.check:last-child { border-bottom: none; }
.check .name { font-weight: 600; min-width: 160px; }
.check .detail { color: var(--muted); font-size: 12.5px; word-break: break-word; }

/* ---------- filter bar ---------- */
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filters label { margin-top: 0; }
.filters .field { min-width: 150px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 372px; background: var(--white); border: 1px solid var(--border); border-radius: 16px; padding: 26px; }
.login-card h1 { margin: 0 0 4px; font-size: 21px; color: var(--maroon); }
.login-card p.sub { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); }

/* ---------- misc ---------- */
/* The label column is capped and the value column is allowed to shrink, so a
   long value (a list of tithis, a raw timestamp) wraps instead of forcing the
   whole page to scroll sideways in a narrow window. */
.kv { display: grid; grid-template-columns: minmax(104px, 176px) minmax(0, 1fr); gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv dd > div { overflow-wrap: anywhere; }
pre.payload { background: #2B231C; color: #F3E6C4; padding: 13px; border-radius: 10px; overflow: auto; font-size: 12px; max-height: 460px; }

/* Tables use natural layout (display:table) so columns fill the full width.
   The parent .card or .content > table wrapper handles horizontal overflow. */

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .content { padding: 14px; }
}
.pill-list { display: flex; gap: 6px; flex-wrap: wrap; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: 12.5px; }
.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 5px; }

/* ---------- breadcrumb ---------- */
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.breadcrumb a { color: var(--saffron); text-decoration: none; font-weight: 600; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep, .breadcrumb span { color: var(--border); font-size: 14px; }
.breadcrumb .current { color: var(--ink); font-weight: 600; }

/* ---------- page head + actions ---------- */
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- profile header ---------- */
.profile-header { display: flex; gap: 16px; align-items: flex-start; background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 0; }
.ph-avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--saffron-soft); color: var(--maroon); font-size: 22px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ph-meta { flex: 1; min-width: 0; }
.ph-name { font-size: 17px; font-weight: 700; margin: 0 0 2px; }
.ph-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 6px; }
.ph-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; align-self: flex-start; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin: 0 0 18px; }
.tab { padding: 9px 14px; font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none; border-radius: 8px 8px 0 0; border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tab:hover { color: var(--ink); background: var(--ivory); }
.tab.active { color: var(--maroon); font-weight: 600; border-bottom-color: var(--saffron); background: var(--white); }
.tab-count { display: inline-block; background: var(--saffron-soft); color: var(--maroon); border-radius: 9px; font-size: 10.5px; font-weight: 700; padding: 1px 6px; margin-left: 5px; }
.tab.active .tab-count { background: var(--saffron); color: var(--ivory); }

/* ---------- card sections ---------- */
.card-section { border-top: 1px solid var(--border); padding: 14px 16px; margin: 0 -16px; }
.card-section:first-child { border-top: none; }
.card-section-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }

/* ---------- permissions table ---------- */
tr.perm-group-header td { background: var(--ivory); color: var(--muted); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; padding: 6px 11px; }
tr.perm-row td { vertical-align: middle; }
tr.perm-granted td { background: var(--sage-soft); }
tr.perm-granted td:first-child { border-left: 3px solid var(--sage); }
tr.perm-row input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--sage); }

/* ---------- form sections ---------- */
.form-section { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.fs-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 12px; }
.form-section.danger-zone { border-color: var(--red); }
.form-section.danger-zone .fs-title { color: var(--red); }
.form-footer { display: flex; gap: 10px; align-items: center; margin-top: 18px; }

/* ---------- queue cards ---------- */
.queue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 18px; }
.queue-card { background: var(--white); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.queue-card.urgent { border-color: var(--red); }
.queue-card.urgent .qc-head { background: var(--red-soft); }
.qc-head { padding: 11px 14px; background: var(--ivory); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.qc-body { padding: 12px 14px; }
.qc-foot { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* ---------- muhurat suite ---------- */
/* Two tool tables side by side on a wide screen, stacked on a narrow one. */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.cols table { width: 100%; }
.plain { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.plain li { margin-bottom: 4px; }
/* Gowri Panchangam's auspicious names, marked inline rather than in a column. */
.good { color: var(--green, #2f7d4f); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.bad { color: var(--red); }
.meta-line { font-size: 12.5px; overflow-wrap: anywhere; }

/* ---------- runbooks (Sprint 14) ---------- */
/* The runbook text is shown exactly as committed: an operator under pressure is
   reading a procedure, and the panel must not paraphrase it. */
.runbook {
  border: 1px solid var(--border);
  background: #FFFDF8;
  border-radius: 6px;
  padding: 14px 16px;
  margin: 0 0 16px;
}
.runbook h2 { margin: 0 0 8px; font-size: 16px; }
.runbook-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--ink);
}

/* ═══════════════════════════════════════════════════════════════════════════
   UI UPGRADE — doc 07-ADMIN-UI-DESIGN-FULL, §6d Step 1.
   Every class below is additive: the tokens above are unchanged, so existing
   screens keep the look they already had and new markup opts in.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tab panels (server-driven ?tab=, no JS required) ───────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Section divider inside a card ─────────────────────────────────────── */
.card-section { border-top: 1px solid var(--border); margin-top: var(--spacing-md); padding-top: var(--spacing-md); }
.card-section:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.card-section-title { font-size: var(--font-size-sm); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }

/* ── Form section card (doc rule 7) ─────────────────────────────────────── */
.form-section .fs-title { display: flex; align-items: center; gap: 6px; color: var(--maroon); border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 12px; text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.form-section.danger-zone { border-color: var(--red); }
.form-section.danger-zone .fs-title { color: var(--red); border-bottom-color: var(--red-soft); }

/* ── Sticky form footer ────────────────────────────────────────────────── */
.form-footer.sticky { position: sticky; bottom: 0; background: var(--white); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-md) var(--radius-md); padding: 12px 16px; margin: 4px -16px -16px; z-index: 10; }

/* ── Queue cards ───────────────────────────────────────────────────────── */
.queue-card { display: flex; flex-direction: column; }
.queue-card .qc-body { flex: 1; }
.queue-card.urgent { border-color: var(--red); }
.queue-card.urgent .qc-head { background: var(--red-soft); }

/* ── Bulk action bar (doc §6b Pattern 1) ───────────────────────────────── */
.bulk-bar { background: var(--maroon); color: var(--ivory); padding: 10px 16px; border-radius: var(--radius-md); align-items: center; gap: 12px; margin-bottom: 12px; font-size: 13px; flex-wrap: wrap; display: none; }
.bulk-bar.visible { display: flex; }
.bulk-bar .bulk-count { font-weight: 700; background: rgba(255,255,255,.2); padding: 2px 10px; border-radius: 8px; font-size: 12px; }
.bulk-bar .btn { color: var(--ivory); background: rgba(255,255,255,.16); }
.bulk-bar .btn.ghost { background: transparent; border-color: rgba(255,255,255,.35); color: var(--ivory); }
.bulk-bar .btn.danger { background: var(--red); }

/* ── Confirm box (high-stakes destructive actions) ─────────────────────── */
.confirm-box { background: var(--red-soft); border: 1px solid #E7BFBF; border-radius: var(--radius-md); padding: 14px 16px; margin-top: 10px; }
.confirm-box p { font-size: 13px; color: var(--red); margin: 0 0 10px; }

/* ── Info rows (key/value without a definition list) ───────────────────── */
.info-row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; align-items: baseline; }
.info-row:last-child { border-bottom: none; }
.info-row .ir-label { min-width: 160px; font-size: 12px; color: var(--muted); font-weight: 600; flex-shrink: 0; }
.info-row .ir-value { flex: 1; overflow-wrap: anywhere; }

/* ── KPI cards (dashboard) ─────────────────────────────────────────────── */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; display: block; color: inherit; text-decoration: none; }
.kpi-card:hover { border-color: var(--saffron); }
.kpi-card .kv-label { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.kpi-card .kv-value { font-family: var(--font-display); font-size: 24px; color: var(--maroon); line-height: 1.2; margin: 5px 0 3px; }
.kpi-card .kv-delta { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.kv-up { color: var(--green); }
.kv-dn { color: var(--red); }

/* ── Chart card (real data; Script.js-optional) ────────────────────────── */
.chart-card canvas { max-height: 260px; }
.chart-fallback { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }

/* ── Button aliases (doc uses .btn-primary / .btn-danger naming) ───────── */
.btn.primary, .btn-primary { background: var(--saffron); color: var(--ivory); }
.btn-secondary { background: var(--saffron-soft); color: var(--maroon); }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--maroon); border: 1.5px solid var(--border); }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 5px; }

/* ── Data table inside a card ──────────────────────────────────────────── */
.card table:last-child { margin-bottom: -16px; }
.card > table { margin-bottom: 0; }

/* A table that is a direct child of the content area is not inside a `.card`
   wrapper, so give it the card's surface (doc §6d rule 12) without editing
   every template. Tables already inside a card are nested and stay flat. */
.content > table {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  display: block;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(107,39,55,0.06);
}

/* ── Missing utility classes ────────────────────────────────────────────── */

/* .btn.sm is an alias for .btn.small; some templates use the shorter name. */
.btn.sm { padding: 5px 11px; font-size: 12px; }

/* Vertical form stack: <form class="stack"> makes each <label>...</label>
   block a labeled field with the label text above the control. Used by the
   admin user create form and any one-column form that needs stacking without
   a grid. */
.stack { display: flex; flex-direction: column; }
.stack > label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px;
  font-size: 11.5px; font-weight: 600; color: var(--maroon); }
.stack > label.checkbox { flex-direction: row; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 400; color: var(--ink); }
.stack > label > input, .stack > label > select, .stack > label > textarea {
  font-weight: 400; color: var(--ink); }

/* Revenue / stats grid: a wider card grid than .kpi-row, used by the
   revenue dashboard for KPI cards that need a sub-line and optional colour. */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 18px; }
.stat-card { background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px;
  box-shadow: 0 2px 8px rgba(107,39,55,.06); }
.stat-card.ok { border-color: var(--sage); }
.stat-label { font-size: 10.5px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.stat-value { font-family: var(--font-display); font-size: 26px;
  color: var(--maroon); line-height: 1.2; margin-bottom: 4px; }
.stat-card.ok .stat-value { color: var(--sage); }
.stat-sub { font-size: 11.5px; color: var(--muted); }

/* Section heading between cards on dashboard / report pages. */
.section-head { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); margin: 20px 0 10px; }

@media (max-width: 900px) {
  .sidebar-toggle { display: inline-flex; }
  /* On a phone the sidebar slides over the content instead of pushing it. */
  .layout { position: relative; }
  /* The drawer is narrower than the screen: content stays visible beside it and
     the scrim behind it is what closes it. */
  .sidebar {
    position: fixed;
    z-index: 40;
    left: 0;
    top: 0;
    width: 264px;
    flex-basis: 264px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .18s ease;
  }
  .layout.nav-open .sidebar { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  /* A drawer is not an icon rail: neutralise the rail rules so the drawer keeps
     its labels and its sections can still be opened on a phone. */
  .layout.rail .sidebar { width: 264px; flex-basis: 264px; }
  .layout.rail .sidebar .brand,
  .layout.rail .sidebar .nav-heading,
  .layout.rail .sidebar .nav-label,
  .layout.rail .sidebar .nav-caret { display: revert; }
  .layout.rail .sidebar .nav-content { display: grid; }
  .kpi-row { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .topbar { flex-wrap: wrap; }
  .info-row { flex-direction: column; gap: 2px; }
  .info-row .ir-label { min-width: 0; }
  .form-footer.sticky { position: static; margin: 4px 0 0; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .breadcrumb { font-size: 11.5px; }
}


/* ── Checkbox grid (multi-select occasion lists etc.) ── */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px 12px; margin-top: 6px; }
.checkbox-label { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; user-select: none; }
.checkbox-label input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--saffron, #c0582b); flex-shrink: 0; cursor: pointer; }

/* ── Danger card variant ── */
.card-danger { border-color: var(--color-error, #c0392b); }
