:root {
  --c-bg: #f5f7fa;
  --c-panel: #ffffff;
  --c-text: #1a2233;
  --c-text-soft: #5b6678;
  --c-text-mute: #8a94a6;
  --c-border: #e6e9ef;
  --c-primary: #4f8df7;
  --c-primary-dark: #2f6fe0;
  --c-success: #18a058;
  --c-warn: #f59e0b;
  --c-danger: #ef4444;
  --c-sidebar: #0b1f3a;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(11,31,58,0.06), 0 1px 2px rgba(11,31,58,0.04);
  --shadow-md: 0 4px 12px rgba(11,31,58,0.08);
  --font: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--c-text); background: var(--c-bg); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
ul { list-style: none; }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at top, #1a3a6e, #0b1f3a); padding: 20px; }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); width: 380px; padding: 36px 32px; }
.login-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 22px; justify-content: center; margin-bottom: 6px; }
.login-brand .mk { width: 30px; height: 30px; border-radius: 7px; background: linear-gradient(135deg, var(--c-primary), #7c5cff); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 14px; }
.login-sub { text-align: center; color: var(--c-text-mute); font-size: 13px; margin-bottom: 28px; }
.login-card h2 { font-size: 18px; margin-bottom: 20px; text-align: center; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--c-text-soft); margin-bottom: 6px; }
.field input { width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--c-border); border-radius: 6px; font-size: 14px; transition: border .15s; }
.field input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(79,141,247,0.12); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 18px; border-radius: 6px; font-size: 14px; font-weight: 600; transition: all .15s; cursor: pointer; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-ghost { background: transparent; color: var(--c-text-soft); border: 1px solid var(--c-border); }
.btn-ghost:hover { color: var(--c-text); border-color: #ccd3e0; }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.login-error { background: #fef2f2; color: var(--c-danger); padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; display: none; }
.login-tip { margin-top: 20px; padding: 12px 14px; background: #f0f5ff; border-radius: 6px; font-size: 12px; color: var(--c-text-soft); line-height: 1.7; }
.login-tip code { background: #fff; padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono); color: var(--c-primary-dark); }

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--c-sidebar); color: #a9b4c7; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 18px 20px; color: #fff; font-weight: 700; font-size: 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand .mk { width: 26px; height: 26px; border-radius: 6px; background: linear-gradient(135deg, var(--c-primary), #7c5cff); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 12px; }
.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: #a9b4c7; font-size: 13.5px; transition: all .15s; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-nav a.active { background: rgba(79,141,247,0.15); color: #fff; border-left: 3px solid var(--c-primary); padding-left: 17px; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; color: #6b7689; }
.sidebar-foot .email { color: #a9b4c7; margin-bottom: 8px; word-break: break-all; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--c-border); display: flex; align-items: center; padding: 0 24px; gap: 16px; }
.topbar h1 { font-size: 17px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.content { flex: 1; padding: 24px; overflow: auto; }

/* ===== Cards / Grid ===== */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.card { background: var(--c-panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.stat-card .label { font-size: 12.5px; color: var(--c-text-mute); margin-bottom: 8px; }
.stat-card .value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.stat-card .delta { font-size: 12px; color: var(--c-success); margin-top: 4px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--c-border); }
th { background: #fafbfc; font-weight: 600; color: var(--c-text-soft); font-size: 12.5px; white-space: nowrap; }
td { color: var(--c-text); }
tr:hover td { background: #f9fafb; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

/* ===== Badge ===== */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.green { background: #e6f7ee; color: var(--c-success); }
.badge.yellow { background: #fef4e2; color: var(--c-warn); }
.badge.red { background: #fee2e2; color: var(--c-danger); }
.badge.gray { background: #f0f2f5; color: var(--c-text-mute); }
.badge.blue { background: #e8f0ff; color: var(--c-primary-dark); }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--c-border); margin-bottom: 20px; }
.tabs button { padding: 10px 18px; font-size: 13.5px; font-weight: 600; color: var(--c-text-mute); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ===== Form ===== */
.form-row { display: flex; gap: 12px; margin-bottom: 14px; }
.form-row > * { flex: 1; }
.form-row label { display: block; font-size: 12.5px; font-weight: 600; color: var(--c-text-soft); margin-bottom: 6px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--c-border); border-radius: 6px; font-size: 13.5px; }
.form-row textarea { height: auto; padding: 8px 12px; resize: vertical; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: var(--c-primary); }

/* ===== Toast ===== */
.toast { position: fixed; top: 20px; right: 20px; z-index: 9999; padding: 12px 20px; border-radius: 8px; color: #fff; font-size: 13.5px; box-shadow: var(--shadow-md); opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }
.toast.ok { background: var(--c-success); }
.toast.err { background: var(--c-danger); }

/* ===== Chart (simple bar) ===== */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 180px; padding: 10px 0; }
.chart .bar { flex: 1; background: linear-gradient(180deg, var(--c-primary), #7aa8f5); border-radius: 3px 3px 0 0; position: relative; min-height: 2px; transition: opacity .15s; }
.chart .bar:hover { opacity: 0.8; }
.chart .bar .v { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--c-text-mute); white-space: nowrap; }
.chart-x { display: flex; gap: 4px; font-size: 10px; color: var(--c-text-mute); }
.chart-x span { flex: 1; text-align: center; }

.empty { text-align: center; padding: 40px; color: var(--c-text-mute); font-size: 13.5px; }
.mt-16 { margin-top: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar-brand span:not(.mk), .sidebar-nav a span:not(.ic), .sidebar-foot { display: none; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.topbar-user { font-size: 13px; color: var(--c-text-soft); margin-right: 12px; }
.login-back { display: block; text-align: center; margin-top: 14px; font-size: 13px; color: var(--c-text-mute); text-decoration: none; }
.login-back:hover { color: var(--c-accent); }
.nav-user { font-size: 13px; color: rgba(255,255,255,0.85); margin-right: 8px; }