:root {
  color-scheme: dark;
  --bg: #101412;
  --bg-2: #171d1a;
  --bg-3: #212924;
  --bg-4: #2a342e;
  --line: rgba(236, 226, 206, 0.12);
  --line-strong: rgba(236, 226, 206, 0.22);
  --text: #f4f0e6;
  --muted: #a8b2a8;
  --faint: #748078;
  --copper: #e0a15a;
  --copper-2: #f2c48a;
  --ink: #2a1c10;
  --moss: #8fce78;
  --moss-dim: #1b3324;
  --red: #ff7d6b;
  --red-dim: #3a221e;
  --warn: #f0c35a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --radius: 16px;
  --font: "Segoe UI", "Avenir Next", sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
html { overflow-x: clip; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 420px at -10% -20%, rgba(224, 161, 90, 0.16), transparent 55%),
    var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(224, 161, 90, 0.35); }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }
.skip {
  position: absolute;
  left: 12px;
  top: 12px;
  transform: translateY(-140%);
  background: var(--copper);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 5;
}
.skip:focus { transform: none; }

.boot, .login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.boot { color: var(--muted); }
.login-card, .card, .modal-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-card {
  width: min(420px, 100%);
  padding: 28px;
  display: grid;
  gap: 14px;
}
.login-card h1, .topbar h1, .modal-card h2 { margin: 0; font-weight: 650; letter-spacing: -0.03em; }
.kicker {
  margin: 0;
  color: var(--copper);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.lede, .muted, .help { color: var(--muted); }
.help { display: block; font-size: 13px; }
.command-form input, .inline-form input, .row-actions select { width: auto; }
.row-actions select { max-width: 150px; }
#modal-form { display: grid; gap: 10px; }
.lede { margin: 0; }
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background:
    linear-gradient(#7dbe78, #7dbe78) 0 0 / 100% 38% no-repeat,
    linear-gradient(#d4894c, #d4894c) 0 42% / 100% 58% no-repeat,
    #171d1a;
  border: 1px solid var(--line-strong);
}

label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px;
}
textarea { min-height: 120px; resize: vertical; }
.mono, textarea.mono, .log { font-family: var(--mono); }

.btn {
  border: 1px solid var(--line-strong);
  background: var(--bg-3);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:hover { border-color: var(--copper); }
.btn.primary { background: var(--copper); color: var(--ink); border-color: transparent; font-weight: 650; }
.btn.danger { background: var(--red); color: #2a100c; border-color: transparent; font-weight: 650; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--text);
  text-align: left;
}
button.link:hover, .entry.dir { color: var(--copper-2); }
.form-error { color: var(--red); margin: 0; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(16, 20, 18, 0.9);
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px; }
.brand strong { display: block; }
.nav { display: grid; gap: 4px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
}
.nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.nav a:hover, .nav a.active { background: var(--bg-3); color: var(--text); }
.nav a.active { box-shadow: inset 2px 0 0 var(--copper); }
.sidebar-foot { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px; color: var(--faint); font-size: 12px; }
.sidebar-foot .btn { width: auto; }
.workspace { min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 22px 0;
}
.topbar h1 { font-size: 28px; }
#page { padding: 18px 22px 40px; display: grid; gap: 16px; align-content: start; }
.pill {
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.pill.ok { color: var(--moss); background: var(--moss-dim); border-color: transparent; }
.pill.bad { color: var(--red); background: var(--red-dim); border-color: transparent; }

.hero, .stats, .split, .stack { display: grid; gap: 16px; }
.hero { grid-template-columns: 1fr auto; align-items: center; padding: 18px; }
.hero-main { display: flex; gap: 14px; align-items: center; min-width: 0; }
.server-icon, .icon-fallback {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  flex: none;
}
.icon-fallback { border: 1px solid var(--line-strong); }
.server-icon { object-fit: cover; background: var(--bg); }
.hero h2 { margin: 4px 0; font-size: 26px; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.hero-actions, .row-actions, .toolbar, .modal-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stats { grid-template-columns: repeat(4, 1fr); }
.stat { padding: 14px 16px; }
.stat span { display: block; color: var(--faint); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.stat strong { display: block; margin-top: 6px; font-size: 22px; font-weight: 650; }
.split { grid-template-columns: 1fr 1fr; }
.card { padding: 16px 18px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.callout {
  border: 1px solid rgba(255, 125, 107, 0.35);
  background: rgba(255, 125, 107, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
}
.callout.note {
  border-color: var(--line-strong);
  background: rgba(224, 161, 90, 0.08);
}
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.log-wrap { position: relative; }
.log.short { height: 220px; min-height: 0; }
.log {
  background: #0b0e0c;
  border-radius: 12px;
  min-height: 280px;
  height: calc(100vh - 340px);
  overflow: auto;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.55;
}
.log div { white-space: pre-wrap; overflow-wrap: anywhere; }
.lvl-error { color: var(--red); }
.lvl-warn { color: var(--warn); }
.lvl-cmd { color: var(--copper-2); }
.lvl-result { color: #d5ddd4; }
.jump { position: absolute; right: 14px; bottom: 14px; }
.command-form, .inline-form { display: flex; gap: 8px; }
.command-form input, .inline-form input { flex: 1; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button[aria-selected="true"] { background: var(--copper); color: var(--ink); border-color: transparent; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; text-align: left; vertical-align: middle; }
th { color: var(--faint); font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; font-weight: 650; }
td { border-top: 1px solid var(--line); }
.person { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: white;
  flex: none;
}
.av-0 { background: #8d5a3a; }
.av-1 { background: #3d6b4f; }
.av-2 { background: #3f5f8a; }
.av-3 { background: #7a4e74; }
.av-4 { background: #8a6232; }
.av-5 { background: #4d6a3a; }
.av-6 { background: #6a4a3a; }
.av-7 { background: #3f6d6a; }
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  background: var(--bg-4);
  color: var(--muted);
}
.badge.on { background: var(--moss-dim); color: var(--moss); }
.badge.off { background: var(--red-dim); color: var(--red); }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); }
.crumbs a { color: var(--copper-2); text-decoration: none; }
.dropzone {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  color: var(--muted);
}
.dropzone.drag { border-color: var(--copper); background: rgba(224, 161, 90, 0.08); }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); }
.check input { width: auto; flex: none; margin-top: 3px; }
.check-copy { display: grid; gap: 4px; min-width: 0; }
.fields { display: grid; gap: 14px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.group-title { margin: 8px 0 0; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 4;
}
.modal-card { width: min(560px, 100%); padding: 18px; display: grid; gap: 12px; }
.modal-card.wide { width: min(860px, 100%); }
.modal-card textarea { min-height: 50vh; }
.modal-copy { margin: 0; white-space: pre-wrap; }
main a { color: var(--copper-2); }
.market-list { display: grid; gap: 10px; }
.mod-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.mod-icon, .mod-fallback {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--bg-4);
}
.mod-icon { object-fit: cover; }
.mod-fallback { display: grid; place-items: center; font-weight: 700; }
.mod-card h3 { margin: 0 0 4px; font-size: 16px; }
.mod-card p { margin: 0; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mod-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; color: var(--faint); font-size: 13px; }
body.modal-open { overflow: hidden; }

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 6;
  width: min(360px, calc(100% - 32px));
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.toast.error { border-color: rgba(255, 125, 107, 0.5); }
.toast.ok { border-color: rgba(143, 206, 120, 0.5); }
.toast-hint { color: var(--muted); margin-top: 4px; font-size: 13px; }

.mc-0 { color: #9a9a9a; }
.mc-1 { color: #7d7dff; }
.mc-2 { color: #5dcc5d; }
.mc-3 { color: #5dcccc; }
.mc-4 { color: #e15b5b; }
.mc-5 { color: #d45bd4; }
.mc-6 { color: #ffaa00; }
.mc-7 { color: #c8c8c8; }
.mc-8 { color: #7a7a7a; }
.mc-9 { color: #8d8dff; }
.mc-a { color: #7dff7d; }
.mc-b { color: #7dffff; }
.mc-c { color: #ff7d7d; }
.mc-d { color: #ff7dff; }
.mc-e { color: #ffff7d; }
.mc-f { color: #ffffff; }
.mc-bold { font-weight: 700; }
.mc-italic { font-style: italic; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    z-index: 3;
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 12px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
  }
  .brand { min-width: 0; padding: 0; }
  .nav {
    display: flex;
    gap: 4px;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 2px;
  }
  .nav a { flex: none; white-space: nowrap; min-height: 44px; }
  .nav a.active { box-shadow: inset 0 -2px 0 var(--copper); }
  .sidebar-foot { margin-top: 0; padding: 0; }
  .workspace, #page, .card, .table-wrap { min-width: 0; }
  .topbar { padding: 14px 14px 0; }
  .topbar h1 { font-size: 22px; }
  #page { padding: 14px 14px calc(28px + env(safe-area-inset-bottom)); }
  .stats { grid-template-columns: 1fr 1fr; }
  .split, .hero, .field-grid { grid-template-columns: 1fr; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1 1 140px; }
  .command-form, .inline-form { flex-direction: column; align-items: stretch; }
  .command-form .btn, .inline-form .btn { width: 100%; }
  .command-bar {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 0 -14px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--line);
  }
  .log { height: min(52dvh, 480px); min-height: 180px; }
  .log.short { height: 180px; }
  .kv { grid-template-columns: 1fr; }
  .mod-card { grid-template-columns: 48px minmax(0, 1fr); align-items: start; }
  .mod-card .btn { grid-column: 2; justify-self: stretch; }
  .btn.small { min-height: 40px; padding: 8px 12px; }
  .table-wrap { overflow-x: auto; }
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap th, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { padding: 12px 0; border-top: 1px solid var(--line); }
  .table-wrap td { border: 0; padding: 4px 0; }
  .table-wrap td:empty { display: none; }
  .table-wrap td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--faint);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .row-actions select { max-width: none; width: 100%; }
  .modal { padding: 10px; align-items: end; }
  .modal-card, .modal-card.wide {
    width: 100%;
    max-height: calc(100dvh - 20px);
    overflow: auto;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  .modal-card textarea { min-height: 36dvh; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
  .toasts {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
