:root {
  --bg: #0b1220;
  --bg-2: #101a2c;
  --panel: #132036;
  --panel-2: #182842;
  --line: #24365a;
  --text: #e6edf7;
  --muted: #8ea0bd;
  --accent: #38bdf8;
  --accent-2: #f59e0b;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f6fb; --bg-2: #e9eef6; --panel: #ffffff; --panel-2: #f5f8fc; --line: #d5deeb;
  --text: #13213a; --muted: #5a6b86; --accent: #0284c7; --accent-2: #d97706;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }

.boot { display: grid; place-items: center; height: 100vh; }
.boot-logo { font-size: 28px; font-weight: 700; letter-spacing: 4px; color: var(--accent); opacity: .7; }

/* Auth screens */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% -10%, #1b2c4d 0%, transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgb(0 0 0 / .35); }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.brand img { width: 36px; height: 36px; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.auth h1 { font-size: 20px; margin: 0 0 6px; }
.auth p.lead { color: var(--muted); margin: 0 0 18px; }

/* Forms */
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), textarea, select {
  width: 100%; padding: 9px 11px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.check input { width: auto; }
.opt .check input, td input[type=checkbox] { width: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04111f; font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; margin-top: 18px; }
.btn:disabled { opacity: .5; cursor: default; }
.error { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 18px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--bg-2); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; }
.side .brand { padding: 0 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav a:hover { background: var(--panel); }
.nav a.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.nav .ico { width: 18px; text-align: center; opacity: .8; }
.nav .soon { margin-left: auto; font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 0 6px; }
.side-foot { margin-top: auto; color: var(--muted); font-size: 12px; padding: 8px 6px 0; }
.main { display: flex; flex-direction: column; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 2; }
.top h2 { margin: 0; font-size: 17px; }
.top .spacer { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.user-chip { font-size: 13px; color: var(--muted); }
.user-chip b { color: var(--text); }
.content { padding: 22px; display: flex; flex-direction: column; gap: 18px; }

/* Cards */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat { font-size: 26px; font-weight: 700; }
.stat small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.bar { height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s; }
.bar > i.warn { background: var(--warn); }
.bar > i.bad { background: var(--bad); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.actions { text-align: right; white-space: nowrap; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; border: 1px solid var(--line); color: var(--muted); }
.badge.owner { color: var(--accent-2); border-color: var(--accent-2); }

/* Dialog */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(440px, 92vw); }
dialog::backdrop { background: rgb(0 0 0 / .55); }
dialog h3 { margin: 0 0 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast { position: fixed; bottom: 18px; right: 18px; background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--ok); padding: 10px 14px; border-radius: 8px; z-index: 50; }
.toast.err { border-left-color: var(--bad); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow-x: auto; padding: 8px; }
  .side .brand, .side-foot { display: none; }
  .nav { flex-direction: row; margin: 0; }
  .nav .soon { display: none; }
  .form-row { grid-template-columns: 1fr; }
}
h3.section { margin: 22px 0 4px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
form.card { max-width: 640px; }

/* Servers */
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.state.ok { color: var(--ok); } .state.ok::before { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.state.bad { color: var(--bad); } .state.bad::before { background: var(--bad); }
.state.busy { color: var(--warn); } .state.busy::before { background: var(--warn); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.grid.servers { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.server-card { color: var(--text); text-decoration: none; display: block; }
.server-card:hover { border-color: var(--accent); }
.server-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.big-name { font-size: 20px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.actions-row select { width: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { padding: 8px 14px; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.console { background: #050a14; color: #cfe3ff; font: 12px/1.45 Consolas, "Cascadia Mono", monospace; padding: 12px;
  border-radius: 8px; border: 1px solid var(--line); height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 10px 0 0; }
.console.tall { height: 60vh; }
.console-form { display: flex; gap: 8px; margin-top: 10px; }
.console-form input { flex: 1; font-family: Consolas, "Cascadia Mono", monospace; }
textarea { width: 100%; padding: 9px 11px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; color: inherit; font: inherit; }

/* Live view and chat (step 3) */
.table-wrap { overflow-x: auto; }
.chat { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; height: 55vh; overflow-y: auto; margin-top: 8px; }
.chat-line { padding: 3px 0; font-size: 13px; overflow-wrap: anywhere; }
.chat-line .badge { margin: 0 6px; }
.chat-line.from-eam b { color: var(--accent-2); }
.chat-time { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.console-form select { width: auto; }
#chat-more-wrap { text-align: center; }
@media (max-width: 760px) { .console-form { flex-wrap: wrap; } .console-form select { width: 100%; } }
#tab, #live { display: flex; flex-direction: column; gap: 14px; }

/* Server name, state and actions in the top bar */
.top { flex-wrap: wrap; }
.top-extra { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.top-extra:empty { display: none; }
.top-actions { margin-top: 0; }
.top-actions .btn { padding: 6px 12px; }
.server-top .error { margin-top: 0; }

/* Steps 4 and 5: players, backups, scheduler, options */
.btn.small { padding: 4px 10px; font-size: 12px; }
input.small { width: 90px !important; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin-left: 4px; }
.check.inline { display: inline-flex; margin: 0 10px 0 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--panel-2); }
tr.muted { opacity: .55; }
.actions-row.wrap .btn { flex: 0 0 auto; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.days { display: flex; flex-wrap: wrap; gap: 4px; }
select.picker { height: auto; min-height: 160px; }
.history { max-height: 320px; overflow-y: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.opt-filter { margin-bottom: 8px; }
.opts { max-height: 60vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.opt { display: grid; grid-template-columns: minmax(180px, 280px) minmax(120px, 1fr); gap: 4px 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); align-items: center; }
.opt:last-child { border-bottom: 0; }
.opt .hint { grid-column: 1 / -1; font-size: 12px; }
.opt.off .opt-val { opacity: .5; }
.opt.off b { color: var(--muted); font-weight: 500; }
.ws-list { display: grid; gap: 8px; margin-bottom: 10px; }
.ws-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
details.card summary { cursor: pointer; }
textarea.console { width: 100%; min-height: 50vh; font-family: Consolas, monospace; font-size: 12px; color: var(--text); resize: vertical; }
h4 { margin: 12px 0 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
@media (max-width: 700px) {
  .opt { grid-template-columns: 1fr; }
  .form-row.three { grid-template-columns: 1fr 1fr 1fr; }
  .row-actions { white-space: normal; }
}
.history .chat-time { margin-right: 8px; }

/* ---- steps 6 to 9 */
dialog.wide { width: min(860px, 96vw); max-height: 90vh; overflow: auto; }
.badge.warn { background: var(--warn); color: #000; }
.badge.bad { background: var(--bad); color: #000; }
canvas.map { width: 100%; height: 480px; display: block; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); cursor: grab; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.btn.active { border-color: var(--accent); color: var(--accent); }
.settings-form details.card summary { cursor: pointer; margin-bottom: 8px; }
.sticky-save { position: sticky; bottom: 0; padding: 10px 0; background: linear-gradient(transparent, var(--bg) 40%); }
table.rows td { padding: 4px; }
table.rows input, table.rows select { min-width: 70px; width: 100%; }
table.rows input[type=checkbox] { min-width: 0; width: auto; }
svg.chart { width: 100%; height: 170px; display: block; }
svg.chart .grid-line { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; }
svg.chart .serie { stroke-width: 1.6; }
.s0 { stroke: var(--accent); color: var(--accent); } .s1 { stroke: var(--accent-2); color: var(--accent-2); }
.s2 { stroke: var(--ok); color: var(--ok); } .s3 { stroke: var(--bad); color: var(--bad); }
.sev-1 { border-left: 3px solid var(--warn); padding-left: 6px; } .sev-2 { border-left: 3px solid var(--bad); padding-left: 6px; }
.alerts-banner { border-left: 3px solid var(--warn); }
.chat-line.alert { background: rgb(251 191 36 / .15); }
.translated { color: var(--muted); font-style: italic; }
.subtabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tabs { flex-wrap: wrap; }
.chat-line .tr { padding: 0 4px; font-size: 11px; opacity: 0; margin-left: 4px; }
.chat-line:hover .tr, .chat-line .tr:focus { opacity: 1; }

/* step 9 */
.badge.ok { background: rgba(60, 180, 110, .18); color: #4cc38a; }
.card.inner { margin: 8px 0; padding: 10px 12px; box-shadow: none; }
textarea.mono, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; width: 100%; }
label.btn.disabled { opacity: .5; pointer-events: none; }

/* 0.9.5: online players stand out in the list */
tr.row-online td { background: color-mix(in srgb, var(--ok) 9%, transparent); }
tr.row-online td:first-child { box-shadow: inset 4px 0 0 var(--ok); }
tr.row-online { outline: 1px solid color-mix(in srgb, var(--ok) 55%, transparent); outline-offset: -1px; }
.mark { color: var(--accent-2); margin-left: 4px; }
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 12px; font-size: 13px; }
.update-banner { margin: 8px 12px; padding: 10px 12px; border: 1px solid var(--accent-2); border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent-2) 12%, transparent); font-size: 13px; }
.update-banner b { display: block; color: var(--accent-2); }
.update-banner .btn { margin-top: 6px; width: 100%; }
/* 0.9.8: chat tools and channel colours */
.chat-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.chat-tools input[type=search] { flex: 1 1 180px; }
.chat-line.ch-Faction .badge { color: #4ade80; border-color: #4ade80; }
.chat-line.ch-Alliance .badge { color: #60a5fa; border-color: #60a5fa; }
.chat-line.ch-SinglePlayer .badge { color: #f472b6; border-color: #f472b6; }
.chat-line.ch-Server .badge { color: var(--warn); border-color: var(--warn); }
.warn-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.chat-tools select, .chat-tools .check { width: auto; flex: 0 0 auto; margin: 0; }
.chat-tools input[type=search] { width: auto; margin: 0; }
[hidden] { display: none !important; }

/* Inventory grid (like in game) */
.inv-slots { display: grid; gap: 4px; max-width: 640px; }
.inv-slots.c9 { grid-template-columns: repeat(9, minmax(0, 1fr)); }
.inv-slots.c7 { grid-template-columns: repeat(7, minmax(0, 1fr)); max-width: 500px; }
.inv-slot { position: relative; aspect-ratio: 1; border: 1px solid var(--border, #444); border-radius: 6px; background: rgba(127,127,127,.12);
  display: flex; align-items: center; justify-content: center; overflow: hidden; min-width: 0; }
.inv-slot.empty { background: rgba(127,127,127,.05); }
.inv-slot img { width: 80%; height: 80%; object-fit: contain; position: absolute; inset: 10%; }
.inv-slot .inv-name { font-size: 10px; line-height: 1.1; text-align: center; padding: 2px; word-break: break-word; opacity: .85; }
.inv-slot img + .inv-name { display: none; }
.inv-slot .inv-count { position: absolute; right: 3px; bottom: 1px; font-size: 12px; text-shadow: 0 0 3px #000, 0 0 3px #000; color: #fff; }
