/* Project Zomboid control panel.
   Dark by default and only dark: this is a game admin tool that gets opened
   at night next to a game that is itself very dark, and a white flash is
   genuinely unpleasant. The accent is the same #ff4d6d the dashboard already
   uses for Zomboid, so the two read as one system. */

:root {
  --bg:        #14161a;
  --panel:     #1c1f25;
  --panel-2:   #22262e;
  --line:      #2e3440;
  --line-soft: #262b33;
  --text:      #e6e9ef;
  --muted:     #949cab;
  --dim:       #6b7382;
  --accent:    #ff4d6d;
  --accent-dk: #c9294a;
  --ok:        #43d17c;
  --warn:      #ffb454;
  --bad:       #ff5c5c;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- masthead ---------- */

header.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: linear-gradient(180deg, #1b1e24, #17191f);
  border-bottom: 1px solid var(--line);
}
header.bar .brand {
  font-weight: 700; letter-spacing: .2px; font-size: 15px;
  display: flex; align-items: center; gap: 9px; white-space: nowrap;
}
header.bar .brand .mark { font-size: 17px; }
header.bar .spacer { flex: 1; }
header.bar .who { color: var(--dim); font-size: 13px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: .3px;
  border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted);
  white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.up   { color: var(--ok);  border-color: #1e5236; background: #14261c; }
.pill.down { color: var(--bad); border-color: #5a2222; background: #261616; }
.pill.up .dot { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ---------- nav ---------- */

nav.tabs {
  display: flex; gap: 2px; padding: 0 14px;
  background: #17191f; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a {
  padding: 11px 15px; font-size: 14px; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
nav.tabs a:hover { color: var(--text); text-decoration: none; background: #1d2027; }
nav.tabs a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- layout ---------- */

main { max-width: 1100px; margin: 0 auto; padding: 22px 20px 80px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 18px; overflow: hidden;
}
.card > h2 {
  margin: 0; padding: 13px 17px; font-size: 13px; font-weight: 700;
  letter-spacing: .6px; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line-soft); background: #1a1d23;
  display: flex; align-items: center; gap: 10px;
}
.card > h2 .count { color: var(--dim); font-weight: 500; letter-spacing: 0; text-transform: none; }
.card .body { padding: 17px; }
.card .body > :first-child { margin-top: 0; }
.card .body > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ---------- stats ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px;
         background: var(--line-soft); }
.stat { background: var(--panel); padding: 15px 17px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim); }
.stat .v { font-size: 21px; font-weight: 650; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat .v.sm { font-size: 15px; font-weight: 550; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: 6px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 550;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: #2a2f38; border-color: #3a4150; text-decoration: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent-dk); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent); }
.btn.ok   { color: var(--ok); border-color: #24543a; }
.btn.ok:hover:not(:disabled) { background: #17301f; }
.btn.bad  { color: var(--bad); border-color: #5a2626; }
.btn.bad:hover:not(:disabled) { background: #2a1717; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 9px; }

/* ---------- forms ---------- */

label.f { display: block; margin-bottom: 15px; }
label.f:last-child { margin-bottom: 0; }
label.f .n {
  display: flex; align-items: baseline; gap: 8px;
  font-weight: 600; font-size: 14px; margin-bottom: 3px;
}
label.f .n code { font: 500 12px var(--mono); color: var(--dim); }
label.f .h { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; line-height: 1.45; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px;
  background: #12141a; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  font: inherit; font-size: 14px;
}
textarea { font: 13px/1.5 var(--mono); resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,77,109,.13);
}
select { cursor: pointer; }

/* A checkbox that reads as a switch. The settings pages are ~120 booleans and
   native checkboxes at that density are hard to scan. */
.sw { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.sw input { position: absolute; opacity: 0; width: 0; height: 0; }
.sw .track {
  width: 38px; height: 21px; border-radius: 999px; flex: none;
  background: #2b3039; border: 1px solid var(--line); position: relative;
  transition: background .15s, border-color .15s;
}
.sw .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%; background: var(--dim);
  transition: transform .15s, background .15s;
}
.sw input:checked + .track { background: #35203c; border-color: var(--accent); }
.sw input:checked + .track::after { transform: translateX(17px); background: var(--accent); }
.sw input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(255,77,109,.13); }

/* ---------- settings list ---------- */

.setting {
  display: grid; grid-template-columns: minmax(0,1fr) 260px; gap: 18px;
  padding: 13px 17px; border-bottom: 1px solid var(--line-soft); align-items: start;
}
.setting:last-child { border-bottom: none; }
.setting:hover { background: #1e2128; }
.setting .meta .n { font-weight: 600; font-size: 14px; }
.setting .meta .h { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.setting .ctl { display: flex; justify-content: flex-end; }
.setting.changed { background: #241a1e; box-shadow: inset 3px 0 0 var(--accent); }
.setting[hidden] { display: none; }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 4px; margin-left: 7px;
  font: 600 10.5px/1.7 system-ui; letter-spacing: .4px; text-transform: uppercase;
  vertical-align: middle;
}
.tag.lock { background: #2a2f38; color: var(--dim); }
.tag.gen  { background: #33291a; color: var(--warn); }
.tag.live { background: #14261c; color: var(--ok); }

/* ---------- misc ---------- */

.note {
  padding: 11px 14px; border-radius: 6px; font-size: 13.5px; line-height: 1.5;
  background: #1d2430; border: 1px solid #2b3648;
  color: var(--muted); margin-bottom: 16px;
}
.note.warn { background: #2a2113; border-color: #4a3a1c; color: #e8c07a; }
.note.bad  { background: #2a1717; border-color: #5a2626; color: #f0a0a0; }
.note.ok   { background: #14261c; border-color: #1e5236; color: #8fe0b0; }
.note b { color: var(--text); }

.search {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 17px; border-bottom: 1px solid var(--line-soft); background: #1a1d23;
}
.search input { flex: 1; }
.search .n { font-size: 12.5px; color: var(--dim); white-space: nowrap; }

pre.out {
  margin: 0; padding: 14px 16px; background: #0e1014;
  border: 1px solid var(--line); border-radius: 6px;
  font: 12.5px/1.55 var(--mono); color: #c8d0dc;
  max-height: 62vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
}

table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th {
  text-align: left; padding: 9px 17px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--dim); border-bottom: 1px solid var(--line-soft);
  background: #1a1d23; font-weight: 700;
}
table.list td { padding: 10px 17px; border-bottom: 1px solid var(--line-soft); }
table.list tr:last-child td { border-bottom: none; }
table.list tr:hover td { background: #1e2128; }

.empty { padding: 30px 17px; text-align: center; color: var(--dim); font-size: 14px; }

/* Save bar: fixed, and only present once something is actually dirty. */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: none; align-items: center; gap: 14px;
  padding: 12px 20px; background: #1b1e24; border-top: 1px solid var(--accent);
  box-shadow: 0 -6px 22px rgba(0,0,0,.45);
}
.savebar.show { display: flex; }
.savebar .msg { flex: 1; font-size: 13.5px; color: var(--muted); }
.savebar .msg b { color: var(--text); }

/* ---------- login ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 370px; }
.login .card .body { padding: 22px; }
.login h1 {
  font-size: 19px; margin: 0 0 4px; display: flex; align-items: center; gap: 10px;
}
.login .sub { color: var(--dim); font-size: 13px; margin: 0 0 20px; }

@media (max-width: 680px) {
  .setting { grid-template-columns: 1fr; gap: 9px; }
  .setting .ctl { justify-content: flex-start; }
  main { padding: 16px 13px 90px; }
  header.bar { flex-wrap: wrap; gap: 9px; padding: 10px 14px; }
}

/* ---------- utilities ----------------------------------------------
   The panel sends a strict Content-Security-Policy with `style-src 'self'`,
   which means no inline style="" attributes: the browser drops them and the
   layout quietly falls apart. Everything that would otherwise have been an
   inline style lives here instead. */

.r        { text-align: right; }
.flat     { padding: 0; }
.plain    { background: transparent; gap: 18px; }
.wide     { width: 100%; }
.m0       { margin: 0; }
.mb-sm    { margin-bottom: 13px; }
.gap-sm   { gap: 14px; }
.push     { margin-left: auto; }
.inline   { display: inline; }
.actions  { display: inline-flex; gap: 6px; }
.dim      { color: var(--dim); }
.unit     { font-size: 13px; color: var(--dim); }
.sw-label { font-size: 13px; color: var(--muted); }
.fine     { font-size: 12.5px; }
.hint     { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.ok-text  { color: var(--ok); }
.bad-text { color: var(--bad); }

.sub-block {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft);
}
.sub-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--dim); margin-bottom: 9px;
}
