:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel2: #1c2230;
  --border: #2a3040;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2ea043;
  --accent2: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --info: #58a6ff;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#app { display: flex; height: 100vh; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 220px; min-width: 220px; background: var(--panel);
  border-right: 1px solid var(--border); padding: 18px 12px;
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 2px 6px; }
.brand .logo { font-size: 28px; }
.brand small { display: block; color: var(--muted); }
#nav { display: flex; flex-direction: column; gap: 4px; }
#nav a {
  padding: 9px 12px; border-radius: 8px; cursor: pointer; color: var(--text);
  display: flex; justify-content: space-between; align-items: center;
}
#nav a:hover { background: var(--panel2); }
#nav a.active { background: rgba(46,160,67,.14); color: var(--accent2); font-weight: 600; }
#nav .count { background: var(--panel2); border-radius: 10px; padding: 1px 8px; font-size: 12px; color: var(--muted); }
.sidebar-foot { margin-top: auto; color: var(--muted); font-size: 12px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: var(--accent2); }
.dot.bad { background: var(--bad); }

/* ---------- Main ---------- */
#main { flex: 1; overflow: auto; padding: 26px 30px 60px; }
h1 { font-size: 20px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px;
}
.card h3 { margin: 0 0 8px; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.meta { color: var(--muted); font-size: 12.5px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mt { margin-top: 10px; }
.warn-t { color: var(--warn); }
.kpi { font-size: 26px; font-weight: 700; margin: 2px 0; }
.hintline { color: var(--muted); font-size: 12px; margin: 6px 0; }

.pill { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; display: inline-block; }
.pill.ok { background: rgba(46,160,67,.16); color: var(--accent2); }
.pill.bad { background: rgba(248,81,73,.15); color: var(--bad); }
.pill.warn { background: rgba(210,153,34,.15); color: var(--warn); }
.pill.neutral { background: var(--panel2); color: var(--muted); }

/* ---------- Controls ---------- */
.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 13px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: #3d4657; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { background: rgba(248,81,73,.12); border-color: rgba(248,81,73,.4); color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.cta { font-size: 14px; padding: 9px 18px; border-radius: 10px; }
input, select, textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--info); }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; margin: 0 0 14px; }
legend { color: var(--muted); font-size: 12px; padding: 0 6px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 10px; border-bottom: 1px solid var(--border); }
td { padding: 6px 10px; border-bottom: 1px solid rgba(42,48,64,.5); vertical-align: top; }
tr:hover td { background: rgba(255,255,255,.015); }
td code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.table-card { padding: 10px 14px; }

/* ---------- Modal ---------- */
#modal-root:empty { display: none; }
#modal-root {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 40px 16px;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  width: min(760px, 96vw); padding: 20px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal.wide { width: min(920px, 96vw); }
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.src-row, .hook-row { display: grid; grid-template-columns: 150px 1fr 1fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.hook-row { grid-template-columns: 1fr auto auto; }
.src-excl { grid-column: 2 / 4; margin-top: -4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.four { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---------- ABB: Wizard ---------- */
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps .st {
  flex: 1; text-align: center; font-size: 12px; color: var(--muted);
  padding: 7px 4px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border);
}
.steps .st.on { color: var(--accent2); border-color: rgba(46,160,67,.5); background: rgba(46,160,67,.08); font-weight: 600; }
.steps .st.done { color: var(--text); }

.radiocards { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 12px; }
.radiocard { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.radiocard:hover { border-color: #3d4657; }
.radiocard.on { border-color: var(--accent); background: rgba(46,160,67,.1); }
.radiocard b { display: block; font-size: 13px; }
.radiocard small { color: var(--muted); font-size: 11px; }

.checklist { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.checklist .citem {
  display: flex; gap: 10px; align-items: center; padding: 8px 12px;
  border-bottom: 1px solid rgba(42,48,64,.5); cursor: pointer;
}
.checklist .citem:last-child { border-bottom: none; }
.checklist .citem:hover { background: rgba(255,255,255,.02); }
.checklist .citem input { width: auto; }
.checklist .citem code { flex: 1; }

.summary { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.summary table td, .summary table th { padding: 5px 8px; }

/* ---------- Auth (Planbrett-Schema) ---------- */
#auth-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 200; display: flex; align-items: center; justify-content: center; overflow: auto; }
.auth-card { width: min(430px, 94vw); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 26px 28px; }
.auth-card h2 { margin: 0 0 4px; font-size: 18px; display: flex; gap: 8px; align-items: center; }
.auth-card .sub { margin-bottom: 16px; }
.auth-err { color: var(--bad); font-size: 12.5px; min-height: 18px; margin: 4px 0 8px; }
.qr-box { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: 10px; margin-bottom: 10px; }
.mono-secret { background: var(--bg); border: 1px dashed var(--border); border-radius: 8px; padding: 8px; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; word-break: break-all; margin-bottom: 10px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; max-width: 460px; box-shadow: 0 8px 30px rgba(0,0,0,.4);
  animation: slidein .18s ease-out;
}
.toast.ok { border-color: rgba(46,160,67,.5); }
.toast.bad { border-color: rgba(248,81,73,.55); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }