:root {
  --bg: #0b0f14;
  --bg-2: #0f1419;
  --surface: rgba(22, 30, 42, 0.72);
  --surface-solid: #161e2a;
  --surface-hover: rgba(30, 41, 59, 0.9);
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.22);
  --text: #e8edf4;
  --muted: #8b9cb3;
  --primary: #38bdf8;
  --primary-dim: rgba(56, 189, 248, 0.14);
  --primary-glow: rgba(56, 189, 248, 0.35);
  --success: #4ade80;
  --success-dim: rgba(74, 222, 128, 0.12);
  --danger: #f87171;
  --danger-dim: rgba(248, 113, 113, 0.12);
  --warning: #fbbf24;
  --sidebar-w: 240px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

/* ── background glow ── */
body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}
body::before {
  width: 480px; height: 480px;
  top: -120px; left: -80px;
  background: rgba(56, 189, 248, 0.08);
}
body::after {
  width: 400px; height: 400px;
  bottom: -100px; right: -60px;
  background: rgba(99, 102, 241, 0.07);
}

/* ── layout shell ── */
.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px var(--primary-glow);
  flex-shrink: 0;
}
.brand-icon svg { width: 18px; height: 18px; color: #fff; }

.brand-text { line-height: 1.2; }
.brand-text strong { display: block; font-size: 0.95rem; font-weight: 700; }
.brand-text span { font-size: 0.72rem; color: var(--muted); }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.7; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active {
  background: var(--primary-dim);
  color: var(--primary);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}
.nav-item.logout:hover { background: var(--danger-dim); color: var(--danger); }

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

.page-header {
  padding: 24px 32px 0;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-header .subtitle {
  margin-top: 4px;
  font-size: 0.88rem;
  color: var(--muted);
}

.container {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 32px 48px;
}

/* ── panels ── */
.panel {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}
.panel-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.panel-header .hint { font-size: 0.82rem; color: var(--muted); }

/* ── stats ── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.stat:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.stat::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-users::before { background: linear-gradient(90deg, #38bdf8, #818cf8); }
.stat-total::before { background: linear-gradient(90deg, #a78bfa, #c084fc); }
.stat-pass::before { background: linear-gradient(90deg, #4ade80, #34d399); }
.stat-fail::before { background: linear-gradient(90deg, #f87171, #fb923c); }

.stat-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  font-size: 1rem;
}
.stat-users .stat-icon { background: var(--primary-dim); }
.stat-total .stat-icon { background: rgba(167, 139, 250, 0.14); }
.stat-pass .stat-icon { background: var(--success-dim); }
.stat-fail .stat-icon { background: var(--danger-dim); }

.stat .label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 1.75rem; font-weight: 700; margin-top: 2px; letter-spacing: -0.03em; }
.stat-pass .value { color: var(--success); }
.stat-fail .value { color: var(--danger); }

/* ── tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(15, 20, 28, 0.6);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 32px 14px;
}

.mono { font-family: "SF Mono", "Fira Code", monospace; font-size: 0.85rem; }

/* ── forms ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 18px;
  align-items: end;
}
.form-grid .field-full { grid-column: 1 / -1; }

.field { margin-bottom: 0; }
label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}
input, select {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(11, 15, 20, 0.6);
  color: var(--text);
  font-size: 0.88rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}
input::placeholder { color: #4b5563; }
input.input-sm { max-width: 130px; padding: 6px 10px; font-size: 0.82rem; }

/* ── buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.3);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4); }
.btn:active { transform: translateY(0); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 2px 12px rgba(220, 38, 38, 0.3); }
.btn-ghost {
  background: rgba(51, 65, 85, 0.5);
  border: 1px solid var(--border);
  box-shadow: none;
  color: var(--text);
}
.btn-ghost:hover { background: rgba(51, 65, 85, 0.8); box-shadow: none; }
.btn-success { background: linear-gradient(135deg, #22c55e, #16a34a); box-shadow: 0 2px 12px rgba(22, 163, 74, 0.3); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* ── tags & badges ── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.tag.pass { background: var(--success-dim); color: var(--success); border: 1px solid rgba(74,222,128,.25); }
.tag.fail { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(248,113,113,.25); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
}
.badge.on { background: var(--success-dim); color: var(--success); }
.badge.off { background: rgba(100,116,139,.2); color: var(--muted); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── messages ── */
.msg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.88rem;
  border: 1px solid transparent;
  transition: opacity 0.35s ease, margin 0.35s ease, padding 0.35s ease, max-height 0.35s ease;
  overflow: hidden;
  max-height: 80px;
}
.msg.msg-hide {
  opacity: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  max-height: 0;
  border-color: transparent;
}
.msg.ok { background: var(--success-dim); color: var(--success); border-color: rgba(74,222,128,.2); }
.msg.err { background: var(--danger-dim); color: var(--danger); border-color: rgba(248,113,113,.2); }

/* ── quick actions ── */
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
}
.row-actions form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
td.actions-cell {
  width: 1%;
  white-space: nowrap;
  position: relative;
}
.fn-edit-details {
  display: inline-flex;
  flex-shrink: 0;
}
.fn-edit-details summary {
  list-style: none;
  cursor: pointer;
}
.fn-edit-details summary::-webkit-details-marker {
  display: none;
}
.fn-edit-details[open] form {
  position: absolute;
  z-index: 10;
  right: 0;
  top: 100%;
  margin-top: 6px;
  min-width: 320px;
  padding: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

/* ── pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.pagination-info { font-size: 0.85rem; color: var(--muted); }

/* ── filter bar ── */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.filter-bar .field { min-width: 220px; }

.col-detail {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  color: var(--muted);
}

.sn-record-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sn-record-card {
  padding: 0;
  overflow: hidden;
}

.sn-record-head {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(160px, 1fr) minmax(200px, 1fr);
  gap: 16px;
  align-items: center;
  padding: 18px 22px;
}

.sn-record-head-action .sn-record-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.record-detail-nav {
  margin-bottom: 14px;
}

.sn-record-detail-page .sn-record-head {
  border-bottom: none;
}

.sn-record-sn {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sn-record-meta {
  margin-top: 4px;
  font-size: 0.86rem;
  color: var(--muted);
}

.sn-record-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sn-stat {
  font-size: 0.82rem;
  color: var(--muted);
}

.sn-record-side {
  text-align: right;
  font-size: 0.82rem;
  color: var(--muted);
}

.sn-record-operator {
  margin-bottom: 0;
  color: var(--text);
}

.sn-fn-table .col-detail {
  max-width: none;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: visible;
  text-overflow: unset;
  min-width: 220px;
}

@media (max-width: 900px) {
  .sn-record-head {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .sn-record-side {
    text-align: left;
  }
}

/* ── login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow), 0 0 60px rgba(56, 189, 248, 0.06);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand .brand-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  margin: 0 auto 16px;
}
.login-brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.login-brand p { font-size: 0.85rem; color: var(--muted); }
.login-form .field { margin-bottom: 16px; }
.login-hint {
  margin-top: 20px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── welcome banner ── */
.welcome-banner {
  background: linear-gradient(135deg, rgba(14,165,233,.12), rgba(99,102,241,.1));
  border: 1px solid rgba(56,189,248,.18);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.welcome-banner h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; }
.welcome-banner p { font-size: 0.85rem; color: var(--muted); }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .sidebar-brand { border-bottom: none; padding: 14px 16px; }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0 8px 8px;
    flex: unset;
  }
  .sidebar-footer { border-top: none; padding: 0 8px 8px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .container { padding: 16px; }
  .page-header { padding: 16px 16px 0; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
}
