:root {
  color-scheme: light;
  --bg: #f4f6f9; --surface: #fff; --surface-subtle: #f8fafc; --surface-muted: #f1f5f9;
  --text: #172033; --text-strong: #0f172a; --muted: #64748b; --muted-2: #94a3b8;
  --line: #e2e8f0; --line-strong: #cbd5e1; --brand: #4f46e5; --brand-hover: #4338ca; --brand-soft: #eef2ff;
  --success: #059669; --success-soft: #ecfdf5; --warning: #b45309; --warning-soft: #fffbeb;
  --danger: #dc2626; --danger-soft: #fef2f2; --sidebar: #0f172a; --sidebar-muted: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04); --shadow-md: 0 12px 32px rgba(15, 23, 42, .08);
  --radius-sm: 8px; --radius: 12px; --radius-lg: 18px;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 0; color: var(--text-strong); font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.logo { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand); color: #fff; box-shadow: 0 6px 14px rgba(79, 70, 229, .22); }
.logo svg { width: 18px; height: 18px; }
.brand-copy { display: grid; gap: 1px; line-height: 1.15; }
.brand-copy small { color: var(--muted-2); font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.field { min-width: 0; }
.field label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 8px; color: #334155; font-size: 13px; font-weight: 650; }
.field-hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.input, .select { width: 100%; min-height: 42px; border: 1px solid var(--line-strong); border-radius: 10px; outline: none; background: var(--surface); color: var(--text-strong); padding: 10px 12px; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
textarea.input { resize: vertical; line-height: 1.6; }
.input::placeholder { color: #a1adbd; }
.input:hover, .select:hover { border-color: #a8b5c7; }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.input:disabled, .select:disabled { cursor: not-allowed; background: var(--surface-muted); color: var(--muted); }
.btn { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 8px 14px; color: var(--text); background: transparent; font-size: 13px; font-weight: 650; line-height: 1.2; transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .08s ease; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(79, 70, 229, .2); outline-offset: 2px; }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { color: #fff; background: var(--brand); border-color: var(--brand); box-shadow: 0 1px 2px rgba(79, 70, 229, .2); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-secondary { color: #334155; background: var(--surface); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface-subtle); border-color: #a8b5c7; }
.btn-ghost { color: var(--muted); background: transparent; border-color: transparent; }
.btn-ghost:hover { color: var(--text-strong); background: var(--surface-muted); }
.btn-danger { color: var(--danger); background: var(--surface); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger-soft); border-color: #fca5a5; }
.btn-sm { min-height: 32px; padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.full-button { width: 100%; margin-top: 16px; }
.form-row { display: flex; gap: 10px; }

.admin-layout { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px 16px; background: var(--sidebar); color: #fff; overflow-y: auto; }
.sidebar .brand { padding: 0 8px; color: #fff; }
.sidebar .logo { background: #fff; color: var(--sidebar); box-shadow: none; }
.sidebar .brand-copy small { color: #64748b; }
.sidebar-section-label { margin: 30px 10px 9px; color: #64748b; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.nav { display: grid; gap: 3px; }
.nav button { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 9px; padding: 0 11px; background: transparent; color: var(--sidebar-muted); text-align: left; font-size: 13px; font-weight: 550; transition: background .15s ease, color .15s ease; }
.nav button svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .82; }
.nav button:hover { background: rgba(255, 255, 255, .06); color: #e2e8f0; }
.nav button.active { background: rgba(99, 102, 241, .18); color: #fff; }
.nav button.active svg { color: #a5b4fc; opacity: 1; }
.sidebar-footer { margin-top: auto; padding-top: 24px; }
.system-state { display: flex; align-items: center; gap: 9px; margin: 0 8px 14px; color: var(--sidebar-muted); font-size: 11px; }
.system-state i { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 4px rgba(52, 211, 153, .1); }
.sidebar .btn-secondary { width: 100%; color: #cbd5e1; background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.1); }
.sidebar .btn-secondary:hover { color: #fff; background: rgba(255,255,255,.08); }
.admin-workspace { min-width: 0; }
.admin-topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 clamp(20px, 3.5vw, 48px); background: rgba(255, 255, 255, .92); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20; }
.admin-topbar-title { color: var(--muted); font-size: 12px; }
.admin-topbar-title strong { display: block; margin-top: 2px; color: var(--text-strong); font-size: 14px; }
.admin-topbar-actions { display: flex; align-items: center; gap: 10px; }
.admin-avatar { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid #c7d2fe; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 750; }
.mobile-menu { display: none; width: 36px; height: 36px; padding: 0; }
.main { width: 100%; max-width: 1560px; margin: 0 auto; padding: 32px clamp(20px, 3.5vw, 48px) 56px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 7px; color: var(--text-strong); font-size: 24px; line-height: 1.2; letter-spacing: -.025em; }
.page-head .muted { font-size: 13px; }
.page-head-actions { display: flex; align-items: center; gap: 10px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { position: relative; overflow: hidden; padding: 20px; }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stat small { color: var(--muted); font-size: 12px; font-weight: 550; }
.stat-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-muted); color: var(--muted); }
.stat-icon svg { width: 16px; height: 16px; }
.stat strong { display: block; margin-top: 16px; color: var(--text-strong); font-size: 28px; font-weight: 720; letter-spacing: -.035em; }
.stat-meta { margin-top: 7px; color: var(--muted-2); font-size: 11px; }
.panel { margin-top: 16px; overflow: hidden; }
.panel-header { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.panel-header h3 { margin: 0; color: var(--text-strong); font-size: 14px; }
.panel-header span { color: var(--muted); font-size: 12px; }
.panel-body { padding: 18px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.toolbar .left, .toolbar .right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .input { width: 220px; }
.toolbar .select { width: 140px; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; min-width: 820px; border-collapse: collapse; background: var(--surface); }
th, td { padding: 13px 16px; border-bottom: 1px solid #edf1f5; color: #334155; text-align: left; font-size: 12px; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-subtle); color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .02em; white-space: nowrap; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: 0; }
td strong { color: var(--text-strong); font-weight: 650; }
td small { font-size: 11px; }
.cell-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.empty-state { padding: 54px 24px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 14px; }
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-muted); color: #475569; font-size: 10px; font-weight: 650; line-height: 1; white-space: nowrap; }
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .72; }
.badge.success { border-color: #a7f3d0; background: var(--success-soft); color: #047857; }
.badge.warning { border-color: #fde68a; background: var(--warning-soft); color: var(--warning); }
.badge.danger { border-color: #fecaca; background: var(--danger-soft); color: var(--danger); }
.switch { position: relative; width: 36px; height: 20px; display: inline-block; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #cbd5e1; transition: .18s ease; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15,23,42,.25); transition: .18s ease; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 3px solid rgba(79,70,229,.2); outline-offset: 2px; }
.chart-shell { height: 260px; padding: 24px 18px 34px; display: flex; align-items: stretch; gap: 18px; }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; color: var(--muted-2); font-size: 10px; }
.chart { flex: 1; min-width: 0; display: flex; align-items: end; gap: clamp(8px, 2.4vw, 24px); border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(25% - 1px), #edf1f5 25%); }
.bar { flex: 1; min-width: 12px; max-width: 58px; margin: 0 auto; border-radius: 5px 5px 0 0; background: #818cf8; position: relative; transition: background .15s ease; }
.bar:hover { background: var(--brand); }
.bar span { position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 10px; }
.summary { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-subtle); margin: 16px 0; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary small { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.summary strong { color: var(--text-strong); font-size: 14px; }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(15, 23, 42, .48); backdrop-filter: blur(4px); }
.modal.hidden { display: none !important; }
.modal-box { width: min(560px, 100%); max-height: min(760px, calc(100vh - 40px)); overflow: auto; border: 1px solid rgba(255,255,255,.7); border-radius: 16px; background: var(--surface); box-shadow: 0 24px 80px rgba(15,23,42,.24); animation: modal-in .16s ease-out; }
.modal-close { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 8px; }
.modal-content { position: relative; padding: 24px; }
.modal-content h2 { margin: 0 42px 6px 0; color: var(--text-strong); font-size: 19px; letter-spacing: -.015em; }
.modal-subtitle { margin: 0 0 22px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 150; max-width: min(380px, calc(100vw - 32px)); padding: 12px 15px; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; background: #172033; color: #fff; box-shadow: var(--shadow-md); font-size: 12px; animation: toast-in .18s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 46%) 1fr; background: var(--surface); }
.login-aside { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: clamp(32px, 5vw, 72px); background: var(--sidebar); color: #fff; }
.login-aside::after { content: ''; position: absolute; right: -18%; bottom: -18%; width: 420px; height: 420px; border: 1px solid rgba(165,180,252,.14); border-radius: 50%; box-shadow: 0 0 0 70px rgba(165,180,252,.035), 0 0 0 140px rgba(165,180,252,.025); }
.login-aside .brand { color: #fff; position: relative; z-index: 1; }
.login-aside .logo { background: #fff; color: var(--sidebar); box-shadow: none; }
.login-aside-content { position: relative; z-index: 1; max-width: 480px; }
.login-kicker { margin-bottom: 18px; color: #a5b4fc; font-size: 11px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.login-aside h1 { margin: 0 0 18px; font-size: clamp(34px, 4vw, 54px); line-height: 1.08; letter-spacing: -.045em; }
.login-aside p { max-width: 430px; margin: 0; color: #94a3b8; font-size: 14px; line-height: 1.8; }
.login-aside-footer { position: relative; z-index: 1; color: #64748b; font-size: 11px; }
.login-main { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.login-card { width: min(390px, 100%); }
.login-card .mobile-brand { display: none; margin-bottom: 44px; }
.login-title { margin: 0 0 8px; color: var(--text-strong); font-size: 28px; letter-spacing: -.035em; }
.login-intro { margin: 0 0 30px; color: var(--muted); line-height: 1.65; }
.login-field { margin-top: 17px; }
.turnstile-field { min-height: 96px; }
.turnstile-widget { width: 100%; min-height: 65px; }
.turnstile-field small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
.login-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; color: var(--muted); font-size: 11px; }
.secure-note { display: inline-flex; align-items: center; gap: 6px; }
.secure-note svg { width: 13px; height: 13px; }
.form-error { min-height: 18px; margin: 12px 0 0; color: var(--danger); font-size: 12px; }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .admin-layout { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 236px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 24px 0 60px rgba(15,23,42,.24); }
  .admin-layout.sidebar-open .sidebar { transform: translateX(0); }
  .admin-layout.sidebar-open::after { content: ''; position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.38); }
  .mobile-menu { display: inline-flex; }
  .admin-topbar { padding: 0 20px; }
  .main { padding: 24px 20px 48px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-main { min-height: 100vh; }
  .login-card .mobile-brand { display: inline-flex; }
}
@media (max-width: 620px) {
  .stats { grid-template-columns: 1fr; }
  .page-head { align-items: stretch; flex-direction: column; gap: 16px; }
  .page-head-actions, .page-head-actions .btn, .page-head-actions .select { width: 100%; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar .left, .toolbar .right { width: 100%; }
  .toolbar .input, .toolbar .select, .toolbar .btn, .toolbar a { width: 100%; }
  .form-row, .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
  .summary-grid { grid-template-columns: 1fr; }
  .admin-topbar-title { display: none; }
  .login-main { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
