/* МедРадар — design system (port from Claude Design prototype) */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0a0a0a;
  --text-muted: #6b7280;
  --text-subtle: #9ca3af;
  --accent: #059669;
  --accent-hover: #047857;
  --accent-bg: #d1fae5;
  --accent-bg-strong: #b8f1d6;
  --positive: #059669;
  --warning: #d97706;
  --negative: #dc2626;

  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Compact density (default) */
  --pad-card-y: 12px;
  --pad-card-x: 16px;
  --pad-row-y: 8px;
  --pad-row-x: 12px;
  --pad-section-gap: 32px;
  --row-h: 32px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

main.container { flex: 1; padding-bottom: 16px; }

/* ── Beta strip ─────────────────────────────────────── */
.beta-strip {
  background: #f3f4f6;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.beta-strip-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0;
  gap: 16px; flex-wrap: wrap;
}
.beta-strip b { color: var(--text); font-weight: 500; }
.beta-strip a { color: var(--accent); }

/* ── Header ─────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 56px;
}
.header-inner {
  display: flex; align-items: center; gap: 20px;
  height: 100%;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14px; color: var(--text);
}
.brand-logo {
  height: 28px !important; width: auto !important;
  max-width: 140px;
  display: block; flex-shrink: 0;
  object-fit: contain;
}
.brand-logo-lg { height: 44px !important; max-width: 200px; }

.nav {
  display: flex; align-items: center; gap: 4px;
  flex: 1;
}
.nav a {
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 4px;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); background: rgba(0,0,0,0.03); }
.nav a.active { color: var(--text); }

.header-search {
  position: relative;
  width: 240px;
  flex-shrink: 0;
}
.header-search input {
  width: 100%; height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  padding: 0 8px 0 28px;
  outline: none;
}
.header-search input::placeholder { color: var(--text-subtle); }
.header-search input:focus { border-color: var(--accent); background: var(--surface); }
.header-search-icon {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-subtle);
}
.header-search kbd {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  line-height: 1.2;
}

.user-strip {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.user-strip .email { color: var(--text); font-weight: 500; }
.user-strip a, .user-strip button.linkbtn {
  color: var(--text-muted);
  background: transparent; border: 0; padding: 0;
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.user-strip a:hover, .user-strip button.linkbtn:hover { color: var(--text); }
.user-strip .sep { color: var(--text-subtle); }

/* ── Page header ──────────────────────────────────── */
.page-head {
  padding: 24px 0 8px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
}
.page-head h1 {
  font-size: 24px; font-weight: 600; line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
}
.page-head .sub {
  font-size: 13px; color: var(--text-muted);
  margin-top: 4px;
}
.page-head .meta {
  font-size: 12px; color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.page-head .meta b { color: var(--text); font-weight: 500; }
.page-head .meta div { margin-top: 2px; }

/* ── Section ──────────────────────────────────────── */
.section { margin-top: var(--pad-section-gap); }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
  gap: 16px;
}
.section-head h2 {
  font-size: 18px; font-weight: 600; margin: 0;
  letter-spacing: -0.005em;
}
.section-head .section-meta {
  font-size: 12px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex: 1;
}
.section-head .section-link {
  font-size: 13px; color: var(--accent);
}

/* ── KPI grid ─────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 24px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--pad-card-y) var(--pad-card-x);
  display: flex; flex-direction: column;
  gap: 8px;
  position: relative;
  min-height: 120px;
}
.kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 500;
}
.kpi-value {
  font-size: 36px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.02em;
  display: flex; align-items: baseline; gap: 4px;
}
.kpi-value .unit {
  font-size: 16px; font-weight: 500; color: var(--text-muted);
  letter-spacing: 0;
}
.kpi-value.zero { color: var(--text-subtle); }
.kpi-foot {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 6px;
  margin-top: auto;
  flex-wrap: wrap;
}
.kpi-foot .delta { font-weight: 500; }
.kpi-foot .delta.pos { color: var(--positive); }
.kpi-foot .delta.neg { color: var(--negative); }
.kpi-spark {
  position: absolute;
  right: var(--pad-card-x);
  top: var(--pad-card-y);
  pointer-events: none;
}
.kpi-breakdown {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: auto;
  font-variant-numeric: tabular-nums;
}
.kpi-breakdown b {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ── Tables ────────────────────────────────────────── */
.tbl-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tbl th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: var(--pad-row-y) var(--pad-row-x);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface);
}
.tbl td {
  padding: var(--pad-row-y) var(--pad-row-x);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: rgba(0,0,0,0.02); }
.tbl tbody tr.row-own { background: var(--accent-bg); }
.tbl tbody tr.row-own:hover { background: var(--accent-bg-strong); }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl th.sortable a {
  color: inherit; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.tbl th.sortable a:hover { color: var(--accent); }
.tbl th.sortable.active a { color: var(--text); }
.tbl th.sortable .sort-arrow { font-size: 10px; opacity: 0.6; }
.num-strong { font-weight: 500; color: var(--text); }
.mono { font-family: var(--font-mono); font-size: 13px; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.nowrap { white-space: nowrap; }

.cell-name { font-weight: 500; }
.cell-name a { color: var(--text); }
.cell-name a:hover { color: var(--accent); }

.delta-cell { font-variant-numeric: tabular-nums; }
.delta-cell.pos { color: var(--positive); }
.delta-cell.neg { color: var(--negative); }

/* ── Badges ───────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  letter-spacing: 0;
  white-space: nowrap;
  line-height: 1.4;
}
.badge-ok { background: var(--accent-bg); color: #065f46; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-stop { background: #fee2e2; color: #991b1b; }
.badge-neutral { background: #f3f4f6; color: #374151; }

.evt-NEW_LICENSE { background: var(--accent-bg); color: #065f46; }
.evt-LICENSE_REINSTATED { background: var(--accent-bg); color: #065f46; }
.evt-LICENSE_SUSPENDED { background: #fef3c7; color: #92400e; }
.evt-LICENSE_REVOKED { background: #fee2e2; color: #991b1b; }
.evt-LICENSE_ANNULLED { background: #fee2e2; color: #991b1b; }
.evt-LICENSE_TERMINATED { background: #fee2e2; color: #991b1b; }
.evt-STATUS_CHANGED { background: #f3f4f6; color: #374151; }
.evt-NEW_ADDRESS { background: #f3f4f6; color: #374151; }
.evt-NEW_WORK_TYPE { background: #f3f4f6; color: #374151; }
.evt-WORK_TYPE_REMOVED { background: #fef3c7; color: #92400e; }

.changes-pill {
  display: inline-block; min-width: 24px;
  padding: 1px 7px; border-radius: 3px;
  font-size: 12px; font-weight: 500;
  font-variant-numeric: tabular-nums;
  background: #f3f4f6; color: #374151;
}
.changes-pill.hot { background: #fef3c7; color: #92400e; }

/* ── Events feed ──────────────────────────────────── */
.events {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.events-day {
  display: flex; align-items: baseline; gap: 12px;
  padding: var(--pad-row-y) var(--pad-row-x);
  background: rgba(0,0,0,0.015);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 500;
}
.events-day .count {
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0;
}
.event-row {
  display: grid;
  grid-template-columns: 56px 140px 1fr 120px;
  gap: 12px;
  align-items: center;
  padding: 10px var(--pad-row-x);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.event-row:last-child { border-bottom: 0; }
.event-row:hover { background: rgba(0,0,0,0.02); }
.event-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.event-clinic a {
  color: var(--text);
  font-weight: 500;
}
.event-clinic a:hover { color: var(--accent); }
.event-clinic .inn {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 1px;
}
.event-detail {
  font-size: 13px;
  color: var(--text-muted);
}
.event-detail b { color: var(--text); font-weight: 500; }
.event-region {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Footer ───────────────────────────────────────── */
.footer {
  margin-top: 64px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.footer-inner {
  display: flex; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--text); }

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; padding: 0 16px;
  border-radius: 4px;
  font-size: 13px; font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  background: transparent;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: rgba(0,0,0,0.02); color: var(--text); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

/* ── Form controls ────────────────────────────────── */
input[type="text"], input[type="email"], input[type="search"], input[type="number"], input[type="password"], select, textarea {
  font-family: var(--font-sans);
  font-size: 13px;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

textarea { height: auto; padding: 8px 12px; }

label { font-size: 13px; }

.filter-label {
  font-size: 12px; color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  display: block;
}

/* ── Auth pages (login, verify) ───────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 16px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 32px;
}
.auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 20px;
  font-size: 18px; font-weight: 600;
}
.auth-brand .brand-mark {
  width: 28px; height: 28px;
}
.auth-h1 {
  margin: 0 0 4px;
  text-align: center;
  font-size: 18px; font-weight: 600;
}
.auth-sub {
  text-align: center;
  color: var(--text-muted); font-size: 13px;
  margin: 0 0 20px;
}
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card label {
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: -6px;
}
.auth-card input[type="email"],
.auth-card input[type="text"] {
  width: 100%;
}
.auth-card .btn-primary { width: 100%; }
.auth-help {
  margin: 16px 0 0;
  text-align: center;
  font-size: 12px; color: var(--text-muted);
  line-height: 1.5;
}
.auth-help a { color: var(--accent); }
.auth-error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 8px;
}

/* OTP code field */
.otp-row {
  display: flex; justify-content: center; align-items: center;
  gap: 6px; margin: 8px 0 16px;
}
.otp-row input.otp {
  width: 36px; height: 44px;
  margin: 0; padding: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 22px; font-weight: 600;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
}
.otp-row input.otp:focus { outline: none; border-color: var(--accent); }
.otp-row input.otp.filled { border-color: var(--accent); }
.otp-sep {
  color: var(--text-subtle);
  font-size: 18px; font-weight: 400;
  user-select: none;
}

/* Empty state cards */
.empty-card {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  padding: 32px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-card a { color: var(--accent); font-weight: 500; }

/* ── Combobox локации (используется на /search и /market-share) ── */
.combo { position: relative; }
.combo input[type="text"] { width: 100%; padding-right: 80px; }
.combo-kind-badge {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-muted);
  background: var(--bg);
  padding: 1px 7px; border-radius: 3px;
  text-transform: lowercase;
  pointer-events: none;
}
.combo-kind-badge:empty { display: none; }
.combo-options {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  list-style: none; padding: 4px 0; margin: 0;
  max-height: 320px; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  z-index: 50;
  display: none;
}
.combo-options.open { display: block; }
.combo-options li {
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  line-height: 1.4;
}
.combo-options li.active,
.combo-options li:hover { background: var(--accent-bg); color: #065f46; }
.combo-options li.is-region { font-weight: 500; }
.combo-options li .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-options li .hint { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.combo-options li .kind {
  font-size: 10px; color: var(--text-subtle);
  text-transform: uppercase; letter-spacing: 0.05em;
  flex-shrink: 0;
}
.combo-group-header {
  padding: 6px 12px 2px;
  font-size: 11px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* ── Pico-compat shim ─────────────────────────────── */
/* Чтобы старые шаблоны (settings/clinic/search/market-share/onboarding/admin)
   рендерились прилично без полного переписывания. Постепенно мигрируем
   их на новый дизайн, и тогда этот блок можно ужать. */

/* <article> = карточка */
article {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  margin: 0 0 16px;
}

/* Любая кнопка по умолчанию — primary */
button, input[type="submit"], input[type="button"],
a[role="button"] {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; padding: 0 16px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
  text-decoration: none;
}
button:hover, input[type="submit"]:hover, a[role="button"]:hover {
  background: var(--accent-hover); border-color: var(--accent-hover); color: #fff;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* secondary outline = ghost-вариант */
button.secondary.outline,
button.outline,
a.secondary.outline {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
button.secondary.outline:hover,
button.outline:hover,
a.secondary.outline:hover {
  background: rgba(0,0,0,0.02); color: var(--text);
  border-color: var(--text-muted);
}

button.contrast { background: #0a0a0a; border-color: #0a0a0a; }

/* Маленькие кнопки в таблицах */
button[style*="font-size: 0.8"], button[style*="font-size: 0.85"] {
  height: 28px; padding: 0 10px; font-size: 12px;
}

/* <hr> — тонкий разделитель */
hr {
  border: 0; border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* <details>/<summary> */
details {
  margin: 8px 0;
  font-size: 13px;
}
details summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  padding: 4px 0;
  user-select: none;
}
details summary:hover { color: var(--accent-hover); }
details[open] summary { margin-bottom: 8px; }

/* Label по умолчанию — блочный, отступ снизу */
form label:not(.ms-check):not(.favorite-item):not(.onb-check):not(.auth-card label) {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--text);
}

/* Form layout */
form {
  margin: 0;
}
form > * + * {
  margin-top: 8px;
}
fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  margin: 0;
}
fieldset legend {
  font-size: 13px; font-weight: 500;
  padding: 0 6px;
  color: var(--text);
}

/* Заголовки в content-секциях */
h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 600; margin: 24px 0 12px; letter-spacing: -0.005em; }
h3 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; }

/* Таблицы без класса tbl — базовое причёсывание */
main table:not(.tbl) {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 8px 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
main table:not(.tbl) th {
  text-align: left;
  font-size: 12px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
main table:not(.tbl) td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
main table:not(.tbl) tr:last-child td { border-bottom: 0; }
main table:not(.tbl) tbody tr:hover { background: rgba(0,0,0,0.02); }

main table code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* Pico-style filter-bar пилюли */
.filter-bar {
  display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0 16px;
}
.filter-bar a {
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 12px; text-decoration: none;
  color: var(--text-muted); background: transparent;
}
.filter-bar a.active {
  background: var(--accent); color: white;
  border-color: var(--accent);
}
.filter-bar a:hover:not(.active) { color: var(--text); }

/* Карточки клиник (старая разметка) */
.clinic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 12px;
}
.clinic-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; flex-wrap: wrap;
}
.clinic-name {
  font-size: 16px; font-weight: 500;
}
.clinic-name a { color: var(--text); text-decoration: none; }
.clinic-name a:hover { color: var(--accent); }
.meta {
  color: var(--text-muted); font-size: 13px; margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.meta div { margin-top: 2px; }
.specialties { margin-top: 8px; }
.specialties span {
  display: inline-block; margin: 2px 4px 0 0;
  padding: 2px 8px; border-radius: 3px;
  background: var(--accent-bg); color: #065f46;
  font-size: 12px; font-weight: 500;
}

/* События (legacy) */
.events-list { list-style: none; padding: 0; margin: 0; }
.events-list li {
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.events-list li:last-child { border-bottom: none; }

/* Pagination links / pill links */
mark {
  background: #fef08a; color: inherit;
  padding: 0 2px; border-radius: 2px;
}

/* aside: тонкая инфоплашка */
aside, aside.muted {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin: 16px 0;
}
aside a { color: var(--accent); }

/* Day-grouped events (legacy index) */
.day-group { margin-top: 16px; }
.day-group-title {
  font-size: 12px; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.05em;
  margin-bottom: 6px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* Stat grid (legacy) */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin: 16px 0;
}
@media (min-width: 720px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.stat-card .stat-label {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.stat-card .stat-value {
  font-size: 22px; font-weight: 600; line-height: 1.2;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.stat-card .stat-sub {
  font-size: 11px; color: var(--text-muted);
  margin-top: 2px;
}

.stats-section-title {
  font-size: 12px; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.05em;
  margin-top: 24px; margin-bottom: 4px;
}

/* Code/kbd inline */
code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(0,0,0,0.04);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--text);
}

/* Input groups в Pico-формах */
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent);
}

/* ── Mobile fallback ──────────────────────────────── */
@media (max-width: 1024px) {
  .header-search { width: 200px; }
}

@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .header { height: auto; }
  .header-inner {
    flex-wrap: wrap;
    padding: 8px 0;
    gap: 8px 16px;
  }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; gap: 0; padding-bottom: 4px; }
  .nav a { padding: 6px 8px; font-size: 12px; flex-shrink: 0; }
  .header-search { width: 100%; order: 4; }
  .header-search kbd { display: none; }
  .user-strip { font-size: 12px; }
  .user-strip .email { display: none; }

  .page-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-head .meta { text-align: left; }

  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 28px; }

  .event-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 12px var(--pad-row-x);
  }
  .event-region { text-align: left; }

  .tbl-wrap { overflow-x: auto; }
  table.tbl { min-width: 720px; }
  .section-head { flex-wrap: wrap; }

  .footer-inner { flex-direction: column; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
