:root {
  color-scheme: dark;
  --ground: #10241c;
  --ground-deep: #0b1a14;
  --panel: rgba(239, 231, 216, 0.05);
  --panel-hi: rgba(239, 231, 216, 0.09);
  --line: rgba(176, 141, 87, 0.28);
  --brass: #b08d57;
  --brass-dim: #6d5a3c;
  --gold: #c9a227;
  --vellum: #efe7d8;
  --vellum-dim: rgba(239, 231, 216, 0.62);
  --good: #8fcf9d;
  --warn: #e0b25a;
  --bad: #e4948a;
  --idle: #8d958c;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(circle at 50% 0%, var(--ground) 0%, var(--ground-deep) 70%) fixed;
  color: var(--vellum);
  font-family: "Jost", ui-sans-serif, system-ui, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
h1, h2, h3 { font-family: "Playfair Display", Georgia, "Times New Roman", serif; font-weight: 500; margin: 0; }
button { font-family: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.eyebrow { margin: 0; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.28em; font-weight: 500; color: var(--brass); }

/* ---------- sign-in ---------- */
.gate-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.gate { width: 100%; max-width: 30rem; text-align: center; }
.gate .mark { width: 56px; height: 56px; margin: 0 auto 2rem; display: block; }
.gate h1 { text-transform: uppercase; letter-spacing: 0.1em; font-size: 1.35rem; margin-bottom: 0.5rem; }
.gate .eyebrow { margin-bottom: 2.25rem; }
.rule { width: 2.5rem; height: 1px; background: var(--brass-dim); margin: 0 auto 2.25rem; }
.message { font-size: 0.95rem; line-height: 1.7; color: var(--vellum-dim); margin: 0 0 2rem; }
.gate form { display: flex; flex-direction: column; gap: 0.9rem; align-items: center; }
.gate input { width: 100%; max-width: 18rem; text-align: center; letter-spacing: 0.04em; }
input[type="password"] {
  background: rgba(239, 231, 216, 0.06); border: 1px solid var(--brass-dim); color: var(--vellum); font: inherit; font-size: 0.95rem;
  padding: 0.7rem 0.9rem; border-radius: 3px; outline: none; transition: border-color 0.2s;
}
input[type="password"]:focus { border-color: var(--gold); }
.error { font-size: 0.78rem; letter-spacing: 0.04em; color: var(--bad); min-height: 1.2em; margin: 0; }
.shake { animation: shake 0.4s ease; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- buttons ---------- */
.btn {
  background: transparent; border: 1px solid var(--brass); color: var(--vellum); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.16em;
  padding: 0.5rem 0.95rem; border-radius: 3px; cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--gold); border-color: var(--gold); color: var(--ground-deep); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn.danger { border-color: #a85a50; color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: #a85a50; border-color: #a85a50; color: var(--vellum); }
.btn.busy { position: relative; color: transparent; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 0.9rem; height: 0.9rem; border: 2px solid var(--vellum-dim); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.linkbtn { background: none; border: none; color: var(--vellum-dim); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.2em; cursor: pointer; padding: 0.4rem 0.2rem; }
.linkbtn:hover { color: var(--gold); }

/* ---------- top ---------- */
.top { max-width: 80rem; margin: 0 auto; padding: 1.25rem 1.25rem 0.5rem; display: grid; grid-template-columns: 1fr auto; gap: 0.9rem 1rem; align-items: center; }
.brand { display: flex; align-items: center; gap: 0.85rem; min-width: 0; }
.brand .mark { width: 40px; height: 40px; flex: none; }
.brand h1 { font-size: 1.15rem; letter-spacing: 0.08em; text-transform: uppercase; }
.top-actions { display: flex; gap: 0.6rem; }
.pills { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.45rem; }
.pill {
  display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.3rem 0.8rem; border: 1px solid var(--line); border-radius: 999px;
  color: var(--vellum); text-decoration: none; font-size: 0.8rem; letter-spacing: 0.04em; background: var(--panel); transition: border-color 0.15s, background 0.15s;
}
.pill:hover { border-color: var(--gold); background: var(--panel-hi); }
.dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--idle); display: inline-block; flex: none; }
.pill.good .dot { background: var(--good); box-shadow: 0 0 6px rgba(143, 207, 157, 0.6); }
.pill.warn .dot { background: var(--warn); }
.pill.bad .dot { background: var(--bad); }

.banner { max-width: 80rem; margin: 0.6rem auto 0; padding: 0.55rem 1rem; border: 1px solid var(--warn); border-radius: 4px; color: var(--warn); font-size: 0.85rem; background: rgba(224, 178, 90, 0.08); }
.banner[hidden] { display: none; }
main { max-width: 80rem; margin: 0 auto; padding: 0.75rem 1.25rem 3rem; }

/* ---------- this machine ---------- */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0.75rem; margin: 0.5rem 0 1rem; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 0.65rem 0.85rem; }
.tile .k { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.2em; color: var(--brass); }
.tile .v { font-family: "Playfair Display", Georgia, serif; font-size: 1.45rem; line-height: 1.2; }
.tile .s { font-size: 0.74rem; color: var(--vellum-dim); }
.tile .bar { height: 3px; background: rgba(239, 231, 216, 0.1); border-radius: 2px; margin-top: 0.35rem; overflow: hidden; }
.tile .bar i { display: block; height: 100%; background: var(--good); transition: width 0.4s; }
.tile .bar i.warn { background: var(--warn); } .tile .bar i.bad { background: var(--bad); }

/* ---------- widgets ---------- */
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(21.5rem, 1fr)); gap: 1rem; }
.w { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.05rem 0.95rem; display: flex; flex-direction: column; gap: 0.7rem; min-width: 0; }
.w.off { border-color: rgba(141, 149, 140, 0.35); }
.w.bad { border-color: rgba(228, 148, 138, 0.55); }
.wh { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.7rem; }
.wh h3 { font-size: 1.12rem; letter-spacing: 0.02em; min-width: 0; }
.wh h3 small { display: block; font-family: "Jost", sans-serif; font-weight: 300; font-size: 0.74rem; color: var(--vellum-dim); letter-spacing: 0.02em; margin-top: 0.05rem; }
.wh .open { margin-left: auto; color: var(--brass); text-decoration: none; font-size: 0.85rem; border: 1px solid var(--line); border-radius: 999px; padding: 0.1rem 0.6rem; }
.wh .open:hover { color: var(--gold); border-color: var(--gold); }
.state { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 500; padding: 0.18rem 0.6rem; border-radius: 999px; border: 1px solid currentColor; flex: none; }
.state i { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }
.state.good { color: var(--good); } .state.warn { color: var(--warn); } .state.bad { color: var(--bad); } .state.idle { color: var(--idle); }
.sub { margin: -0.25rem 0 0; font-size: 0.76rem; color: var(--vellum-dim); overflow-wrap: anywhere; }
.sub b { font-weight: 400; color: var(--vellum); }
.vis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.vis div { background: rgba(0, 0, 0, 0.18); border-radius: 6px; padding: 0.45rem 0.6rem; }
.vis b { display: block; font-family: "Playfair Display", Georgia, serif; font-size: 1.55rem; font-weight: 500; line-height: 1.1; color: var(--gold); }
.vis b.zero { color: var(--vellum-dim); }
.vis span { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--vellum-dim); }
.checks, .facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1.1rem; font-size: 0.78rem; color: var(--vellum-dim); }
.checks b, .facts b { font-weight: 400; color: var(--vellum); }
.checks b.good { color: var(--good); } .checks b.warn { color: var(--warn); } .checks b.bad { color: var(--bad); }
.hint { margin: 0; font-size: 0.76rem; color: var(--vellum-dim); }
.hint.warn { color: var(--warn); }
.btns { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: auto; padding-top: 0.15rem; }
details.ips summary { cursor: pointer; font-size: 0.74rem; color: var(--vellum-dim); letter-spacing: 0.04em; }
details.ips summary:hover { color: var(--gold); }
details.ips ul { list-style: none; margin: 0.4rem 0 0; padding: 0; font-size: 0.76rem; font-variant-numeric: tabular-nums; }
details.ips li { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.12rem 0; border-bottom: 1px dashed rgba(176, 141, 87, 0.15); }
details.ips li span { color: var(--vellum-dim); }
pre.logs { margin: 0; max-height: 15rem; overflow: auto; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem; font: 0.7rem/1.4 ui-monospace, Consolas, monospace; color: var(--vellum-dim); white-space: pre-wrap; overflow-wrap: anywhere; }
pre.logs[hidden] { display: none; }
pre.logs .err { color: var(--bad); }

.activity { margin-top: 1.6rem; }
.activity h2 { font-size: 0.95rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brass); margin-bottom: 0.5rem; }
.activity ul { list-style: none; margin: 0; padding: 0; font-size: 0.8rem; }
.activity li { display: flex; gap: 0.8rem; padding: 0.3rem 0; border-bottom: 1px solid rgba(176, 141, 87, 0.12); color: var(--vellum-dim); flex-wrap: wrap; }
.activity li time { color: var(--brass); font-variant-numeric: tabular-nums; min-width: 9.5rem; }
.activity li .ok { color: var(--good); } .activity li .no { color: var(--bad); }

/* ---------- dialogs and toasts ---------- */
dialog { background: #14291f; color: var(--vellum); border: 1px solid var(--brass); border-radius: 10px; padding: 1.2rem 1.3rem; max-width: 26rem; width: calc(100% - 2rem); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6); }
dialog::backdrop { background: rgba(5, 12, 9, 0.7); }
dialog h3 { font-size: 1.15rem; margin-bottom: 0.5rem; }
dialog p { margin: 0 0 0.9rem; font-size: 0.9rem; color: var(--vellum-dim); }
.extra { display: block; margin-bottom: 1rem; font-size: 0.8rem; color: var(--vellum-dim); }
.extra select, .field input { display: block; width: 100%; margin-top: 0.3rem; background: rgba(239, 231, 216, 0.06); color: var(--vellum); border: 1px solid var(--brass-dim); border-radius: 3px; padding: 0.55rem 0.6rem; font: inherit; font-size: 0.9rem; }
.field { display: block; margin-bottom: 0.8rem; font-size: 0.78rem; color: var(--vellum-dim); }
.dlg-btns { display: flex; justify-content: flex-end; gap: 0.6rem; }
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 50; max-width: min(24rem, calc(100% - 2rem)); }
.toast { background: #14291f; border: 1px solid var(--brass); border-left-width: 4px; border-radius: 6px; padding: 0.6rem 0.85rem; font-size: 0.85rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); animation: rise 0.2s ease; }
.toast.good { border-color: var(--good); } .toast.bad { border-color: var(--bad); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 560px) {
  .top { padding: 1rem 1rem 0.4rem; }
  main { padding: 0.6rem 1rem 3rem; }
  .brand h1 { font-size: 1rem; }
  .two, .grid { grid-template-columns: 1fr; }
  .w { padding: 0.9rem; }
  .btn { padding: 0.6rem 0.85rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
