/* Admin panel. Tokens per theme: the system setting by default, the ◐ button overrides it. */
/* Admin panel, brand "Хороший тон": navy, coral and blue on a light grey page, as in the
   brand's presentation. Tokens per theme: the system setting by default, the ◐ button
   overrides it. */
:root {
  color-scheme: light;
  --navy: #2b2d42;
  --coral: #ef5545;
  --blue: #6c9bd0;
  --logo-grey: #959db0;
  --accent-ink: #ffffff;
  --topbar-ink: #e9ebf2;
  --topbar-dim: #a3a9be;
  --page: #eceff3;
  --surface: #ffffff;
  --surface-2: #f2f4f8;
  --border: #dfe3ea;
  --text: #2b2d42;
  --text-2: #6b7286;
  --link: #3f72b5;
  --accent: #ef5545;
  --ok-bg: #e4f2ea;
  --ok-ink: #1d7a46;
  --err-bg: #fde6e3;
  --err-ink: #b5301f;
  --warn-ink: #d4402f;
  --topbar: #2b2d42;
  --shadow: 0 1px 2px rgba(43, 45, 66, 0.06), 0 4px 16px rgba(43, 45, 66, 0.05);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #1d1e2e;
    --surface: #2b2d42;
    --surface-2: #35384f;
    --border: #43465f;
    --text: #f1f2f6;
    --text-2: #aab0c4;
    --link: #93b8e6;
    --accent: #f0604f;
    --ok-bg: #173826;
    --ok-ink: #6fd59b;
    --err-bg: #47201c;
    --err-ink: #ff9b8f;
    --warn-ink: #ff8a7a;
    --topbar: #23243a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #1d1e2e;
  --surface: #2b2d42;
  --surface-2: #35384f;
  --border: #43465f;
  --text: #f1f2f6;
  --text-2: #aab0c4;
  --link: #93b8e6;
  --accent: #f0604f;
  --ok-bg: #173826;
  --ok-ink: #6fd59b;
  --err-bg: #47201c;
  --err-ink: #ff9b8f;
  --warn-ink: #ff8a7a;
  --topbar: #23243a;
  --shadow: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 1.5rem; margin: 0 0 12px; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.muted { color: var(--text-2); }
.small { font-size: 0.85rem; }
.warn { color: var(--warn-ink); }
.nowrap { white-space: nowrap; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; padding: 10px 24px;
  background: var(--topbar); color: var(--topbar-ink);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--topbar-ink); }
.brand:hover { text-decoration: none; }
.brand-sub { font-weight: 400; color: var(--topbar-dim); font-size: 0.9rem; }
.topnav { display: flex; flex-wrap: wrap; gap: 4px 18px; flex: 1; }
.topnav a { color: var(--topbar-dim); padding: 4px 0; border-bottom: 2px solid transparent; }
.topnav a:hover { color: var(--topbar-ink); text-decoration: none; border-bottom-color: var(--coral); }
/* The section you are in: always marked, not only on hover. */
.topnav a[aria-current="page"] { color: var(--topbar-ink); font-weight: 700; border-bottom-color: var(--coral); }
.who { color: var(--topbar-dim); font-size: 0.9rem; }
.topbar button { background: transparent; color: var(--topbar-ink); border-color: #4a4d68; }

/* Logo: two quotes (grey and coral) and the word mark. */
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: 0.02em; }
.logo-mark { width: 30px; height: 26px; }
.logo-q1 { fill: var(--logo-grey); }
.logo-q2 { fill: var(--coral); }
.logo-word { color: var(--logo-grey); font-size: 1.05rem; }
.logo-word b { color: var(--coral); font-weight: 800; }
.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 40px; display: grid; gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px 20px; min-width: 0; box-shadow: var(--shadow);
}
.narrow { max-width: 460px; }
.login-card { max-width: 380px; width: 100%; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tile { color: var(--text); display: block; }
.tile:hover { text-decoration: none; border-color: var(--blue); }
.tile h2 { position: relative; padding-left: 12px; }
.tile h2::before { content: ""; position: absolute; left: 0; top: 0.2em; bottom: 0.2em; width: 4px; border-radius: 2px; background: var(--blue); }
.tile.disabled { opacity: 0.6; }
.tile p { margin: 0; }

.notice, .error { margin: 0; padding: 10px 14px; border-radius: 8px; }
.notice { background: var(--ok-bg); color: var(--ok-ink); }
.error { background: var(--err-bg); color: var(--err-ink); }

form.stack { display: grid; gap: 12px; }
form.stack label { display: grid; gap: 4px; }
form.row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
form.row label { display: grid; gap: 4px; }
fieldset.days { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.num-short { width: 6em; }
fieldset.clinics { display: grid; gap: 4px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; margin: 0; }
fieldset.clinics legend { font-size: 0.85rem; color: var(--text-2); padding: 0 4px; }
form.clinics { display: grid; gap: 6px; justify-items: start; margin: 6px 0; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 2px 6px 2px 0; }
input, button, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px;
}
button { cursor: pointer; background: var(--surface-2); }
button:hover { border-color: var(--blue); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { filter: brightness(0.95); }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.data th { text-align: left; color: var(--text-2); font-weight: 600; font-size: 0.85rem; }
table.data th, table.data td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.actions input[type="password"] { width: 11em; }
.theme-toggle { border-radius: 999px; width: 34px; height: 34px; padding: 0; line-height: 1; }
/* Login pages: the theme switch sits in the screen corner, not in the content column. */
.login-tools { position: fixed; top: 16px; right: 16px; z-index: 2; }
.login-card .error, .login-card .notice { margin-top: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* "Звонки": player, engine switch, transcript lines. */
.call-player audio { width: 100%; }
.call-switch { display: flex; gap: 8px; flex-wrap: wrap; }
.call-switch button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.call-texts { display: grid; gap: 16px; }
.call-texts.both { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.segments { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.seg { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 4px 6px; border-radius: 6px; }
.seg:hover { background: var(--surface-2); }
.seg.current { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.cases { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.cases p { margin: 2px 6px; }
.seg-t { color: var(--text-2); font-variant-numeric: tabular-nums; margin-right: 6px; }

.badge { font-weight: 700; color: var(--warn-ink); }
.password-once { font: 700 1.6rem/1.3 ui-monospace, monospace; letter-spacing: 0.08em; user-select: all; }

/* Дашборд: KPI cards, server-drawn SVG charts (colours by class, no inline styles). */
:root {
  --s0: #6c9bd0; --s1: #ef5545; --s2: #959db0; --s3: #3f72b5; --s4: #f2a097; --s5: #5b5f7d;
  --heat0: var(--surface-2); --heat1: #dbe7f5; --heat2: #b5cdea; --heat3: #8cb1dd; --heat4: #6c9bd0; --heat5: #3f72b5;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --heat1: #1c2d44; --heat2: #23426a; --heat3: #2c5f97; --heat4: #3a7fd0; --heat5: #7fb2ee;
  }
}
:root[data-theme="dark"] {
  --heat1: #1c2d44; --heat2: #23426a; --heat3: #2c5f97; --heat4: #3a7fd0; --heat5: #7fb2ee;
}
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: grid; gap: 2px; margin: 0; }
.kpi b { font-size: 1.5rem; }
svg.chart { width: 100%; height: auto; display: block; }
svg.heat { display: block; }
svg .gridline { stroke: var(--border); stroke-width: 1; }
svg .tick { fill: var(--text-2); font-size: 11px; }
svg .c0, .key.c0 { fill: var(--s0); background: var(--s0); }
svg .c1, .key.c1 { fill: var(--s1); background: var(--s1); }
svg .c2, .key.c2 { fill: var(--s2); background: var(--s2); }
svg .c3, .key.c3 { fill: var(--s3); background: var(--s3); }
svg .c4, .key.c4 { fill: var(--s4); background: var(--s4); }
svg .c5, .key.c5 { fill: var(--s5); background: var(--s5); }
svg .h0 { fill: var(--heat0); } svg .h1 { fill: var(--heat1); } svg .h2 { fill: var(--heat2); }
svg .h3 { fill: var(--heat3); } svg .h4 { fill: var(--heat4); } svg .h5 { fill: var(--heat5); }
.legend { font-size: 0.85rem; color: var(--text-2); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }
.tag { font-size: 0.75rem; font-weight: 600; color: var(--warn-ink); border: 1px solid var(--warn-ink); border-radius: 6px; padding: 0 6px; vertical-align: middle; }
tr.total td { font-weight: 600; }

/* Unsaved form on "Аккаунты" and the delete control on "Клиники". */
form.dirty { outline: 2px dashed var(--warn-ink); outline-offset: 4px; border-radius: 6px; }
.unsaved { color: var(--warn-ink); font-size: 0.85rem; font-weight: 600; }
details.danger { display: inline-block; margin-left: 6px; }
details.danger summary { cursor: pointer; color: var(--err-ink); font-size: 0.9rem; }
button.danger { background: var(--err-bg); color: var(--err-ink); border-color: var(--err-ink); }

/* Login: the title slide of the brand (logo, slogan, two soft circles). */
body.login-page { overflow-x: hidden; position: relative; min-height: 100vh; }
body.login-page::before, body.login-page::after { content: ""; position: fixed; border-radius: 50%; z-index: 0; pointer-events: none; }
body.login-page::before { width: 520px; height: 520px; right: -170px; top: -150px; background: var(--surface-2); opacity: 0.9; }
body.login-page::after { width: 340px; height: 340px; left: -120px; bottom: -150px; background: var(--coral); opacity: 0.14; }
body.login-page .page { position: relative; z-index: 1; }
/* The logo and the sign-in card sit in the middle of the screen, both ways. */
body.login-page main.page { min-height: 100vh; box-sizing: border-box; align-content: center; }
.login-hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, 380px); gap: 40px; align-items: center; }
.logo-big .logo-mark { width: 84px; height: 74px; }
.logo-big .logo-word { font-size: 2.6rem; }
.hero-title { font-size: 2.2rem; line-height: 1.15; margin: 28px 0 10px; }
.hero-sub { color: var(--text-2); font-size: 1.05rem; margin: 0; }
@media (max-width: 760px) {
  .login-hero { grid-template-columns: 1fr; gap: 24px; min-height: 0; }
  .logo-big .logo-word { font-size: 1.8rem; }
  .logo-big .logo-mark { width: 58px; height: 51px; }
  .hero-title { font-size: 1.6rem; }
}

/* Dashboard: completion bars, as on the brand's "personal dashboard" slide. */
.bars { display: grid; gap: 12px; margin: 8px 0 16px; max-width: 760px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline; }
.bar-row b { font-variant-numeric: tabular-nums; }
.bar-row svg { grid-column: 1 / -1; width: 100%; height: 8px; display: block; }
.bar-bg { fill: var(--surface-2); }
.bar-ok { fill: var(--blue); }
.bar-low { fill: var(--coral); }

/* A link that looks like a button ("Скачать mp3"). */
a.button-link { display: inline-block; padding: 7px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
a.button-link:hover { text-decoration: none; border-color: var(--blue); }

/* "Скачать" with a choice: mp3, the transcripts, or both */
details.dl { position: relative; display: inline-block; }
details.dl > summary { list-style: none; cursor: pointer; padding: 5px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); white-space: nowrap; }
details.dl > summary::-webkit-details-marker { display: none; }
details.dl > summary::after { content: " ▾"; color: var(--text-2); }
details.dl > summary:hover, details.dl[open] > summary { border-color: var(--blue); }
.dl-menu { position: absolute; right: 0; z-index: 20; margin-top: 4px; min-width: 190px; display: grid; padding: 6px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); box-shadow: 0 6px 24px rgba(43, 45, 66, 0.18); }
.dl-menu a { padding: 7px 10px; border-radius: 6px; color: var(--text); white-space: nowrap; }
.dl-menu a:hover { background: var(--surface-2); text-decoration: none; }
.dl-menu.floating { position: fixed; right: auto; margin-top: 0; }
[hidden] { display: none !important; }
.dl-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 10px 0; }
.dl-status { min-height: 1.4em; margin: 10px 0 0; }
.dl-status:empty { display: none; }
.dl-status.ok { color: var(--text-2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* "Звонки": page size and page links above and below the table. */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 4px 0 10px; }
.pager-size label { display: inline-flex; align-items: center; gap: 6px; }
.pager-links { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.pager-links a, .pager-links b { min-width: 28px; padding: 2px 8px; border-radius: 6px; text-align: center; }
.pager-links a { border: 1px solid var(--border); }
.pager-links b { background: var(--accent); color: #fff; }
#calls-list .table-wrap, #calls-list .pager { transition: opacity 0.15s ease; }
#calls-list.loading .table-wrap, #calls-list.loading .pager { opacity: 0.55; }

/* "Звонок": the panel's own player (static/player.js), in the theme's colours. */
.player {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin: 6px 0 12px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.player button { border-radius: 999px; line-height: 1; }
.pl-play {
  width: 42px; height: 42px; padding: 0; flex: none; display: grid; place-items: center;
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 2px 8px rgba(239, 85, 69, 0.35);
}
.pl-play:hover { filter: brightness(1.08); }
.pl-play svg { width: 22px; height: 22px; fill: currentColor; }
.pl-btn { background: var(--surface); min-width: 40px; height: 32px; padding: 0 10px; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.pl-mute { min-width: 32px; width: 32px; padding: 0; display: grid; place-items: center; }
.pl-mute svg { width: 18px; height: 18px; fill: currentColor; }
.pl-time { font-variant-numeric: tabular-nums; font-size: 0.9rem; color: var(--text-2); min-width: 3.2em; text-align: center; }
.pl-range {
  --p: 0%;
  -webkit-appearance: none; appearance: none; height: 6px; border-radius: 999px; padding: 0; border: 0;
  background: linear-gradient(to right, var(--accent) var(--p), var(--border) var(--p));
  cursor: pointer;
}
.pl-seek { flex: 1 1 200px; min-width: 120px; }
.pl-vol { width: 80px; flex: none; }
.pl-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.pl-range::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--accent);
}
.pl-range:focus-visible { outline: 2px solid var(--link); outline-offset: 4px; }
@media (max-width: 560px) { .pl-vol, .pl-mute { display: none; } }

/* "Стандарты": every block's table has the same columns, so weights and checkboxes line up. */
.std-items { table-layout: fixed; width: 100%; }
.std-items .c-weight { width: 110px; }
.std-items .c-active { width: 100px; }
.std-items .c-marks { width: 190px; }
.std-items td { vertical-align: middle; overflow-wrap: anywhere; }
.std-items td:nth-child(3) { text-align: center; }
.std-items th:nth-child(3) { text-align: center; }
.std-items input[type="number"] { width: 80px; }
.std-items .badge + .badge { margin-left: 4px; }
.std-items tr.std-guide td { padding-top: 0; border-top: 0; }
.std-items tr.std-guide summary { cursor: pointer; color: var(--text-2); font-size: 0.85rem; }
.std-items tr.std-guide textarea { width: 100%; box-sizing: border-box; margin-top: 6px; font: inherit; font-size: 0.9rem; }
@media (max-width: 760px) {
  .std-items .c-weight { width: 84px; }
  .std-items .c-active { width: 64px; }
  .std-items .c-marks { width: 100px; }
}
label.inline-check, form.row label.inline-check { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; }
