:root {
  --bg: #f2f4ef;
  --panel: #ffffff;
  --ink: #1a211b;
  --muted: #667065;
  --line: #d8ddd2;
  --accent: #2f6f57;
  --accent-2: #b84a3b;
  --warn: #b98216;
  --crit: #b83b3b;
  --ok: #2f6f57;
  --shadow: 0 18px 45px rgba(34, 43, 36, .12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, "Aptos", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #eef1e8 0%, #f7f6f0 45%, #e9efe9 100%);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 28px;
  border-radius: 8px;
  display: grid;
  gap: 14px;
}
.brand, .mark {
  font-weight: 800;
  letter-spacing: 0;
  font-size: 22px;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcf8;
  color: var(--ink);
}
textarea {
  min-height: 360px;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 13px;
  line-height: 1.5;
}
button {
  border: 1px solid #22533f;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 700;
}
button.secondary {
  background: #f8faf5;
  color: var(--ink);
  border-color: var(--line);
}
button.danger {
  background: var(--accent-2);
  border-color: #91382d;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
}
.side {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.mark { margin: 4px 8px 24px; }
.nav {
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border-color: transparent;
}
.nav.active {
  background: #dfe8dd;
  border-color: #c8d5c4;
}
.nav.low { margin-top: 28px; color: var(--muted); }
.content { padding: 24px; min-width: 0; }
.top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}
h1 { margin: 0; font-size: 30px; line-height: 1.1; }
p { color: var(--muted); margin: 6px 0 0; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.card {
  background: rgba(255, 255, 255, .86);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 25px rgba(34,43,36,.06);
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 18px; }
.stat {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #e8ece4;
  color: var(--muted);
}
.pill.active, .pill.ok { background: #d9eadf; color: var(--ok); }
.pill.warning { background: #fff1cf; color: var(--warn); }
.pill.critical { background: #f9d8d8; color: var(--crit); }
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.actions.compact { margin-top: 0; }
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}
.tab {
  background: #f8faf5;
  color: var(--ink);
  border-color: var(--line);
}
.tab.active {
  background: var(--ink);
  color: white;
}
.two {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  gap: 14px;
}
.game-browser {
  display: grid;
  grid-template-columns: minmax(230px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.game-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 150px);
  overflow: auto;
  position: sticky;
  top: 18px;
}
.game-main { min-width: 0; }
.game-select {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 10px;
  gap: 8px;
  text-align: left;
  background: rgba(255,255,255,.76);
  color: var(--ink);
  border-color: var(--line);
}
.game-select.active {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}
.game-select small {
  grid-column: 1;
  color: inherit;
  opacity: .68;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-select i {
  grid-row: 1 / span 2;
  grid-column: 2;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #b8bfb6;
  align-self: center;
}
.game-select i.on { background: #71d28b; }
.form-grid {
  display: grid;
  gap: 10px;
}
.field {
  display: grid;
  gap: 6px;
}
.field span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
}
.field small, .muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.field.boolean {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcf8;
}
.field.boolean input { width: auto; }
.field-scroll {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}
.soft {
  background: #f9fbf5;
  box-shadow: none;
}
.preset-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}
.preset-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 220px;
  overflow: auto;
}
.preset-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.preset-row span {
  display: grid;
  min-width: 0;
}
.preset-row small {
  color: var(--muted);
}
.config-layout {
  display: grid;
  grid-template-columns: minmax(280px, 460px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.modal-open { overflow: hidden; }
#modalRoot.hidden { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 14, .52);
  z-index: 50;
}
.modal-panel {
  position: fixed;
  inset: 28px;
  z-index: 51;
  overflow: auto;
  background: linear-gradient(135deg, #f7f8f2 0%, #eef3eb 100%);
  border: 1px solid rgba(255,255,255,.65);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
  padding: 18px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}
.modal-head h2 { margin: 0; }
.modal-body {
  display: grid;
  gap: 14px;
}
.log {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 520px;
  background: #121712;
  color: #d8f1d6;
  padding: 14px;
  border-radius: 8px;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 12px;
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--ink);
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .mark { grid-column: 1 / -1; margin-bottom: 8px; }
  .nav { margin: 0; text-align: center; }
  .two { grid-template-columns: 1fr; }
  .game-browser { grid-template-columns: 1fr; }
  .game-list {
    position: static;
    max-height: none;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  .config-layout { grid-template-columns: 1fr; }
  .preset-create { grid-template-columns: 1fr; }
  .modal-panel { inset: 10px; padding: 12px; }
  .modal-head { flex-direction: column; }
  .top { align-items: flex-start; flex-direction: column; }
}
