:root {
  --bg: #0d1117; --panel: #161b22; --panel-2: #1c2230; --border: #2a3038;
  --text: #e6edf3; --muted: #8b949e; --accent: #2f81f7; --accent-2: #1f6feb;
  --green: #3fb950; --yellow: #d29922; --red: #f85149; --radius: 12px;
}
[data-theme="light"] {
  --bg: #f6f8fa; --panel: #ffffff; --panel-2: #f0f3f6; --border: #d0d7de;
  --text: #1f2328; --muted: #656d76; --accent: #0969da; --accent-2: #0860ca;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
}
#app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand-mark { font-size: 26px; color: var(--accent); }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: .5px; }
.brand-tag { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
nav button {
  text-align: left; background: none; border: none; color: var(--muted);
  padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500;
}
nav button:hover { background: var(--panel-2); color: var(--text); }
nav button.active { background: var(--accent); color: #fff; }
.sidebar-foot { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.conn { font-size: 11px; color: var(--muted); }
.conn.ok::before { content: "● "; color: var(--green); }
.conn.bad::before { content: "● "; color: var(--red); }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 28px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--bg); z-index: 5;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar-actions { display: flex; gap: 8px; }
.view { padding: 24px 28px; max-width: 1100px; }

/* Cards & grid */
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.grid.cols2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px;
}
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat { text-align: left; }
.stat .num { font-size: 30px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 12px; }
.stat.alert .num { color: var(--red); }
.stat.warn .num { color: var(--yellow); }
.stat.good .num { color: var(--green); }

/* Lists */
.tasklist { list-style: none; margin: 0; padding: 0; }
.tasklist li {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.tasklist li:last-child { border-bottom: none; }
.tasklist .area { font-size: 11px; color: var(--accent); background: var(--panel-2);
  padding: 1px 7px; border-radius: 20px; white-space: nowrap; }
.tasklist .due { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.tasklist .overdue { color: var(--red); }
.check { cursor: pointer; border: 1px solid var(--border); width: 18px; height: 18px;
  border-radius: 5px; background: var(--panel-2); flex-shrink: 0; margin-top: 2px; }
.check:hover { border-color: var(--green); }
.prio2 { border-left: 3px solid var(--yellow); padding-left: 8px; }
.prio3, .prio4 { border-left: 3px solid var(--red); padding-left: 8px; }

/* Forms */
form.stack { display: flex; flex-direction: column; gap: 12px; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: 8px; font-size: 14px; font-family: inherit;
}
textarea { min-height: 120px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 140px; }

/* Buttons */
button.btn {
  background: var(--accent); color: #fff; border: none; padding: 10px 16px;
  border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;
}
button.btn:hover { background: var(--accent-2); }
button.ghost {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
button.ghost:hover { border-color: var(--accent); }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: var(--panel-2); color: var(--muted); margin: 2px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }

/* Markdown output */
pre.md { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; }

.muted { color: var(--muted); }
.section-title { margin: 24px 0 10px; font-size: 13px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); }
.empty { color: var(--muted); padding: 16px; text-align: center; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  transition: transform .25s ease; z-index: 50; max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--red); }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  padding: 7px 14px; border-radius: 20px; cursor: pointer; font-size: 13px; }
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.spinner { color: var(--muted); padding: 40px; text-align: center; }

@media (max-width: 720px) {
  .sidebar { width: 64px; }
  .brand-name, .brand-tag, nav button span, .conn { display: none; }
  nav button { text-align: center; }
}
