/* Beyond the Wire panel. Brand kit: palette 6B Classic Crimson, Urbanist / Mulish / DM Mono. */

:root {
  --bg: #0a1120; --surface: #111a2c; --line: #26344d; --text: #f3ead8; --muted: #a39c8f;
  --red: #ef4444; --on-red: #0a1120; --red-deep-fg: #fca5a5; --red-deep-bg: #450a0a;
  --ok: #4ade80; --maint: #f59e0b; --off: #8b93a3;
  --inset: #0d1526; --term-bg: #070c17; --term-text: #d9e1ee;
  --shadow: 0 1px 0 rgba(255,255,255,0.02), 0 12px 32px -18px rgba(0,0,0,0.7);
  --scrim: linear-gradient(180deg, rgba(10,17,32,0.86) 0%, rgba(10,17,32,0.92) 100%);
  --font-head: 'Urbanist', system-ui, sans-serif;
  --font-body: 'Mulish', system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f0e4; --surface: #fbf7ef; --line: #dccfb8; --text: #0b1526; --muted: #5f5a52;
    --red: #dc2626; --on-red: #fff8ee; --red-deep-fg: #991b1b; --red-deep-bg: #991b1b1f;
    --ok: #15803d; --maint: #b45309; --off: #6b7280;
    --inset: #f1e9da; --term-bg: #0b1526; --term-text: #e8eef8;
    --shadow: 0 1px 0 rgba(255,255,255,0.6), 0 12px 28px -20px rgba(60,40,10,0.35);
    --scrim: linear-gradient(180deg, rgba(246,240,228,0.80) 0%, rgba(246,240,228,0.88) 100%);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f0e4; --surface: #fbf7ef; --line: #dccfb8; --text: #0b1526; --muted: #5f5a52;
  --red: #dc2626; --on-red: #fff8ee; --red-deep-fg: #991b1b; --red-deep-bg: #991b1b1f;
  --ok: #15803d; --maint: #b45309; --off: #6b7280;
  --inset: #f1e9da; --term-bg: #0b1526; --term-text: #e8eef8;
  --shadow: 0 1px 0 rgba(255,255,255,0.6), 0 12px 28px -20px rgba(60,40,10,0.35);
  --scrim: linear-gradient(180deg, rgba(246,240,228,0.80) 0%, rgba(246,240,228,0.88) 100%);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  min-height: 100%;
  background: var(--scrim), url('/assets/background.jpg') center / cover no-repeat fixed, var(--bg);
  background-color: var(--bg);
}
body {
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1440px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px) 64px; }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 22px 0; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; line-height: 0; }
.brand img { height: 46px; width: auto; }
.brand .tag {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  line-height: 1; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted);
}
.logo-light { display: none; }
:root[data-theme="light"] .logo-dark { display: none; }
:root[data-theme="light"] .logo-light { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .logo-dark { display: none; }
  :root:not([data-theme="dark"]) .logo-light { display: block; }
}
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a {
  font-family: var(--font-mono); font-size: 14px; text-decoration: none; color: var(--muted);
  padding: 8px 12px; border-radius: 8px; transition: color .15s, background-color .15s;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); background: color-mix(in srgb, var(--surface) 80%, transparent); box-shadow: inset 0 0 0 1px var(--line); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.who b { color: var(--text); font-weight: 500; }
.role-pill { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--red); color: var(--red); margin-left: 6px; }

.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-mono); font-weight: 500; font-size: 14px; letter-spacing: .02em;
  border-radius: 10px; padding: 10px 16px; border: 1px solid transparent; cursor: pointer;
  text-decoration: none; white-space: nowrap; background: transparent;
  transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease-out), opacity .15s;
}
.btn-primary { background: var(--red); color: var(--on-red); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-ghost { color: var(--text); border-color: var(--line); background: color-mix(in srgb, var(--surface) 70%, transparent); }
.btn-ghost:hover:not(:disabled) { border-color: var(--muted); }
.btn-ok    { color: var(--ok);    border-color: color-mix(in srgb, var(--ok) 45%, transparent);    background: color-mix(in srgb, var(--ok) 10%, transparent); }
.btn-warn  { color: var(--maint); border-color: color-mix(in srgb, var(--maint) 45%, transparent); background: color-mix(in srgb, var(--maint) 10%, transparent); }
.btn-stop  { color: var(--red-deep-fg); border-color: color-mix(in srgb, var(--red) 45%, transparent); background: var(--red-deep-bg); }
.btn-ok:hover:not(:disabled), .btn-warn:hover:not(:disabled), .btn-stop:hover:not(:disabled) { filter: brightness(1.12); }
.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .spinner { animation: soft-pulse 1s ease-in-out infinite; }

/* ---------- Layout bits ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 28px 0 24px; }
.prompt { font-family: var(--font-mono); font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.prompt .chev { color: var(--red); }
h1 { font-family: var(--font-head); font-weight: 800; font-size: clamp(32px, 4.5vw, 52px); line-height: 1.05; letter-spacing: -0.02em; }
h2 { font-family: var(--font-head); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; }
h3 { font-family: var(--font-head); font-weight: 700; font-size: 18px; }
.label { font-family: var(--font-mono); font-weight: 500; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); position: relative;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 20px; }

.win-bar { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--inset); border-radius: 13px 13px 0 0; }
.win-dots { display: flex; gap: 5px; }
.win-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: block; transition: background-color .25s; }
.win-title { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; width: fit-content;
  font-family: var(--font-mono); font-weight: 500; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; border: 1px solid currentColor;
}
.badge .icon { width: 13px; height: 13px; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok    { color: var(--ok);    background: color-mix(in srgb, var(--ok) 12%, transparent);    border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.maint { color: var(--maint); background: color-mix(in srgb, var(--maint) 12%, transparent); border-color: color-mix(in srgb, var(--maint) 40%, transparent); }
.badge.off   { color: var(--off);   background: color-mix(in srgb, var(--off) 12%, transparent);   border-color: color-mix(in srgb, var(--off) 40%, transparent); }

/* ---------- Auth screens ---------- */
.auth { min-height: calc(100vh - 120px); display: grid; place-items: center; padding: 24px 0 64px; }
.auth .panel { width: min(440px, 100%); }
.auth .panel-body { padding: 28px; }
.auth h1 { font-size: 34px; margin-bottom: 6px; }
.auth .sub { color: var(--muted); margin-bottom: 22px; }

.field { margin-bottom: 16px; }
.field > label, .field > .label { display: block; margin-bottom: 7px; }
.input, select.input {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted); opacity: .75; }
.input:focus { border-color: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 20%, transparent); }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.form-error {
  margin: 4px 0 14px; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  color: var(--red-deep-fg); background: var(--red-deep-bg); border: 1px solid color-mix(in srgb, var(--red) 30%, transparent);
}
.full { width: 100%; padding: 13px; font-size: 15px; }

/* ---------- Server grid ---------- */
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 18px; }
.server-card { display: flex; flex-direction: column; transition: border-color .2s, transform .25s var(--ease-out); }
.server-card:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--muted)); }
.server-card:hover .win-dots i:nth-child(1) { background: var(--red); }
.server-card:hover .win-dots i:nth-child(2) { background: var(--maint); }
.server-card:hover .win-dots i:nth-child(3) { background: var(--ok); }
.server-card .card-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; flex: 1; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.server-name { font-family: var(--font-head); font-weight: 700; font-size: 24px; line-height: 1.15; text-decoration: none; }
a.server-name:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; text-decoration-color: var(--red); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stat { padding: 11px 13px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-val { display: block; font-family: var(--font-mono); font-weight: 500; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .label { font-size: 10.5px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.empty {
  padding: 40px 24px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 14px; background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.empty h3 { color: var(--text); margin-bottom: 6px; }
.notice {
  display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 13px;
  padding: 10px 12px; border-radius: 10px;
}
.notice.warn { color: var(--maint); background: color-mix(in srgb, var(--maint) 10%, transparent); border: 1px solid color-mix(in srgb, var(--maint) 35%, transparent); }
.notice.err  { color: var(--red-deep-fg); background: var(--red-deep-bg); border: 1px solid color-mix(in srgb, var(--red) 30%, transparent); }
.notice.ok   { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }

/* ---------- Server detail ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 12px; }
.back:hover { color: var(--text); }
.back .icon { transform: rotate(180deg); width: 15px; height: 15px; }
.detail-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.tile-val { display: block; font-family: var(--font-head); font-weight: 700; font-size: 30px; line-height: 1.1; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 18px; align-items: start; }

.console { display: flex; flex-direction: column; }
.term {
  background: var(--term-bg); color: var(--term-text); font-family: var(--font-mono); font-size: 13px; line-height: 1.55;
  height: 460px; overflow: auto; padding: 14px 16px; white-space: pre-wrap; word-break: break-word;
  border-bottom: 1px solid var(--line);
}
.term .ln { display: block; }
.term .ln.warn { color: #fbbf24; }
.term .ln.error { color: #fca5a5; }
.term .ln.me { color: #93c5fd; }
.term-empty { color: #8b93a3; font-style: italic; }
.cmd-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.cmd-row .chev { font-family: var(--font-mono); color: var(--red); font-weight: 500; }
.cmd-row .input { font-family: var(--font-mono); font-size: 14px; padding: 10px 12px; }
.follow { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); cursor: pointer; }

.list { list-style: none; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 0; }
.list .meta { font-size: 13px; color: var(--muted); }

/* ---------- Admin ---------- */
.admin-grid { display: grid; gap: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-family: var(--font-mono); font-weight: 500; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.mono, td .mono { font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-family: var(--font-mono); font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--inset); border: 1px solid var(--line); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; max-height: 220px; overflow: auto; padding: 2px; }
.check { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 14px; }
.check input { accent-color: var(--red); width: 16px; height: 16px; }
.check:has(input:checked) { border-color: var(--red); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { padding: 9px 14px; cursor: pointer; font-family: var(--font-mono); font-size: 13px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--red); color: var(--on-red); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--red); outline-offset: -2px; }

/* ---------- Dialog ---------- */
dialog {
  margin: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; box-shadow: 0 30px 80px -20px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(5, 9, 18, .6); }
dialog .panel-body { padding: 22px; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
dialog .dialog-actions .spacer { flex: 1; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 16px 40px -16px rgba(0,0,0,.6);
}
.toast.ok .icon { color: var(--ok); }
.toast.err { border-color: color-mix(in srgb, var(--red) 50%, var(--line)); }
.toast.err .icon { color: var(--red); }

.skeleton { display: block; height: 14px; border-radius: 4px; background: var(--line); animation: soft-pulse 1.4s ease-in-out infinite; }

/* ---------- Motion (tiered per .claude/skills/accessible-animation) ---------- */
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes pop-in  { from { opacity: 0; transform: scale(.94); } }
@keyframes soft-pulse { 50% { opacity: .45; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

.view { animation: fade-in .2s ease both; }
.toast { animation: fade-in .2s ease both; }
dialog[open] { animation: fade-in .2s ease both; }
dialog[open]::backdrop { animation: fade-in .2s ease both; }

@media (prefers-reduced-motion: no-preference) {
  .view > * { animation: rise-in .5s var(--ease-out) both; }
  .view > :nth-child(2) { animation-delay: 60ms; }
  .view > :nth-child(3) { animation-delay: 120ms; }
  .view > :nth-child(4) { animation-delay: 180ms; }
  .server-grid > * { animation: rise-in .5s var(--ease-out) both; animation-delay: calc(80ms + var(--i, 0) * 70ms); }
  .server-card:hover { transform: translateY(-3px); }
  .btn:hover:not(:disabled) { transform: translateY(-1px); }
  .btn:active:not(:disabled) { transform: scale(.97); transition-duration: .06s; }
  .btn .spinner { animation: spin .8s linear infinite; }
  .toast { animation: rise-in .3s var(--ease-out) both; }
  dialog[open] { animation: pop-in .25s var(--ease-out) both; }
  .form-error { animation: rise-in .25s var(--ease-out), shake .4s ease .25s; }
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .detail-grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .brand img { height: 36px; }
  .nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .who { display: none; }
  #logout span { display: none; }
  #logout { padding: 10px; }
  .topbar { gap: 10px; }
  .term { height: 360px; font-size: 12px; }
  .stat-val { font-size: 16px; }
  th:nth-child(4), td:nth-child(4) { display: none; }
}
