:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #334155;
  --primary: #2563eb;
  --danger: #dc2626;
  --radius: 12px;
  --gap: clamp(6px, 1.5vmin, 14px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: clamp(13px, 1.6vmin, 16px);
}

.app {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: var(--gap);
}

.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- Top bar ---------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: clamp(6px, 1.4vmin, 12px) var(--gap);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-left strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(220,38,38,.2);
}
.dot.online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: clamp(6px, 1.3vmin, 10px) clamp(10px, 1.8vmin, 16px);
  font-size: inherit;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.1;
  white-space: nowrap;
}
.btn:hover { border-color: #475569; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: #fca5a5; border-color: #7f1d1d; }
.btn.tiny { padding: 4px 8px; border-radius: 8px; font-size: .85em; }

/* ---------- Auth ---------- */
.auth-card {
  max-width: min(420px, 92vw);
  margin: clamp(12px, 6vh, 60px) auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(16px, 3vmin, 28px);
}
.brand { margin: 0 0 4px; font-size: clamp(20px, 3vmin, 28px); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: .9em; color: var(--muted); }
input, select {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: inherit;
}
input[type="color"] { padding: 2px; height: 38px; }
.alert {
  background: #7f1d1d; color: #fff; padding: 10px; border-radius: 10px; margin-bottom: 12px;
}
hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
a { color: #93c5fd; }

/* ---------- Icons ---------- */
.icon { display: inline-flex; }
.icon svg { width: 1em; height: 1em; display: block; }

/* ---------- Nurse: type grid ---------- */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(90px, 22vmin, 150px), 1fr));
  gap: var(--gap);
  align-content: start;
}
.type-btn {
  --c: var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  aspect-ratio: 1 / 1;
  padding: var(--gap);
  border: 2px solid var(--c);
  border-radius: 16px;
  background: color-mix(in srgb, var(--c) 14%, var(--panel));
  color: var(--text);
  cursor: pointer;
  font-size: inherit;
  transition: transform .05s ease;
}
.type-btn:active { transform: scale(.96); }
.type-btn:disabled {
  cursor: not-allowed;
  opacity: .38;
  filter: grayscale(1);
}
.type-btn:disabled:active { transform: none; }

.block-note {
  margin: 0 0 var(--gap);
  padding: 8px 12px;
  border-radius: 10px;
  background: #78350f;
  color: #fde68a;
  border: 1px solid #b45309;
  font-size: .9em;
}
.type-btn .icon { color: var(--c); font-size: clamp(28px, 7vmin, 56px); }
.type-label {
  font-size: clamp(11px, 1.6vmin, 15px);
  text-align: center;
  line-height: 1.15;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------- Nurse: pinned active ---------- */
.pinned {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: var(--gap);
}
/* ONE card look for every notification, every scope (my items and incoming
   alike): a tinted, coloured chip. */
.pin-card {
  --c: var(--primary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  min-height: var(--notif-h, 46px);
  box-sizing: border-box;
  border-radius: 12px;
  background: color-mix(in srgb, var(--c) 16%, var(--panel));
  border: 1px solid var(--c);
  position: relative;
}
.pin-card .icon { color: var(--c); font-size: clamp(20px, 4.5vmin, 34px); }
.pin-body { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.pin-name { font-weight: 600; }
.pin-from { color: var(--c, var(--muted)); font-size: .82em; font-weight: 600; }
.pin-meta { color: var(--muted); font-size: .85em; }
/* Sender-only "who can see this" row: a full-width line along the bottom-left
   of the chip, under all the other content. */
.aud-row {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  margin-top: 1px;
}
.aud-eye { color: var(--muted); display: inline-flex; }
.aud-eye svg { width: 1em; height: 1em; }
.aud-row .aud-eye { font-size: .8em; }
.aud-chip {
  font-size: .58em;
  font-weight: 600;
  line-height: 1.35;
  padding: 0 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 26%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--c) 45%, var(--border));
  color: var(--text);
  white-space: nowrap;
}
.pin-actions { display: flex; gap: 6px; flex: 0 0 auto; }
/* Icon-only button (e.g. delete = bin): keep it compact and square-ish. */
.btn.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 4px 6px; }
.btn.icon-btn .icon { display: inline-flex; }
.btn.icon-btn .icon svg { width: 1.1em; height: 1.1em; }
.pin-wait { font-size: .85em; flex: 0 0 auto; }
.tag-toggles { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.tag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.tag-btn .icon { font-size: 18px; }
.tag-btn:hover { border-color: var(--muted); color: var(--text); }
/* The active (highlighted) fill + readable glyph color are applied inline via
   applyTagHighlight() in board.js, shared with the receiver-side tag badges. */

/* ---------- Doctor board ---------- */
.doctor-board {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  /* Same bottom spacing as `.pinned`, so there is a consistent gap before the
     quick-send grid whether the section above it is "mine" or "incoming". */
  margin-bottom: var(--gap);
}
.empty-board { margin-top: clamp(12px, 8vh, 60px); font-size: clamp(14px, 2.2vmin, 18px); }
.ord-row {
  /* Shared height for the label, notification chips and chain chips in this
     row, so all three rectangles line up. The label and chain chips are squares
     of this size; the chip hugs its content but is at least this tall. Chips
     stay top-aligned so squares keep their shape when chips wrap to more rows. */
  --notif-h: clamp(40px, 7vmin, 54px);
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
}
.outgoing {
  display: flex;
  align-items: stretch;
  gap: var(--gap);
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
}
.outgoing .ord-label { background: transparent; border: 1px solid var(--border); }
.notif-sub { font-size: clamp(9px, 1.3vmin, 12px); }
.outgoing-chip { align-items: center; }
.ord-label {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--notif-h);
  height: var(--notif-h);
  font-weight: 700;
  /* Starting size; fitLabel() in board.js shrinks it per-label so long names
     stay inside the square. */
  font-size: clamp(15px, 3.4vmin, 26px);
  line-height: 1.02;
  text-align: center;
  overflow: hidden;
  word-break: break-word;
  background: var(--panel-2);
  border-radius: 12px;
  padding: 2px;
}
.ord-items {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-content: flex-start;
  align-items: flex-start;
  flex: 1 1 auto;
  min-width: 0;
}
/* Press-and-hold to dismiss: any dismissable `.pin-card` adds `.holdable`, so
   there is ONE implementation for every scope. */
.holdable {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.holdable:hover { background: color-mix(in srgb, var(--c) 28%, var(--panel)); }
/* Keep every child above the fill overlay (which is the one exempt child). */
.holdable > :not(.hold-fill) { position: relative; z-index: 1; }
.holdable.holding { background: color-mix(in srgb, var(--c) 24%, var(--panel)); }
.holdable.holding .hold-cue { opacity: 1; }
.hold-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: color-mix(in srgb, var(--c) 48%, transparent);
  z-index: 0;
  pointer-events: none;
}
.hold-cue {
  margin-left: auto;
  align-self: center;
  font-size: clamp(10px, 1.4vmin, 12px);
  font-weight: 700;
  color: var(--c);
  opacity: .65;
  min-width: 2.4em;
  text-align: right;
}
.forced-badge {
  font-size: .62em; font-weight: 800; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 999px; flex: 0 0 auto; white-space: nowrap;
  background: rgba(220, 38, 38, .18); color: #ef4444;
}
.pin-card.forced {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--c) 55%, var(--border));
}
/* Chain icons and action buttons render OUTSIDE the coloured chip: the chip is
   wrapped in a row and the buttons are pushed to the far-right edge. */
.notif-item { display: flex; align-items: center; gap: 6px; }
.notif-item.has-actions { flex: 1 1 100%; }
.notif-item.has-actions .pin-actions { margin-left: auto; align-self: center; }
.notif-tags { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.notif-tags .tag-icon {
  font-size: clamp(14px, 2.4vmin, 18px);
  padding: 3px;
  border-radius: 6px;
  box-sizing: content-box;
}

/* Follow-up lineage: previous notification icon(s) shown inside the card. */
.chain-arrow { color: var(--muted); font-size: clamp(16px, 3vmin, 24px); line-height: 1; }
.chain-chip {
  --c: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--notif-h, 46px);
  height: var(--notif-h, 46px);
  box-sizing: border-box;
  padding: 0;
  border-radius: 12px;
  background: color-mix(in srgb, var(--c) 16%, var(--panel));
  border: 1px solid var(--c);
}
.chain-chip .chain-icon { color: var(--c); font-size: clamp(18px, 3.6vmin, 28px); }

/* ---------- Send modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
  z-index: 50;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
  width: min(520px, 96vw);
  max-height: 90vh;
  overflow: auto;
}
.send-types {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--gap);
  margin: 10px 0;
}
.target-row { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.type-btn.selected { outline: 3px solid var(--c); outline-offset: 2px; }

/* Doctor "Send" modal: compact tiles with smaller icons (closer to the nurse
   board's icon size) so the picker isn't oversized. */
.send-types { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.send-type { aspect-ratio: auto; padding: 12px 8px; gap: 6px; }
.send-type .icon { font-size: clamp(24px, 5vmin, 32px); }

.send-dests { margin: 12px 0; }
.send-dests-label { display: block; font-size: .82em; color: var(--muted); margin-bottom: 6px; }
.dest-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.dest-btn {
  min-width: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.dest-btn:hover { border-color: var(--muted); }
.dest-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.dest-btn.dest-all { font-weight: 800; }

/* ---------- Admin ---------- */
.admin { display: flex; flex-direction: column; gap: var(--gap); max-width: 1100px; margin: 0 auto; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
}
.panel h2 { margin: 0 0 10px; font-size: clamp(15px, 2.2vmin, 20px); }
.type-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
/* `display: flex` below would otherwise beat the [hidden] UA rule, so a
   filtered-out row must force display:none to actually disappear. */
.type-row[hidden], .tag-row[hidden] { display: none !important; }
.type-row, .tag-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel-2);
  border-radius: 10px;
  padding: 6px 8px;
}
.type-summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.type-toggle {
  display: flex; align-items: center; gap: 8px;
  flex: 1 1 auto; min-width: 0;
  background: none; border: 0; color: var(--text);
  font: inherit; text-align: left; cursor: pointer; padding: 4px 2px;
}
.type-toggle .icon { font-size: 22px; flex: 0 0 auto; }
/* Name on top, direction/inactive badge stacked directly beneath it (aligned
   with the name, not the icon), so a long name just truncates and the badge
   stays put - consistent on desktop and mobile. */
.type-head { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; flex: 1 1 auto; }
.type-summary-name { flex: 1 1 auto; min-width: 0; max-width: 100%; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevron { color: var(--muted); font-size: 18px; line-height: 1; transition: transform .15s ease; flex: 0 0 auto; }
.type-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.type-badges:empty { display: none; }
.type-row:not(.collapsed) .chevron,
.tag-row:not(.collapsed) .chevron { transform: rotate(90deg); }
.type-row.collapsed .type-body,
.tag-row.collapsed .type-body { display: none; }
.dir-badge {
  font-size: .68em; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  white-space: nowrap; flex: 0 0 auto; text-align: center;
  background: rgba(37, 99, 235, .15); color: #2563eb;
}
/* Employee collapsed-row role pill (distinct class so the shared summary-sync
   for notification types never overwrites it). */
.role-badge {
  font-size: .68em; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  white-space: nowrap; flex: 0 0 auto; text-transform: capitalize;
  background: rgba(37, 99, 235, .15); color: #2563eb;
}
/* Employee edit fields: each label stacks over a normally-sized control that
   fills its field. Overrides the type row's `flex: 1 1 120px` on text inputs,
   which otherwise makes them grow TALL inside the column-flex `.field`. */
.user-row .type-edit { align-items: flex-start; }
.user-row .type-edit .field { flex: 1 1 200px; min-width: 0; }
.user-row .type-edit .field input,
.user-row .type-edit .field select { width: 100%; flex: 0 0 auto; }
.scope-badge {
  font-size: .62em; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  white-space: nowrap; flex: 0 0 auto; text-align: center; text-transform: uppercase;
  letter-spacing: .03em;
}
.scope-ord { background: rgba(22, 163, 74, .16); color: #16a34a; }
.scope-bc { background: rgba(217, 119, 6, .16); color: #d97706; }
.place-badge {
  font-size: .62em; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  white-space: nowrap; flex: 0 0 auto; text-align: center; text-transform: uppercase;
  letter-spacing: .03em;
}
.place-quick { background: rgba(37, 99, 235, .15); color: #2563eb; }
.place-modal { background: rgba(100, 116, 139, .18); color: #64748b; }
.fu-badge {
  font-size: .62em; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  white-space: nowrap; flex: 0 0 auto; text-align: center; text-transform: uppercase;
  letter-spacing: .03em; background: rgba(168, 85, 247, .16); color: #a855f7;
}
.force-badge {
  font-size: .62em; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  white-space: nowrap; flex: 0 0 auto; text-align: center; text-transform: uppercase;
  letter-spacing: .03em; background: rgba(220, 38, 38, .16); color: #dc2626;
}
.role-picks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.role-picks .chk { text-transform: capitalize; }
.type-off-badge {
  font-size: .72em; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--panel); color: var(--muted); flex: 0 0 auto;
}
.type-tools { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }
.type-edit { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1 1 auto; }
.type-edit input[type="text"] { width: auto; min-width: 80px; flex: 1 1 120px; }
.type-edit .icon { font-size: 22px; }
.chk { display: inline-flex; align-items: center; gap: 4px; font-size: .85em; color: var(--muted); white-space: nowrap; }
.chk input { width: auto; }

/* Default-tags picker inside a notification type */
.type-tags-field { flex: 1 1 100%; display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.field-label { font-size: .78em; color: var(--muted); }
.tag-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pick {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 6px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--muted); cursor: pointer; font-size: .82em;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.tag-pick input { width: auto; margin: 0; }
.tag-pick .icon { font-size: 16px; color: var(--tagc, var(--muted)); }
.tag-pick:has(input:checked) {
  border-color: var(--tagc, var(--accent));
  color: var(--text);
  background: color-mix(in srgb, var(--tagc, #2563eb) 14%, transparent);
}
.grid-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.grid-form input, .grid-form select { width: auto; flex: 1 1 140px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: flex-end; }
.inline-form input, .inline-form select { width: auto; flex: 0 1 auto; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: .82em; color: var(--muted); }
.field input { width: auto; }
.add-block { margin-top: 10px; }
.add-block summary { cursor: pointer; color: var(--muted); }
.hint { margin: 8px 0; font-size: .82em; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.panel-head h2 { margin: 0; }
/* Keep the header (with the Save button) in view while scrolling a long panel.
   The scroll container is `.content`, so sticky is relative to it. Negative
   margins + matching padding make the sticky bar full-bleed within the panel. */
.panel-head.sticky-head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--panel);
  margin: calc(-1 * var(--gap)) calc(-1 * var(--gap)) 10px;
  padding: var(--gap) var(--gap) 10px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.panel-actions { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.save-status { font-size: .85em; color: var(--muted); min-height: 1em; }
.save-status.ok { color: #16a34a; }
.save-status.err { color: #dc2626; }

.icon-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.icon-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  transition: border-color .12s ease, transform .12s ease;
}
.icon-cell:hover { border-color: var(--accent, #2563eb); transform: translateY(-1px); }
.icon-cell.selected { border-color: var(--accent, #2563eb); box-shadow: 0 0 0 1px var(--accent, #2563eb) inset; }
.icon-cell .icon { font-size: 24px; }
.icon-cell-name { font-size: .72em; color: var(--muted); word-break: break-word; text-align: center; }

.icon-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  color: inherit;
  cursor: pointer;
  transition: border-color .12s ease;
}
.icon-pick:hover { border-color: var(--accent, #2563eb); }
.icon-pick .icon { font-size: 22px; }

/* ---------- Sound picker (admin) ---------- */
.sound-picks { display: flex; flex-direction: column; gap: 6px; }
.sound-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sound-label { min-width: 68px; color: var(--muted); font-size: .85em; }
.sound-pick { min-width: 64px; text-transform: capitalize; }
.sound-interval { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .85em; }
.sound-interval input { width: 64px; }
.sound-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.sound-cell {
  padding: 10px 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  text-transform: capitalize;
  font-weight: 600;
  transition: border-color .12s ease, transform .12s ease;
}
.sound-cell:hover { border-color: var(--accent, #2563eb); transform: translateY(-1px); }
.sound-cell.selected { border-color: var(--accent, #2563eb); box-shadow: 0 0 0 1px var(--accent, #2563eb) inset; }

/* Board mute toggle: highlight in red when muted. */
#mute-toggle.on,
#split-mute-toggle.on { color: var(--danger, #ef4444); border-color: currentColor; }
/* Split header: title on the left, mute + close grouped on the right. */
.split-title { flex: 1 1 auto; min-width: 0; }
.split-head-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Drag-to-reorder grip handle on type/tag rows. */
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  cursor: grab;
  border-radius: 8px;
  user-select: none;
  touch-action: none;
}
.drag-handle:hover { color: var(--text); background: var(--panel-2); }
.drag-handle:active { cursor: grabbing; }
.type-row.dragging,
.tag-row.dragging {
  opacity: 0.55;
  outline: 2px dashed var(--accent, #2563eb);
  outline-offset: -2px;
}

/* Per-role reorder selector in the Notification types panel head. */
.reorder-role-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .82em;
  color: var(--muted);
  text-transform: capitalize;
}
.reorder-role-label select { text-transform: capitalize; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.chips, .assign-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .assign-list li {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); border-radius: 999px; padding: 4px 10px;
}
.chip-x { background: none; border: none; color: #fca5a5; cursor: pointer; font-size: 16px; line-height: 1; padding: 0; }
.chip form, .assign-list form { display: inline; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: .9em; }
.tbl th { color: var(--muted); font-weight: 600; }
.tbl td input, .tbl td select { padding: 6px 8px; font-size: .95em; min-width: 90px; }
.tbl td input[type="text"], .tbl td input[type="email"], .tbl td input[type="password"] { min-width: 120px; }
.row-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.row-actions form { display: inline; }

/* ---------- Super-admin banner ---------- */
.super-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 6px 14px; font-size: .88em;
  background: rgba(220, 38, 38, .12);
  color: #b91c1c; border-bottom: 1px solid rgba(220, 38, 38, .3);
}
.super-banner form { display: inline; margin-left: auto; }

/* Create-clinic form: normal-height fields laid out in a wrapping row. */
.clinic-create { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.clinic-create .field { flex: 1 1 180px; min-width: 0; }
.clinic-create .field input { width: 100%; flex: 0 0 auto; }
.clinic-create > .btn { flex: 0 0 auto; }

/* ---------- Switch-view modal ---------- */
.view-groups { display: flex; flex-direction: column; gap: 12px; margin: 8px 0; }
.view-group { display: flex; flex-direction: column; gap: 6px; }
.view-group-label {
  font-size: .72em; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted);
}
.view-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.view-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); color: var(--text); text-decoration: none;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
  font-size: .95em;
}
.view-btn:hover { border-color: var(--primary); }
.view-btn.current { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 16%, var(--panel)); }
.ro-badge {
  font-size: .7em; font-weight: 700; padding: 1px 6px; border-radius: 999px;
  background: rgba(100, 116, 139, .2); color: var(--muted);
}

/* ---------- Split screen ---------- */
.split-picker {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.split-picker-title { margin: 0 0 6px; font-size: 1em; }

/* When splitting, `.content-inner` fills the scroll area and stacks two panes
   at half height each; each pane scrolls its own overflow. Without `.split`
   it's a plain wrapper and the board flows normally. */
.content-inner.split {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.content-inner.split .board-pane {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
}
.content-inner.split .split-pane {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.split-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.split-title {
  font-weight: 600;
  font-size: .9em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: auto;
}
.split-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 0;
  display: block;
}

/* ---------- Collapsible panel ---------- */
.panel-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.panel-toggle h2 { margin: 0; }
.panel-toggle .chevron {
  display: inline-block;
  transition: transform .15s ease;
  font-size: 1.3em;
  line-height: 1;
  color: var(--muted);
}
.panel:not(.collapsed) .panel-toggle .chevron { transform: rotate(90deg); }
.panel.collapsed .panel-body { display: none; }
/* A collapsed panel hides its body AND its header actions (Save changes,
   Expand all, filters, refresh, etc.) - only the title/toggle stays visible. */
.panel.collapsed .panel-head .panel-actions { display: none; }

/* ---------- Diagnostics ---------- */
.diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.diag-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--panel) 70%, var(--bg));
}
.diag-card h3 { margin: 0 0 6px; font-size: .95em; }
/* Super-admin usage KPIs + capacity bar. */
.diag-card.kpi { text-align: center; }
.kpi-big {
  font-size: 2em;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { font-size: .8em; margin: 4px 0 0; }
.cap-bar {
  height: 10px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 60%, var(--bg));
  border: 1px solid var(--border);
  overflow: hidden;
  margin: 4px 0 8px;
}
.cap-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: #22c55e;
  transition: width .4s ease;
}
.cap-bar > span.warn { background: #eab308; }
.cap-bar > span.danger { background: #ef4444; }
/* machine-vs-app usage rows (label | bar | value) */
.usage-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.usage-row .usage-k { flex: 0 0 58px; color: var(--muted); font-size: .8em; }
.usage-row .cap-bar { flex: 1 1 auto; margin: 0; }
.usage-row .usage-v {
  flex: 0 0 auto; min-width: 44px; text-align: right;
  font-size: .85em; font-variant-numeric: tabular-nums;
}
.diag-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  margin: 0;
}
.diag-dl dt { color: var(--muted); font-size: .85em; }
.diag-dl dd { margin: 0; font-size: .85em; text-align: right; font-variant-numeric: tabular-nums; }
.diag-dl dd.diag-path {
  text-align: left; word-break: break-all; font-family: ui-monospace, monospace; font-size: .75em;
}
.diag-subhead { margin: 16px 0 4px; font-size: .95em; }
.diag-logs-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-top: 16px;
}
.diag-console {
  margin: 6px 0 0;
  max-height: 320px;
  overflow: auto;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78em;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* ---------- Narrow / corner overlay ---------- */
@media (max-width: 420px) {
  .topbar { flex-wrap: wrap; }
  .type-label { -webkit-line-clamp: 3; }
}
