/* Сайт и админка. Тема — по системной (prefers-color-scheme), акцент — фиолетовый Twitch. */
:root {
  --bg: #0e0e12;
  --surface: #18181f;
  --surface-2: #1f1f28;
  --border: #2c2c38;
  --text: #ececf1;
  --muted: #9a9aab;
  --accent: #9146ff;
  --accent-hover: #a970ff;
  --accent-text: #ffffff;
  --ok: #3ecf8e;
  --warn: #f5a524;
  --bad: #f2555a;
  --bad-bg: rgba(242, 85, 90, .12);
  --ok-bg: rgba(62, 207, 142, .12);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f6f9;
    --surface: #ffffff;
    --surface-2: #f0f0f5;
    --border: #e1e1ea;
    --text: #17171f;
    --muted: #63637a;
    --accent: #7a2ff0;
    --accent-hover: #6420d6;
    --ok: #12895a;
    --warn: #a86a00;
    --bad: #c9262c;
    --bad-bg: rgba(201, 38, 44, .08);
    --ok-bg: rgba(18, 137, 90, .08);
    --shadow: 0 1px 3px rgba(20, 20, 40, .08);
  }
}

* { 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 { color: var(--accent-hover); text-decoration: underline; }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
h1, h2 { line-height: 1.25; margin: 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }

/* --- шапка --- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 17px; }
.logo:hover { color: var(--text); text-decoration: none; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; }
.user-name { font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 28px; height: 28px; border-radius: 50%; flex: none; object-fit: cover; }
.avatar-letter { display: inline-grid; place-items: center; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 13px; }
.inline-form { display: inline; margin: 0; }

/* --- кнопки --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn-primary, .btn-twitch { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover, .btn-twitch:hover { background: var(--accent-hover); color: var(--accent-text); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); color: var(--bad); }
.btn-small { min-height: 30px; padding: 0 10px; font-size: 13px; background: var(--surface-2); color: var(--text); border-color: var(--border); }

/* --- главная и ошибки --- */
.hero { padding: 72px 16px; max-width: 720px; }
.hero h1 { font-size: 40px; margin-bottom: 12px; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 24px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* --- админка --- */
.admin { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; padding-top: 24px; padding-bottom: 48px; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 80px; align-self: start; }
.admin-group { margin: 14px 10px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.admin-link { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 8px; color: var(--text); }
.admin-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.admin-link.on { background: var(--accent); color: var(--accent-text); }
.admin-link.locked { color: var(--muted); cursor: not-allowed; }
.admin-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.page-title { font-size: 26px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin: 0; min-width: 0; }
fieldset.card { display: flex; flex-direction: column; gap: 14px; }
.card-title { font-size: 17px; margin-bottom: 8px; padding: 0; }
legend.card-title { float: left; width: 100%; margin-bottom: 4px; font-weight: 700; }
.card > p:last-child { margin-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card-link { color: var(--text); }
.card-link:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.card-link p { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 20px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.notice { margin: 0; padding: 10px 14px; border-radius: 8px; background: var(--ok-bg); border: 1px solid var(--ok); }
.notice-bad { background: var(--bad-bg); border-color: var(--bad); }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* --- формы --- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 13px; color: var(--muted); }
.field-wide { width: 100%; }
input[type=text], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; min-height: 36px; width: 100%;
}
textarea { resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.row-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 4px 0 12px; }
.field-check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.more { margin: 4px 0; }
.more summary { cursor: pointer; color: var(--accent); margin-bottom: 8px; }
.cmd-response { max-width: 460px; white-space: pre-wrap; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-off { opacity: .55; }
.row-form .field { flex: 1 1 180px; }

/* --- таблицы --- */
.table-scroll { overflow-x: auto; }
.table, .matrix { width: 100%; border-collapse: collapse; }
.table th, .table td, .matrix th, .matrix td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th, .matrix thead th { font-size: 13px; color: var(--muted); font-weight: 600; }
.matrix td { text-align: center; }
.matrix thead th:not(:first-child) { text-align: center; white-space: nowrap; }
.matrix-group th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.person { display: flex; align-items: center; gap: 10px; }
.tag { display: inline-block; padding: 1px 8px; margin: 1px 4px 1px 0; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.tag-win { border-color: var(--ok); color: var(--ok); }
.details { display: block; max-width: 420px; white-space: pre-wrap; overflow-wrap: anywhere; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.people li { padding: 3px 10px; background: var(--surface-2); border-radius: 999px; }

/* --- ставки --- */
.outcomes { list-style: none; margin: 8px 0 16px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.outcomes li { display: grid; grid-template-columns: minmax(80px, 180px) minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.outcome-title { font-weight: 600; overflow-wrap: anywhere; }
meter { width: 100%; height: 10px; }

@media (max-width: 760px) {
  .admin { grid-template-columns: minmax(0, 1fr); padding-top: 12px; }
  .admin-nav { position: static; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .admin-group { display: none; }
  .admin-link { padding: 6px 10px; background: var(--surface-2); }
  .hero { padding: 40px 16px; }
  .hero h1 { font-size: 30px; }
  .user-name { display: none; }
  .outcomes li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .facts { grid-template-columns: minmax(0, 1fr); }
}
