/* CMC call line admin. Plain and dense: white panels, grey rules, one navy accent. */
:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --wash: #f6f7f8;
  --ink: #1f2328;
  --ink-2: #3d444d;
  --muted: #6a737d;
  --line: #dde1e6;
  --line-strong: #c4cad1;

  --navy: #1d3557;
  --navy-deep: #142640;
  --navy-soft: #e8edf4;

  --ok: #1e7a3c;     --ok-soft: #e6f2ea;
  --warn: #8a5a00;   --warn-soft: #fbf1db;
  --danger: #b42318; --danger-soft: #fbe9e7;

  --accent: var(--navy);
  --accent-soft: var(--navy-soft);
  --radius: 4px;
  --font: "IBM Plex Sans", "Noto Sans Sinhala", "Noto Sans Tamil", -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--navy); }
code { font-family: var(--mono); font-size: 13px; background: var(--wash); border: 1px solid var(--line); padding: 0 4px; border-radius: 3px; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 220px; z-index: 5;
  background: var(--navy-deep); color: #c9d3df;
  display: flex; flex-direction: column; overflow-y: auto;
}
body.with-sidebar { padding-left: 220px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; padding: 16px 16px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.brand-mark {
  flex: none; width: 34px; height: 34px; border-radius: 3px;
  background: #fff; color: var(--navy-deep);
  display: grid; place-items: center;
  font-weight: 700; font-size: 11.5px; letter-spacing: 0.03em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 13.5px; font-weight: 600; }
.brand-sub { font-size: 12px; color: #8fa0b3; }
.sidenav { flex: 1; padding: 10px 0; }
.nav-group { margin-bottom: 8px; }
.nav-heading { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #7c8da1; padding: 10px 16px 4px; }
.sidenav a {
  display: flex; align-items: center; justify-content: space-between;
  color: #c9d3df; text-decoration: none; font-size: 14px;
  padding: 7px 16px; border-left: 3px solid transparent;
}
.sidenav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidenav a.active { background: rgba(255, 255, 255, 0.1); color: #fff; border-left-color: #fff; font-weight: 600; }
.nav-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 3px; background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 18px; text-align: center; }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, 0.1); padding: 6px 0; }
.signout { display: block; color: #8fa0b3; font-size: 13.5px; text-decoration: none; padding: 8px 16px; }
.signout:hover { color: #fff; }

/* ---------- Page ---------- */
main { padding: 24px 28px 70px; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; line-height: 1.3; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.section-note { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 20px; max-width: 720px; font-size: 14px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 10px; font-size: 13.5px; }

/* ---------- Panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card > h2 + .field, .card > h2 + form, .card > h2 + .grid { margin-top: 12px; }
.card > .grid + .field, .card > .field + .grid, .card > .grid + .grid { margin-top: 14px; }
.field > .grid { margin-top: 6px; }
.grid { display: grid; gap: 14px 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid > .card { margin-bottom: 0; }
.grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }

.stat { padding: 12px 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 2px; line-height: 1.2; font-variant-numeric: tabular-nums; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13.5px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.field { margin-bottom: 0; }
form > * + *, .card > .field + .field { margin-top: 14px; }
form > .actions, form > button { margin-top: 18px; }
.grid > .field + .field { margin-top: 0; }

input[type="text"], input[type="password"], input[type="tel"], input[type="number"], input[type="time"], input[type="url"],
input[type="datetime-local"], input[type="date"], input[type="email"], select, textarea {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
textarea { height: auto; min-height: 80px; padding: 7px 9px; resize: vertical; line-height: 1.5; }
select { padding-right: 6px; cursor: pointer; }
input::placeholder, textarea::placeholder { color: #9aa3ad; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9db3d1; outline-offset: 0; border-color: var(--navy); }
input[type="file"] { font: inherit; font-size: 13.5px; }
input[type="checkbox"], input[type="radio"] { width: 15px; height: 15px; accent-color: var(--navy); margin: 0; }

.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.checks label { font-weight: 400; display: flex; gap: 6px; align-items: center; margin: 0; cursor: pointer; }

/* ---------- Buttons ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 3px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--wash); border-color: #a9b1ba; }
button.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
button.primary:hover { background: var(--navy-deep); border-color: var(--navy-deep); }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
button.big { height: 38px; padding: 0 18px; font-size: 14.5px; }
button.small, .btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.savebar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.savebar .hint { margin-right: auto; }

/* ---------- Tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs button { height: 34px; background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 0 14px; margin-bottom: -1px; }
.tabs button:hover { background: none; color: var(--ink); }
.tabs button.active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: var(--wash); border-bottom-color: var(--line-strong); }
tbody tr:last-child td { border-bottom: none; }
tr.error td { background: var(--danger-soft); }
td .hint { font-size: 12.5px; }
.empty { color: var(--muted); text-align: center; padding: 20px 10px !important; }
.row-click { cursor: pointer; }
.row-click:hover td { background: #f0f3f7; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 0 6px; border-radius: 3px; font-size: 12px; font-weight: 600; line-height: 20px; background: var(--wash); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.completed, .badge.uploaded, .badge.resolved { background: var(--ok-soft); color: var(--ok); border-color: #c4dfcc; }
.badge.failed, .badge.missing { background: var(--danger-soft); color: var(--danger); border-color: #f1c7c2; }
.badge.new, .badge.placeholder { background: var(--warn-soft); color: var(--warn); border-color: #ecd9ae; }
.badge.in_progress, .badge.interrupted { background: var(--navy-soft); color: var(--navy); border-color: #c8d4e4; }
.badge.closed, .badge.disabled, .badge.cancelled, .badge.not_sent { color: var(--muted); }
.badge.approved, .badge.sent, .badge.delivered, .badge.read { background: var(--ok-soft); color: var(--ok); border-color: #c4dfcc; }
.badge.pending { background: var(--warn-soft); color: var(--warn); border-color: #ecd9ae; }
.badge.rejected, .badge.failed { background: var(--danger-soft); color: var(--danger); border-color: #f1c7c2; }
.badge.key { font-family: var(--mono); min-width: 24px; text-align: center; background: var(--surface); color: var(--ink); border-color: var(--line-strong); font-size: 13px; }

/* ---------- Lists, notes ---------- */
.msg-card { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.msg-card:last-child { border-bottom: none; padding-bottom: 0; }
.msg-card:first-child { padding-top: 4px; }
.msg-card .who { font-weight: 600; }
.msg-card .body { margin: 4px 0; white-space: pre-wrap; }
.msg-card .meta { color: var(--muted); font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; }
.msg-card .note { border-left: 3px solid var(--line-strong); padding: 2px 10px; font-size: 13.5px; margin-top: 6px; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.warn-box { background: var(--warn-soft); border: 1px solid #ecd9ae; color: #6b4600; border-radius: var(--radius); padding: 9px 14px; margin-bottom: 16px; font-size: 14px; }
.progress { height: 8px; background: var(--wash); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; display: flex; }
.progress > .up { background: var(--ok); }
.progress > .ph { background: #c9962c; }

/* ---------- Transcript ---------- */
.transcript { display: flex; flex-direction: column; max-height: 540px; overflow-y: auto; border-top: 1px solid var(--line); }
.transcript.full { max-height: none; }
.msg { padding: 8px 0 8px 10px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; font-size: 14.5px; }
.msg .who { font-size: 12px; font-weight: 600; color: var(--muted); }
.msg.agent { border-left-color: var(--navy); }
.msg.caller { border-left-color: #c9962c; }
.msg.tool, .msg.system, .msg.ivr { color: var(--muted); font-size: 13px; font-family: var(--mono); }
.msg.partial { opacity: 0.6; }
.msg .cut { color: var(--muted); font-size: 12px; margin-left: 6px; }
.msg .live { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.card-title-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }

/* ---------- Test call ---------- */
.call-status { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.dot.live { background: var(--ok); }
.keypad { display: grid; grid-template-columns: repeat(3, 56px); gap: 6px; justify-content: start; }
.keypad button { height: 44px; padding: 0; font-size: 18px; font-family: var(--mono); }
.keypad button.pressed { background: var(--navy); color: #fff; border-color: var(--navy); }
.menu-view .crumbs { color: var(--muted); font-size: 13px; }
.menu-view .options { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 4px; }
.menu-view .options li { display: flex; gap: 8px; align-items: center; }
.menu-view .now-playing { margin-top: 8px; font-size: 13px; color: var(--muted); }
pre.prompt { white-space: pre-wrap; background: var(--wash); border: 1px solid var(--line); padding: 12px; border-radius: 3px; max-height: 460px; overflow: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; margin: 10px 0 0; }

/* ---------- Menu tree ---------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { margin-left: 14px; padding-left: 16px; border-left: 1px solid var(--line-strong); }
.tree-node { padding: 8px 0; border-bottom: 1px solid var(--line); }
.tree > li:last-child > .tree-node { border-bottom: none; }
.tree-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; }
.tree-row .titles { display: flex; flex-direction: column; }
.tree-row .titles strong { font-weight: 600; }
.tree-row .titles .other { color: var(--ink-2); font-size: 13.5px; }
.tree-row .kind { color: var(--muted); font-size: 12.5px; }
.tree-node.off .titles { opacity: 0.5; }
.tree-root { display: flex; align-items: center; gap: 10px; font-weight: 600; padding-bottom: 6px; }

/* ---------- Recordings ---------- */
.rec-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rec-row:last-child { border-bottom: none; }
.rec-row .lang { font-weight: 600; font-size: 14px; }
.rec-row .lang .hint { display: block; font-weight: 400; }
.rec-row .script { white-space: pre-wrap; color: var(--ink-2); font-size: 14px; }
.rec-row .script.custom::after { content: " (edited)"; color: var(--muted); font-size: 12.5px; }
.rec-row .meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.rec-row .side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.rec-row audio { height: 30px; width: 220px; }
.rec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 18px 0 0; padding-bottom: 4px; border-bottom: 1px solid var(--line-strong); }
.rec-head h3 { margin: 0; font-size: 14px; font-weight: 600; }

/* ---------- Dialog, toast ---------- */
dialog { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); color: var(--ink); background: var(--surface); }
dialog::backdrop { background: rgba(20, 30, 45, 0.4); }
dialog form { padding: 18px 20px; }
dialog h2 { margin-bottom: 12px; font-size: 16px; }
dialog .actions { justify-content: flex-end; margin-top: 18px; }
dialog.wide { width: min(780px, calc(100vw - 32px)); }
dialog.wide form { max-height: calc(100vh - 60px); overflow-y: auto; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-row label, dialog label:has(input[type="radio"]) { display: flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 3px; opacity: 0; transition: opacity 0.15s; pointer-events: none; z-index: 10; font-size: 13.5px; max-width: 420px; }
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }

@media (max-width: 860px) {
  body.with-sidebar { padding-left: 0; }
  .sidebar { position: static; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { border-bottom: none; flex: 1; }
  .brand-sub { display: none; }
  .sidenav { order: 3; flex-basis: 100%; display: flex; overflow-x: auto; padding: 0; }
  .nav-group { display: contents; }
  .nav-heading { display: none; }
  .sidenav a { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .sidenav a.active { border-bottom-color: #fff; }
  .sidebar-foot { border-top: none; }
  main { padding: 16px 16px 60px; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv { grid-template-columns: 1fr; }
  .rec-row { grid-template-columns: 1fr; }
  .rec-row .side { align-items: flex-start; }
  .tree .tree { margin-left: 4px; padding-left: 10px; }
}

/* ---------- Officers: weekly hours and days off ---------- */
.hours-grid { display: grid; gap: 8px; }
.day-row { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: start; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.day-row:last-child { border-bottom: none; }
.day-row .day-name { font-weight: 600; padding-top: 6px; }
.day-ranges { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.range-row, .off-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.range-row input[type="time"] { width: 132px; }
.off-row input[type="date"] { width: 150px; }
.off-row input[type="text"] { width: 240px; max-width: 100%; }
.off-list { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; margin-bottom: 8px; }
.officer-line { margin: 2px 0; }
@media (max-width: 860px) {
  .day-row { grid-template-columns: 1fr; gap: 4px; }
}

.dept-select { width: auto; max-width: 240px; padding: 3px 6px; font-size: 13px; }
.dept-line { color: var(--muted); font-size: 14px; margin-top: 3px; }

/* Dashboard charts */
.card[hidden] { display: none; }
.chart { margin-top: 12px; overflow-x: auto; }
.hbar { display: grid; grid-template-columns: minmax(90px, 40%) 1fr 64px; gap: 10px; align-items: center; padding: 4px 0; font-size: 14px; }
.hbar-track { background: var(--wash); height: 12px; border-radius: 2px; }
.hbar-fill { height: 100%; border-radius: 2px; }
.hbar-num { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.hbar-num span { margin-left: 6px; font-weight: 400; color: var(--muted); font-size: 12px; }
.donut { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut svg { flex: none; }
.legend { list-style: none; margin: 0; padding: 0; font-size: 13px; display: grid; gap: 6px; flex: 1; min-width: 150px; }
.legend li { display: flex; align-items: baseline; gap: 7px; }
.legend .name { flex: 1; }
.legend b { font-variant-numeric: tabular-nums; }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }

/* The Mayor's login only views: hide everything that changes something. */
body.readonly .msg-card .actions button, body.readonly #delete-btn, body.readonly #check-btn { display: none; }
body.readonly .dept-select { pointer-events: none; appearance: none; border-color: transparent; background: none; padding-left: 0; }
.report-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.report-bar select { width: auto; }
@media print { .sidebar, .report-bar, .pager { display: none; } body.with-sidebar { padding-left: 0; } }
body.readonly .msg-card .actions button.mayor-act { display: inline-flex; }
