:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1f2328; --muted: #656d76; --border: #d8dee4;
  --accent: #2563eb; --accent-text: #fff; --ok: #1a7f37; --bad: #cf222e; --warn: #9a6700; --code: #f1f3f5;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d1117; --panel: #161b22; --text: #e6edf3; --muted: #8d96a0; --border: #30363d;
          --accent: #4493f8; --ok: #3fb950; --bad: #f85149; --warn: #d29922; --code: #1f242c; }
}
* { box-sizing: border-box; }
/* `display` rules below would otherwise override the hidden attribute. */
[hidden] { display: none !important; }
/* Column layout: the footer sits at the bottom of the window (sticky). */
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 20px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 2; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); text-decoration: none; font-size: 16px; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
nav a.active, nav a:hover { color: var(--text); background: var(--code); }
nav a.active .ico { color: var(--accent); }
#me { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
main { flex: 1 0 auto; width: 100%; max-width: 1280px; margin: 24px auto; padding: 0 24px; }
footer { position: sticky; bottom: 0; z-index: 2; padding: 8px 24px; background: var(--panel); border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; text-align: center; }
h1 { display: flex; align-items: center; gap: 8px; font-size: 20px; margin: 0 0 16px; }
h1 .ico { width: 22px; height: 22px; color: var(--accent); }
h2 { display: flex; align-items: center; gap: 6px; font-size: 16px; margin: 24px 0 8px; }
h2 .ico { color: var(--muted); }
a { color: var(--accent); }
.small { font-size: 11px; }

/* Icons (inline SVG, stroked with the text colour) */
.ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.ico.on { color: var(--ok); }
.ico.off { color: var(--muted); opacity: .7; }
.ico.ok { color: var(--ok); }
.ico.spin { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ico.spin { animation: none; } }

/* Names: icon, friendly name over the exact key, edit pencil on hover */
.name { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.name-text { display: inline-flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.name-text .key { font-size: 11px; color: var(--muted); }
.name .edit { visibility: hidden; padding: 2px; line-height: 0; }
.name:hover .edit, .name .edit:focus-visible { visibility: visible; }
.name .edit .ico { width: 13px; height: 13px; }
.name-input { padding: 3px 6px; min-width: 200px; }

/* Live state */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.online { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.live-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live-state.on .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.busy { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--warn); text-decoration: none; }
.busy strong { color: var(--text); }
.progress { display: inline-flex; align-items: center; gap: 6px; }
.progress .track { display: inline-block; width: 90px; height: 6px; border-radius: 3px; background: var(--code); border: 1px solid var(--border); overflow: hidden; }
.progress .fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s ease; }
.progress .pct { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.timing { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.since { font-variant-numeric: tabular-nums; }
.quiet { display: flex; align-items: center; gap: 8px; }

/* Activity cards, chips, project cards */
.activity { padding: 12px 16px; }
.activity-head, .card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.activity-head .spacer, .card-head .spacer { flex: 1; }
.activity .chips { margin-top: 10px; gap: 6px; }
.chips.compact { gap: 4px; }
.chips.compact .chip { padding: 1px 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg); }
.card-head { margin-bottom: 12px; }
.card-head .big { font-size: 16px; }
.card-head .ico { vertical-align: -3px; }
.project table { border-radius: 6px; }

/* Deployment timings */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.stat-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.stat-value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.gantt { display: block; width: 100%; height: auto; }
.gantt text { fill: var(--text); font-size: 12px; font-family: inherit; }
.gantt .g-tick { fill: var(--muted); font-size: 11px; }
.g-grid { stroke: var(--border); stroke-width: 1; }
.g-stage { fill: color-mix(in srgb, var(--accent) 35%, transparent); }
.g-dl { fill: var(--accent); }
.g-act { fill: var(--ok); }
.g-fail { fill: var(--bad); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.sw-stage { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.sw-dl { background: var(--accent); }
.sw-act { background: var(--ok); }
.sw-fail { background: var(--bad); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
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 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; text-align: right; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--code); white-space: nowrap; }
.badge .ico { width: 12px; height: 12px; }
.ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); }
.badge.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); }
button, .btn { font: inherit; border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 5px 12px; border-radius: 6px; cursor: pointer; text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--bad); }
button.link { border: none; background: none; color: var(--muted); padding: 4px; }
button:disabled { opacity: .5; cursor: default; }
button + button { margin-left: 6px; }
form.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; align-items: end; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
label.check { flex-direction: row; align-items: center; gap: 6px; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
textarea { width: 100%; min-height: 70px; resize: vertical; }
.log { background: var(--code); border: 1px solid var(--border); border-radius: 8px; padding: 10px; height: 420px; overflow: auto; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; white-space: pre-wrap; }
.log .ts { color: var(--muted); margin-right: 8px; }
.log .srv { color: var(--accent); margin-right: 6px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.login { max-width: 360px; margin: 10vh auto; }
.login form { display: flex; flex-direction: column; gap: 12px; }
#toast { position: fixed; bottom: 48px; right: 20px; max-width: 420px; z-index: 3; }
#toast div { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 6px; margin-top: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
#toast div.error { border-left-color: var(--bad); }
.secretbox { background: var(--code); padding: 10px; border-radius: 6px; word-break: break-all; }

/* MCP access editor */
.wide { grid-column: 1 / -1; }
.mcp-groups { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.mcp-groups label.check { flex-wrap: wrap; }
.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
