:root {
  --bg: #0e131b;
  --bg-2: #0b0f16;
  --surface: #161d29;
  --surface-2: #1d2632;
  --border: #29323f;
  --border-2: #333e4d;
  --text: #e8edf4;
  --muted: #8a95a6;
  --faint: #5d6879;
  --accent: #f5b342;        /* amber phosphor — the signature */
  --accent-ink: #1b1204;
  --up: #46c88a;
  --degraded: #e6913c;
  --down: #6b7688;
  --danger: #ef6b6b;
  --hover: #222c39;
  --hover-border: #3c4959;
  --ghost-hover: rgba(255,255,255,.07);
  --danger-bg: #2a1717;
  --danger-border: #43292c;
  --accent-hover: #ffc45f;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.28);
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0; font-family: var(--sans); color: var(--text);
  background: radial-gradient(1200px 600px at 78% -8%, #17202e 0%, var(--bg) 55%) fixed;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error { color: var(--danger); min-height: 1.2em; margin: .4rem 0 0; font-size: .88rem; }
a { color: var(--accent); }

/* Buttons */
button {
  font: 600 .9rem/1 var(--sans); cursor: pointer; border: 1px solid var(--border-2);
  background: var(--surface-2); color: var(--text); border-radius: 8px; padding: .55rem .95rem;
  transition: background .13s, border-color .13s, transform .05s, box-shadow .13s;
}
button:hover { background: var(--hover); border-color: var(--hover-border); }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 4px 16px rgba(245,179,66,.22); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--ghost-hover); color: var(--text); }
button.danger { color: var(--danger); border-color: var(--border-2); background: transparent; }
button.danger:hover { background: var(--danger-bg); border-color: var(--danger); }
button:disabled { opacity: .5; cursor: default; transform: none; }

input {
  font: 400 .92rem var(--sans); padding: .55rem .65rem; border: 1px solid var(--border-2);
  border-radius: 8px; width: 100%; background: var(--bg-2); color: var(--text);
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,179,66,.18); }
input::placeholder { color: var(--faint); }

/* Brand + terminal cursor */
.brand { font-family: var(--mono); font-weight: 600; letter-spacing: -.3px; font-size: 1.02rem; display: flex; align-items: center; gap: .1rem; }
.brand .cur { color: var(--accent); animation: blink 1.1s steps(1) infinite; margin-left: 1px; }
.brand .muted { color: var(--faint); font-weight: 400; }
@keyframes blink { 50% { opacity: 0; } }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: min(370px, 92vw); text-align: center; }
.login-card h1 { font-family: var(--mono); margin: 0 0 .2rem; letter-spacing: -.5px; }
.login-card h1::after { content: "▊"; color: var(--accent); animation: blink 1.1s steps(1) infinite; }
.login-card input, .login-card button { margin-top: .85rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.7rem; box-shadow: var(--shadow); }

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .8rem 1.5rem; background: rgba(11,15,22,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.topbar .actions { display: flex; gap: .45rem; }
.brand .back { font-family: var(--mono); color: var(--muted); padding: .3rem .55rem; margin-right: .4rem; }
.brand .back:hover { color: var(--accent); }

main { max-width: 1080px; margin: 0 auto; padding: 1.8rem 1.5rem 3rem; }

/* Blocks */
.block { margin-bottom: 2.2rem; }
.block-title { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--faint); margin: 0 0 .9rem; }
.empty { text-align: center; padding: 3rem 0; }

/* Service chips */
.svc-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.svc-card {
  display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .45rem .9rem; transition: border-color .13s, color .13s, background .13s;
}
.svc-card:hover { border-color: var(--accent); color: var(--accent); background: var(--hover); }
.svc-card h3 { margin: 0; font-size: .88rem; font-weight: 600; }
.svc-card .ext { opacity: .6; font-size: .8rem; }
.svc-card p { display: none; }

/* App list */
.grid { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.app-card {
  display: flex; align-items: center; gap: .95rem; padding: .95rem 1.1rem; cursor: pointer;
  border-top: 1px solid var(--border); border-left: 2px solid transparent; transition: background .12s, border-color .12s;
}
.app-card:first-child { border-top: none; }
.app-card:hover { background: var(--hover); border-left-color: var(--accent); }
.app-card h3 { margin: 0; font-family: var(--mono); font-size: .98rem; font-weight: 600; }
.app-card .dom { font-size: .8rem; color: var(--muted); }
.app-card .ac-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.app-card .ac-main .dom { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-card .meta { display: flex; align-items: center; gap: .7rem; font-size: .82rem; color: var(--muted); }

/* LED + chip + badge */
.led { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--down); }
.led.up { background: var(--up); box-shadow: 0 0 8px rgba(70,200,138,.6); }
.led.degraded { background: var(--degraded); box-shadow: 0 0 8px rgba(230,145,60,.6); }
.chip { font-family: var(--mono); font-size: .78rem; background: var(--bg-2); border: 1px solid var(--border); padding: .1rem .45rem; border-radius: 5px; color: var(--text); }
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .74rem; font-weight: 600; padding: .16rem .55rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .4px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.up { color: var(--up); background: rgba(70,200,138,.12); }
.badge.degraded { color: var(--degraded); background: rgba(230,145,60,.12); }
.badge.down { color: var(--down); background: rgba(107,118,136,.14); }

/* Modal (new app) */
.modal { position: fixed; inset: 0; background: rgba(6,9,14,.7); display: grid; place-items: center; padding: 1rem; z-index: 20; }
.modal-card { position: relative; width: min(500px, 96vw); max-height: 90vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.7rem; box-shadow: var(--shadow); }
.modal-card h2 { margin-top: 0; font-family: var(--mono); letter-spacing: -.3px; }
.close { position: absolute; top: .5rem; right: .5rem; border: none; background: none; font-size: 1.5rem; color: var(--muted); padding: .2rem .5rem; }

/* Forms */
.form { display: flex; flex-direction: column; gap: .85rem; }
.form label { display: flex; flex-direction: column; gap: .32rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
.form label.check { flex-direction: row; align-items: flex-start; gap: .55rem; font-weight: 400; color: var(--text); }
.form label.check input { margin-top: 1px; }
/* Custom checkbox (native accent-color looked out of place) */
.check input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 18px; height: 18px; flex: none; margin: 0;
  border: 1.5px solid var(--border-2); border-radius: 5px; background: var(--bg-2); cursor: pointer;
  position: relative; transition: background .12s, border-color .12s;
}
.check input[type="checkbox"]:hover { border-color: var(--accent); }
.check input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.check input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 5px; top: 1.5px; width: 4px; height: 8px;
  border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.check input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form .row { display: flex; gap: .85rem; } .form .row label { flex: 1; }
.provision-box { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: .9rem; display: flex; flex-direction: column; gap: .6rem; }
.provision-box code { font-family: var(--mono); background: var(--surface-2); padding: 0 .3rem; border-radius: 4px; font-size: .85em; color: var(--accent); }

/* Detail page */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.detail-head .sub { color: var(--muted); font-size: .9rem; margin-bottom: .35rem; font-family: var(--mono); word-break: break-all; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.dom-link { font-family: var(--mono); text-decoration: none; font-weight: 600; }
.stat-row { display: flex; gap: 1.6rem; }
.stat b { display: block; font-family: var(--mono); font-size: 1.35rem; } .stat span { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; align-items: start; }
.col { display: flex; flex-direction: column; gap: 1.1rem; }
.sect { padding: 1.15rem 1.25rem; }
.sect h4 { margin: 0 0 .8rem; font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: 1.2px; color: var(--faint); }
.inline { display: flex; gap: .5rem; align-items: center; }
.inline input { flex: 1; }
.data-row { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; font-size: .9rem; }
.data-row button { margin-left: auto; }
.danger-card { border-color: var(--danger-border); }
.danger-card .check { display: flex; align-items: center; gap: .55rem; margin-bottom: .85rem; font-size: .85rem; color: var(--muted); }
.hist { list-style: none; padding: 0; margin: 0; font-size: .86rem; }
.hist li { display: flex; gap: .6rem; align-items: center; padding: .34rem 0; border-bottom: 1px solid var(--border); }
.hist li:last-child { border-bottom: none; }
.hist b { font-family: var(--mono); font-weight: 600; } .hist .ok { color: var(--up); } .hist .fail { color: var(--danger); }
.env-row { display: flex; gap: .5rem; margin-bottom: .45rem; }
.env-row input { flex: 1; font-family: var(--mono); font-size: .84rem; }
.env-row .k { flex: 0 0 40%; }

/* Toast */
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text); padding: .7rem 1.1rem; border-radius: 8px; box-shadow: var(--shadow); z-index: 40; max-width: 90vw; font-size: .9rem; }
.toast::before { content: "▸ "; color: var(--accent); }
.toast.err { border-color: var(--danger); } .toast.err::before { content: "✕ "; color: var(--danger); }

@media (max-width: 720px) {
  .detail-grid { grid-template-columns: 1fr; }
  main { padding: 1.3rem 1rem 2.5rem; }
  .app-card { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { .brand .cur, .login-card h1::after { animation: none; } * { transition: none !important; } }

/* Light theme */
:root[data-theme="light"] {
  --bg: #eef1f5; --bg-2: #ffffff; --surface: #ffffff; --surface-2: #f1f4f8;
  --border: #dde3ea; --border-2: #cfd6df; --text: #1a2230; --muted: #5b6675; --faint: #8a95a6;
  --accent: #cf8418; --accent-ink: #ffffff; --up: #2fa872; --degraded: #c77f16; --down: #94a0b0; --danger: #d64545;
  --hover: #e8edf3; --hover-border: #c2cad4; --ghost-hover: rgba(20,30,45,.06); --danger-bg: #fbeaea; --danger-border: #f0cccc; --accent-hover: #b9770f;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 26px rgba(16,24,40,.10);
}
:root[data-theme="light"] body { background: radial-gradient(1200px 600px at 78% -8%, #ffffff 0%, var(--bg) 55%) fixed; }
:root[data-theme="light"] .topbar { background: rgba(255,255,255,.85); }
:root[data-theme="light"] .chip { background: #eef2f6; }

/* Service cards with credentials (overrides the earlier pill style) */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: .8rem; }
.svc-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); transition: border-color .12s; }
.svc-card:hover { transform: none; background: var(--surface); border-color: var(--border-2); }
.svc-open { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; text-decoration: none; color: var(--text); font-size: .95rem; }
.svc-open:hover { color: var(--accent); }
.svc-open .ext { opacity: .6; font-size: .82rem; }
.creds { margin-top: .65rem; display: flex; flex-direction: column; gap: .4rem; }
.cred { display: flex; align-items: center; gap: .5rem; font-size: .82rem; }
.cred .ck { color: var(--faint); font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .5px; width: 32px; flex: none; }
.cred code { font-family: var(--mono); color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cred .copy { padding: .2rem .55rem; font-size: .72rem; font-weight: 600; flex: none; }
.theme-toggle { font-size: 1rem; padding: .5rem .6rem; }

/* Loading + spinner */
.loading { display: flex; align-items: center; gap: .6rem; padding: 1.4rem; color: var(--muted); font-size: .9rem; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Streamed deploy log */
.op-log { margin: .7rem 0 0; padding: .7rem .8rem; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; font-family: var(--mono); font-size: .78rem; line-height: 1.5; color: var(--text); max-height: 280px; overflow: auto; white-space: pre-wrap; word-break: break-word; }

/* Dozzle logs link on the detail header */
.logs-link { font-family: var(--mono); font-size: .82rem; text-decoration: none; color: var(--muted); font-weight: 600; margin-left: .8rem; }
.logs-link:hover { color: var(--accent); }

/* GitHub device flow + repo list */
.device-code-row { display: flex; align-items: center; gap: .6rem; margin: .5rem 0; }
.device-code { flex: 1; font-family: var(--mono); font-size: 1.55rem; font-weight: 700; letter-spacing: 4px; color: var(--accent); background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: .7rem 1rem; text-align: center; }
.device-code-row .copy { padding: .55rem .9rem; font-size: .85rem; font-weight: 600; }
.gh-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .85rem; }
.repo-list { display: flex; flex-direction: column; gap: .5rem; max-height: 55vh; overflow: auto; }
.repo-item { display: flex; align-items: center; gap: .8rem; padding: .65rem .9rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-2); }
.repo-item .ri-info { flex: 1; min-width: 0; }
.repo-item .ri-info b { font-family: var(--mono); }

/* Service icon + name row */
.svc-open { gap: .5rem; width: 100%; }
.svc-icon { width: 18px; height: 18px; flex: none; color: var(--accent); }
.svc-name { flex: 1; min-width: 0; }

/* Offline service (e.g. RabbitMQ when its profile isn't started) */
.svc-card.offline { opacity: .62; }
.svc-card.offline .svc-open, .svc-card.offline .svc-icon { color: var(--muted); }
.off-tag { font-size: .62rem; font-weight: 600; color: var(--faint); border: 1px solid var(--border-2); border-radius: 999px; padding: .05rem .42rem; text-transform: uppercase; letter-spacing: .6px; }
