/* COD2Reverse Server Manager - WWII operations room. No external fonts or libraries (CSP: self only). */
:root {
  --bg: #11130d;
  --bg-2: #171a12;
  --panel: #1d2117;
  --panel-2: #23281b;
  --line: #343b29;
  --line-2: #4a5339;
  --text: #e7e2cf;
  --muted: #a39f8b;
  --khaki: #c9b98a;
  --brass: #d4a84a;
  --brass-2: #f0c565;
  --olive: #6b7a3a;
  --go: #6fa34a;
  --go-2: #8cc463;
  --warn: #d79a2b;
  --stop: #c4513b;
  --stop-2: #e0684f;
  --info: #7aa0b8;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .35);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --nav-w: 216px;
  --top-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(212, 168, 74, .07), transparent 60%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .012) 0 2px, transparent 2px 6px);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--brass-2); }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: .02em; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .14em; color: var(--khaki); }
code, .mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.eyebrow { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .22em; color: var(--brass); font-weight: 700; }
.big { margin: 4px 0 0; font-size: 26px; font-weight: 700; line-height: 1.15; word-break: break-word; }

/* ---------------- buttons / inputs */
.btn {
  appearance: none; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  padding: 9px 16px; border-radius: 8px; font: 600 14px var(--font); letter-spacing: .03em; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, opacity .15s; min-height: 40px;
}
.btn:hover { border-color: var(--khaki); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, .user-btn:focus-visible { outline: 2px solid var(--brass-2); outline-offset: 2px; }
.btn-primary { background: linear-gradient(#a8853a, #8a6b2a); border-color: #c79c47; color: #17130a; }
.btn-primary:hover { background: linear-gradient(#bf9845, #9c7a31); border-color: var(--brass-2); }
.btn-go { background: linear-gradient(#5e8f3d, #476f2d); border-color: #79ab55; color: #f3f6ea; }
.btn-go:hover { background: linear-gradient(#6aa046, #527d33); }
.btn-warn { background: #3a2f16; border-color: #7a5c22; color: #f4d38e; }
.btn-stop { background: #3a1c16; border-color: #8a3a2b; color: #ffcfc4; }
.btn-stop:hover { background: #4a231b; border-color: var(--stop-2); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn-lg { padding: 13px 26px; font-size: 16px; min-height: 50px; text-transform: uppercase; letter-spacing: .1em; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row.end { justify-content: flex-end; }

input, select {
  background: #0f110b; color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 11px;
  font: 14px var(--font); min-height: 40px; max-width: 100%;
}
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--brass); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
.w-num { width: 90px; }
.w-filter { width: 150px; min-height: 32px; padding: 5px 9px; }
.grow { flex: 1 1 220px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.form-error { color: var(--stop-2); min-height: 1.4em; margin: 0; font-size: 13px; }

/* ---------------- login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line);
  border-radius: 14px; padding: 32px 26px 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.login-card h1 { font-size: 28px; text-transform: uppercase; letter-spacing: .12em; }
.login-card label { text-align: left; }
.insignia { display: grid; place-items: center; }

/* ---------------- shell */
.shell { min-height: 100%; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: rgba(17, 19, 13, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand strong { display: block; font-size: 15px; letter-spacing: .04em; }
.brand .eyebrow { font-size: 9.5px; }
.user-btn { background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 6px 12px; cursor: pointer; font: 600 13px var(--font); display: flex; gap: 8px; align-items: center; }
.role { font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--brass); }
.menu { position: fixed; z-index: 30; top: calc(var(--top-h) - 4px); right: 12px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 180px; overflow: hidden; }
.menu a, .menu button { padding: 12px 16px; text-align: left; color: var(--text); text-decoration: none; background: none; border: 0; font: 14px var(--font); cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--panel-2); }

.nav {
  position: fixed; top: var(--top-h); bottom: 0; left: 0; width: var(--nav-w); padding: 14px 10px; border-right: 1px solid var(--line);
  background: var(--bg-2); display: flex; flex-direction: column; gap: 2px; z-index: 10;
}
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; letter-spacing: .02em; }
.nav a svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a.active { color: var(--brass-2); background: linear-gradient(90deg, rgba(212, 168, 74, .14), transparent); box-shadow: inset 3px 0 0 var(--brass); }
.content { margin-left: var(--nav-w); padding: 22px 24px 60px; max-width: calc(1200px + var(--nav-w)); display: flex; flex-direction: column; gap: 18px; }
.page { display: none; flex-direction: column; gap: 18px; }
.page.active { display: flex; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------- cards */
.card { background: linear-gradient(180deg, var(--panel), #1a1e14); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.narrow { max-width: 480px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.two.tight { gap: 12px; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 16px 18px; }

.hero { display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 22px;
  background: linear-gradient(120deg, rgba(107, 122, 58, .22), rgba(29, 33, 23, .95) 55%), var(--panel); border-color: var(--line-2); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 220px; height: 220px; border-radius: 50%;
  border: 1px dashed rgba(212, 168, 74, .18); box-shadow: 0 0 0 30px rgba(212, 168, 74, .03), 0 0 0 60px rgba(212, 168, 74, .02); pointer-events: none; }
.hero h2 { font-size: 30px; margin: 4px 0 10px; word-break: break-word; }
.hero-main { min-width: 0; flex: 1 1 320px; }
.hero-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.connect { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.connect code { background: #0d0f09; border: 1px solid var(--line-2); padding: 5px 10px; border-radius: 6px; font-size: 15px; color: var(--brass-2); }

/* ---------------- status pill */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; border: 1px solid; white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-on { color: var(--go-2); border-color: rgba(140, 196, 99, .4); background: rgba(111, 163, 74, .12); }
.pill-on .dot { box-shadow: 0 0 0 0 rgba(140, 196, 99, .6); animation: pulse 2s infinite; }
.pill-off { color: var(--muted); border-color: var(--line-2); background: rgba(255, 255, 255, .02); }
.pill-busy { color: var(--warn); border-color: rgba(215, 154, 43, .4); background: rgba(215, 154, 43, .1); }
.pill-bad { color: var(--stop-2); border-color: rgba(224, 104, 79, .45); background: rgba(196, 81, 59, .12); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(140, 196, 99, .55); } 70% { box-shadow: 0 0 0 8px rgba(140, 196, 99, 0); } 100% { box-shadow: 0 0 0 0 rgba(140, 196, 99, 0); } }
@media (prefers-reduced-motion: reduce) { .pill-on .dot, .page.active { animation: none; } }

/* ---------------- meters, kv */
.meter-row { display: grid; grid-template-columns: 70px 1fr 110px; align-items: center; gap: 12px; margin: 10px 0; font-size: 13px; }
.meter-row b { text-align: right; font-family: var(--mono); font-weight: 600; font-size: 12.5px; }
.meter { height: 8px; background: #0d0f09; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--olive), var(--go-2)); transition: width .5s; }
.meter i.hot { background: linear-gradient(90deg, var(--warn), var(--stop-2)); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px dashed var(--line); font-size: 13px; }
.kv b { font-family: var(--mono); font-weight: 600; font-size: 12.5px; text-align: right; }

.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto; }
.events li { padding: 8px 10px; border-left: 3px solid var(--line-2); background: rgba(255, 255, 255, .015); font-size: 13px; border-radius: 0 6px 6px 0; }
.events li.error { border-left-color: var(--stop); }
.events li.info { border-left-color: var(--olive); }
.events time { display: block; font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* ---------------- tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: rgba(255, 255, 255, .015); }
.table .num { text-align: right; font-family: var(--mono); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.team { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.team-allies { background: rgba(122, 160, 184, .16); color: #a9cbe0; }
.team-axis { background: rgba(196, 81, 59, .16); color: #f0a898; }
.team-spectator { background: rgba(255, 255, 255, .05); color: var(--muted); }
.empty { text-align: center; padding: 18px 0 6px; margin: 0; }
.scoreboard { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.scoreboard .side { flex: 1 1 140px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.scoreboard .side b { font-size: 26px; font-family: var(--mono); }
.side.allies { background: rgba(122, 160, 184, .08); }
.side.axis { background: rgba(196, 81, 59, .08); }

.list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; font-family: var(--mono); word-break: break-all; }

.rotation { margin: 0 0 14px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; counter-reset: r; }
.rotation li { counter-increment: r; display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(255, 255, 255, .02); border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.rotation li::before { content: counter(r); font-family: var(--mono); color: var(--brass); width: 22px; }
.rotation li .gt { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-left: auto; }

/* ---------------- settings */
.set-group { margin-bottom: 18px; }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 260px); gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: 0; }
.set-row .lbl { font-weight: 600; font-size: 14px; }
.set-row .help { font-size: 12px; color: var(--muted); }
.apply { display: inline-block; margin-top: 3px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line-2); color: var(--muted); }
.apply-live { color: var(--go-2); border-color: rgba(140, 196, 99, .35); }
.apply-map_restart, .apply-next_round { color: var(--warn); border-color: rgba(215, 154, 43, .35); }
.apply-restart { color: var(--stop-2); border-color: rgba(224, 104, 79, .35); }
.set-row .ctl { display: flex; justify-content: flex-end; }
.set-row .ctl input:not([type=checkbox]), .set-row .ctl select { width: 100%; }
.set-row.changed .lbl::after { content: " •"; color: var(--brass-2); }
.weapons { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.weapons label { flex-direction: row; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); cursor: pointer; background: rgba(255, 255, 255, .015); }
.weapons label.changed { border-color: var(--brass); }
.sticky-save { position: sticky; bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; background: rgba(29, 33, 23, .96); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); }

.perms { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin: 0; }
.perms legend { padding: 0 6px; font-size: 12px; color: var(--muted); }
.perm-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.perm-tags span { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: rgba(255, 255, 255, .05); color: var(--khaki); white-space: nowrap; }

/* ---------------- console */
.console-card { display: flex; flex-direction: column; }
.console { margin: 0; background: #0a0b07; border: 1px solid var(--line); border-radius: 8px; padding: 12px; height: min(68vh, 720px); overflow: auto;
  font: 12.5px/1.5 var(--mono); color: #cfd8b8; white-space: pre-wrap; word-break: break-word; }
.console .err { color: var(--stop-2); }
.console .warn { color: var(--warn); }

/* ---------------- banners, toast, dialog */
.banner { padding: 12px 16px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); font-size: 14px; }
.banner-warn { border-color: rgba(215, 154, 43, .5); background: rgba(215, 154, 43, .08); }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text); padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow); transition: .2s; max-width: calc(100vw - 32px); font-size: 14px; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { border-color: var(--stop); }
.toast.good { border-color: var(--go); }
.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 12px; padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog h3 { margin-bottom: 10px; }
.dlg-text { white-space: pre-line; margin: 0 0 16px; color: var(--muted); }
.dlg-text .perms { white-space: normal; }

.job-steps { list-style: none; margin: 10px 0 0; padding: 0; font: 12px/1.6 var(--mono); color: var(--muted); max-height: 200px; overflow: auto; }

/* ---------------- responsive */
@media (max-width: 1100px) { .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  :root { --top-h: 56px; }
  .nav { top: auto; bottom: 0; right: 0; width: auto; height: calc(62px + env(safe-area-inset-bottom)); padding: 4px 4px env(safe-area-inset-bottom); flex-direction: row;
    border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; justify-content: space-around; gap: 0; z-index: 25; }
  .nav a { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 8px; min-width: 64px; justify-content: center; letter-spacing: .04em; }
  .nav a.active { box-shadow: inset 0 3px 0 var(--brass); background: rgba(212, 168, 74, .08); }
  .content { margin-left: 0; padding: 16px 16px calc(90px + env(safe-area-inset-bottom)); }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: 18px; }
  .hero h2 { font-size: 24px; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1 1 auto; }
  .hero-actions .btn-lg { flex-basis: 100%; }
  .set-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .set-row .ctl { justify-content: flex-start; }
  .brand div { display: none; }
  .sticky-save { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .meter-row { grid-template-columns: 60px 1fr 92px; }
}
@media (max-width: 480px) {
  .grid.stats { gap: 10px; }
  .stat { padding: 12px; }
  .big { font-size: 20px; }
  .card { padding: 14px; }
  .table td, .table th { padding: 8px 6px; }
  .user-btn .role { display: none; }
}
