/* Инструмент для работы, а не витрина: плотная таблица, спокойный фон, читаемые цифры. */
:root {
  --bg: #f7f5f1;
  --surface: #fffefc;
  --line: rgba(24, 22, 18, 0.10);
  --text: #1c1a17;
  --muted: #6d675e;
  --accent: #d4503a;
  --accent-soft: rgba(212, 80, 58, 0.10);
  --ok: #2f7d51;
  --warn: #b4741a;
  --shadow: 0 1px 2px rgba(24, 22, 18, .05), 0 4px 12px rgba(24, 22, 18, .04);
  --radius: 12px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #14130f;
  --surface: #1c1b17;
  --line: rgba(255, 253, 248, 0.12);
  --text: #ece8e1;
  --muted: #9a938a;
  --accent: #f0705a;
  --accent-soft: rgba(240, 112, 90, 0.14);
  --ok: #6cc08b;
  --warn: #e0a34a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* без этого display:flex у .filters перебивает атрибут hidden */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

.mono { font-family: ui-monospace, "SF Mono", Menlo, "JetBrains Mono", monospace; }

/* ------------------------------------------------------------------ шапка */
header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 var(--line);
}

h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.source {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.src-short { display: none; }
.dot.stale { background: var(--warn); }
.dot.off { background: var(--muted); }

.spacer { flex: 1; }

/* ------------------------------------------------------------- вкладки */
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--accent-soft); border-radius: 11px; }

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  min-height: 34px;
  border-radius: 8px;      /* концентрично: 11 внешний − 3 отступ */
  cursor: pointer;
  transition-property: background-color, color, scale;
  transition-duration: .15s;
  transition-timing-function: cubic-bezier(.2, 0, 0, 1);
}
.tab:hover { color: var(--text); }
.tab:active { scale: .96; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* --------------------------------------------------------------- фильтры */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

input[type="search"], input[type="text"], select {
  appearance: none;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 11px;
  min-height: 36px;
  transition-property: border-color, box-shadow;
  transition-duration: .15s;
}
input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="search"] { flex: 1 1 260px; min-width: 200px; }
input::placeholder { color: var(--muted); }

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  padding: 8px 10px;
  min-height: 36px;
  border-radius: 9px;
  cursor: pointer;
  user-select: none;
  transition-property: background-color, color;
  transition-duration: .15s;
}
.check:hover { background: var(--accent-soft); color: var(--text); }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

button.action {
  appearance: none;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 13px;
  min-height: 36px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition-property: scale, background-color, color, border-color;
  transition-duration: .15s;
  transition-timing-function: cubic-bezier(.2, 0, 0, 1);
}
button.action:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
button.action:active { scale: .96; }
button.action.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.action[disabled] { opacity: .5; cursor: default; scale: 1; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  font-size: 15px;
  display: grid;
  place-items: center;
  transition-property: background-color, color, scale;
  transition-duration: .15s;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }
.icon-btn:active { scale: .96; }

/* --------------------------------------------------------------- сводка */
.summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  min-height: 40px;
}
.summary b { color: var(--text); font-weight: 600; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

/* полоска загрузки: видно, что фильтр применяется, без прыжков раскладки */
.bar { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--accent); z-index: 60; opacity: 0; transition-property: width, opacity; transition-duration: .2s; }
.bar.on { width: 70%; opacity: 1; }
.bar.done { width: 100%; opacity: 0; transition-duration: .35s; }

/* --------------------------------------------------------------- таблица */
.scroll { overflow: auto; max-height: calc(100vh - 190px); }

table { border-collapse: collapse; width: 100%; font-size: 13px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 9px 12px;
  white-space: nowrap;
  box-shadow: 0 1px 0 var(--line);
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--text); }
thead th.plain { cursor: default; }
thead th[aria-sort] { color: var(--accent); }

tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  max-width: 460px;
}
tbody tr { transition-property: background-color; transition-duration: .12s; }
tbody tr:hover { background: var(--accent-soft); cursor: pointer; }

.clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.dim { color: var(--muted); }

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  background: color-mix(in srgb, var(--muted) 16%, transparent);
}
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.bad { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.badge.nch { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ----------------------------------------------------------- состояния */
.state { padding: 56px 20px; text-align: center; color: var(--muted); }
.state h2 { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 6px; text-wrap: balance; }
.state p { margin: 0 auto; max-width: 52ch; text-wrap: pretty; font-size: 13px; }
.state.error h2 { color: var(--accent); }

/* ------------------------------------------------------------ пагинация */
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 20px; font-size: 13px; color: var(--muted); }

/* --------------------------------------------------------------- панель */
.panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100vh;
  background: var(--surface);
  box-shadow: -1px 0 0 var(--line), -12px 0 40px rgba(0, 0, 0, .12);
  z-index: 50;
  overflow: auto;
  padding: 20px 24px 40px;
  translate: 100% 0;
  pointer-events: none;   /* закрытая панель не должна ловить клики по шапке */
  transition-property: translate;
  transition-duration: .22s;
  transition-timing-function: cubic-bezier(.2, 0, 0, 1);
}
.panel.open { translate: 0 0; pointer-events: auto; }
.panel h2 { font-size: 16px; margin: 0 8px 4px 0; text-wrap: balance; }
.panel h3 { font-size: 13px; font-weight: 600; margin: 22px 0 6px; color: var(--accent); }
.panel p { margin: 0; font-size: 13px; line-height: 1.55; text-wrap: pretty; color: var(--muted); }
.panel p b { color: var(--text); font-weight: 600; }
.panel dl { display: grid; grid-template-columns: 130px 1fr; gap: 7px 14px; margin: 18px 0 0; font-size: 13px; }
.panel h3 + dl { margin-top: 8px; }
.panel dt { color: var(--muted); }
.panel dd { margin: 0; overflow-wrap: anywhere; }
.panel .head { display: flex; align-items: flex-start; gap: 8px; }

@media (max-width: 860px) {
  .filters { padding: 10px 12px; }
  .summary, .pager, header { padding-inline: 12px; }

  /* шапка в две строки: иначе вкладки уезжают за край экрана */
  header { flex-wrap: wrap; gap: 8px 10px; padding-block: 8px; }
  h1 { font-size: 14px; }
  .source { order: 3; width: 100%; font-size: 11.5px; }
  .tabs { order: 2; margin-left: auto; }
  .tab { padding: 7px 10px; font-size: 12.5px; }
  #help, #theme { order: 2; }

  .scroll { max-height: calc(100vh - 250px); }
  tbody td { max-width: 260px; }
}

@media (max-width: 560px) {
  /* на телефоне от подписи оставляем только дату данных,
     а вкладки занимают всю ширину — по ним попадают пальцем */
  .src-full { display: none; }
  .src-short { display: inline; }
  .tabs { order: 1; width: 100%; margin-left: 0; }
  .tab { flex: 1; }
  .source { order: 2; width: auto; flex: 1; }
  #help, #theme { order: 2; }
}
