:root {
  --bg: #090b0e;
  --bg-2: #10141a;
  --card: #161c24;
  --line: #2a3340;
  --text: #eef2f6;
  --muted: #8b97a8;
  --accent: #ff4d1c;
  --accent-2: #ffb020;
  --win: #3dd68c;
  --danger: #ff5d73;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #2a140e 0%, transparent 50%),
              radial-gradient(900px 500px at 100% 0%, #142033 0%, transparent 45%),
              var(--bg);
  color: var(--text);
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100%;
}

.sidebar {
  background: rgba(16, 20, 26, 0.92);
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #ff8a3d);
  font-weight: 800; letter-spacing: 0.04em;
}
.brand-name { font-weight: 800; letter-spacing: 0.04em; }
.brand-sub { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; }

.nav { display: flex; flex-direction: column; gap: 8px; }
.nav-btn, .btn, select, input, textarea {
  font: inherit; color: inherit;
}
.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
}
.nav-btn:hover, .nav-btn.active {
  background: #1d2530;
  color: var(--text);
  border-color: var(--line);
}
.nav-btn.active { box-shadow: inset 3px 0 0 var(--accent); }
.nav-btn .badge { margin-left: 8px; vertical-align: middle; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.field.row { flex-direction: row; align-items: center; justify-content: space-between; }
input, select, textarea {
  background: #0d1116;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
textarea { min-height: 80px; resize: vertical; }

.btn {
  border: 1px solid var(--line);
  background: #1a222c;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: #4a2430; }
.file-btn { display: inline-flex; align-items: center; }

.main { padding: 22px 28px 48px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.topbar h1 { margin: 0; font-size: 28px; }
.top-actions { display: flex; gap: 8px; }

.view { display: flex; flex-direction: column; gap: 18px; }
.grid { display: grid; gap: 14px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.two { grid-template-columns: 1.2fr 0.8fr; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card h2, .card h3 { margin: 0 0 12px; }
.muted { color: var(--muted); }
.stat { font-size: 32px; font-weight: 800; }
.stat.small { font-size: 20px; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.note { margin: 0 0 10px; }
.toolbar.spread { justify-content: space-between; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 600; }
tr.me { background: rgba(255, 77, 28, 0.08); }
.num { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent-2); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #11161d; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted);
}
.chip.live { color: var(--win); border-color: #245a42; }
.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--accent); color: #fff;
}
.reg-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.switch-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.switch-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.status-dot { color: var(--win); font-weight: 700; }
.status-dot.closed { color: var(--danger); }
td .sub { display: block; font-weight: 400; }

.bracket {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 1fr);
  gap: 18px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.round { display: flex; flex-direction: column; justify-content: space-around; gap: 12px; min-height: 520px; }
.round h3 { margin: 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.match {
  background: #10151c;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
}
.match:hover { border-color: #445064; }
.pilot {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px;
  padding: 9px 10px;
  align-items: center;
}
.pilot + .pilot { border-top: 1px solid var(--line); }
.pilot.winner { background: rgba(61, 214, 140, 0.12); }
.pilot.bye { color: var(--muted); }
.seed { color: var(--muted); font-size: 12px; }

.attendance-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 18px; }
.attendance-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 9px 12px; background: #10151c; border: 1px solid var(--line); border-radius: 10px; }
.attendance-status { font-size: 12px; }
.attendance-status.present { color: #55d69a; }
.attendance-status.absent { color: #ff8b8b; }
.attendance-row .switch-row { margin: 0; white-space: nowrap; }
.qual-list { display: flex; flex-direction: column; gap: 8px; }
.qual-row {
  display: grid;
  grid-template-columns: 42px 1fr 210px 70px 80px;
  gap: 10px;
  align-items: center;
  background: #10151c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
}
.qual-row .scores { display: flex; gap: 6px; }
.qual-row .scores input { width: 100%; min-width: 0; padding: 8px 10px; }

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
/* онлайн-этап: шире, чтобы сетка батлов помещалась без горизонтального скролла */
.page.wide { max-width: 1180px; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head .brand-name { font-size: 20px; }
.page h1 { margin: 0 0 10px; font-size: 26px; }
.page form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.page .field > span { display: block; }
.reg-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #10151c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0 0 14px;
}
.reg-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.reg-label { color: var(--muted); font-size: 12px; min-width: 130px; }
.reg-closed {
  border: 1px solid #4a2430;
  background: rgba(255, 93, 115, 0.12);
  color: #ffb3bd;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 14px;
}
.hidden { display: none !important; }

.error {
  border: 1px solid #4a2430;
  background: rgba(255, 93, 115, 0.12);
  color: #ffb3bd;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.link-box { display: flex; gap: 8px; }
.link-box input { flex: 1; min-width: 0; font-size: 13px; }
td.win { color: var(--win); font-weight: 700; }
td.lose { color: var(--danger); }

.modal.hidden { display: none; }
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: grid; place-items: center;
  padding: 20px;
  z-index: 40; /* выше мобильного сайдбара (30) и его оверлея (25) */
}
.modal-card {
  width: min(520px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 14px; }
.modal-body { display: flex; flex-direction: column; gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Бейджи статусов в таблице аккаунтов: только цвета,
   базовый вид .badge (счётчик заявок и др.) не перебиваем */
.badge.ok,
.badge.warn,
.badge.muted {
  height: auto; min-height: 22px; padding: 2px 9px;
  font-size: 11px; letter-spacing: 0.06em;
}
.badge.ok   { color: var(--win); background: rgba(61, 214, 140, 0.12); border: 1px solid rgba(61, 214, 140, 0.35); }
.badge.warn { color: var(--accent-2); background: rgba(255, 176, 32, 0.12); border: 1px solid rgba(255, 176, 32, 0.35); }
.badge.muted{ color: var(--muted); background: transparent; border: 1px solid var(--line); }

/* Бургер-кнопка — скрыта на ПК, показана на телефоне */
#burgerBtn { display: none; }

/* Сайдбар по умолчанию скрыт на телефоне */
@media (max-width: 900px) {
  #burgerBtn { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; font-size: 20px; }
  /* drawer выезжает слева — как на десктопе */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 270px;
    max-width: 82vw;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .app { grid-template-columns: 1fr; }
  .grid.two { grid-template-columns: 1fr; }

  /* Overlay при открытом сайдбаре на телефоне */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 25;
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.open { display: block; }

  body.no-scroll { overflow: hidden; }
}

@media (min-width: 901px) {
  .sidebar { transform: none; position: static; width: auto; max-width: none; }
}

.brand-logo { width: 58px; height: 58px; object-fit: cover; border-radius: 12px; flex: 0 0 auto; }
.site-credit { position: fixed; right: 12px; bottom: 8px; z-index: 5; color: rgba(210,216,225,.42); font-size: 10px; letter-spacing: .08em; pointer-events: none; user-select: none; }
