/* ============================================================
   设计令牌 —— 所有颜色只在这里定义，组件不得写死色值
   ============================================================ */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --surface-3: #e4e8ee;
  --border: #dfe3ea;
  --border-strong: #c8cfda;
  --text: #101828;
  --text-2: #4a5568;
  --text-3: #8a94a6;
  --brand: #1f5eff;
  --brand-hover: #1849cc;
  --brand-weak: #e8eeff;
  --brand-text: #1339a6;
  --danger: #c4271b;
  --danger-weak: #fde9e7;
  --warn: #a4540a;
  --warn-weak: #fdf1d9;
  --ok: #046c46;
  --ok-weak: #d9f5e6;
  --info: #0b5cc4;
  --info-weak: #e5eefc;
  --sidebar-bg: #0e1726;
  --sidebar-text: #a9b4c6;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: rgba(255, 255, 255, 0.09);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 18px 40px rgba(16, 24, 40, 0.18);
  --sidebar-w: 232px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b111b;
    --surface: #121a27;
    --surface-2: #182231;
    --surface-3: #1f2b3d;
    --border: #223045;
    --border-strong: #2f3f57;
    --text: #e8edf4;
    --text-2: #a8b4c6;
    --text-3: #75839a;
    --brand: #4b7bff;
    --brand-hover: #6a92ff;
    --brand-weak: #16243f;
    --brand-text: #9cb6ff;
    --danger: #ff6b5e;
    --danger-weak: #351714;
    --warn: #f0a64a;
    --warn-weak: #33240f;
    --ok: #4fd39a;
    --ok-weak: #0e2a20;
    --info: #6ba6ff;
    --info-weak: #13233c;
    --sidebar-bg: #070c14;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #0b111b;
  --surface: #121a27;
  --surface-2: #182231;
  --surface-3: #1f2b3d;
  --border: #223045;
  --border-strong: #2f3f57;
  --text: #e8edf4;
  --text-2: #a8b4c6;
  --text-3: #75839a;
  --brand: #4b7bff;
  --brand-hover: #6a92ff;
  --brand-weak: #16243f;
  --brand-text: #9cb6ff;
  --danger: #ff6b5e;
  --danger-weak: #351714;
  --warn: #f0a64a;
  --warn-weak: #33240f;
  --ok: #4fd39a;
  --ok-weak: #0e2a20;
  --info: #6ba6ff;
  --info-weak: #13233c;
  --sidebar-bg: #070c14;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.6);
}

/* ============================================================
   基础
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.muted {
  color: var(--text-2);
}

.faint {
  color: var(--text-3);
}

.nowrap {
  white-space: nowrap;
}

/* 启动占位 */
.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.boot-inner {
  display: grid;
  justify-items: center;
  gap: 14px;
  color: var(--text-2);
}

.boot-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================================
   布局：侧栏 + 主区
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  color: #fff;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  flex: none;
}

.brand-text strong {
  display: block;
  font-size: 13.5px;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.brand-text span {
  display: block;
  font-size: 11px;
  color: var(--sidebar-text);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  text-decoration: none;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
  font-weight: 500;
}

.nav-item svg {
  flex: none;
  opacity: 0.85;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11.5px;
  color: var(--sidebar-text);
  line-height: 1.7;
}

.sidebar-foot .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--ok);
  vertical-align: middle;
}

.sidebar-foot .dot.off {
  background: var(--danger);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 16px;
}

.topbar .crumb {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  padding: 24px 28px 48px;
  display: grid;
  gap: 18px;
  align-content: start;
}

/* ============================================================
   组件：按钮 / 输入 / 卡片 / 表格 / 徽标
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}

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

.btn-danger {
  color: var(--danger);
  border-color: var(--border-strong);
}

.btn-danger:hover {
  background: var(--danger-weak);
}

.btn-sm {
  height: 28px;
  padding: 0 9px;
  font-size: 12.5px;
}

.btn-icon {
  width: 34px;
  padding: 0;
}

.field {
  display: grid;
  gap: 6px;
}

.field > label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}

.field .hint {
  font-size: 11.5px;
  color: var(--text-3);
}

.input,
.select {
  height: 34px;
  width: 100%;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13px;
}

.input:focus,
.select:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-weak);
}

.input::placeholder {
  color: var(--text-3);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.card-head h2 {
  font-size: 14px;
}

.card-head .sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.card-body {
  padding: 16px 18px;
}

.card-body.flush {
  padding: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.toolbar .spacer {
  flex: 1;
}

.toolbar .input,
.toolbar .select {
  width: auto;
  min-width: 150px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th {
  position: sticky;
  top: 0;
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data tbody tr:hover {
  background: var(--surface-2);
}

table.data tbody tr:last-child td {
  border-bottom: none;
}

table.data td.right,
table.data th.right {
  text-align: right;
}

.empty {
  padding: 44px 18px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.empty svg {
  color: var(--border-strong);
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-red {
  color: var(--danger);
  background: var(--danger-weak);
}

.badge-orange {
  color: var(--warn);
  background: var(--warn-weak);
}

.badge-yellow {
  color: var(--warn);
  background: transparent;
  border: 1px dashed currentColor;
}

.badge-yellow::before {
  display: none;
}

.badge-green {
  color: var(--ok);
  background: var(--ok-weak);
}

.badge-gray {
  color: var(--text-2);
  background: var(--surface-3);
}

.badge-blue {
  color: var(--info);
  background: var(--info-weak);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-2);
}

.pager .pages {
  display: flex;
  gap: 6px;
}

/* 状态点 */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}

.status-dot i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-on {
  color: var(--ok);
}

.status-off {
  color: var(--text-3);
}

/* 加载条 */
.loading-bar {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: slide 1s linear infinite;
}

@keyframes slide {
  0% {
    background-position: -40% 0;
  }
  100% {
    background-position: 140% 0;
  }
}

.hidden {
  display: none !important;
}
