/* Nivas 5 — dark design system.
   Loaded after the legacy stylesheets so it owns the shared primitives:
   surfaces, typography, controls, status colours, focus states and the
   day-grouped list layout. Page-specific rules stay in their own files. */

:root {
  /* Surfaces */
  --bg: #15171b;
  --bg-elevated: #1c2025;
  --surface: #1c2025;
  --surface-2: #20232c;
  --surface-3: #23272d;
  --surface-inset: #15181c;

  /* Lines */
  --line: #2a2e35;
  --line-strong: #343a42;
  --line-soft: #23272d;

  /* Text */
  --text: #f2eee9;
  --text-bright: #e4e0da;
  --text-soft: #c9c4bd;
  --text-muted: #8d8780;
  --text-dim: #6f6a63;
  --text-on-accent: #fff;

  /* Mode identity */
  --accent: #6a63d8;
  --accent-strong: #b7b2f5;
  --accent-text: #c3bffa;
  --accent-deep: #2b2f4a;
  --accent-soft: #282a45;
  --accent-line: #3b3d63;
  --mode-accent: var(--accent);
  --mode-strong: var(--accent-strong);
  --mode-text: var(--accent-text);
  --mode-soft: var(--accent-soft);
  --mode-line: var(--accent-line);
  --mode-deep: var(--accent-deep);

  /* Status palette — the same hues the status scale uses. */
  --ok: #3f9e68;
  --ok-soft: #13301f;
  --warn: #d16890;
  --warn-soft: #38202c;
  --danger: #c0554b;
  --danger-text: #ef9a90;
  --danger-soft: #331919;
  --danger-line: #4e2723;
  --info: #8fa3c4;
  --info-soft: #242b36;
  --neutral-soft: #23272d;

  /* Shape */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-card: 11px;
  --radius-pill: 999px;
  --shadow: 0 6px 22px rgba(0, 0, 0, .38);
  --shadow-lg: 0 18px 46px rgba(0, 0, 0, .5);
  --focus: 0 0 0 3px rgba(106, 99, 216, .5);

  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Numbers, timestamps, phone numbers and the small tracking-letter labels are
   set in the mono face, which is what gives the design its instrument-panel
   read. */
.mono,
.public-request-number,
.card-when,
.stat-tile strong,
.day-group__header .day-date { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }

/* The technician mode re-points the accent so every accented control,
   pill and focus ring follows the active work mode. The design plan only
   specifies the admin purple; technician reuses the „Насрочена“ teal, which
   is the one hue in the scale that reads as the field-work colour. */
body.mode-technician {
  --mode-accent: #17a08f;
  --mode-strong: #7fc9bb;
  --mode-text: #7fc9bb;
  --mode-soft: #12312c;
  --mode-line: #1e4a43;
  --mode-deep: #123a34;
  --focus: 0 0 0 3px rgba(23, 160, 143, .5);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

::selection { background: rgba(63, 157, 242, .32); }

* { scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--radius-pill); }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- typography */

h1 { font-size: 25px; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; margin: 4px 0 0; color: var(--text); display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 6px; color: var(--text); }
h3 { font-size: 15px; font-weight: 600; color: var(--text); }
p { color: var(--text); }
small, .muted { color: var(--text-muted); }
a { color: var(--accent-strong); }

/* The eyebrow is a quiet tracking label, not a second accent. */
.eyebrow {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin: 0;
}

.request-count {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--mode-text);
  background: var(--mode-soft);
  border: 1px solid var(--mode-line);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
}

/* The approved screen is drawn at 1780px; the card grid is proportioned for
   it, so the shell opens up to match instead of staying at the old 1120px. */
:root { --page-max: 1780px; }

.page { max-width: var(--page-max); padding: 18px 26px 72px; }

.heading-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 13px;
  padding-bottom: 0;
  border-bottom: 0;
}

/* ------------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--bg-elevated);
  color: var(--text);
  border-bottom: 1px solid var(--line);
  /* The 3px rule along the top edge is the whole mode signal. */
  border-top: 3px solid var(--mode-accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  padding: 0 max(20px, calc((100% - var(--page-max)) / 2));
}

.topbar--admin, .topbar--technician { box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }

.topbar-brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; display: block; }
.topbar strong { font-size: 14px; font-weight: 600; letter-spacing: .06em; color: var(--text); }

.top-actions > a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
}
.top-actions > a:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }
.top-actions > a.active,
.top-actions > a[aria-current="page"] {
  color: #fff;
  background: var(--mode-deep);
  font-weight: 600;
  text-decoration: none;
}

/* Бялото кръгче с броя непрочетени сяда горе върху бутона „Съобщения“.
   Пръстенът пулсира тихо, за да се хване с крайчеца на окото, без да мига. */
.nav-badge {
  display: inline-block;
  position: relative;
  min-width: 17px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: #fff;
  color: var(--mode-deep);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  vertical-align: 5px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .3);
}
.nav-badge[hidden] { display: none; }
.nav-badge::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 2px solid #fff;
  border-radius: var(--radius-pill);
  animation: nav-badge-pulse 2.2s ease-out infinite;
  pointer-events: none;
}
.nav-badge.is-new { animation: nav-badge-pop .5s ease-out; }

@keyframes nav-badge-pulse {
  0% { opacity: .8; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(1.6); }
}
@keyframes nav-badge-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.5); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .nav-badge.is-new { animation: none; }
  .nav-badge::after { animation: none; opacity: .5; transform: scale(1); }
}

/* Reads as one more nav item, not a raised button. */
.settings-toggle {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  min-height: 0;
}
.settings-toggle:hover,
.settings-toggle:focus,
.settings-toggle.active,
.settings-toggle[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }
.topbar--technician .settings-toggle:hover,
.topbar--technician .settings-toggle:focus,
.topbar--technician .settings-toggle.active,
.topbar--technician .settings-toggle[aria-expanded="true"] { color: var(--text); }

.settings-dropdown {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
}
.top-actions .settings-dropdown a { color: var(--text-muted); }
.top-actions .settings-dropdown a:hover,
.top-actions .settings-dropdown a:focus,
.top-actions .settings-dropdown a.active { background: var(--surface-3); color: var(--text); }
.settings-logout { border-top-color: var(--line); color: var(--text-muted); }
.settings-logout:hover, .settings-logout:focus-visible { background: var(--surface-3); color: var(--text); }

/* Segmented control: both modes are visible, the active one is filled, so the
   current mode is legible without reading the button label as an action. */
.mode-switch {
  display: flex;
  gap: 3px;
  background: var(--surface-inset);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 3px;
}
.mode-switch button {
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  min-height: 0;
  cursor: pointer;
  white-space: nowrap;
}
.mode-switch button:hover { color: var(--text); }
.mode-switch button.is-active { background: var(--mode-accent); color: #fff; cursor: default; }

/* -------------------------------------------------------- surfaces and cards */

.panel,
.visit-card,
.inbox-message,
.archive-row,
.kpi-card,
.technician-task,
.request-card,
.user-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
}

.panel { padding: 18px; }
.panel + .panel { margin-top: 14px; }

.kpi-card { background: var(--surface); border-top-width: 3px; }
.kpi-card strong { color: var(--text); }
.kpi-card span, .kpi-card small { color: var(--text-muted); }

.empty {
  border: 1px dashed var(--line-strong);
  background: var(--surface-inset);
  color: var(--text-muted);
  border-radius: var(--radius);
}
.empty strong { color: var(--text); }

/* -------------------------------------------------------------- form controls */

label { color: var(--text); font-size: 14px; }

input, textarea, select {
  background: var(--surface-inset);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  min-height: 44px;
}
textarea { min-height: 76px; }
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:hover, textarea:hover, select:hover { border-color: #3e4f61; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--mode-accent);
  box-shadow: var(--focus);
}
select option { background: var(--surface-2); color: var(--text); }
input[type="checkbox"], input[type="radio"] { min-height: 0; accent-color: var(--mode-accent); }
input[type="date"], input[type="time"], input[type="datetime-local"] { color-scheme: dark; }

.primary {
  background: var(--mode-accent);
  color: var(--text-on-accent);
  border-radius: var(--radius-sm);
  font-weight: 800;
  min-height: 44px;
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .5; cursor: not-allowed; }

.secondary,
.status-action,
.task-actions a,
.task-actions button {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
}
.secondary:hover,
.status-action:hover,
.task-actions a:hover,
.task-actions button:hover { background: var(--surface-3); border-color: var(--mode-accent); }

.danger-primary { background: var(--danger); color: #1a0709; }
.cancel-button { background: transparent; border-color: var(--danger); color: var(--danger); }
.cancel-button:hover { background: var(--danger-soft); }

/* One visible, consistent keyboard focus treatment across the whole app. */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible,
.request-card:focus-visible,
.archive-row:focus-visible,
.schedule-event:focus-visible {
  outline: 2px solid var(--mode-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.top-actions > a:focus-visible { outline-offset: -2px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  padding: 12px 18px;
  background: var(--mode-accent);
  color: var(--text-on-accent);
  font-weight: 800;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* --------------------------------------------------------------------- pills */

.status-pill,
.read-state,
.status,
.import-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--neutral-soft);
  color: var(--text-muted) !important;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .02em;
  border: 1px solid transparent;
}

/* Status tones live in request-statuses.css so the status scale has one home. */

/* „Спешно“ keeps a loud colour of its own next to the address. */
.urgent-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: #38202c !important;
  color: #f0a3c3 !important;
  border: 1px solid #54313f !important;
  font-size: 11px;
  font-weight: 600;
}
/* Срокът на спешната услуга се чете от етикета, за да триажираш с един поглед. */
.urgent-pill--missed { background: var(--warn-soft) !important; color: var(--warn) !important; border-color: rgba(209, 104, 144, .4) !important; }
.urgent-pill--delivered { background: var(--ok-soft) !important; color: var(--ok) !important; border-color: rgba(63, 158, 104, .4) !important; }

.customer-state-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--neutral-soft);
  border: 1px dashed var(--line-strong);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
}

.status { margin-top: 6px !important; }

/* --------------------------------------------- header stat tiles (variant 3a) */

.stat-tiles { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }

.stat-tile {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 7px 11px;
  min-width: 108px;
}
.stat-tile > span { display: block; font-size: 10px; letter-spacing: .02em; color: var(--text-muted); }
.stat-tile strong { display: block; margin-top: 2px; font-size: 16px; font-weight: 600; color: var(--text); }
.stat-tile--wide { min-width: 126px; }

/* The service load keeps the accent so it reads as the one tile that is a
   setting rather than a measurement. */
.stat-tile--load {
  border-color: var(--mode-line);
  background: var(--mode-soft);
  min-width: 168px;
}
.stat-tile--load > span, .stat-tile--load summary { color: var(--mode-text); }
.stat-tile--load strong { color: var(--mode-text); font-size: 11px; }
.load-meter { display: flex; gap: 3px; margin-top: 6px; }
.load-meter i { flex: 1; height: 4px; border-radius: 3px; background: var(--line-strong); }
.load-meter i.is-on { background: var(--mode-accent); }
.stat-tile--load .load-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-tile--load .load-label { display: block; margin-top: 4px; font-size: 10px; color: var(--mode-text); }
.stat-tile--load summary { font-size: 10px; cursor: pointer; list-style: none; }
.stat-tile--load summary::-webkit-details-marker { display: none; }
.stat-tile--load form { margin-top: 8px; display: grid; gap: 6px; }
.stat-tile--load p { font-size: 11px; color: var(--text-soft); margin: 6px 0 0; }

/* ---------------------------------------------------- tabs and filter chips */

.request-tabs a,
.task-periods a,
.period-presets a,
.schedule-view-switch a {
  background: var(--surface-3);
  border: 1px solid transparent;
  color: #bdb8b0;
  font-size: 12px;
  font-weight: 600;
}
.request-tabs a:hover,
.task-periods a:hover,
.period-presets a:hover { background: var(--surface-3); color: #fff; }
.request-tabs a.active,
.task-periods a.active,
.period-presets a.active,
.schedule-view-switch a.active {
  background: var(--mode-accent);
  border-color: var(--mode-accent);
  color: #fff;
}
.request-tabs .chip-count { opacity: .72; font-weight: 600; }

/* The filter row is one bar: chips left, search right. */
.request-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.request-filter .request-tabs { display: flex; gap: 5px; flex-wrap: wrap; padding: 0; }
.request-search { display: flex; gap: 7px; margin-left: auto; flex: 1; max-width: 620px; }
.request-search input { flex: 1; min-height: 40px; font-size: 13px; }
.request-search select { width: 170px; min-height: 40px; font-size: 13px; }
.request-search .primary { min-height: 40px; padding: 10px 18px; font-size: 13px; font-weight: 600; }

/* -------------------------------------------------- day grouping (lists) */

.day-group + .day-group { margin-top: 22px; }

.day-group__header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  padding: 0 2px 8px;
  border-bottom: 1px solid var(--line);
}
/* „Днес · 16 август 2026 г. · 3 заявки“ — one accent-tinted weekday, then the
   date and the count stepping down in weight, the same shape the technician
   task list uses. */
.day-group__header strong { font-size: 16px; font-weight: 600; color: var(--mode-text); letter-spacing: 0; }
.day-group__header span { color: var(--text-muted); font-size: 12px; }
.day-group__header .day-count { color: var(--text-dim); font-size: 12px; }
.day-group__header .day-relative {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--mode-soft);
  border: 1px solid var(--mode-line);
  color: var(--mode-text);
  font-size: 11px;
  font-weight: 600;
}

/* legacy technician day headers reuse the same language */
.task-day-header { padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.task-day-header strong { font-size: 15px !important; }
.task-day-group + .task-day-group { border-top: 0; padding-top: 0; margin-top: 22px; }

/* ------------------------------------------------------------ request cards */

.request-list { display: flex; flex-direction: column; gap: 8px; }

/* Variant 3a card: a 4px status stripe, the address-led block, what the
   customer currently sees, the status pill, then when it arrived and whose
   it is. The address leads because that is what the dispatcher scans for. */
.request-card {
  display: grid;
  grid-template-columns: 4px minmax(0, 1.5fr) minmax(0, .85fr) 210px 118px;
  gap: 16px;
  align-items: center;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color .12s ease, background .12s ease;
}
.request-card:hover { border-color: #4b4d78; background: var(--surface-2); }
body.mode-technician .request-card:hover { border-color: #2c6b62; }

.card-stripe { align-self: stretch; display: block; }

.card-main { padding: 11px 0; min-width: 0; }

.card-head { display: flex; align-items: center; gap: 9px; }

.card-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  text-wrap: pretty;
}

.card-service {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin: 6px 0 0;
  font-size: 13px;
}
.card-service b { font-weight: 600; color: var(--text-bright); white-space: nowrap; }
.card-service span { color: var(--text-soft); white-space: nowrap; }
.card-service .sep { color: var(--text-dim); }

/* Name and phone sit last and smallest — present, never competing with the
   address. */
.card-facts {
  display: block;
  margin: 6px 0 0 !important;
  color: var(--text-muted) !important;
  font-size: 12px;
}
.card-facts .sep { color: var(--text-dim); }

.card-customer {
  min-width: 0;
  padding: 11px 0 11px 16px;
  border-left: 1px solid var(--line);
}
.card-customer .card-label {
  display: block;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--text-dim);
}
.card-customer .card-customer-state {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: #b9b4ac;
}

.request-card .status-pill { justify-self: start; }

.request-card-meta { padding-right: 16px; text-align: right; }
.card-when {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-bright);
  font-variant-numeric: tabular-nums;
}
.card-owner { display: block; margin-top: 3px; font-size: 11px; color: var(--text-muted); }

/* The design's 3a card drops the request number, but search offers „Номер“ and
   the customer quotes it on the phone, so it stays — as the quietest thing on
   the card, well below the address in the hierarchy. */
.card-ref {
  display: block;
  margin-top: 2px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--text-dim);
}

.urgent-pill { flex: none; }

/* ---------------------------------------------------------- technician tasks */

.technician-task { padding: 15px 16px; border-left-width: 3px; }

/* The task card still lists its facts as separate spans, so it keeps the
   spaced-row treatment; the request card writes them as one sentence. */
.technician-task .card-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.technician-task .card-facts b { color: var(--text-bright); font-weight: 600; }
.technician-task .card-units {
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.technician-task:hover { background: var(--surface-2); }
.technician-task > a { color: var(--text); }
.technician-task time strong { color: var(--mode-accent); font-size: 21px; font-variant-numeric: tabular-nums; }
.technician-task time span { color: var(--text-dim); font-size: 12.5px; }
.technician-task h2 { font-size: 16.5px; margin: 4px 0 2px; }
.technician-task small { color: var(--text-muted); }
.task-actions { border-top-color: var(--line); }
.task-actions .task-start {
  background: var(--ok);
  border-color: var(--ok);
  color: #06170f;
  font-weight: 800;
}
.task-actions .task-start:hover { filter: brightness(1.08); }

.work-timer { color: var(--ok) !important; font-weight: 750; font-variant-numeric: tabular-nums; }

.timer-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  background: var(--ok-soft);
  border: 1px solid rgba(64, 207, 141, .35);
  color: var(--ok);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.timer-live::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
  animation: timer-pulse 1.6s ease-in-out infinite;
}
@keyframes timer-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .timer-live::before { animation: none; } }

.work-start-confirm { background: var(--ok); color: #06170f; }
.work-start-dialog, .status-confirm-dialog, dialog {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(4, 8, 13, .78); }
.close { color: var(--text-muted); }
.close:hover { color: var(--text); }

/* --------------------------------------------------------------- data blocks */

.request-details > div,
.summary-lines,
.totals-card,
.quality-grid div,
.raw-request pre {
  background: var(--surface-inset);
  border-color: var(--line);
}
.request-details dt { color: var(--text-dim); }
.request-details dd { color: var(--text); }
.request-details dd a { color: var(--accent-strong); }

.analytics-table th, .analytics-table td { border-bottom-color: var(--line); }
.analytics-table thead th { color: var(--text-dim); }
.compact-list > div, .history-row, .archive-unit > div, .timeline-event, .dashboard-unpaid-row { border-top-color: var(--line); }

.alert {
  background: var(--warn-soft);
  color: #f2c887;
  border: 1px solid rgba(232, 173, 72, .3);
  border-radius: var(--radius-sm);
}
.alert.error { background: var(--danger-soft); color: #ff9a95; border-color: rgba(242, 112, 106, .34); }
.alert.success { background: var(--ok-soft); color: #7fe0b4; border-color: rgba(64, 207, 141, .3); }

/* -------------------------------------------------------------------- chat */

.request-chat .message-incoming { background: var(--surface-2); border: 1px solid var(--line); }
.request-chat .message-outgoing { background: rgba(63, 157, 242, .13); border: 1px solid var(--accent-line); }
.request-chat .message.unread { border-color: var(--mode-accent); box-shadow: 0 0 0 1px var(--mode-accent); }
.request-chat .message strong { color: var(--text); font-size: 12.5px; }
.request-chat .message small { color: var(--text-dim); }
.closed-chat-notice { background: var(--surface-inset); color: var(--text-muted); border: 1px solid var(--line); }
.inbox-message.unread { background: var(--surface-2); border-left: 3px solid var(--mode-accent); }
.attachment-picker { border-color: var(--line-strong); color: var(--text-muted); background: var(--surface-2); }
.attachment-picker:hover { color: var(--text); border-color: var(--mode-accent); }
.selected-file { background: var(--surface-inset); }

/* ------------------------------------------------------------------ schedule */

.schedule-day-heading { background: var(--surface-2); border-color: var(--line); color: var(--text-muted); }
.schedule-day-heading.today { background: var(--mode-soft); color: var(--mode-accent); }
.schedule-day-column { background: var(--surface); border-color: var(--line); }
.schedule-time-corner, .schedule-hour { color: var(--text-dim); }
.schedule-now-line { background: var(--danger); }

/* --------------------------------------------------------- public status page */

.customer-status-page { background: var(--bg); }
.customer-brand {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -2px 0 var(--accent-deep);
  color: var(--text);
}
.customer-brand strong { color: var(--text); }
.customer-brand span, .customer-brand a { color: var(--text-muted); }
.status-hero {
  background: linear-gradient(140deg, #16324e, #123a5f);
  border: 1px solid var(--accent-line);
  color: var(--text);
  box-shadow: var(--shadow);
}
.status-hero .eyebrow { color: var(--accent-strong); }
.status-hero.status-parking,
.status-hero.status-delay_15,
.status-hero.status-delay_30,
.status-hero.status-delay_60 { background: linear-gradient(140deg, #3d2c12, #4d3512); border-color: rgba(232, 173, 72, .4); }
.status-hero.status-cancelled_customer,
.status-hero.status-cancelled_service { background: linear-gradient(140deg, #3d1b1c, #4d2224); border-color: rgba(242, 112, 106, .4); }
.status-hero.status-completed { background: linear-gradient(140deg, #103528, #0f4030); border-color: rgba(64, 207, 141, .38); }
.visit-countdown { background: rgba(255, 255, 255, .05); border: 1px solid var(--line-strong); }
.live-age { border-top-color: var(--line-strong); }
.timeline-event i { background: var(--mode-accent); box-shadow: 0 0 0 4px var(--mode-soft); }
.status-scale__segment { background: var(--surface-3); }
.status-scale__segment.is-active { background: var(--mode-accent); }
.status-shell footer { color: var(--text-dim); border-top: 1px solid var(--line); padding-top: 20px; }

/* --------------------------------------------------------------- PDF preview */

.pdf-preview-panel { background: var(--surface-inset); border: 1px solid var(--line); }
.sticky-actions { background: var(--surface-2); border-color: var(--line-strong); box-shadow: var(--shadow-lg); }

/* ------------------------------------------------------- list chrome and meta */

.list-summary {
  margin: 0 0 14px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.day-relative {
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--mode-soft);
  color: var(--mode-accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.request-count {
  background: var(--info-soft);
  color: var(--info);
  border: 1px solid rgba(90, 169, 245, .3);
  font-weight: 800;
  font-size: 12.5px;
  vertical-align: 3px;
}

.top-actions > a.has-unread { color: #fff; font-weight: 700; }

.service-load-control { min-width: 260px; }
.service-load-control > summary {
  cursor: pointer;
  padding: 9px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  list-style: none;
}
.service-load-control > summary::-webkit-details-marker { display: none; }
.service-load-control > summary:hover { color: var(--text); border-color: var(--mode-accent); }
.service-load-control > div {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.service-load-control p { color: var(--text-muted); font-size: 13px; margin-top: 0; }

/* Статус на сервиза — второто каре-настройка до натовареността. Държи се
   като нея (details/popover), но носи тона на състоянието, за да се вижда от
   един поглед дали публичното съобщение е живо. */
.service-status-control { min-width: 168px; }
/* Разгънато карето става работна форма, а не тясна плочка. */
.service-status-control[open] { flex: 1 1 320px; min-width: 280px; }
.service-status-control .status-state {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 700;
  color: var(--mode-text);
}
.service-status-control.state-active {
  border-color: rgba(209, 104, 144, .38);
  background: var(--warn-soft);
}
.service-status-control.state-active > summary,
.service-status-control.state-active .status-state,
.service-status-control.state-active .load-label,
.service-status-control.state-active > summary > span > span { color: var(--warn); }
.service-status-control.state-expired .status-state,
.service-status-control.state-upcoming .status-state { color: var(--text-muted); }
.service-status-control .service-status-flag {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.45;
}
.service-status-control.state-expired .service-status-flag {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger-text);
}
.service-status-control .service-status-form { display: grid; gap: 10px; margin-top: 0; }
.service-status-modes { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.service-status-modes legend { padding: 0 0 5px; font-size: 11px; color: var(--text-muted); }
/* Двата режима са избираеми редове, а не голи radio-та: глобалното
   `input { width: 100% }` разтяга кръгчето през целия ред, затова тук то се
   връща към собствения си размер — както при `.eta-choice`. */
.service-status-modes label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.service-status-modes label:hover { border-color: var(--mode-accent); }
.service-status-modes label:has(input:checked) {
  border-color: var(--mode-accent);
  background: var(--mode-soft);
  color: var(--mode-text);
}
.service-status-modes label:has(input:focus-visible) { box-shadow: var(--focus); }
.service-status-modes input {
  width: 16px;
  height: 16px;
  flex: none;
  min-height: 0;
  margin: 0;
  accent-color: var(--mode-accent);
}
.service-status-fields { display: grid; gap: 6px; }
.service-status-fields[hidden] { display: none; }
.service-status-fields label { font-size: 11px; color: var(--text-muted); }
.service-status-fields small { color: var(--text-dim); font-size: 11px; line-height: 1.45; }
.service-status-dates { display: flex; gap: 8px; flex-wrap: wrap; }
.service-status-dates > span { flex: 1 1 130px; display: grid; gap: 4px; min-width: 0; }
.service-status-dates input { width: 100%; }
.service-status-notice { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12px; color: var(--text-soft); }
.service-status-notice input { width: 72px; flex: none; }
.service-status-notice small { color: var(--text-dim); font-size: 11px; }

.heading-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.request-headline { margin: 8px 0 0; color: var(--text-muted); font-size: 14px; }

.request-summary .status-heading { flex-wrap: wrap; gap: 10px; justify-content: flex-start; }
.request-summary .customer-state-line { margin: 12px 0 0; }
.request-summary .request-details { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.request-summary .detail-district { grid-column: span 2; }
.request-summary .detail-address { grid-column: span 7; }
.request-summary .detail-customer { grid-column: span 3; }
.request-summary .detail-brand,
.request-summary .detail-unit-count,
.request-summary .detail-unit-age { grid-column: span 4; }
.request-summary .detail-service { grid-column: span 5; }
.request-summary .detail-phone { grid-column: span 3; }
.request-summary .detail-email { grid-column: span 4; }
.request-summary .detail-received,
.request-summary .detail-technician,
.request-summary .detail-eta,
.request-summary .detail-confirmation,
.request-summary .detail-activity { grid-column: span 3; }
.completion-summary p { margin: 6px 0; color: var(--text-muted); }

/* Ново посещение по приключена заявка — връзката между старата и новата. */
.follow-up-panel .muted { margin: 0 0 12px; line-height: 1.55; }
.follow-up-panel form { margin: 0; }
.follow-up-existing, .follow-up-origin {
  margin: 0 0 12px;
  padding: 9px 11px;
  border: 1px solid var(--mode-line);
  border-radius: var(--radius-sm);
  background: var(--mode-soft);
  color: var(--mode-text);
  font-size: 13px;
  line-height: 1.5;
}
.follow-up-existing a, .follow-up-origin a {
  color: inherit;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 600;
}
.completion-summary strong { color: var(--text); }

.status.paid { background: var(--ok-soft); color: var(--ok) !important; border-color: rgba(64, 207, 141, .3); }
.status.unpaid { background: var(--warn-soft); color: var(--warn) !important; border-color: rgba(232, 173, 72, .3); }

.archive-row:hover { background: var(--surface-2); border-color: var(--mode-accent); }
.archive-row strong { color: var(--text); }
.archive-money strong { color: var(--text); font-size: 17px; font-variant-numeric: tabular-nums; }

.inbox-message h2 { font-size: 16px; }
.inbox-message:hover { border-color: var(--line-strong); }

.archive-flag {
  display: inline-block;
  margin-top: 6px;
  margin-left: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.archive-detail h2 { margin: 0; }
.work-time-panel { margin-top: 14px; }
.archive-unit .unit-note { color: var(--text-muted); font-size: 13px; margin-top: 6px; }
.archive-unit .unit-note b { color: var(--text); font-weight: 650; }

/* Public page: the phone link is the primary action on a stuck visit. */
.call-technician {
  display: block;
  margin: 16px 0;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--ok-soft);
  border: 1px solid rgba(64, 207, 141, .38);
  color: var(--ok);
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}
.call-technician:hover { background: rgba(64, 207, 141, .2); }

/* Auth screens sit on their own, so they get a little more air. */
.login-panel { max-width: 420px; margin: 9vh auto; padding: 28px; }
.login-panel h1 { font-size: 24px; margin-bottom: 18px; }
.auth-form { display: grid; gap: 14px; }
.auth-form .check-row { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.auth-form .check-row input { width: auto; }

.visit-card time { color: var(--mode-accent) !important; font-variant-numeric: tabular-nums; }
.visit-card:hover { border-color: var(--line-strong); }
.cancelled-visit { opacity: .85; }

.invoice-meta dt { color: var(--text-dim); }
.invoice-meta dd { color: var(--text); }
.invoice-table th, .invoice-table td { border-color: var(--line); }
.invoice-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 800;
}
.invoice-status--review { background: var(--info-soft); color: var(--info); }
.invoice-status--needs_review { background: var(--warn-soft); color: var(--warn); }
.invoice-status--sending { background: var(--neutral-soft); color: var(--text-muted); }
.invoice-status--sent { background: var(--ok-soft); color: var(--ok); }
.invoice-status--error { background: var(--danger-soft); color: var(--danger); }

/* ------------------------------------------------------------------ responsive */

@media (max-width: 1000px) {
  .request-summary .request-details { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .request-summary .detail-district { grid-column: span 2; }
  .request-summary .detail-address { grid-column: span 4; }
  .request-summary .detail-customer,
  .request-summary .detail-brand,
  .request-summary .detail-unit-count,
  .request-summary .detail-unit-age { grid-column: span 2; }
  .request-summary .detail-service { grid-column: span 3; }
  .request-summary .detail-phone { grid-column: span 3; }
  .request-summary .detail-email,
  .request-summary .detail-received,
  .request-summary .detail-technician,
  .request-summary .detail-eta,
  .request-summary .detail-confirmation,
  .request-summary .detail-activity { grid-column: span 3; }
}

@media (max-width: 620px) {
  .request-summary .request-details { grid-template-columns: 1fr; }
  .request-summary .request-details > div { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .page { padding: 20px 14px 64px; }
  h1 { font-size: 23px; }
}

/* Between phone and desktop the two narrow columns give way first: the pill
   and the timestamp move under the address rather than being squeezed. */
@media (max-width: 1180px) {
  .request-card { grid-template-columns: 4px minmax(0, 1.4fr) minmax(0, .9fr) 190px; }
  .request-card-meta { grid-column: 2 / -1; padding: 0 16px 11px 0; text-align: left; }
  .card-when, .card-owner, .card-ref { display: inline; }
  .card-owner::before, .card-ref::before { content: " · "; color: var(--text-dim); }
}

@media (max-width: 900px) {
  .request-card { grid-template-columns: 4px minmax(0, 1fr); }
  .card-main { padding-right: 16px; }
  .card-customer {
    grid-column: 2;
    padding: 0 16px 10px 0;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 10px;
    margin-top: 2px;
  }
  .request-card .status-pill { grid-column: 2; margin-bottom: 11px; }
  .request-card-meta { grid-column: 2; }
}

@media (max-width: 720px) {
  /* The bar wraps to two rows on a phone; keeping it sticky would eat a fifth
     of the viewport on every screen, so it scrolls away with the page. */
  .topbar { position: static; padding: 8px 14px 6px; }
  .top-actions > a { font-size: 13px; padding: 7px 8px; }

  /* Лентата се пренася на два реда, затова хоризонталният скрол е излишен — а
     той режеше падащото меню. Панелът на „Настройки“ се мери спрямо целия ред,
     а не спрямо бутона: иначе, когато бутонът застане вляво, менюто се разгъва
     наляво и излиза извън екрана. */
  .top-actions { position: relative; flex-wrap: wrap; overflow: visible; }
  .settings-menu { position: static; }
  .settings-dropdown {
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    width: min(280px, calc(100vw - 20px));
    min-width: 0;
  }
  .topbar strong { font-size: 14px; }
  .mode-switch button { padding: 7px 10px; font-size: 12px; }
  .settings-toggle { padding: 7px 10px; font-size: 13px; }
  .card-facts { gap: 3px 12px; }
  .request-search { max-width: none; flex-wrap: wrap; }
  .request-search input { flex: 1 1 100%; }
  .request-search select { flex: 1; width: auto; }
  .stat-tiles { width: 100%; }
  .stat-tile { flex: 1; min-width: 0; }
  .stat-tile--load { flex: 1 1 100%; }
}

@media (max-width: 520px) {
  .page { padding: 16px 12px 64px; }
  .card-title { font-size: 15px; }
  .card-main { padding: 11px 12px 11px 0; }
  .card-customer, .request-card-meta { padding-right: 12px; }
  .request-card .status-pill { margin-left: 0; }
  .heading-row { display: block; }
  .heading-row > *:not(:first-child) { margin-top: 12px; }
  .day-group__header { gap: 6px; }
}

/* Touch controls keep a 44px target on phones, including the compact
   navigation and inline actions inherited from the older page styles. */
@media (max-width: 720px) {
  button,
  input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
  select,
  textarea,
  summary,
  .top-actions > a,
  .settings-dropdown a,
  .request-tabs a,
  .task-periods a,
  .period-presets a,
  .schedule-navigation a,
  .schedule-view-switch a,
  .invoice-filters a,
  .button,
  .task-actions a,
  .attachment-picker,
  .call-technician,
  .action-link {
    min-height: 44px;
  }

  .top-actions > a,
  .settings-toggle,
  .mode-switch button,
  .settings-dropdown a,
  .settings-logout,
  .invoice-filters a,
  .button,
  .task-actions a,
  .action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .settings-logout { width: 100%; justify-content: flex-start; }
  .close { width: 44px; min-width: 44px; padding: 0; }

  /* Checkbox and radio controls retain their native visual size; their labels
     own the full tap target so the form layout remains readable. */
  .auth-form .check-row,
  .payment-status-options label,
  .import-confirm .confirm-check,
  .eta-choice {
    min-height: 44px;
  }
  .auth-form .check-row { padding: 10px 0; }
}

/* ------------------------------------- лентата горе: оборот, режим, навигация

   Лентата носи две групи. Горе вдясно стои „какъв ден е, колко е изкарано и в
   кой режим съм“, а навигацията е отделен ред отдолу. Преди превключвателят на
   режима се носеше с връзките и падаше на трети ред; сега редът на връзките е
   само един, а „Още“ се събра зад иконата с зъбното колело. */

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  /* На широк екран групата „оборот + режим“ стои най-вдясно, след връзките —
     мястото, на което превключвателят стоеше и досега. */
  order: 3;
}

.top-actions { order: 2; flex: 1 1 auto; }

/* Оборотът за деня: датата отгоре с дребни сиви букви, сумата отдолу в зелено.
   Сиянието минава три пъти при отваряне на страницата и спира — колкото да се
   хване с крайчеца на окото, без да мига цял ден. */
.revenue-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  padding: 4px 10px;
  border: 1px solid rgba(63, 158, 104, .38);
  border-radius: var(--radius-sm);
  background: rgba(63, 158, 104, .12);
  line-height: 1.15;
  animation: revenue-chip-glow 3.2s ease-in-out 3;
}

.revenue-chip__day {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--text-muted);
  white-space: nowrap;
}

.revenue-chip__sum {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  font-weight: 600;
  color: #6fc492;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Сумата е нараснала, откакто страницата е била отваряна: кратко просветване,
   за да се забележи новият протокол. */
.revenue-chip.is-up { animation: revenue-chip-pop .7s ease-out; }

@keyframes revenue-chip-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(63, 158, 104, 0); }
  50% { box-shadow: 0 0 0 3px rgba(63, 158, 104, .16); }
}
@keyframes revenue-chip-pop {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(63, 158, 104, .45); }
  40% { transform: scale(1.06); box-shadow: 0 0 0 6px rgba(63, 158, 104, .18); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(63, 158, 104, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .revenue-chip, .revenue-chip.is-up { animation: none; }
}

/* „Още“ е икона, не дума: менюто побира Табло, Архив, Календар и Изход, а
   редът с връзките трябва да остане един. */
.settings-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.settings-icon { display: block; flex: none; }

@media (max-width: 720px) {
  /* Марката, оборотът и режимът делят първия ред; връзките взимат втория. */
  .topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 7px 12px 8px;
  }
  .topbar-brand { width: auto; flex: 1 1 auto; min-width: 0; }
  .topbar-meta { order: 2; }
  .top-actions { order: 3; width: 100%; overflow: visible; padding: 0; }

  /* Само режимът „Техник“ се събира на един ред — в него връзките са три.
     Админ лентата носи още „Табло“ и „Архив“ и остава с пренасяне. */
  body.mode-technician .top-actions {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 3px;
  }
  body.mode-technician .top-actions > a {
    min-width: 0;
    padding: 0 7px;
    font-size: 12px;
    white-space: nowrap;
    background: var(--surface-inset);
    border: 1px solid var(--line);
  }
  body.mode-technician .top-actions > a.active,
  body.mode-technician .top-actions > a[aria-current="page"] { border-color: var(--mode-line); }
  body.mode-technician .settings-menu { margin-left: auto; }
  body.mode-technician .settings-toggle {
    width: 38px;
    padding: 0;
    background: var(--surface-inset);
    border-color: var(--line);
  }

  .mode-switch { padding: 2px; }
  .mode-switch button { min-height: 32px; padding: 5px 9px; font-size: 11.5px; }
  .revenue-chip { padding: 3px 9px; }
  .revenue-chip__sum { font-size: 13.5px; }
}

/* На тесен телефон името „НИВАС 5“ отстъпва мястото си на оборота и на
   превключвателя: знакът на марката и цветът на лентата остават достатъчни, а
   първият ред не се пренася. Текстът се чете от екранни четци. */
@media (max-width: 420px) {
  .topbar-brand strong {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ------------------------------------------- requests summary panel (B) */
/* One unified panel under the page title: four counts, the acceptance
   comparison and — in the recessed right-hand zone — the two settings
   controls, which open as dropdowns instead of resizing the panel. */

.rate-fraction { font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 600; color: var(--text); white-space: nowrap; }
.rate-fraction i { font-style: normal; font-weight: 500; color: var(--text-muted); }
.rate-pct { font-style: normal; font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 600; color: var(--mode-text); white-space: nowrap; }
.rate-bar { display: block; height: 3px; border-radius: 3px; background: var(--line-strong); overflow: hidden; }
.rate-bar i { display: block; height: 100%; border-radius: 3px; background: var(--mode-accent); }

.summary-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-card);
  margin: 0 0 16px;
}
.summary-group { display: flex; align-items: stretch; }
.summary-group + .summary-group { border-left: 1px solid var(--line-strong); }
.summary-cell { display: flex; flex-direction: column; justify-content: center; padding: 10px 18px; min-width: 112px; }
.summary-cell + .summary-cell { border-left: 1px solid var(--line); }
.summary-label { display: block; font-size: 10px; letter-spacing: .02em; color: var(--text-muted); }
.summary-value {
  display: block;
  margin-top: 3px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--text);
  white-space: nowrap;
}
.summary-group--rates { flex: 1 1 380px; align-items: center; padding: 9px 20px; }
.summary-rates { display: grid; gap: 10px; width: 100%; }
.summary-rate { display: grid; grid-template-columns: 112px 118px 56px minmax(60px, 1fr); align-items: center; column-gap: 14px; }
.summary-rate .rate-fraction, .summary-rate .rate-pct { font-size: 16px; }
.summary-rate .rate-pct { text-align: right; }
.summary-rate .rate-bar { height: 4px; }

.summary-group--settings {
  gap: 8px;
  padding: 8px;
  margin-left: auto;
  background: var(--surface-inset);
  border-radius: 0 var(--radius-card) var(--radius-card) 0;
}
.summary-group--settings .stat-tile--load { position: relative; min-width: 168px; max-width: none; }
/* The status control used to grow into a form when opened; in the panel it
   keeps its tile size and the form floats over the page instead. */
.summary-group--settings .service-status-control[open] { flex: 0 0 auto; min-width: 168px; }

.summary-panel .stat-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  z-index: 40;
  width: min(380px, calc(100vw - 32px));
  margin: 0;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  text-align: left;
}
.summary-panel .stat-popover > :first-child { margin-top: 0; }
.summary-panel .stat-popover > p { margin: 0 0 10px; }
.summary-panel .stat-popover label { color: var(--text); }
.summary-group--settings details[open] > summary { color: var(--text); }
.summary-group--settings summary:focus-visible { outline: 0; box-shadow: var(--focus); border-radius: var(--radius-sm); }

@media (max-width: 1360px) {
  .summary-group--counts { flex: 1 1 auto; }
  .summary-group--settings { flex: 1 1 100%; margin-left: 0; border-left: 0; border-top: 1px solid var(--line-strong); border-radius: 0 0 var(--radius-card) var(--radius-card); }
  .summary-group--settings .stat-tile--load { flex: 1; }
  /* The panel has two rows here, so the dropdown opens from the left edge of
     its tile instead of hanging off the right side. */
  .summary-group--settings .service-load-control .stat-popover { left: 0; right: auto; }
}
@media (max-width: 900px) {
  .summary-group--counts, .summary-group--rates { flex: 1 1 100%; }
  .summary-group--rates { border-left: 0; border-top: 1px solid var(--line-strong); }
  .summary-group--counts .summary-cell { flex: 1 1 25%; min-width: 0; }
}
@media (max-width: 620px) {
  .summary-group--counts { flex-wrap: wrap; }
  .summary-group--counts .summary-cell { flex: 1 1 50%; }
  .summary-group--counts .summary-cell:nth-child(3) { border-left: 0; }
  .summary-group--counts .summary-cell:nth-child(n+3) { border-top: 1px solid var(--line); }
  .summary-rate { grid-template-columns: 1fr auto auto; row-gap: 5px; }
  .summary-rate .rate-bar { grid-column: 1 / -1; }
  .summary-group--settings { flex-wrap: wrap; }
  .summary-group--settings .stat-tile--load { flex: 1 1 100%; }
  .summary-panel .stat-popover, .summary-group--settings .service-load-control .stat-popover { left: 0; right: 0; width: auto; }
}
