:root {
  --bg: #15171a;
  --panel: #1e2125;
  --panel-2: #262a30;
  --border: #33383f;
  --text: #e6e8eb;
  --muted: #9aa1aa;
  --accent: #6cc04a;
  --accent-dark: #3f7f2a;
  --danger: #e5534b;
  --warn: #d9a33a;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0 0 12px; font-weight: 600; }
h2 { font-size: 22px; }
h3 { font-size: 16px; margin-top: 24px; color: var(--muted); }

a { color: var(--accent); }

input, button {
  font: inherit;
  color: inherit;
  border-radius: 6px;
}

input {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 10px;
  min-width: 0;
}

input:focus { outline: 2px solid var(--accent-dark); outline-offset: 0; }

button {
  background: var(--accent-dark);
  border: 1px solid var(--accent);
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover { background: var(--accent); color: #0d1a08; }

button.small { padding: 2px 8px; font-size: 13px; }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: var(--danger); color: #fff; }
button.ghost { background: transparent; border-color: var(--border); }
button.ghost:hover { border-color: var(--accent); color: var(--text); }
button.link { background: none; border: none; color: var(--muted); padding: 6px 0; text-align: left; }
button.link:hover { color: var(--text); background: none; }

.muted { color: var(--muted); }
.error { color: var(--danger); margin: 8px 0 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 10px; }
.login-card h1 { font-size: 20px; }

/* Layout */
.app { display: flex; min-height: 100%; }

.nav {
  width: 190px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav .brand { font-weight: 700; font-size: 18px; color: var(--accent); margin-bottom: 12px; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a.active { color: var(--text); background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.nav #logout { margin-top: auto; padding-left: 10px; }

main { flex: 1; min-width: 0; padding: 24px; }

.view { max-width: 1100px; }

/* Dashboard */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.cards .label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.cards .big { font-size: 26px; font-weight: 600; margin: 4px 0; overflow-wrap: anywhere; }
.status-online { color: var(--accent); }
.status-offline { color: var(--danger); }

.progress { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress.large { height: 12px; margin: 0 0 6px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* Console */
.log {
  height: calc(100vh - 190px);
  min-height: 300px;
  overflow-y: auto;
  background: #0d0e10;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: 13px/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log .line-warn { color: var(--warn); }
.log .line-error { color: var(--danger); }
.log .line-cmd { color: var(--accent); margin-top: 6px; }
.log .line-reply { color: #cfd3d8; border-left: 2px solid var(--accent-dark); padding-left: 8px; }

.console-form { display: flex; gap: 8px; margin-top: 10px; }
.console-form input { flex: 1; font-family: var(--mono); }

/* Map */
.view-map { max-width: none; display: flex; flex-direction: column; height: calc(100vh - 48px); }
.map-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
#map-frame { flex: 1; width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #000; }

/* Goals */
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.row input { flex: 1 1 180px; }
#goal-category { flex: 0 1 200px; }

.category { margin-top: 18px; }
.category h3 { margin: 0 0 6px; color: #7fc8e8; }

.goal {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  margin-bottom: 6px;
}

.goal .check {
  width: 26px;
  height: 26px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  border-color: var(--border);
  flex-shrink: 0;
}

.goal.done .check { background: var(--accent-dark); border-color: var(--accent); }
.goal .title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.goal.done .title { color: var(--muted); text-decoration: line-through; }
.goal .meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.goal .id { color: var(--muted); font-size: 13px; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; background: var(--panel-2); }
tr:last-child td { border-bottom: none; }
td.mono { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
td.right { text-align: right; }
td.empty { color: var(--muted); text-align: center; padding: 20px; }

.counts { padding-left: 22px; margin: 0; }
.counts li { margin: 2px 0; }
.counts .n { color: var(--danger); margin-left: 6px; }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 10; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; white-space: pre-wrap; }
.toast.error { border-left-color: var(--danger); color: var(--text); margin: 0; }

/* Minecraft formatting codes */
.mc-0 { color: #000000; } .mc-1 { color: #5555ff; } .mc-2 { color: #55c055; } .mc-3 { color: #2fb5b5; }
.mc-4 { color: #d04040; } .mc-5 { color: #b040b0; } .mc-6 { color: #ffaa00; } .mc-7 { color: #aaaaaa; }
.mc-8 { color: #777777; } .mc-9 { color: #7777ff; } .mc-a { color: #55ff55; } .mc-b { color: #55ffff; }
.mc-c { color: #ff5555; } .mc-d { color: #ff55ff; } .mc-e { color: #ffff55; } .mc-f { color: #ffffff; }
.mc-l { font-weight: 700; } .mc-o { font-style: italic; } .mc-n { text-decoration: underline; } .mc-m { text-decoration: line-through; }

/* Phones */
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .nav { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: none; border-bottom: 1px solid var(--border); padding: 10px 16px; gap: 4px; }
  .nav .brand { margin: 0 8px 0 0; width: 100%; }
  .nav #logout { margin: 0 0 0 auto; }
  main { padding: 16px; }
  .log { height: calc(100vh - 280px); }
  .view-map { height: calc(100vh - 160px); }
  table { display: block; overflow-x: auto; }
  .goal .meta { display: none; }
}
