:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --card: #ffffff;
  --head: #fafbfc;
  --text: #1d2330;
  --muted: #6b7385;
  --line: #dfe3ea;
  --accent: #2459c9;
  --accent-text: #ffffff;
  --ok-bg: #e7f5ec;
  --ok-text: #17663a;
  --err-bg: #fdecec;
  --err-text: #a12626;
  --warn-bg: #fff4e0;
  --warn-text: #8a5300;
  --row-hover: #f0f4fb;
}

/* Тёмная тема: по настройке системы, пока пользователь не выбрал сам (data-theme из theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #15181e;
    --card: #1d2129;
    --head: #20252e;
    --text: #e4e7ee;
    --muted: #9099ad;
    --line: #2f3542;
    --accent: #6f9bff;
    --accent-text: #0e1320;
    --ok-bg: #16331f;
    --ok-text: #8fd9a8;
    --err-bg: #3b1c1c;
    --err-text: #f29a9a;
    --warn-bg: #3a2c12;
    --warn-text: #f1c27a;
    --row-hover: #242a36;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15181e;
  --card: #1d2129;
  --head: #20252e;
  --text: #e4e7ee;
  --muted: #9099ad;
  --line: #2f3542;
  --accent: #6f9bff;
  --accent-text: #0e1320;
  --ok-bg: #16331f;
  --ok-text: #8fd9a8;
  --err-bg: #3b1c1c;
  --err-text: #f29a9a;
  --warn-bg: #3a2c12;
  --warn-text: #f1c27a;
  --row-hover: #242a36;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 13px; }
h1 { font-size: 20px; margin: 4px 0 14px; }
h2 { font-size: 16px; margin: 0 0 10px; }

.top {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 48px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.top-anon { justify-content: flex-end; background: transparent; border: 0; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--text); }
.top nav a.active, .top nav a:hover { background: var(--bg); text-decoration: none; }
.me { display: flex; align-items: center; gap: 12px; }
button.theme { width: 32px; padding: 0; font-size: 16px; line-height: 1; color: var(--muted); }

main { padding: 16px 20px 32px; max-width: 1400px; margin: 0 auto; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 12px 0 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 0 0 16px;
}
.narrow { max-width: 460px; }
.login { max-width: 340px; margin: 8vh auto 0; }
.login h1 { text-align: center; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.card label { margin-bottom: 10px; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 12px; padding: 8px 12px; }
legend { color: var(--muted); font-size: 12px; }

input, select, button, .button {
  font: inherit;
  color: var(--text);
  height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
}
input[type="checkbox"] { height: auto; }
textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 10px; resize: vertical; font-family: Consolas, Menlo, monospace; font-size: 13px; }
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.agents td form.row { max-width: 520px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .button { cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.button:hover { text-decoration: none; background: var(--bg); }
button:hover { background: var(--bg); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; height: auto; }
button.link:hover { text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
form.inline { display: inline; }
form.row { display: flex; gap: 6px; align-items: center; }
form.row input { min-width: 0; flex: 1; }
label .row { display: flex; gap: 6px; }
label .row input { flex: 1; min-width: 0; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.filters .grow { flex: 1; min-width: 220px; }
.filters label.check { height: 32px; }

.summary { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin: 0 0 10px; }
.index-status { flex: 1; text-align: right; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--head); }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: 0; }
tr.disabled td { color: var(--muted); }
.num { text-align: right; }
.nowrap { white-space: nowrap; }
.who { max-width: 380px; overflow-wrap: anywhere; }
.details { font-family: Consolas, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; max-width: 560px; }
.player-col { width: 1%; text-align: right; }
.player-col audio { height: 32px; width: 300px; vertical-align: middle; }
.play, .player-col .button { width: 34px; padding: 0; }
a.sort { color: var(--muted); }
a.sort.active { color: var(--text); }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.err { background: var(--err-bg); color: var(--err-text); }
.muted { color: var(--muted); }
.bad { color: var(--err-text); }
.tag { display: inline-block; padding: 0 5px; border-radius: 4px; background: var(--bg); color: var(--muted); font-size: 11px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.pages { display: flex; justify-content: center; gap: 4px; align-items: center; flex-wrap: wrap; }
.pages a, .pages span { min-width: 32px; height: 32px; padding: 0 8px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center; }
.pages a:hover { background: var(--card); text-decoration: none; }
.pages .current { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.secret { width: 100%; font-family: Consolas, Menlo, monospace; }
.key-created { border-color: var(--ok-text); }
.op h2 { display: flex; align-items: center; gap: 8px; }
.method { font-size: 12px; padding: 2px 6px; border-radius: 4px; background: var(--ok-bg); color: var(--ok-text); }
.method.post { background: var(--warn-bg); color: var(--warn-text); }
.users form.row select { flex: 0 0 auto; }
/* Узкая база для полей в строках таблицы: растут, если есть место, и не раздвигают страницу. */
.users form.row input, .agents form.row input { width: 8em; }
