:root {
  --bg: #f3f0e9;
  --surface: #ffffff;
  --surface-2: #f7f5f0;
  --text: #1f2328;
  --muted: #5f6368;
  --line: #e2ded5;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #e8efff;
  --ok: #2f7a23;
  --ok-soft: #e6f3e2;
  --warn: #b26a00;
  --warn-soft: #fff1dc;
  --bad: #c62828;
  --bad-soft: #fde8e8;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #202328;
    --surface-2: #262a30;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --line: #353a41;
    --accent: #60a5fa;
    --accent-ink: #0b1220;
    --accent-soft: #1d2a40;
    --ok: #7bd389;
    --ok-soft: #1c3322;
    --warn: #f0b45a;
    --warn-soft: #3a2c14;
    --bad: #ff8a80;
    --bad-soft: #3d1f1f;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }

/* Шапка и навигация */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-inner { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { flex: none; white-space: nowrap; font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 500; color: var(--muted); font-size: 13px; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; order: 3; width: 100%; padding-bottom: 2px; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  white-space: nowrap; padding: 7px 12px; border-radius: 999px; color: var(--muted); font-weight: 500; font-size: 14px;
}
.nav a:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.nav a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--line); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
@media (min-width: 900px) {
  .top-inner { flex-wrap: nowrap; }
  .nav { order: 0; width: auto; min-width: 0; }
  .top-right { margin-left: auto; flex: none; }
}

main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { font-size: 24px; margin: 4px 0 4px; letter-spacing: -.01em; }
.lead { color: var(--muted); margin: 0 0 20px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }

/* Карточки */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; min-width: 0;
}
.grid .card { margin-bottom: 0; }
.stat-label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 18px; font-weight: 650; margin: 4px 0 2px; overflow-wrap: anywhere; }
.stat-sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

/* Значки */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Сообщения */
.flash { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid transparent; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash.err { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alerts { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.alerts h2 { color: var(--warn); }
.alerts ul { margin: 0; padding-left: 18px; }
.alerts li { margin: 4px 0; }

/* Формы */
form { margin: 0; }
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
label:first-child { margin-top: 0; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=email], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; outline: none;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; margin: 10px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.row { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 14px; }
.row label { margin-top: 0; }
.row > div > label { margin-top: 0; }
@media (max-width: 440px) { .row > div + div > label { margin-top: 14px; } }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.seg label { margin: 0; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 8px 6px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--line); }
.seg small { display: block; font-weight: 400; font-size: 12px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.05); }
button.danger { color: var(--bad); }
button.small { padding: 6px 12px; font-size: 13px; }
button.link { border: none; background: none; padding: 6px 8px; color: var(--muted); font-weight: 500; }
.inline { display: inline; }

/* Списки и таблицы */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: none; padding-top: 0; }
.ev-title { font-weight: 600; }
.ev-meta { color: var(--muted); font-size: 13px; }
table.log { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.log td { padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; }
table.log td.t { white-space: nowrap; color: var(--muted); width: 1%; }
table.log td.m { white-space: pre-wrap; overflow-wrap: anywhere; }
.lvl-error { color: var(--bad); font-weight: 600; }
.lvl-warn { color: var(--warn); font-weight: 600; }
pre.box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow: auto; max-height: 260px; font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 0; }
.copy { display: flex; gap: 8px; align-items: stretch; }
.copy input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
ol.steps { padding-left: 20px; margin: 6px 0; }
ol.steps li { margin: 4px 0; }
.muted { color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filters a { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; }
.filters a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Вход */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login .logo { font-size: 40px; text-align: center; }
.login h1 { text-align: center; margin-bottom: 2px; }
.login .lead { text-align: center; }
.login button { width: 100%; margin-top: 18px; padding: 11px; }
footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 0 16px 28px; }

.user-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-main { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; color: var(--text); }
.user-main:hover { text-decoration: none; }
.user-main:hover .ev-title { color: var(--accent); }
.user-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.gacc { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 10px; background: var(--surface-2); }
.gacc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gacc .check { margin: 8px 0 0; }
details > summary { list-style-position: outside; }
