:root {
  --primary: #5B5BD6;
  --primary-dark: #4545B0;
  --primary-light: #7B7BE8;
  --surface: #F4F6FB;
  --card: #FFFFFF;
  --text: #1A1D2E;
  --text-muted: #6B7280;
  --border: #E5E8F0;
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --gold: #D97706;
  --sidebar-w: 240px;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(91, 91, 214, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--surface); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
code { background: #EEF0F8; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* ===== Login Page ===== */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.login-bg { position: fixed; inset: 0; background: linear-gradient(135deg, #3D3DA8 0%, #5B5BD6 40%, #7B8CFF 100%); z-index: 0; }
.login-bg::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 20% 80%, rgba(255,255,255,.08) 0%, transparent 50%), radial-gradient(circle at 80% 20%, rgba(255,255,255,.06) 0%, transparent 40%); }
.login-container { position: relative; z-index: 1; width: 100%; max-width: 440px; padding: 24px; }
.login-card { background: var(--card); border-radius: 20px; padding: 40px 36px; box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.login-brand { text-align: center; margin-bottom: 32px; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 16px; background: linear-gradient(135deg, var(--primary), var(--primary-light)); border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; color: #fff; box-shadow: 0 8px 24px rgba(91,91,214,.35); }
.login-brand h1 { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: 2px; }
.login-brand p { color: var(--text-muted); font-size: 14px; margin-top: 6px; }
.login-form .form-group { margin-bottom: 18px; }
.login-form label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.login-form input { width: 100%; padding: 13px 16px; border: 1.5px solid var(--border); border-radius: 12px; font-size: 15px; transition: border-color .2s, box-shadow .2s; outline: none; }
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,91,214,.12); }
.login-hint { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 20px; }
.login-footer { text-align: center; color: rgba(255,255,255,.7); font-size: 13px; margin-top: 24px; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 18px; border: none; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; transition: all .2s; gap: 6px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(91,91,214,.3); }
.btn-block { width: 100%; padding: 14px; font-size: 16px; border-radius: 12px; }
.btn-lg { padding: 14px 32px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-ghost { background: #F0F1F8; color: var(--text); }
.btn-ghost:hover { background: #E5E7F0; }

/* ===== Alerts ===== */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #FEF2F2; border: 1px solid #FECACA; color: #DC2626; }
.alert-success { background: #ECFDF5; border: 1px solid #A7F3D0; color: #059669; }

/* ===== Admin Shell ===== */
.admin-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: linear-gradient(180deg, #2D2D7A 0%, #1E1E5C 100%); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
.brand { display: flex; align-items: center; gap: 12px; padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-icon { width: 42px; height: 42px; background: linear-gradient(135deg, var(--primary-light), var(--primary)); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; }
.brand-title { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,.5); margin-top: 2px; }
.nav-menu { flex: 1; padding: 16px 12px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 10px; color: rgba(255,255,255,.7); margin-bottom: 4px; transition: all .2s; font-size: 14px; font-weight: 500; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(91,91,214,.4); }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.admin-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.admin-avatar { width: 36px; height: 36px; background: rgba(255,255,255,.15); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.admin-name { font-size: 14px; font-weight: 600; }
.admin-role { font-size: 11px; color: rgba(255,255,255,.45); }
.logout-btn { display: block; text-align: center; padding: 10px; border-radius: 8px; background: rgba(255,255,255,.08); color: rgba(255,255,255,.7); font-size: 13px; transition: all .2s; }
.logout-btn:hover { background: rgba(239,68,68,.2); color: #FCA5A5; }

/* Content */
.content-area { flex: 1; margin-left: var(--sidebar-w); padding: 28px 32px; min-height: 100vh; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
.page-title { font-size: 24px; font-weight: 800; color: var(--text); }
.page-desc { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.page-meta { font-size: 13px; color: var(--text-muted); background: var(--card); padding: 8px 14px; border-radius: 20px; border: 1px solid var(--border); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 16px; border: 1px solid var(--border); box-shadow: var(--shadow); transition: transform .2s; }
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.stat-blue { background: #EEF2FF; }
.stat-gold { background: #FEF3C7; }
.stat-red { background: #FEE2E2; }
.stat-green { background: #D1FAE5; }
.stat-num { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-muted); }

/* Panels */
.panel-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.panel-card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.panel-wide { grid-column: 1 / -1; }
.panel-head { padding: 18px 22px; border-bottom: 1px solid var(--border); }
.panel-head h3 { font-size: 16px; font-weight: 700; }
.panel-head-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.panel-body { padding: 22px; }
.count-badge { background: var(--primary); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 10px; margin-left: 8px; font-weight: 600; }

/* Guide */
.guide-list { display: flex; flex-direction: column; gap: 14px; }
.guide-item { display: flex; align-items: flex-start; gap: 12px; font-size: 14px; color: var(--text-muted); }
.guide-item.guide-warn { background: #FFF8E6; border: 1px solid #F5D78E; border-radius: 10px; padding: 12px; color: #8A6D1D; }
.guide-item.guide-warn .guide-step { background: #E6A817; }
.guide-step { width: 26px; height: 26px; background: var(--primary); color: #fff; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.quick-links { display: flex; flex-direction: column; gap: 10px; }
.quick-link { display: block; padding: 14px 16px; background: var(--surface); border-radius: 10px; font-weight: 600; color: var(--primary); transition: all .2s; }
.quick-link:hover { background: #EEF0FF; transform: translateX(4px); }

/* Table */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { background: #F8F9FD; padding: 12px 16px; text-align: left; font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 14px 16px; border-bottom: 1px solid #F0F1F8; vertical-align: middle; }
.data-table tr:hover td { background: #FAFBFF; }
.col-actions { min-width: 320px; }
.empty-row { text-align: center; color: var(--text-muted); padding: 40px !important; }
.id-cell { color: var(--text-muted); font-family: monospace; }
.text-muted { color: var(--text-muted); font-size: 13px; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-green { background: #D1FAE5; color: #059669; }
.badge-red { background: #FEE2E2; color: #DC2626; }
.badge-gold { background: #FEF3C7; color: #B45309; }

/* Actions */
.search-bar { display: flex; gap: 8px; }
.search-bar input { padding: 8px 14px; border: 1.5px solid var(--border); border-radius: 10px; font-size: 14px; width: 220px; outline: none; }
.search-bar input:focus { border-color: var(--primary); }
.action-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.action-form { display: inline-flex; }
.action-inline { display: inline-flex; gap: 4px; align-items: center; }
.input-mini { width: 72px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }

/* Settings Form */
.settings-grid { display: flex; flex-direction: column; gap: 0; }
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 10px; font-size: 14px; outline: none; transition: border-color .2s; font-family: inherit; }
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,91,214,.1); }
.form-group textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.form-hint-warn { color: #8A6D1D; background: #FFF8E6; border-radius: 6px; padding: 8px 10px; line-height: 1.5; }
.req { color: var(--danger); }
.form-actions { margin-top: 8px; padding-bottom: 32px; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar .brand > div:last-child, .nav-item span:last-child, .admin-user > div, .admin-role, .brand-sub { display: none; }
  .brand { justify-content: center; padding: 16px 8px; }
  .nav-item { justify-content: center; padding: 12px; }
  .content-area { margin-left: 64px; padding: 16px; }
}
