/* Duty Roster — design tokens, layout and components.
   Colours are defined once here; dark mode just swaps the tokens. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #18202e;
  --text-2: #465061;
  --muted: #6b7486;
  --primary: #2952cc;
  --primary-hover: #2145b0;
  --primary-weak: #ebf0fd;
  --on-primary: #ffffff;
  --success: #0f7a52;   --success-weak: #e5f5ee;
  --danger: #c0352b;    --danger-weak: #fdeceb;
  --warning: #a45a00;   --warning-weak: #fdf3e2;

  /* one colour pair per duty, used everywhere a shift appears */
  --morning: #06603f;  --morning-bg: #b9e8cf;
  /* extra colours for duty types a department adds */
  --teal: #0b5e63;  --teal-bg: #b5e4e6;  --rose: #8f1d4f;  --rose-bg: #f6c3d8;  --slate: #333f52;  --slate-bg: #d3d9e3;
  --evening: #173f9e;  --evening-bg: #c3d6fb;
  --night:   #4c26a6;  --night-bg:   #d6c8fb;
  --leave:   #971b1b;  --leave-bg:   #f6c0c0;
  --free:    #744300;  --free-bg:    #f6d898;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .16);
  --font: "Segoe UI", "Nirmala UI", "Noto Sans Bengali", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg:#0f1319; --surface:#171c24; --surface-2:#1e242e; --border:#2a313d; --border-strong:#3a4250; --text:#e6e9ee; --text-2:#b7bec9; --muted:#8a93a2; --primary:#6f95ff; --primary-hover:#86a6ff; --primary-weak:#1d2742; --on-primary:#0c1220;
    --success:#4cc494; --success-weak:#12291f; --danger:#f07b72; --danger-weak:#321816; --warning:#e5a44b; --warning-weak:#2e2210;
    --teal:#8fe6ea; --teal-bg:#17555a; --rose:#ffb0d0; --rose-bg:#6e2242; --slate:#d4dbe6; --slate-bg:#3a4557;
    --morning:#8ef0c3; --morning-bg:#185c40; --evening:#b8ceff; --evening-bg:#24407e; --night:#d6c7ff; --night-bg:#452d8a; --leave:#ffb3b3; --leave-bg:#7a2424; --free:#ffd98f; --free-bg:#6e4a0c;
    --shadow: none; --shadow-lg: 0 16px 40px rgba(0,0,0,.5); color-scheme: dark; }
}
:root[data-theme="dark"] { --bg:#0f1319; --surface:#171c24; --surface-2:#1e242e; --border:#2a313d; --border-strong:#3a4250; --text:#e6e9ee; --text-2:#b7bec9; --muted:#8a93a2; --primary:#6f95ff; --primary-hover:#86a6ff; --primary-weak:#1d2742; --on-primary:#0c1220;
  --success:#4cc494; --success-weak:#12291f; --danger:#f07b72; --danger-weak:#321816; --warning:#e5a44b; --warning-weak:#2e2210;
  --teal:#8fe6ea; --teal-bg:#17555a; --rose:#ffb0d0; --rose-bg:#6e2242; --slate:#d4dbe6; --slate-bg:#3a4557;
  --morning:#8ef0c3; --morning-bg:#185c40; --evening:#b8ceff; --evening-bg:#24407e; --night:#d6c7ff; --night-bg:#452d8a; --leave:#ffb3b3; --leave-bg:#7a2424; --free:#ffd98f; --free-bg:#6e4a0c;
  --shadow: none; --shadow-lg: 0 16px 40px rgba(0,0,0,.5); color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
svg[aria-hidden] { width: 18px; height: 18px; flex: none; }
.notice-bar svg { width: 20px; height: 20px; margin-top: 2px; color: var(--warning); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 700; font-size: 14px; letter-spacing: .5px; }
.brand b { display: block; font-size: 15px; }
.brand span { font-size: 12px; color: var(--muted); }
/* The logo above the name (sidebar, login): black, or white in dark mode. */
.brand.has-logo { flex-direction: column; align-items: flex-start; gap: 8px; }
.brand .logo { height: 30px; width: auto; display: block; }
.login .brand .logo { height: 46px; }
.logo-light { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-dark { display: none !important; }
  :root:not([data-theme="light"]) .logo-light { display: block !important; }
}
:root[data-theme="dark"] .logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: block !important; }
/* Super Admin: department switcher under the brand */
.dept-pick { padding: 0 14px 10px; }
.dept-pick .select { width: 100%; font-weight: 600; }
.dept-pick .super-link { width: 100%; justify-content: center; margin-bottom: 8px; }
/* Super Admin Panel: same layout, darker brand mark so it is clearly not a department */
.app.super .brand-mark { background: var(--text); color: var(--surface); }
.app.super .brand-mark svg { width: 18px; height: 18px; }
/* Page choices with a short description under each (Super Admin Panel, Logins & Access) */
.feature-boxes { gap: 8px 16px; }
.feature-box { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.feature-box:has(input:checked) { border-color: var(--primary); background: var(--primary-weak); }
.feature-box input { margin-top: 3px; flex: none; }
.feature-box span { display: grid; gap: 2px; min-width: 0; }
.feature-box small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }
.nav-group { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--primary-weak); color: var(--primary); }
/* How many wait there (e.g. new Online Requests). */
.nav-count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.nav-count[hidden] { display: none; }
.nav svg { width: 18px; height: 18px; flex: none; }
.me { border-top: 1px solid var(--border); padding: 12px; }
.me-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; background: none; border-radius: var(--radius-sm); cursor: pointer; text-align: left; }
.me-btn:hover { background: var(--surface-2); }
.me-btn .who { min-width: 0; flex: 1; }
.me-btn b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-btn span { font-size: 12px; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; object-fit: cover; background: var(--primary-weak); color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.avatar.lg { width: 96px; height: 96px; font-size: 32px; margin: 0 auto; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title .muted { font-size: 12px; }
.btn.menu-btn { display: none; }
/* Every page uses the whole screen width. */
.view { padding: 24px 28px 48px; width: 100%; }
/* Big grids (roster, fine grid, archives) also use the whole height; so do list pages
   whose table is fitted to the window (fitTables in app.js). */
.view.wide, .view.fit { padding-bottom: 16px; }
.view.wide .roster-wrap { max-height: calc(100vh - 185px); }
.app.has-banner .view.wide .roster-wrap { max-height: calc(100vh - 222px); }
.backdrop { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 264px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(10, 14, 20, .4); }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .view { padding: 16px 16px 40px; }
}

/* ---------- building blocks ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 1100px) { .g4, .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .span2 { grid-column: auto; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-h .muted { font-size: 12px; font-weight: 400; }
.card-b { padding: 16px 18px; }
/* Overview: a card that opens its list. */
a.work-card { display: grid; gap: 6px; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
a.work-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); }
/* Coloured cards: the whole card in its colour (--c), the text in the page colour on top, so it reads in light and dark. */
.tinted, a.work-card.tinted { background: var(--c); border-color: var(--c); color: var(--surface); }
.tinted .muted, .tinted .small.muted { color: inherit; opacity: .82; }
a.work-card.tinted:hover { border-color: var(--c); filter: brightness(1.08); }
.tinted .wc-num { color: inherit; font-size: 26px; font-weight: 700; }
.tinted .num.muted { opacity: .7; }
.wc-head { gap: 8px; align-items: center; font-size: 13px; font-weight: 600; }
.wc-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 22%, transparent); color: inherit; flex: none; }
.wc-icon svg { width: 16px; height: 16px; }
.tinted .badge.danger { background: var(--surface); color: var(--danger); }
.card-b.flush { padding: 0; }

.stat { padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 26px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-weak); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn svg { width: 16px; height: 16px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 550; color: var(--text-2); }
.field small { color: var(--muted); font-size: 12px; }
.input, .select, textarea.input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
textarea.input { height: auto; min-height: 96px; padding: 8px 10px; resize: vertical; }
.input:focus, .select:focus, .btn:focus-visible, .nav a:focus-visible, .duty-select:focus { outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.primary { background: var(--primary-weak); color: var(--primary); }
.badge.success { background: var(--success-weak); color: var(--success); }
.badge.danger { background: var(--danger-weak); color: var(--danger); }
.badge.warning { background: var(--warning-weak); color: var(--warning); }
.badge.yellow { background: var(--free-bg); color: var(--free); }
.badge.dark { background: var(--slate); color: var(--surface); }

/* duty chips + colour-coded duty dropdowns */
.duty { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.d-Morning { background: var(--morning-bg); color: var(--morning); }
.d-Evening { background: var(--evening-bg); color: var(--evening); }
.d-Night { background: var(--night-bg); color: var(--night); }
.d-Leave { background: var(--leave-bg); color: var(--leave); }
.d-Free { background: var(--free-bg); color: var(--free); }
.d-Teal { background: var(--teal-bg); color: var(--teal); }
.d-Rose { background: var(--rose-bg); color: var(--rose); }
.d-Slate { background: var(--slate-bg); color: var(--slate); }
.c-Teal { background: var(--teal); } .c-Rose { background: var(--rose); } .c-Slate { background: var(--slate); }
.c-Morning { background: var(--morning); } .c-Evening { background: var(--evening); } .c-Night { background: var(--night); } .c-Leave { background: var(--leave); } .c-Free { background: var(--free); }
.duty-select { appearance: none; -webkit-appearance: none; width: 88px; height: 28px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px; font-size: 12px; font-weight: 600; text-align: center; text-align-last: center; cursor: pointer; background: var(--surface); color: var(--muted); border-color: var(--border); }
.duty-select.d-Morning { background: var(--morning-bg); color: var(--morning); border-color: transparent; }
.duty-select.d-Evening { background: var(--evening-bg); color: var(--evening); border-color: transparent; }
.duty-select.d-Night { background: var(--night-bg); color: var(--night); border-color: transparent; }
.duty-select.d-Leave { background: var(--leave-bg); color: var(--leave); border-color: transparent; }
.duty-select.d-Free { background: var(--free-bg); color: var(--free); border-color: transparent; }
.duty-select.d-Teal { background: var(--teal-bg); color: var(--teal); border-color: transparent; }
.duty-select.d-Rose { background: var(--rose-bg); color: var(--rose); border-color: transparent; }
.duty-select.d-Slate { background: var(--slate-bg); color: var(--slate); border-color: transparent; }
.duty-select:not([class*="d-"]) { border-style: dashed; }
.duty-select option { background: var(--surface); color: var(--text); }

/* tables */
.table-wrap { overflow: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: 12px; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table .r { text-align: right; }
.table .c { text-align: center; }
.table .nowrap { white-space: nowrap; }
/* Office lists (New Connections, Location Change, …): set column widths, room to breathe, text that wraps evenly. */
.list-table { font-size: 13.5px; line-height: 1.5; }
.list-table.fixed { table-layout: fixed; min-width: 1180px; }
.list-table th { padding: 11px 14px; white-space: normal; line-height: 1.3; vertical-align: bottom; }
.list-table td { padding: 12px 14px; }
/* Column sort: click a column name (A to Z, Z to A, own order). */
/* Page numbers under a list table. */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pager-pages { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pager-pages .btn { min-width: 34px; justify-content: center; }
.pager-size { display: flex; align-items: center; gap: 6px; }
.pager-size .select { width: auto; height: 30px; }
.list-table th.col-filter { cursor: pointer; user-select: none; }
.list-table th.col-filter::after { content: " ⇅"; color: var(--muted); font-size: 11px; }
.list-table th.col-filter[data-sort="▲"]::after { content: " ▲"; }
.list-table th.col-filter[data-sort="▼"]::after { content: " ▼"; }
.list-table th.col-filter:hover { color: var(--text); }
.list-table th.col-filter.on, .list-table th.col-filter.on::after { color: var(--primary); }
.list-table td.wrap { white-space: normal; overflow-wrap: anywhere; }
.list-table td b { font-weight: 600; }
/* A plain date lines up with the coloured ones (same size as a badge). */
.date-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; }

/* monthly roster grid */
.roster-wrap { max-height: calc(100vh - 230px); border-radius: 0 0 var(--radius) var(--radius); }
.roster { font-size: 12px; }
.roster th, .roster td { padding: 5px 6px; text-align: center; border-right: 1px solid var(--border); }
.roster th { z-index: 3; }
.roster .sticky1, .roster .sticky2 { position: sticky; background: var(--surface); z-index: 2; }
.roster .sticky1 { left: 0; min-width: 44px; }
.roster .sticky2 { left: 44px; min-width: 46px; box-shadow: 1px 0 0 var(--border); }
.roster th.sticky1, .roster th.sticky2 { z-index: 5; background: var(--surface-2); }
.roster tr.weekend .sticky1, .roster tr.weekend .sticky2 { color: var(--danger); }
.roster tr.today td { background: var(--primary-weak) !important; }
.roster tr.picked td { box-shadow: inset 0 1px 0 var(--primary), inset 0 -1px 0 var(--primary); }
.table tfoot .total-row td { background: var(--surface-2); border-top: 2px solid var(--border-strong); }
.roster .total { font-weight: 650; min-width: 54px; font-variant-numeric: tabular-nums; }
.roster th.total { font-size: 11px; }

/* lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }

/* duty columns on the dashboard */
.duty-cols { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.duty-col { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; min-width: 0; }
.duty-col h3 { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; font-size: 13px; }
.duty-col ol { margin: 0; padding: 6px 10px 10px 28px; font-size: 13px; }
.duty-col li { padding: 1px 0; }
@media (max-width: 1100px) { .duty-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) { .duty-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: var(--radius-sm); }
.tabs button { border: 0; background: none; padding: 5px 12px; border-radius: 5px; cursor: pointer; font-weight: 550; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.test-banner { display: flex; align-items: center; gap: 10px; padding: 9px 28px; background: var(--warning-weak); color: var(--text); border-bottom: 1px solid color-mix(in srgb, var(--warning) 30%, transparent); font-size: 13px; }
.test-banner svg { color: var(--warning); }
.test-banner b { color: var(--warning); }
@media (max-width: 900px) { .test-banner { padding: 9px 16px; } }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.notice-bar { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius); background: var(--warning-weak); color: var(--text); border: 1px solid color-mix(in srgb, var(--warning) 25%, transparent); }
.notice-bar b { color: var(--warning); }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero h1 { font-size: 24px; }
.clock-card { display: flex; align-items: center; gap: 16px; padding: 14px 16px; }
.clock-card .times { display: flex; gap: 18px; }
.clock-card .times div span { display: block; font-size: 11px; color: var(--muted); }
.clock-card .times div b { font-size: 15px; font-variant-numeric: tabular-nums; }
.clock-card .times div span, .clock-card > div > .small { white-space: nowrap; }
@media (max-width: 700px) {
  .hero > .card { width: 100%; }
  .clock-card { flex-wrap: wrap; justify-content: space-between; }
  .clock-card .btn { width: 100%; }
  .tabs { max-width: 100%; overflow-x: auto; }
  .tabs button { white-space: nowrap; }
}
/* Phones: the top bar in rows - menu, title, language, refresh; then the page's buttons on rows of their
   own, big enough to tap. */
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .topbar .title { order: 1; flex: 1 1 0; }
  .topbar .title h1 { font-size: 18px; line-height: 1.25; }
  .topbar .title .muted { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .topbar > .menu-btn { order: 0; }
  .topbar > div.no-print:not(#top-actions) { order: 2; }
  .topbar > #refresh-btn { order: 3; }
  .topbar #top-actions { order: 4; flex: 0 0 100%; flex-wrap: wrap; gap: 8px; }
  .topbar #top-actions:empty { display: none; }
  .topbar .btn { min-height: 40px; white-space: nowrap; flex: none; }
  .topbar .btn.icon { min-width: 40px; }
}

.status-dot { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-dot.on { color: var(--success); }
.status-dot.off { color: var(--muted); }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 20, .45); display: grid; place-items: center; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(820px, 100%); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-b { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-width: 380px; animation: pop .15s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--success); color: #fff; font-weight: 600; }
/* The entry just saved: shown on its page, lit up for a moment. */
@keyframes just-saved { from { background: var(--success-weak); } to { background: transparent; } }
.list-table tr.just-saved td { animation: just-saved 4s ease-out; }
.list-table tr.just-saved td:first-child { box-shadow: inset 4px 0 0 var(--success); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
.menu { position: absolute; z-index: 60; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--surface-2); }

.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.error-box { padding: 14px 16px; border-radius: var(--radius); background: var(--danger-weak); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(400px, 100%); padding: 28px; }
.login .brand { padding: 0 0 22px; }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app { display: block; }
  .roster-wrap { max-height: none; overflow: visible; }
}

/* One entry of an office-wide list: details | history & comments */
.modal.record-modal { max-width: 920px; width: calc(100vw - 32px); }
.record-modal .modal-h { padding: 10px 16px; }
.record-modal .modal-h h2 { font-size: 15px; }
.record-modal .modal-b { padding: 12px 16px; gap: 10px; }
.record-modal .modal-f { padding: 10px 16px; align-items: center; }
.record-modal .modal-f .record-actions { margin: 0 auto 0 0; }
.record { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; }
.record-fields { display: grid; gap: 5px; align-content: start; }
.rf { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px; font-size: 13px; }
.rf > span { color: var(--muted); }
.rf > div { white-space: pre-wrap; overflow-wrap: anywhere; }
.record-side h3 { margin: 0 0 8px; font-size: 14px; }
/* Files attached to an entry (under its fields). */
.record-files { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.record-files h3 { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.record-files h3 svg, .clip-count svg { width: 15px; height: 15px; }
.file-list { display: grid; gap: 6px; }
.file-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-row .small { flex: 1; min-width: 140px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.link-btn:hover { text-decoration: underline; }
.table tr.group-row td { background: var(--surface-2); font-weight: 600; font-size: 12.5px; padding-top: 7px; padding-bottom: 7px; color: var(--text-2); }
/* A branch's own row in the branch table on its Home. */
.table tr.mine-row td { background: var(--primary-weak); }
.clip-count { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 12px; font-weight: 500; margin-left: 6px; vertical-align: middle; }
/* Why a charge is what it is: offer / reference / referral, each with its own colour. */
.kind-text { font-weight: 600; margin-top: 2px; }
.kind-text.kind-offer { color: var(--success); }
.kind-text.kind-reference { color: var(--primary); }
.kind-text.kind-referral { color: var(--warning); }
.badge.kind-offer { background: var(--success-weak); color: var(--success); }
.badge.kind-reference { background: var(--primary-weak); color: var(--primary); }
.badge.kind-referral { background: var(--warning-weak); color: var(--warning); }
.timeline { max-height: 34vh; overflow: auto; display: grid; gap: 10px; padding-right: 4px; align-content: start; }
.tl-item { border-left: 3px solid var(--border); padding: 2px 0 2px 10px; font-size: 12.5px; }
.tl-item.tl-create { border-color: var(--success); }
.tl-item.tl-comment { border-color: var(--primary); }
.tl-item ul { margin: 4px 0 0; padding-left: 16px; display: grid; gap: 2px; }
.tl-text { background: var(--primary-weak); padding: 6px 10px; border-radius: 8px; white-space: pre-wrap; margin-top: 4px; }
.comment-box { display: grid; gap: 6px; margin-top: 8px; }
.comment-box textarea.input { min-height: 38px; }
.comment-box button { justify-self: end; }
.record-actions { gap: 8px; flex-wrap: wrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
@media (max-width: 800px) { .record { grid-template-columns: 1fr; } .rf { grid-template-columns: 1fr; gap: 2px; } }
