/* 宙斯 · 控制台
 * Single-file design system: tokens -> layout -> components.
 * No frameworks, no web fonts; everything renders from the system stack so the
 * console stays fast on a phone hotspot and inside the server's CSP.
 */

/* ---------------------------------------------------------------- tokens */
:root {
  color-scheme: dark;
  --bg: #070b14;
  --bg-glow: #0d1a2e;
  --surface: #0f1725;
  --surface-2: #141f31;
  --surface-3: #1a2739;
  --stroke: #22304a;
  --stroke-soft: #1a2434;
  --text: #e8f0fc;
  --text-dim: #a3b4cb;
  --text-mute: #6f819b;
  --accent: #56a8ff;
  --accent-soft: #8ccdff;
  --accent-ink: #05121f;
  --ok: #5ee2b2;
  --warn: #f7c870;
  --danger: #ff808a;
  --violet: #b39dff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px -24px rgb(0 0 0 / 90%);
  --font: "Inter", "SF Pro Text", system-ui, -apple-system, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgb(86 168 255 / 12%), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgb(179 157 255 / 8%), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-soft); text-decoration: none; }
a:hover { color: #b9e1ff; }
::selection { background: rgb(86 168 255 / 35%); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 64px;
  padding: 0 clamp(16px, 4vw, 36px);
  border-bottom: 1px solid var(--stroke-soft);
  background: rgb(7 11 20 / 82%);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 16px;
  color: var(--text);
}

.brand .mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 16px;
  background: linear-gradient(150deg, #1b4b7a, #0e2540);
  border: 1px solid rgb(86 168 255 / 45%);
  box-shadow: 0 0 0 1px rgb(86 168 255 / 8%), 0 8px 20px -12px rgb(86 168 255 / 80%);
}

.brand .sub { font-weight: 400; font-size: 13px; color: var(--text-mute); }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12px; color: var(--text-mute); font-family: var(--mono); }

/* ---------------------------------------------------------------- layout */
.shell { max-width: 1240px; margin: 0 auto; padding: clamp(20px, 3vw, 32px) clamp(16px, 4vw, 36px) 64px; }
.stack { display: grid; gap: 18px; }
.grid-2 { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: 18px; grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------------- panels */
.panel {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel.flat { background: var(--surface); box-shadow: none; }

.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.panel-head .hint { font-size: 12px; color: var(--text-mute); font-weight: 400; }
.panel-head .spacer { flex: 1; }

.eyebrow { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-mute); }
h1 { margin: 6px 0 4px; font-size: clamp(22px, 2.4vw, 28px); font-weight: 300; letter-spacing: 0.01em; }
h2.section { margin: 0 0 10px; font-size: 15px; font-weight: 600; }

.muted { color: var(--text-dim); font-size: 13px; }
.small { font-size: 12px; color: var(--text-mute); }
.mono { font-family: var(--mono); }

/* ---------------------------------------------------------------- hero */
.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background:
    radial-gradient(600px 200px at 0% 0%, rgb(86 168 255 / 14%), transparent 70%),
    linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow: var(--shadow);
}
.hero .titles { min-width: 0; }
.hero .spacer { flex: 1 1 40px; }

/* ---------------------------------------------------------------- metrics */
.metric {
  position: relative;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  overflow: hidden;
}
.metric::after {
  content: "";
  position: absolute;
  inset: auto -20% -60% auto;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(86 168 255 / 16%), transparent 65%);
  pointer-events: none;
}
.metric .label { display: block; font-size: 12px; color: var(--text-mute); }
.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.metric strong small { font-size: 13px; color: var(--text-mute); margin-left: 4px; font-weight: 400; }
.metric[data-tone="warn"] strong { color: var(--warn); }
.metric[data-tone="ok"] strong { color: var(--ok); }

/* ---------------------------------------------------------------- tabs */
.tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab[aria-selected="true"] {
  background: rgb(86 168 255 / 14%);
  border-color: rgb(86 168 255 / 45%);
  color: var(--accent-soft);
}
.tab .count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: rgb(255 255 255 / 8%);
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.tab .count[data-tone="warn"] { background: rgb(247 200 112 / 18%); color: var(--warn); }

/* ---------------------------------------------------------------- forms */
label { display: block; font-size: 12px; color: var(--text-dim); }

input, select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: var(--bg-glow);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  transition: border-color 120ms ease, background 120ms ease;
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgb(86 168 255 / 70%);
  background: #0b1524;
}
textarea { resize: vertical; font-family: var(--mono); font-size: 12px; word-break: break-all; }

.field-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field-row > * { flex: 1 1 180px; }
.field-row > .fit { flex: 0 0 auto; }
.field-row > .narrow { max-width: 130px; }

/* ---------------------------------------------------------------- buttons */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, transform 60ms ease;
}
button:hover, .button:hover { background: #223148; border-color: #33486a; }
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.primary {
  background: linear-gradient(180deg, #6db8ff, var(--accent));
  border-color: #7cbcff;
  color: var(--accent-ink);
  font-weight: 650;
}
.primary:hover { background: linear-gradient(180deg, #8ecaff, #6bb4ff); border-color: #9ad2ff; }

.ghost { background: none; color: var(--text-dim); }
.ghost:hover { background: var(--surface-2); color: var(--text); }

.danger { color: var(--danger); border-color: rgb(255 128 138 / 45%); background: rgb(255 128 138 / 10%); }
.danger:hover { background: rgb(255 128 138 / 18%); border-color: rgb(255 128 138 / 70%); }

.warn { color: var(--warn); border-color: rgb(247 200 112 / 45%); background: rgb(247 200 112 / 10%); }
.warn:hover { background: rgb(247 200 112 / 18%); }

.icon-button { width: 30px; height: 30px; padding: 0; border-radius: 8px; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions.gap-top, .stack.gap-top { margin-top: 12px; }
.actions.end { justify-content: flex-end; margin-top: 18px; }
.filters .spacer { flex: 1; }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--stroke);
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge.plain::before { display: none; }
.badge.live { color: var(--ok); border-color: rgb(94 226 178 / 40%); background: rgb(94 226 178 / 10%); }
.badge.warn { color: var(--warn); border-color: rgb(247 200 112 / 40%); background: rgb(247 200 112 / 10%); }
.badge.idle { color: var(--text-mute); }
.badge.danger { color: var(--danger); border-color: rgb(255 128 138 / 40%); background: rgb(255 128 138 / 10%); }
.badge.violet { color: var(--violet); border-color: rgb(179 157 255 / 40%); background: rgb(179 157 255 / 10%); }

/* ---------------------------------------------------------------- rooms */
.room-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }

.room {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  transition: border-color 140ms ease, transform 140ms ease;
}
.room:hover { border-color: #33486a; transform: translateY(-1px); }
.room-top { display: flex; gap: 10px; align-items: flex-start; }
.room-top h3 { margin: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.room-top .spacer { flex: 1; }
.room-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; font-size: 12px; color: var(--text-mute); }
.room-meta b { color: var(--text-dim); font-weight: 500; }
.room .actions { margin-top: auto; }
.room .actions button, .room .actions a { padding: 7px 11px; font-size: 12px; }
.room-foot { display: flex; gap: 14px; padding-top: 10px; border-top: 1px solid var(--stroke-soft); }
.room-foot button { padding: 0; border: 0; background: none; color: var(--text-mute); font-size: 12px; }
.room-foot button:hover { color: var(--text); background: none; }
.room-foot button.danger-text:hover { color: var(--danger); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.chip {
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--stroke);
  background: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}
.chip[aria-pressed="true"] {
  background: rgb(86 168 255 / 14%);
  border-color: rgb(86 168 255 / 45%);
  color: var(--accent-soft);
}

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); cursor: pointer; }
.check input { width: auto; margin: 0; accent-color: var(--accent); }

/* ---------------------------------------------------------------- tables */
.table-wrap { border: 1px solid var(--stroke); border-radius: 12px; background: var(--surface); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--stroke-soft); white-space: nowrap; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--text-mute);
  font-size: 12px;
  font-weight: 500;
}
tbody tr:hover { background: rgb(86 168 255 / 5%); }
tbody tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 180px; max-width: 340px; }
td.num { font-variant-numeric: tabular-nums; }
td .actions { gap: 6px; }
td .actions button { padding: 5px 9px; font-size: 12px; }

/* ---------------------------------------------------------------- card bulk edit */
th.select, td.select { width: 40px; padding-right: 0; }
.row-check { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }
tbody tr[data-selected] { background: rgb(86 168 255 / 10%); }
tbody tr[data-selected]:hover { background: rgb(86 168 255 / 14%); }

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.batch-bar .batch-shown { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--text-dim); }
.batch-bar .hint button { padding: 5px 9px; font-size: 12px; }

.empty-state { padding: 36px 16px; text-align: center; color: var(--text-mute); font-size: 13px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-mute);
}

/* ---------------------------------------------------------------- dialogs */
dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100dvh - 64px);
  padding: 24px;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  color: var(--text);
  box-shadow: 0 40px 80px -30px #000;
  overflow: auto;
}
dialog::backdrop { background: rgb(3 7 14 / 72%); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 4px; font-size: 17px; font-weight: 650; }
dialog .close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 0;
  background: none;
  color: var(--text-mute);
  font-size: 20px;
}
dialog .close:hover { color: var(--text); background: var(--surface-3); }
dialog .stack > * + * { margin-top: 12px; }

.copy-row { display: flex; gap: 8px; align-items: flex-end; }
.copy-row > :first-child { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: calc(100dvh - 64px); display: grid; place-items: center; padding: 24px 16px; }
.login { width: min(420px, 100%); padding: 28px; }
.login .mark-lg {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 18px;
  border-radius: 14px;
  font-size: 22px;
  background: linear-gradient(150deg, #1b4b7a, #0e2540);
  border: 1px solid rgb(86 168 255 / 45%);
}
.login h1 { font-size: 24px; font-weight: 300; }
.login form { margin-top: 20px; display: grid; gap: 14px; }
.login .primary { padding: 11px; }

/* ---------------------------------------------------------------- toast */
#message {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgb(20 31 49 / 96%);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 20px 40px -20px #000;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
#message:not(:empty) { opacity: 1; transform: translate(-50%, 0); }
#message[data-tone="error"] { border-color: rgb(255 128 138 / 50%); color: #ffd0d4; }

/* ---------------------------------------------------------------- misc */
.divider { height: 1px; background: var(--stroke-soft); border: 0; margin: 16px 0; }
.kv { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--text-mute); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--ok)); }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
