/* Простой интерфейс в духе Google Material: белые карточки, синий акцент, никаких библиотек. */
:root {
  --blue: #1a73e8; --blue-dark: #1765cc; --blue-soft: #e8f0fe;
  --text: #202124; --muted: #5f6368; --line: #dadce0; --bg: #f8f9fa; --surface: #fff;
  --green: #137333; --green-soft: #e6f4ea; --red: #c5221f; --red-soft: #fce8e6;
  --amber: #b06000; --amber-soft: #fef7e0; --grey-soft: #f1f3f4;
  --radius: 8px;
  font-family: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 400; margin: 0; }
h2 { font-size: 16px; font-weight: 500; margin: 0; }
p { margin: 0; }
code, .mono { font-family: "Roboto Mono", ui-monospace, Menlo, monospace; }

/* Верхняя панель */
.appbar { height: 64px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 10; }
.appbar .brand { font-size: 20px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.appbar .brand b { color: var(--text); font-weight: 500; }
.appbar .logo { width: 32px; height: 32px; border-radius: 8px; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; }
.appbar .spacer { flex: 1; }
.appbar .who { color: var(--muted); }

/* Раскладка с боковым меню */
.layout { display: flex; min-height: calc(100vh - 64px); }
.nav { width: 240px; flex-shrink: 0; padding: 12px 12px 12px 0; }
.nav a { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 24px;
  border-radius: 0 22px 22px 0; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--grey-soft); text-decoration: none; }
.nav a.on { background: var(--blue-soft); color: var(--blue-dark); }
.main { flex: 1; min-width: 0; padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1200px; }
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.crumbs { color: var(--muted); }

/* Карточки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { padding: 16px 24px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.card-head .spacer { flex: 1; }
.card-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.hint { color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 16px 20px; }
.kpi .label { color: var(--muted); }
.kpi .value { font-size: 28px; margin-top: 4px; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px;
  padding: 0 20px; border-radius: 18px; border: 1px solid transparent; font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; background: var(--blue); color: #fff; }
.btn:hover { background: var(--blue-dark); text-decoration: none; box-shadow: 0 1px 2px rgba(60,64,67,.3); }
.btn.outline { background: var(--surface); color: var(--blue); border-color: var(--line); }
.btn.outline:hover { background: var(--blue-soft); box-shadow: none; }
.btn.text { background: transparent; color: var(--blue); padding: 0 12px; }
.btn.text:hover { background: var(--blue-soft); box-shadow: none; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
form.inline { display: inline; }

/* Поля */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], select {
  height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 4px; font: inherit;
  background: var(--surface); color: var(--text); width: 100%; }
input:focus, select:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 1px var(--blue); }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 200px; }

/* Статусы */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: 12px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 3px; background: currentColor; }
.chip.ok { background: var(--green-soft); color: var(--green); }
.chip.error, .chip.failed, .chip.lost { background: var(--red-soft); color: var(--red); }
.chip.paused, .chip.skipped { background: var(--grey-soft); color: var(--muted); }
.chip.setup, .chip.download, .chip.transcribe, .chip.no_record { background: var(--amber-soft); color: var(--amber); }
.chip.analyze, .chip.done { background: var(--blue-soft); color: var(--blue-dark); }

/* Таблицы */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tr.link:hover td { background: var(--grey-soft); cursor: pointer; }
td.num, th.num { text-align: right; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }

/* Сообщения */
.flash { padding: 12px 16px; border-radius: var(--radius); display: flex; gap: 12px; align-items: center; }
.flash.ok { background: var(--green-soft); color: var(--green); }
.flash.error { background: var(--red-soft); color: var(--red); }
.secret { background: var(--amber-soft); border: 1px solid #f9d77e; border-radius: var(--radius);
  padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.secret .value { display: flex; gap: 12px; align-items: center; }
.secret code { font-size: 20px; background: #fff; padding: 6px 12px; border-radius: 4px; letter-spacing: .05em; }

/* Вход */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth .card { width: 100%; max-width: 420px; padding: 40px; display: flex; flex-direction: column; gap: 20px; }
.auth .logo { width: 48px; height: 48px; border-radius: 12px; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; }

/* Кабинет: список звонков */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 16px; overflow-x: auto; }
.tabs a { padding: 12px 16px; color: var(--muted); font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--blue); border-bottom-color: var(--blue); }
.tabs a:hover { text-decoration: none; background: var(--grey-soft); }
audio { height: 32px; width: 170px; }
details summary { cursor: pointer; color: var(--blue); }
details pre { white-space: pre-wrap; font-family: inherit; margin: 8px 0 0; max-width: 640px; color: var(--text); }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .nav { width: auto; display: flex; padding: 8px; overflow-x: auto; }
  .nav a { border-radius: 22px; }
  .main { padding: 16px; }
  .grid2, .kpis { grid-template-columns: 1fr; }
}

/* v2: дашборд */
.chip.warn { background: var(--amber-soft); color: var(--amber); }
.kpi-accent { border-color: var(--blue); }
.kpi-accent .value { color: var(--blue-dark); }
a.kpi-warn:hover { background: var(--amber-soft); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.booked { background: #1a73e8; }
.not-booked { background: #f29900; }
.other { background: #aecbfa; }
.lost { background: #d93025; }
.chart { display: flex; gap: 8px; }
.chart-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted);
  text-align: right; min-width: 28px; }
.chart-bars { flex: 1; display: flex; align-items: flex-end; gap: 3px; border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, var(--line) 1px, transparent 1px) 0 0 / 100% 50%; }
.bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; min-width: 4px; height: 100%; }
.bar i { display: block; width: 100%; }
.bar i:first-child { border-radius: 3px 3px 0 0; }
.bar:hover i { filter: brightness(0.9); }
.chart-labels { display: flex; gap: 3px; margin-left: 36px; font-size: 11px; color: var(--muted); }
.chart-labels span { flex: 1; min-width: 4px; text-align: center; white-space: nowrap; overflow: visible; }
tr.review td { background: #fff8e1; }
tr.review td:first-child { box-shadow: inset 4px 0 0 #f29900; }
.checklist { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.checklist li::before { display: inline-block; width: 18px; font-weight: 700; }
.checklist li.ok::before { content: "✓"; color: var(--green); }
.checklist li.bad { color: var(--red); }
.checklist li.bad::before { content: "✗"; }
.checklist li.na { color: var(--muted); }
.checklist li.na::before { content: "–"; }
details p { margin: 4px 0; max-width: 640px; }
tr.more td { padding-top: 0; border-top: 0; }
.more-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; padding: 4px 0 8px; }
.more-grid pre { margin: 0; max-height: 360px; overflow: auto; background: var(--grey-soft); padding: 12px; border-radius: 6px; }
@media (max-width: 900px) { .more-grid { grid-template-columns: 1fr; } }
