:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c232c;
  --border: #2a323d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #7c5cff;
  --accent-2: #a58bff;
  /* Solid fill behind white text: #7c5cff only reaches 4.3:1, this reaches 5.2:1. */
  --accent-strong: #6e4cf5;
  --accent-stronger: #5f3ee0;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
  scrollbar-color: var(--border) transparent;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .2em; }
::selection { background: #7c5cff66; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ---- Layout ---- */
header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
header.top .brand { font-weight: 650; color: var(--text); display: flex; align-items: center; gap: .6rem; }
header.top .brand .logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #2ec4b6); }
header.top nav { display: flex; gap: .25rem; flex-wrap: wrap; }
header.top nav a {
  color: var(--muted); padding: .35rem .7rem; border-radius: 8px;
}
header.top nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
header.top nav a.active { color: var(--text); background: var(--panel-2); }
main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin-bottom: 1rem;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---- Home ---- */
.hero { padding: 2rem 0 .5rem; }
.hero p { margin: .25rem 0 0; }
.hero h1 { font-size: 2rem; }
.category { margin: 1.75rem 0 .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; font-weight: 600; }
.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem; }
.service {
  display: flex; gap: .9rem; align-items: center; padding: 1rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); transition: border-color .15s, transform .15s;
}
.service:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.service:focus-visible { border-color: var(--accent); outline-offset: 3px; }
.service .icon {
  flex: none; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 700; font-size: 1.15rem; color: #fff;
}
.service .icon.logo { background: var(--panel-2); border: 1px solid var(--border); }
.service .icon.logo.light { background: #e6edf3; }
.service .icon.logo img { display: block; width: 28px; height: 28px; object-fit: contain; }
.service .meta { min-width: 0; }
.service .name { font-weight: 600; display: flex; align-items: center; gap: .45rem; }
.service .desc { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.service .host { color: var(--muted); font-size: .75rem; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.running { background: var(--ok); }
.dot.exited, .dot.dead { background: var(--bad); }
.dot.restarting, .dot.paused, .dot.created { background: var(--warn); }

footer.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem; }

/* ---- Forms ---- */
label { display: block; font-size: .85rem; color: var(--muted); margin: .6rem 0 .25rem; }
input[type=text], input[type=password], input[type=url], input:not([type]), select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: .55rem .7rem; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox]:focus-visible { outline-offset: 2px; }
textarea.code {
  font-family: var(--mono); font-size: 13px; line-height: 1.45; min-height: 60vh; resize: vertical;
  white-space: pre; tab-size: 2; overflow: auto;
}
.otp-input { font-family: var(--mono); font-size: 1.6rem !important; letter-spacing: .5em; text-align: center; }
input[type=checkbox] { accent-color: var(--accent); }

button, .btn {
  display: inline-flex; align-items: center; gap: .35rem; justify-content: center;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: .45rem .85rem; font: inherit; font-size: .9rem; cursor: pointer;
}
button:hover:not(:disabled), .btn:hover { border-color: var(--accent); text-decoration: none; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-stronger); border-color: var(--accent-stronger); }
button.danger { color: var(--bad); }
button.danger:hover:not(:disabled) { border-color: var(--bad); }
/* Row actions repeat on every table row: keep Stop/Restart quiet until pointed at, so red marks problems, not buttons. */
td .actions button.danger { color: var(--text); }
td .actions button.danger:hover:not(:disabled), td .actions button.danger:focus-visible { color: var(--bad); }
.modal button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.modal button.danger:hover:not(:disabled) { background: #da3633; border-color: #da3633; }
button.sm { padding: .2rem .55rem; font-size: .8rem; }
.error { color: var(--bad); font-size: .9rem; margin-top: .5rem; min-height: 1.2em; }
.success { color: var(--ok); font-size: .9rem; margin-top: .5rem; }

/* ---- Login ---- */
.auth-card { max-width: 380px; margin: 8vh auto; }
.auth-card h1 { margin-bottom: 1rem; }
.auth-card button[type=submit] { width: 100%; margin-top: .25rem; }

/* ---- Stats ---- */
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 1.6rem; font-weight: 650; margin: .2rem 0; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.bar.warn > span { background: var(--warn); }
.bar.bad > span { background: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
td .actions { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.table-wrap { overflow-x: auto; }

pre.log {
  background: #010409; border: 1px solid var(--border); border-radius: 8px; padding: .8rem;
  font-family: var(--mono); font-size: 12px; line-height: 1.45; max-height: 65vh; overflow: auto;
  white-space: pre-wrap; word-break: break-all; margin: 0;
}

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: .6rem .9rem; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:hover:not(:disabled) { color: var(--text); border-color: transparent; border-bottom-color: var(--border); }
.tabs button.active:hover { border-bottom-color: var(--accent); }

.badge { display: inline-block; font-size: .72rem; padding: .05rem .45rem; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: #23863655; }
.badge.bad { color: var(--bad); border-color: #f8514955; }
.badge.warn { color: var(--warn); border-color: #d2992255; }

.svc-edit { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr auto; gap: .5rem; align-items: end; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.svc-edit label { margin-top: 0; }
.svc-edit .wide { grid-column: 1 / 5; }

.banner-bad { border-color: var(--bad); background: #f851491a; }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 100; padding: 1rem;
}
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; width: min(100%, 420px); max-height: 90vh; overflow: auto; }
.modal.wide { width: min(100%, 1000px); }
.modal h2 { margin-bottom: .75rem; }
.modal .row.end { justify-content: flex-end; margin-top: 1rem; }

.toast {
  position: fixed; bottom: 1rem; right: 1rem; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem 1rem; z-index: 200; max-width: 420px; box-shadow: 0 6px 24px #0008;
}
.toast.bad { border-color: var(--bad); }

@media (max-width: 720px) {
  .svc-edit { grid-template-columns: 1fr 1fr; }
  .svc-edit .wide { grid-column: 1 / -1; }
  header.top { flex-wrap: wrap; }
  .hide-sm { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
  .service:hover { transform: none; }
}
