:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #23263a;
  --muted: #6b7084;
  --line: #e6eaf3;
  --main: #ff7a45;
  --blue: #3d6ffd;
  --ok: #1fa86a;
  --bad: #e5484d;
  --gold: #f2b01e;
  --soft: #eef2ff;
  --shadow: 0 1px 2px rgba(35, 38, 58, .06), 0 6px 20px rgba(35, 38, 58, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
code { background: var(--soft); padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }
.muted { color: var(--muted); font-weight: 600; }
.warn { color: var(--bad); font-weight: 800; }

.btn {
  border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 800;
  background: var(--soft); color: var(--ink);
}
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--main); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: #ffe8e9; color: var(--bad); }
.btn.small { padding: 6px 12px; font-size: 14px; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  background: var(--card); border-radius: 20px; padding: 32px 28px; max-width: 440px; width: 100%;
  box-shadow: var(--shadow); text-align: center;
}
.login-card .logo { font-size: 56px; }
.login-card h1 { font-size: 22px; margin: 8px 0; }
.uid-row { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 10px 0; flex-wrap: wrap; }

/* ---------- каркас ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-size: 18px; white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 700; }
.brand em { font-style: normal; font-size: 12px; background: #fff3d6; color: #8a5a00; padding: 2px 8px; border-radius: 8px; margin-left: 6px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 800; color: var(--muted); white-space: nowrap;
}
.tabs button.on { background: var(--soft); color: var(--blue); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--ok); color: #fff; font-size: 12px; text-align: center; }

.main { max-width: 1200px; margin: 0 auto; padding: 20px; }
.view-head h2 { margin: 0 0 4px; font-size: 24px; }
.view-head p { margin: 0 0 16px; }
h3 { margin: 24px 0 10px; font-size: 17px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi small { display: block; color: var(--muted); font-size: 13px; }
.kpi b { font-size: 26px; font-weight: 900; }

/* ---------- онлайн ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pcard {
  background: var(--card); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow);
  border-left: 5px solid var(--muted); cursor: pointer;
}
.pcard.playing { border-left-color: var(--ok); }
.pcard.menu { border-left-color: var(--blue); }
.pcard-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pcard-head b { font-size: 18px; }
.pill { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 8px; background: var(--soft); white-space: nowrap; }
.pill.playing { background: #dcf6ea; color: var(--ok); }
.pill.menu { background: #e5ecff; color: var(--blue); }
.pill.offline { background: #eef0f4; color: var(--muted); }
.pill.win { background: #dcf6ea; color: var(--ok); }
.pill.loss { background: #eef0f4; color: var(--muted); }
.pill.violation { background: #ffe8e9; color: var(--bad); }
.pcard-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; text-align: center; }
.pcard-stats div { background: var(--bg); border-radius: 10px; padding: 6px 2px; }
.pcard-stats small { display: block; color: var(--muted); font-size: 11px; }
.pcard-stats b { font-size: 16px; }
.pcard-foot { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.empty-box { background: var(--card); border-radius: 16px; padding: 28px; text-align: center; color: var(--muted); box-shadow: var(--shadow); }

/* ---------- таблицы ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select {
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); min-width: 180px;
}
.table-wrap { overflow-x: auto; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { font-size: 12px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .03em; background: #fafbfe; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table.clickable tbody tr { cursor: pointer; }
.table.clickable tbody tr:hover { background: #f7f9ff; }
.table .empty { text-align: center; color: var(--muted); padding: 24px; }
.place { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--soft); font-size: 13px; font-weight: 900; }
.place.p1 { background: #ffe39a; } .place.p2 { background: #e2e6ee; } .place.p3 { background: #f6cfae; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; }

/* ---------- настройки ---------- */
.settings fieldset {
  background: var(--card); border: 0; border-radius: 16px; padding: 16px 18px; margin: 0 0 14px; box-shadow: var(--shadow);
}
.settings legend { font-weight: 900; font-size: 16px; padding: 0; float: left; width: 100%; margin-bottom: 10px; }
.settings legend + * { clear: both; }
.grid-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.grid-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 700; }
.settings input[type=number], .settings input[type=text], .settings select {
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 15px; color: var(--ink); width: 100%;
}
.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-weight: 700; }
.check input { width: 18px; height: 18px; margin-top: 2px; }
.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.row { display: grid; gap: 8px; align-items: center; }
.row.age { grid-template-columns: 1fr 1fr auto; }
.row.ach { grid-template-columns: 56px 1fr 1.6fr 1.4fr 90px auto; }
.row .ico-input { text-align: center; font-size: 20px; padding: 4px; }
.row-head { font-size: 12px; color: var(--muted); font-weight: 800; }
.row-del { background: transparent; border: 0; color: var(--bad); font-size: 18px; padding: 4px 8px; }
.save-bar {
  position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--bg); padding: 12px 0;
}

/* ---------- карточка игрока ---------- */
.modal { position: fixed; inset: 0; background: rgba(20, 22, 40, .45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-box {
  position: relative; background: var(--card); border-radius: 20px; padding: 24px; width: 100%; max-width: 720px;
  max-height: calc(100vh - 32px); overflow: auto;
}
.modal-close { position: absolute; top: 12px; right: 12px; border: 0; background: var(--soft); border-radius: 50%; width: 34px; height: 34px; }
.modal h2 { margin: 0; font-size: 24px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin: 16px 0; }
.stat-grid div { background: var(--bg); border-radius: 12px; padding: 10px; }
.stat-grid small { display: block; color: var(--muted); font-size: 12px; }
.stat-grid b { font-size: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 10px; background: #fff6dc; font-size: 13px; }
.chip.off { background: var(--bg); color: var(--muted); opacity: .7; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 150%); opacity: 0;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 30; transition: .3s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; padding: 10px 16px; }
  .tabs { order: 3; flex-basis: 100%; }
  .main { padding: 16px; }
  .row.ach { grid-template-columns: 48px 1fr auto; }
  .row.ach .ach-desc, .row.ach .ach-type { grid-column: 1 / -1; }
}

.pcard.paused { border-left-color: var(--bad); }
.pill.paused { background: #ffe8e9; color: var(--bad); }
.pin-box {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  background: #fff8e6; border-radius: 14px; padding: 12px 14px; margin-top: 14px;
}
.pin { font-size: 18px; font-weight: 900; letter-spacing: .1em; background: #fff; }
.pin-form { display: flex; gap: 8px; }
.pin-form input { padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); width: 190px; }

.steps { text-align: left; padding-left: 22px; line-height: 1.5; margin: 12px 0; }
.steps li { margin-bottom: 4px; }
.steps a { color: var(--blue); font-weight: 800; }
