/* Пастон · панель администратора.
 *
 * Без внешних шрифтов и библиотек (строгий CSP: только свои файлы).
 * Цвета — сукно карточного стола и латунь: тёмно-зелёное меню, золотой
 * акцент. Все цвета — переменные; тёмная тема — по настройке системы. */

:root {
  --bg: #f3f2ee;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --text: #1d2420;
  --muted: #6b726d;
  --line: #e3e1da;
  --line-strong: #d3d0c6;

  --brand: #14402e;
  --brand-2: #1c5a41;
  --brand-text: #eef5f0;
  --brand-muted: #9fb8aa;
  --gold: #c9a24a;

  --accent: #1f7a55;
  --accent-hover: #186446;
  --accent-text: #ffffff;
  --accent-soft: #e3f1ea;

  --danger: #b4322a;
  --danger-soft: #fbe9e7;
  --warn: #9a6a00;
  --warn-soft: #fbf1d9;
  --info: #2a5ea8;
  --info-soft: #e6eef9;
  --neutral-soft: #eeede8;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 14px rgba(20, 30, 25, .05);
  --focus: 0 0 0 3px rgba(31, 122, 85, .28);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --surface: #1a201d;
    --surface-2: #151b18;
    --text: #e6ebe8;
    --muted: #96a19b;
    --line: #2a322e;
    --line-strong: #37413c;

    --brand: #0d1f17;
    --brand-2: #163326;
    --brand-text: #e3efe8;
    --brand-muted: #86a294;

    --accent: #3aa679;
    --accent-hover: #4bb98b;
    --accent-text: #08130e;
    --accent-soft: #173327;

    --danger: #ef7a70;
    --danger-soft: #3a1c1a;
    --warn: #e3b75a;
    --warn-soft: #362a12;
    --info: #79a6ee;
    --info-soft: #1a2638;
    --neutral-soft: #242b28;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* hidden должен скрывать и кнопки, которым задан display. */
[hidden] { display: none !important; }
html, body { height: 100%; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.small { font-size: 12px; }

/* ─── Каркас: меню слева, содержимое справа ─────────────────────────────── */

.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--brand);
  color: var(--brand-text);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--brand-text); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--gold); color: var(--brand);
  font-size: 20px; font-weight: 700;
}
.brand-name { font-weight: 650; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--brand-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--brand-text); text-decoration: none; opacity: .82;
}
.nav a:hover { background: var(--brand-2); opacity: 1; }
.nav a.active { background: var(--brand-2); opacity: 1; box-shadow: inset 3px 0 0 var(--gold); }
.nav .count {
  min-width: 22px; padding: 0 7px; border-radius: 99px;
  background: var(--gold); color: var(--brand); font-size: 12px; font-weight: 700; text-align: center;
}

.who { margin-top: auto; padding: 12px; border-radius: var(--radius-sm); background: var(--brand-2); }
.who-name { font-weight: 600; }
.who-role { font-size: 12px; color: var(--brand-muted); margin-bottom: 10px; }
.who button { width: 100%; background: transparent; color: var(--brand-text); border-color: rgba(255, 255, 255, .25); }
.who button:hover { background: rgba(255, 255, 255, .08); }

.content { padding: 28px 32px 48px; max-width: 1280px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; }
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); }

/* ─── Карточки ──────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .hint { color: var(--muted); font-size: 12px; }
.note {
  background: var(--info-soft); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
}
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.two-col > .card { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > .card { margin-bottom: 0; }

/* ─── Сводка ────────────────────────────────────────────────────────────── */

.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 10px; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 20px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; position: relative; overflow: hidden;
}
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tone, var(--accent)); }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 28px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile.warn { --tone: var(--warn); }
.tile.danger { --tone: var(--danger); }
.tile.info { --tone: var(--info); }
.tile.gold { --tone: var(--gold); }
a.tile { color: inherit; text-decoration: none; display: block; }
a.tile:hover { border-color: var(--line-strong); }
a.tile .go { font-size: 12px; color: var(--accent); margin-top: 6px; }

/* ─── Формы и кнопки ────────────────────────────────────────────────────── */

.filters { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); align-items: end; }
.filters .wide { grid-column: span 2; }
.filters .actions { display: flex; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }

input, select, textarea, button { font: inherit; color: var(--text); }
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  min-height: 38px;
  width: 100%;
  font-size: 14px;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }

button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer; font-weight: 550; white-space: nowrap;
}
button:hover { background: var(--surface-2); }
button:focus-visible { outline: none; box-shadow: var(--focus); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { background: var(--accent-hover); }
button.danger { color: var(--danger); border-color: var(--danger); background: var(--surface); }
button.danger:hover { background: var(--danger-soft); }
button.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ─── Метки состояний ───────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--neutral-soft); color: var(--muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* ─── Таблицы ───────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--surface-2); }
td.wrap { white-space: normal; word-break: break-word; min-width: 180px; }
td.right, th.right { text-align: right; }
td.empty { text-align: center; color: var(--muted); padding: 28px; }
.plus { color: var(--accent); }
.minus { color: var(--danger); }

.who-cell { display: flex; align-items: center; gap: 10px; }
.who-cell .name { font-weight: 600; }
.who-cell .sub { font-size: 12px; color: var(--muted); }

.initials {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-weight: 650; font-size: 13px; color: #fff;
  background: var(--tone, var(--brand-2));
}
.initials.big { width: 64px; height: 64px; font-size: 24px; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 14px; flex-wrap: wrap; }

/* ─── Карточка игрока ───────────────────────────────────────────────────── */

.profile { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile h1 { font-size: 24px; }
.profile .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; color: var(--muted); }
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); margin-top: 18px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }

dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; word-break: break-word; }

.restriction-state {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px;
  background: var(--accent-soft);
}
.restriction-state.active { background: var(--danger-soft); }
.restriction-state .title { font-weight: 600; }

/* ─── Фото ──────────────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border-radius: 99px; min-height: 32px; padding: 4px 14px; }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.avatar-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.avatar-card { display: flex; gap: 14px; margin: 0; padding: 14px; }
.avatar-card img, .avatar-gone {
  width: 148px; height: 148px; border-radius: var(--radius-sm); object-fit: cover; flex: none;
  background: var(--surface-2); border: 1px solid var(--line);
}
.avatar-gone { display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.avatar-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.avatar-body .name { font-weight: 600; }
.bars { display: flex; flex-direction: column; gap: 4px; }
.bar { display: grid; grid-template-columns: 96px 1fr 38px; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.bar .track { height: 6px; border-radius: 99px; background: var(--neutral-soft); overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); }
.bar .fill.warn { background: var(--warn); }
.bar .fill.danger { background: var(--danger); }
.avatar-body .row { margin-top: auto; padding-top: 6px; }

/* ─── Журнал ────────────────────────────────────────────────────────────── */

.audit td { white-space: normal; }
.audit td:first-child, .audit td:nth-child(2), .audit td:last-child { white-space: nowrap; }
.audit td.wrap { min-width: 220px; }
.action-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.details { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }
.details span b { font-weight: 600; color: var(--muted); }

/* ─── Окна ──────────────────────────────────────────────────────────────── */

dialog {
  border: none; border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 0; width: min(500px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(10, 20, 15, .5); }
.dialog-form { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.dialog-form h2 { font-size: 17px; }
.dialog-form .warning { background: var(--warn-soft); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; }
.dialog-form .row { justify-content: flex-end; margin-top: 4px; }

/* ─── Вход ──────────────────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 30% 20%, var(--brand-2), var(--brand) 60%);
}
.login-card {
  width: min(380px, 100%); background: var(--surface); border-radius: 16px;
  padding: 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.login-card .brand { color: var(--text); padding: 0; margin-bottom: 22px; }
.login-card .brand-sub { color: var(--muted); }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card button { width: 100%; }

.loading { color: var(--muted); padding: 24px 0; }

/* ─── Узкие экраны ──────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  /* Меню — шапкой: логотип и выход в строку, разделы — лентой под ними. */
  .sidebar {
    position: sticky; z-index: 5; height: auto;
    display: grid; grid-template-columns: 1fr auto; align-items: center;
    padding: 10px 16px 0; gap: 8px 12px; align-content: start;
  }
  .brand-mark { width: 30px; height: 30px; font-size: 17px; border-radius: 8px; }
  .brand-sub { display: none; }
  .brand { grid-row: 1; grid-column: 1; }
  .who { grid-row: 1; grid-column: 2; margin: 0; padding: 0; background: none; display: flex; align-items: center; gap: 10px; }
  .who-name, .who-role { display: none; }
  .who button { width: auto; }
  .nav {
    grid-row: 2; grid-column: 1 / -1; flex-direction: row; gap: 4px;
    overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 12px 8px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 7px 12px; }
  .nav a.active { box-shadow: inset 0 -2px 0 var(--gold); }
  .content { padding: 20px 16px 40px; }
  .two-col { grid-template-columns: 1fr; }
  .filters .wide { grid-column: auto; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .avatar-card { flex-direction: column; }
  .avatar-card img, .avatar-gone { width: 100%; height: auto; aspect-ratio: 1; }
  .profile { flex-direction: column; align-items: flex-start; gap: 12px; }
  .initials.big { width: 52px; height: 52px; font-size: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile .value { font-size: 22px; }
  dl.props { grid-template-columns: 1fr; gap: 2px; }
  dl.props dd { margin-bottom: 8px; }
}
