:root {
  --bg: #07090d;
  --panel: #121821;
  --panel2: #172130;
  --panel3: #0d131c;
  --text: #eef3fb;
  --muted: #91a0b4;
  --soft: #c6d0df;
  --accent: #d84b34;
  --accent2: #f0a53a;
  --danger: #ff5757;
  --warn: #e6a33a;
  --ok: #55d68a;
  --border: #263241;
  --border2: #334255;
  --shadow: 0 14px 45px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, rgba(216,75,52,.24), transparent 28%),
    radial-gradient(circle at 90% 10%, rgba(240,165,58,.08), transparent 28%),
    linear-gradient(160deg, #07090d 0, #0b1018 55%, #05070a 100%);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: rgba(7, 9, 13, .90);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--border);
  padding: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.brand-logo {
  width: 40px;
  height: 40px;
  min-width: 40px;
  max-width: 40px;
  display: block;
  border-radius: 11px;
  object-fit: contain;
  box-shadow: 0 10px 24px rgba(216,75,52,.24);
}
.brand-title { font-weight: 900; font-size: 17px; line-height: 1.1; letter-spacing: .01em; }
.brand-subtitle { font-size: 11px; color: var(--muted); line-height: 1.2; }

nav { display: grid; gap: 7px; margin-top: 24px; }
nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: .16s ease;
  font-size: 14px;
}
nav a:hover { color: var(--text); background: var(--panel); border-color: var(--border); }

.content { padding: 18px; max-width: 1740px; width: 100%; }

.hero,
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.hero {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(216,75,52,.18), rgba(18,24,33,.92));
  box-shadow: var(--shadow);
}

.compact-hero { padding: 14px 16px; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

h1, h2, p { margin-top: 0; }
h1 { font-size: 25px; margin-bottom: 4px; letter-spacing: -.03em; }
h2 { font-size: 16px; margin-bottom: 9px; }
p { color: var(--muted); margin-bottom: 0; }

.eyebrow {
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
  font-weight: 900;
}

.panel,
.stat-card,
.candidate-card,
.logic-card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(18,24,33,.95), rgba(13,19,28,.95));
  border-radius: 17px;
  padding: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
}

.panel { margin-bottom: 10px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.panel-head h2 { margin-bottom: 0; }
.panel a { color: var(--accent2); }

.control-stack {
  display: grid;
  grid-template-columns: minmax(540px, 1.25fr) minmax(340px, .75fr);
  gap: 10px;
  align-items: stretch;
  margin-bottom: 10px;
}

.control-panel { margin-bottom: 0; }
.settings-panel, .lobby-panel { min-height: 138px; }

.settings-grid {
  display: grid;
  grid-template-columns: minmax(160px, .9fr) minmax(180px, 1fr) minmax(260px, 1.35fr) minmax(150px, .75fr) auto;
  gap: 9px;
  align-items: end;
}
.settings-grid .btn { height: 38px; min-width: 128px; }

.form-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px 13px;
}
.form-panel .panel-head { margin-bottom: 0; }
.form-panel .inline-form { justify-content: flex-end; }
.form-panel input[name="dota_id"] { max-width: 260px; }
.form-panel input[name="slots"] { max-width: 96px; }

.table-panel { padding: 0; overflow: auto; border-radius: 18px; }
.table-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  left: 0;
  background: linear-gradient(180deg, rgba(18,24,33,.98), rgba(13,19,28,.98));
  z-index: 2;
}
.table-title h2 { margin: 0; }
.table-title span { color: var(--muted); font-size: 12px; }

.queue-table { min-width: 1180px; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 8px 9px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
}
th {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: rgba(8,13,20,.92);
  position: sticky;
  top: 0;
  z-index: 1;
}
td a { color: var(--text); font-weight: 800; }

.queue-row { transition: .14s ease; }
.queue-row:hover { background: rgba(255,255,255,.028); }
.queue-row.is-dirty { background: linear-gradient(90deg, rgba(240,165,58,.12), transparent 58%); }
.top-row { background: linear-gradient(90deg, rgba(216,75,52,.16), transparent 55%); }
.top-row:hover { background: linear-gradient(90deg, rgba(216,75,52,.21), rgba(255,255,255,.025)); }

.rank-pill {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: #0b1119;
  border: 1px solid var(--border2);
  font-weight: 900;
  color: var(--accent2);
  font-size: 12px;
}
.reason-text { font-weight: 800; color: var(--soft); margin-bottom: 4px; max-width: 260px; }
.mini-flags { display: flex; gap: 5px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 11px; }
.quick-invite-form .muted { max-width: 260px; line-height: 1.25; }
.strong { font-weight: 900; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.comment-cell { min-width: 150px; max-width: 260px; color: var(--soft); }

.actions-cell {
  display: grid;
  grid-template-columns: repeat(2, minmax(78px, 1fr));
  gap: 6px;
  min-width: 184px;
}
.actions-cell form { margin: 0; }

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border2);
  background: linear-gradient(180deg, var(--panel2), #111925);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 12px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 800;
  transition: .14s ease;
  white-space: nowrap;
  font-size: 13px;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn.small { padding: 7px 8px; border-radius: 10px; font-size: 11px; width: 100%; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #8f2c22); border-color: #bd493b; }
.btn.warn { background: linear-gradient(135deg, #7a4c16, #3f2b13); border-color: #8d6327; }
.btn.danger, .danger { background: linear-gradient(135deg, #6d202a, #3b151b); border-color: #7e3039; }
.queue-row.is-dirty .inline-save-form .btn { border-color: var(--accent2); box-shadow: 0 0 0 2px rgba(240,165,58,.12); color: #ffe0a4; }

.badge { display: inline-flex; padding: 4px 7px; border-radius: 999px; font-size: 10px; font-weight: 900; }
.badge.ok { background: rgba(85,214,138,.14); color: var(--ok); }
.badge.danger { background: rgba(255,75,75,.14); color: var(--danger); }
.warn-badge { background: rgba(230,163,58,.14); color: var(--warn); }

.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 0; }
.quick-invite-form {
  display: grid;
  grid-template-columns: minmax(190px, 260px) auto;
  gap: 8px;
  align-items: end;
}
.quick-invite-form input[name="limit"] { max-width: 92px; }
.stack-form { display: grid; gap: 10px; }

input, textarea, select {
  width: 100%;
  background: #080d13;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 10px;
  color: var(--text);
  outline: none;
  font-size: 13px;
  min-height: 38px;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(216,75,52,.14); }
select.pretty-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent2) 50%), linear-gradient(135deg, var(--accent2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 10px) 52%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
select option { background: #080d13; color: var(--text); }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }

.inline-edit-input { padding: 7px 8px; border-radius: 9px; font-size: 12px; min-height: 32px; }
.editable { cursor: text; border-radius: 8px; }
.editable:hover { outline: 1px dashed rgba(240,165,58,.38); outline-offset: 2px; }
.editable.edited { color: var(--accent2); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.candidate-card, .logic-card { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 12px; }
.candidate-actions { display: grid; gap: 10px; min-width: 240px; }

.alert {
  border: 1px solid #77343a;
  background: rgba(255,75,75,.12);
  color: #ffc7c7;
  border-radius: 14px;
  padding: 11px;
  margin-bottom: 12px;
  font-size: 13px;
}
.alert.inside { margin: 12px; }
.info-list { color: var(--muted); line-height: 1.7; margin-bottom: 18px; }
.empty-state { text-align: center; padding: 40px 18px; }

.lobby-summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.lobby-summary span { color: var(--muted); }
.mini-list { display: grid; gap: 6px; max-height: 160px; overflow: auto; }
.lobby-list-large { max-height: 214px; }
.mini-list div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 9px;
  font-size: 13px;
}
.mini-list small { color: var(--muted); }

.toast-root { position: fixed; right: 18px; top: 18px; z-index: 50; display: grid; gap: 8px; }
.toast {
  border: 1px solid rgba(85,214,138,.32);
  background: rgba(15,35,26,.95);
  color: #d9ffe9;
  border-radius: 14px;
  padding: 11px 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
  animation: toast-in .18s ease;
  font-size: 13px;
}
.toast.warning { border-color: rgba(230,163,58,.35); background: rgba(52,37,14,.96); color: #ffe9bf; }
.toast.error { border-color: rgba(255,87,87,.35); background: rgba(55,19,24,.96); color: #ffd2d2; }
.toast.hide { opacity: 0; transform: translateY(-8px); transition: .28s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: min(420px, 92vw);
  background: rgba(18,24,33,.94);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 30px 90px rgba(0,0,0,.35);
  display: grid;
  gap: 14px;
}
.login-brand { margin-bottom: 8px; }

@media (max-width: 1380px) {
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid label:nth-child(3) { grid-column: span 2; }
  .settings-grid .btn { min-width: 0; }
}

@media (max-width: 1180px) {
  .control-stack { grid-template-columns: 1fr; }
  .form-panel { grid-template-columns: 1fr; }
  .form-panel .inline-form { justify-content: flex-start; }
}

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .grid-2, .settings-grid { grid-template-columns: 1fr; }
  .settings-grid label:nth-child(3) { grid-column: span 1; }
  .hero, .page-head, .candidate-card, .logic-card { display: block; }
  .content { padding: 14px; }
  .head-actions { margin-top: 12px; }
  .quick-invite-form { grid-template-columns: 1fr; }
  .actions-cell { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  h1 { font-size: 22px; }
  .compact-hero { padding: 13px; }
  .quick-invite-form, .inline-form { width: 100%; }
  .quick-invite-form .btn, .inline-form .btn { flex: 1; }
}
