/* 1portal — dark dashboard theme. Tokens mirror the Watchdog palette; adjust here only. */
:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #18202b;
  --border: #222d3a;
  --text: #e6eaf0;
  --muted: #8a97a8;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, .15);
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, .14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, .14);
  --crit: #ef4444;
  --crit-soft: rgba(239, 68, 68, .14);
  --idle: #64748b;
  --idle-soft: rgba(100, 116, 139, .18);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 20px; margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; }
.error { color: var(--crit); }
[hidden] { display: none !important; }

/* ---- shell ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: rgba(11, 15, 20, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; display: flex; align-items: center; gap: 6px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: 13px;
}
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: var(--muted); padding: 8px 12px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a.active { color: var(--text); background: var(--panel-2); }
.user { display: flex; align-items: center; gap: 10px; }
.view { max-width: 1400px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- panels / grid ---- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.panel + .panel, .section + .section { margin-top: 16px; }
.grid > .panel { margin-top: 0; }
.section { margin-top: 20px; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-bottom: 20px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }

.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font: 600 24px/1.2 var(--mono); margin-top: 6px; }
.stat.ok .value { color: var(--ok); }
.stat.warn .value { color: var(--warn); }
.stat.crit .value { color: var(--crit); }

/* ---- tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  background: none; border: 0; color: var(--muted); font: inherit; font-weight: 500;
  padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---- controls ---- */
.btn {
  font: inherit; font-weight: 500; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
}
.btn:hover { border-color: #33414f; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { resize: vertical; min-height: 70px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { min-width: 220px; }
label.field { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { color: var(--text); font-size: 14px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tbody tr:hover { background: var(--panel-2); }
td.wrap { white-space: normal; min-width: 220px; }
td select { padding: 4px 8px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* ---- badges / status ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--idle-soft); color: #cbd5e1;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.crit { background: var(--crit-soft); color: var(--crit); }
.badge.info { background: var(--accent-soft); color: #93c5fd; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.crit { background: var(--crit); box-shadow: 0 0 0 3px var(--crit-soft); }

/* ---- server cards ---- */
.server-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.server-card.crit { border-color: rgba(239, 68, 68, .5); }
.server-card .head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.server-card .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-card .meta { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.disk { margin-top: 10px; }
.disk .row { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.bar { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); border-radius: inherit; }
.bar.warn > span { background: var(--warn); }
.bar.crit > span { background: var(--crit); }

/* ---- breakdown bars (costs) ---- */
.hbar { display: grid; grid-template-columns: minmax(100px, 160px) 1fr auto; gap: 10px; align-items: center; padding: 6px 0; }
.hbar .track { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.hbar .track > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.hbar .key { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.banner {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius);
  background: var(--warn-soft); border: 1px solid rgba(245, 158, 11, .35); margin-bottom: 16px;
}
.banner strong { color: var(--warn); }

/* ---- pagination / misc ---- */
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--muted); }
.pager .btns { display: flex; gap: 6px; }
.updated { font-size: 12px; color: var(--muted); }
.loading { color: var(--muted); padding: 24px 0; }

/* ---- modal / toast ---- */
.modal { border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); padding: 0; width: min(560px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(0, 0, 0, .6); }
.modal-body { padding: 20px; display: grid; gap: 12px; }
.modal-body h2 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 50; max-width: 380px;
  background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.toast.error { border-left-color: var(--crit); }

@media (max-width: 720px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .view { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .grid.two, .grid.cards { grid-template-columns: 1fr; }
  .user #user-name { display: none; }
}

/* ---- task edit / settings ---- */
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.linkish:hover { color: var(--accent); text-decoration: underline; }
.modal-wide { width: min(720px, calc(100vw - 32px)); }
.modal-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.history summary { cursor: pointer; color: var(--muted); }
.history ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 200px; overflow: auto; }
.history li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }

.settings-section + .settings-section { margin-top: 16px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head p { margin: 4px 0 0; font-size: 13px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.inline-form label.field { min-width: 140px; }
.inline-form .grow { flex: 1; min-width: 200px; }
.secret-box {
  display: flex; gap: 8px; align-items: center; padding: 12px; border-radius: 8px; margin-bottom: 12px;
  background: var(--ok-soft); border: 1px solid rgba(34, 197, 94, .35);
}
.secret-box code { flex: 1; font-family: var(--mono); word-break: break-all; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: 12px var(--mono); padding: 2px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--border); }
.model-row td { vertical-align: top; }
.prices { font-size: 12px; }
.prices td, .prices th { padding: 4px 8px; }
.drop {
  border: 1px dashed var(--border); border-radius: var(--radius); padding: 20px; text-align: center; color: var(--muted);
}
.drop.over { border-color: var(--accent); color: var(--text); }

/* ---- task manager v2: workload, notes, repeats ---- */
.workload summary { display: flex; align-items: baseline; gap: 12px; cursor: pointer; list-style: none; }
.workload summary::-webkit-details-marker { display: none; }
.workload summary h2 { margin: 0; }
.workload summary::before { content: "▸"; color: var(--muted); }
.workload[open] summary::before { content: "▾"; }
.workload[open] summary { margin-bottom: 12px; }
.total-row td { border-top: 1px solid var(--border); background: var(--panel-2); }
.task-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--accent); }
.hint { margin: 0; font-size: 12px; }
.notes h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.notes ul { list-style: none; margin: 0 0 8px; padding: 0; max-height: 220px; overflow: auto; }
.notes li { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; background: var(--bg); }
.notes li.system { border-style: dashed; }
.note-head { font-size: 12px; margin-bottom: 2px; }
.note-body { white-space: pre-wrap; word-break: break-word; }
.note-form { display: flex; gap: 8px; align-items: flex-end; }
.note-form textarea { flex: 1; min-height: 44px; }
