:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --secondary: #7c3aed;
  --success: #16a34a;
  --success-soft: #ecfdf3;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --info: #0891b2;
  --info-soft: #ecfeff;
  --sidebar: #0f172a;
  --sidebar-muted: #94a3b8;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #172033;
  --text-2: #475569;
  --muted: #64748b;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08);
  --shadow: 0 8px 24px rgba(15, 23, 42, .08);
  --shadow-lg: 0 22px 50px rgba(15, 23, 42, .18);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-width: 252px;
}

* { box-sizing: border-box; }

html { min-height: 100%; scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.dark {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #172033;
  --border: #273449;
  --text: #e5edf8;
  --text-2: #b8c4d7;
  --muted: #91a0b7;
  --primary-soft: rgba(37, 99, 235, .17);
  --success-soft: rgba(22, 163, 74, .16);
  --warning-soft: rgba(217, 119, 6, .16);
  --danger-soft: rgba(220, 38, 38, .16);
  --info-soft: rgba(8, 145, 178, .16);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .28);
  --shadow: 0 8px 24px rgba(0, 0, 0, .24);
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--primary); }

.noscript {
  padding: 18px;
  color: #991b1b;
  background: #fee2e2;
  text-align: center;
  font-weight: 700;
}

.boot-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  background: radial-gradient(circle at 50% 20%, #dbeafe 0, var(--bg) 48%);
}

.boot-logo { color: #0f172a; font-size: 34px; font-weight: 900; letter-spacing: -1.5px; }
.boot-logo span { color: var(--primary); }
.boot-spinner { width: 34px; height: 34px; border: 3px solid #dbeafe; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(480px, 1.25fr);
  background: var(--surface);
}

.login-form-side { display: flex; align-items: center; justify-content: center; padding: 44px; }
.login-box { width: min(420px, 100%); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 42px; }
.login-brand .language-select { margin-left: auto; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #2563eb, #7c3aed); border-radius: 14px; box-shadow: 0 10px 24px rgba(37, 99, 235, .28); font-size: 20px; font-weight: 900; }
.brand-copy strong { display: block; color: var(--text); font-size: 24px; line-height: 1.1; }
.brand-copy span { color: var(--muted); font-size: 12px; letter-spacing: .7px; }
.login-box h1 { margin: 0 0 8px; font-size: 28px; }
.login-subtitle { margin: 0 0 28px; color: var(--muted); }
.login-field { margin-bottom: 17px; }
.login-field label { display: block; margin-bottom: 7px; color: var(--text-2); font-weight: 650; }
.input-wrap { position: relative; }
.input-wrap .input-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 800; }
.input-wrap input { padding-left: 43px; }
.password-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 8px; }
.captcha-row { display: grid; grid-template-columns: 1fr 112px; gap: 10px; }
.captcha-box { display: grid; place-items: center; border: 1px dashed #93c5fd; color: #1d4ed8; background: #eff6ff; border-radius: var(--radius-sm); font-size: 18px; font-weight: 900; letter-spacing: 2px; cursor: pointer; user-select: none; }
.login-options { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 20px; color: var(--muted); }
.checkline { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }
.checkline input { accent-color: var(--primary); }
.login-submit { width: 100%; height: 46px; }
.login-hint { margin-top: 22px; padding: 12px 14px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }
.login-hint code { color: var(--primary); font-weight: 700; }
.login-error { min-height: 22px; margin: 7px 0; color: var(--danger); font-size: 13px; }
.login-visual {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 9%;
  color: #fff;
  background: linear-gradient(145deg, #0f172a 0%, #172554 45%, #312e81 100%);
}
.login-visual::before, .login-visual::after { content: ""; position: absolute; border-radius: 50%; filter: blur(2px); }
.login-visual::before { width: 420px; height: 420px; right: -120px; top: -130px; background: rgba(59, 130, 246, .22); }
.login-visual::after { width: 300px; height: 300px; left: -80px; bottom: -100px; background: rgba(124, 58, 237, .25); }
.visual-content { position: relative; z-index: 1; max-width: 590px; }
.visual-tag { display: inline-flex; padding: 7px 12px; margin-bottom: 20px; border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.08); border-radius: 999px; font-size: 12px; }
.visual-content h2 { margin: 0 0 14px; font-size: clamp(30px, 4vw, 48px); line-height: 1.18; }
.visual-content > p { margin: 0; color: #cbd5e1; font-size: 16px; }
.visual-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 48px; }
.visual-stat { padding: 17px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.13); border-radius: 14px; backdrop-filter: blur(10px); }
.visual-stat strong { display: block; font-size: 22px; }
.visual-stat span { color: #cbd5e1; font-size: 12px; }

.app-layout { min-height: 100vh; display: flex; }
.sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  color: #e2e8f0;
  background: linear-gradient(180deg, #0f172a, #111c31 72%, #0b1220);
  transition: transform .25s ease;
}
.sidebar-brand { height: 72px; display: flex; align-items: center; gap: 11px; padding: 0 20px; border-bottom: 1px solid rgba(148, 163, 184, .13); }
.sidebar-brand .brand-mark { width: 40px; height: 40px; border-radius: 12px; font-size: 17px; box-shadow: none; }
.sidebar-brand strong { display: block; color: #fff; font-size: 19px; }
.sidebar-brand small { display: block; color: #7f91aa; font-size: 10px; letter-spacing: .8px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 15px 12px; scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.nav-group { margin-bottom: 17px; }
.nav-label { padding: 0 11px 7px; color: #64748b; font-size: 10px; font-weight: 800; letter-spacing: 1.2px; }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 9px 11px; margin: 3px 0; color: #aebdd0; border-radius: 9px; text-decoration: none; transition: .18s; }
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, .055); }
.nav-link.active { color: #fff; background: linear-gradient(90deg, rgba(37, 99, 235, .95), rgba(79, 70, 229, .88)); box-shadow: 0 8px 18px rgba(37, 99, 235, .24); }
.nav-icon { width: 24px; height: 24px; display: grid; place-items: center; flex: 0 0 24px; border-radius: 7px; background: rgba(148,163,184,.1); font-size: 11px; font-weight: 900; }
.nav-link.active .nav-icon { background: rgba(255,255,255,.14); }
.nav-text { flex: 1; }
.nav-badge { min-width: 21px; padding: 2px 6px; color: #fff; background: var(--danger); border-radius: 999px; text-align: center; font-size: 10px; font-weight: 800; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(148, 163, 184, .13); color: #64748b; font-size: 11px; }
.sidebar-foot .server-state { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; color: #94a3b8; }
.state-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(22,163,74,.12); }

.main-shell { min-width: 0; flex: 1; margin-left: var(--sidebar-width); }
.topbar { position: sticky; z-index: 30; top: 0; height: 72px; display: flex; align-items: center; gap: 16px; padding: 0 26px; background: color-mix(in srgb, var(--surface) 92%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(14px); }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.topbar-title small { color: var(--muted); font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.language-select { min-width: 118px; height: 38px; padding: 0 30px 0 10px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; outline: none; cursor: pointer; font-size: 12px; font-weight: 650; }
.language-select:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 1px solid var(--border); color: var(--text-2); background: var(--surface); border-radius: 10px; cursor: pointer; transition: .18s; }
.icon-btn:hover { color: var(--primary); border-color: #bfdbfe; background: var(--primary-soft); }
.menu-button { display: none; }
.sync-state { display: flex; align-items: center; gap: 7px; padding: 7px 10px; color: var(--muted); background: var(--surface-2); border-radius: 9px; font-size: 11px; }
.sync-state .state-dot { width: 6px; height: 6px; }
.sync-state.syncing .state-dot { background: var(--warning); animation: pulse 1s infinite; }
.sync-state.error .state-dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }
.user-menu { display: flex; align-items: center; gap: 10px; padding-left: 8px; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #2563eb, #7c3aed); border-radius: 11px; font-weight: 800; }
.user-meta strong { display: block; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.user-meta span { color: var(--muted); font-size: 10px; }

.page-content { padding: 25px 26px 42px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 21px; }
.page-heading h1 { margin: 0 0 5px; font-size: 23px; line-height: 1.25; }
.page-heading p { margin: 0; color: var(--muted); }
.page-heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }

.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: 18px; border: 1px solid #bfdbfe; color: #1e40af; background: var(--primary-soft); border-radius: 11px; }
.notice.warning { color: #92400e; border-color: #fde68a; background: var(--warning-soft); }
.notice.danger { color: #991b1b; border-color: #fecaca; background: var(--danger-soft); }
.notice-icon { flex: 0 0 auto; font-weight: 900; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi-card { position: relative; overflow: hidden; min-height: 132px; padding: 19px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.kpi-icon { width: 38px; height: 38px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 11px; font-weight: 900; }
.kpi-icon.green { color: var(--success); background: var(--success-soft); }
.kpi-icon.orange { color: var(--warning); background: var(--warning-soft); }
.kpi-icon.purple { color: var(--secondary); background: rgba(124,58,237,.11); }
.kpi-value { margin: 13px 0 5px; font-size: clamp(21px, 2vw, 28px); font-weight: 850; letter-spacing: -.5px; }
.kpi-foot { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.trend-up { color: var(--success); font-weight: 700; }
.trend-down { color: var(--danger); font-weight: 700; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: minmax(0, 1.55fr) minmax(300px, .8fr); }
.grid.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel + .panel { margin-top: 18px; }
.panel-head { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 17px; border-bottom: 1px solid var(--border); }
.panel-title { min-width: 0; }
.panel-title h2 { margin: 0; font-size: 15px; }
.panel-title p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.panel-actions { display: flex; align-items: center; gap: 7px; }
.panel-body { padding: 17px; }
.panel-body.flush { padding: 0; }

.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-bottom: 18px; overflow: hidden; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); }
.strip-item { padding: 16px 18px; background: var(--surface); }
.strip-item span { display: block; color: var(--muted); font-size: 11px; }
.strip-item strong { display: block; margin-top: 4px; font-size: 19px; }

.btn { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 13px; border: 1px solid transparent; border-radius: 9px; background: var(--surface); cursor: pointer; text-decoration: none; font-weight: 650; font-size: 12px; transition: .18s; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--primary), #4f46e5); border-color: var(--primary); box-shadow: 0 5px 12px rgba(37,99,235,.16); }
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), #4338ca); }
.btn-secondary { color: var(--text-2); border-color: var(--border); background: var(--surface); }
.btn-secondary:hover { color: var(--primary); border-color: #93c5fd; background: var(--primary-soft); }
.btn-success { color: #fff; border-color: var(--success); background: var(--success); }
.btn-warning { color: #fff; border-color: var(--warning); background: var(--warning); }
.btn-danger { color: #fff; border-color: var(--danger); background: var(--danger); }
.btn-soft-danger { color: var(--danger); background: var(--danger-soft); border-color: #fecaca; }
.btn-soft-success { color: var(--success); background: var(--success-soft); border-color: #bbf7d0; }
.btn-link { min-height: auto; padding: 4px 6px; color: var(--primary); border: 0; background: transparent; }
.btn-sm { min-height: 30px; padding: 5px 9px; font-size: 11px; border-radius: 7px; }
.btn-lg { min-height: 44px; padding: 10px 18px; font-size: 14px; }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 5px; }

.toolbar { display: flex; align-items: flex-end; gap: 11px; padding: 15px 17px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.filter-grid { display: grid; grid-template-columns: minmax(180px, 1.3fr) repeat(3, minmax(130px, .8fr)); gap: 10px; flex: 1; }
.toolbar-actions { display: flex; gap: 7px; }
.field { min-width: 0; }
.field > label { display: block; margin: 0 0 6px; color: var(--text-2); font-size: 11px; font-weight: 700; }
.required::after { content: " *"; color: var(--danger); }
.form-control { width: 100%; min-height: 38px; padding: 8px 11px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; outline: none; transition: border .17s, box-shadow .17s; }
.form-control:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.form-control::placeholder { color: #94a3b8; }
textarea.form-control { min-height: 82px; resize: vertical; }
.input-help { margin-top: 5px; color: var(--muted); font-size: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field.full { grid-column: 1 / -1; }
.form-section { padding: 2px 0 17px; margin-bottom: 17px; border-bottom: 1px solid var(--border); }
.form-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.form-section h3 { margin: 0 0 13px; font-size: 14px; }
.switch-line { min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.switch { position: relative; width: 42px; height: 23px; display: inline-block; flex: 0 0 42px; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; cursor: pointer; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::after { transform: translateX(19px); }

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.data-table th { padding: 11px 13px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); text-align: left; font-size: 10px; font-weight: 800; letter-spacing: .2px; white-space: nowrap; }
.data-table td { padding: 12px 13px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: color-mix(in srgb, var(--primary-soft) 48%, transparent); }
.data-table .strong { color: var(--text); font-weight: 750; }
.table-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.money { color: var(--text); font-weight: 760; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money.positive { color: var(--success); }
.money.negative { color: var(--danger); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.row-check { width: 15px; height: 15px; accent-color: var(--primary); }
.empty-state { padding: 42px 20px; color: var(--muted); text-align: center; }
.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 10px; color: #94a3b8; background: var(--surface-2); border-radius: 14px; font-size: 20px; }
.empty-state strong { display: block; color: var(--text-2); margin-bottom: 3px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 750; white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .75; }
.badge-success { color: #15803d; background: var(--success-soft); }
.badge-warning { color: #b45309; background: var(--warning-soft); }
.badge-danger { color: #b91c1c; background: var(--danger-soft); }
.badge-info { color: #0e7490; background: var(--info-soft); }
.badge-neutral { color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }
.badge-purple { color: #6d28d9; background: rgba(124,58,237,.11); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 17px; border-top: 1px solid var(--border); }
.pagination-info { color: var(--muted); font-size: 11px; }
.page-buttons { display: flex; gap: 5px; }
.page-btn { min-width: 31px; height: 31px; padding: 0 7px; border: 1px solid var(--border); color: var(--text-2); background: var(--surface); border-radius: 7px; cursor: pointer; }
.page-btn.active { color: #fff; border-color: var(--primary); background: var(--primary); }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }

.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-item { display: flex; align-items: center; gap: 10px; padding: 13px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; text-decoration: none; transition: .18s; }
.quick-item:hover { color: var(--primary); border-color: #93c5fd; transform: translateY(-1px); }
.quick-icon { width: 34px; height: 34px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 9px; font-weight: 900; }
.quick-item strong { display: block; font-size: 12px; }
.quick-item span { color: var(--muted); font-size: 10px; }

.bar-chart { height: 230px; display: flex; align-items: flex-end; gap: 12px; padding: 20px 6px 4px; }
.bar-column { min-width: 0; height: 100%; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; }
.bar-value { color: var(--muted); font-size: 9px; }
.bar-track { width: min(34px, 75%); height: 100%; display: flex; align-items: flex-end; background: var(--surface-2); border-radius: 7px 7px 3px 3px; overflow: hidden; }
.bar-fill { width: 100%; min-height: 3px; background: linear-gradient(180deg, #60a5fa, #4f46e5); border-radius: 7px 7px 3px 3px; transition: height .5s; }
.bar-label { color: var(--muted); font-size: 10px; white-space: nowrap; }
.progress-row { margin: 13px 0; }
.progress-meta { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; color: var(--text-2); font-size: 11px; }
.progress-track { height: 7px; overflow: hidden; background: var(--surface-2); border-radius: 999px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #2563eb, #7c3aed); border-radius: 999px; }

.channel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.channel-card { padding: 17px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.channel-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.channel-logo { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 42px; color: #fff; background: linear-gradient(135deg, #2563eb, #7c3aed); border-radius: 12px; font-size: 11px; font-weight: 900; }
.channel-name { min-width: 0; flex: 1; }
.channel-name strong { display: block; color: var(--text); }
.channel-name span { color: var(--muted); font-size: 10px; }
.channel-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 15px 0; }
.channel-metric { padding: 9px; background: var(--surface-2); border-radius: 9px; }
.channel-metric span { display: block; color: var(--muted); font-size: 9px; }
.channel-metric strong { font-size: 12px; }
.channel-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 13px; border-top: 1px solid var(--border); }

.tabs { display: flex; gap: 4px; padding: 5px; margin-bottom: 18px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tab-btn { padding: 8px 13px; border: 0; color: var(--muted); background: transparent; border-radius: 8px; cursor: pointer; white-space: nowrap; font-weight: 700; font-size: 12px; }
.tab-btn.active { color: var(--primary); background: var(--surface); box-shadow: var(--shadow-sm); }
.api-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); gap: 18px; }
.endpoint { display: flex; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 15px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.method { padding: 3px 7px; color: #fff; background: var(--success); border-radius: 5px; font-size: 9px; font-weight: 900; }
.endpoint code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-box { position: relative; min-height: 130px; padding: 14px; color: #dbeafe; background: #0b1220; border: 1px solid #1e293b; border-radius: 10px; overflow: auto; white-space: pre-wrap; word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; line-height: 1.65; }
.code-box .copy-code { position: absolute; right: 8px; top: 8px; color: #cbd5e1; background: #1e293b; border: 0; border-radius: 6px; padding: 5px 8px; cursor: pointer; font-size: 10px; }
.signature-source { margin-top: 10px; padding: 10px; color: var(--warning); background: var(--warning-soft); border: 1px dashed #fbbf24; border-radius: 8px; word-break: break-all; font-family: ui-monospace, monospace; font-size: 10px; }
.docs-table { width: 100%; border-collapse: collapse; }
.docs-table th, .docs-table td { padding: 9px 10px; border: 1px solid var(--border); text-align: left; vertical-align: top; font-size: 11px; }
.docs-table th { color: var(--muted); background: var(--surface-2); }
.docs-note { padding: 12px; margin: 12px 0; color: var(--text-2); background: var(--surface-2); border-left: 3px solid var(--primary); border-radius: 5px 9px 9px 5px; }
.doc-links { display: flex; flex-wrap: wrap; gap: 8px; }

.settings-nav { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 17px; }
.settings-section { max-width: 940px; }
.danger-zone { border-color: #fecaca; }
.danger-zone .panel-head { background: var(--danger-soft); }

.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; background: var(--border); border: 1px solid var(--border); border-radius: 10px; }
.detail-item { padding: 11px 13px; background: var(--surface); }
.detail-item span { display: block; color: var(--muted); font-size: 10px; }
.detail-item strong, .detail-item code { display: block; margin-top: 3px; color: var(--text); word-break: break-word; }
.secret-line { display: flex; align-items: center; gap: 7px; }
.secret-value { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(2, 6, 23, .58); backdrop-filter: blur(3px); animation: fadeIn .16s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { width: min(680px, 100%); max-height: min(88vh, 860px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); animation: modalIn .2s ease-out; }
.modal.modal-lg { width: min(880px, 100%); }
.modal.modal-sm { width: min(440px, 100%); }
@keyframes modalIn { from { transform: translateY(12px) scale(.985); opacity: .7; } }
.modal-head { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-close { width: 32px; height: 32px; border: 0; color: var(--muted); background: var(--surface-2); border-radius: 8px; cursor: pointer; }
.modal-body { overflow-y: auto; padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.confirm-copy { color: var(--text-2); }
.confirm-copy strong { color: var(--text); }

.toast-stack { position: fixed; z-index: 130; top: 82px; right: 18px; display: grid; gap: 9px; width: min(360px, calc(100vw - 36px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 13px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 10px; box-shadow: var(--shadow-lg); animation: toastIn .2s ease-out; }
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error { border-left-color: var(--danger); }
.toast strong { display: block; color: var(--text); font-size: 12px; }
.toast span { font-size: 11px; }
@keyframes toastIn { from { transform: translateX(18px); opacity: 0; } }
.sidebar-overlay { display: none; }

.hide { display: none !important; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-right { text-align: right !important; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: 10px !important; }
.mt-3 { margin-top: 17px !important; }
.mb-0 { margin-bottom: 0 !important; }
.w-full { width: 100%; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .api-layout { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { justify-content: flex-end; }
}

@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-form-side { min-height: 100vh; padding: 28px; }
  .sidebar { transform: translateX(-102%); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-overlay { position: fixed; z-index: 35; inset: 0; display: none; background: rgba(2, 6, 23, .52); }
  body.sidebar-open .sidebar-overlay { display: block; }
  .main-shell { margin-left: 0; }
  .menu-button { display: inline-grid; }
  .sync-state { display: none; }
  .topbar { padding: 0 17px; }
  .page-content { padding: 20px 17px 34px; }
  .grid.equal, .grid.three, .channel-grid { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  body { font-size: 13px; }
  .login-form-side { padding: 22px 18px; }
  .login-brand { margin-bottom: 30px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading-actions { justify-content: flex-start; }
  .page-heading-actions .btn { flex: 1; }
  .kpi-grid { grid-template-columns: 1fr; gap: 11px; }
  .kpi-card { min-height: 112px; }
  .stat-strip { grid-template-columns: 1fr; }
  .filter-grid, .form-grid, .form-grid.three, .detail-list { grid-template-columns: 1fr; }
  .toolbar-actions { display: grid; grid-template-columns: repeat(2, 1fr); }
  .toolbar-actions .btn { width: 100%; }
  .quick-grid { grid-template-columns: 1fr; }
  .user-meta { display: none; }
  .top-actions .theme-button { display: none; }
  .top-actions .language-select { min-width: 92px; max-width: 105px; }
  .topbar { height: 62px; padding: 0 12px; gap: 9px; }
  .topbar-title small { display: none; }
  .page-content { padding: 15px 12px 28px; }
  .panel-head { align-items: flex-start; }
  .panel-actions { flex-wrap: wrap; justify-content: flex-end; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .bar-chart { gap: 5px; }
  .bar-value { display: none; }
  .channel-metrics { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.modal-lg, .modal.modal-sm { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-foot { border-radius: 0; }
  .toast-stack { top: 70px; right: 10px; width: calc(100vw - 20px); }
}

@media print {
  .sidebar, .topbar, .page-heading-actions, .toolbar, .panel-actions, .pagination, .toast-stack { display: none !important; }
  .main-shell { margin: 0; }
  .page-content { padding: 0; }
  body { background: #fff; }
  .panel { box-shadow: none; break-inside: avoid; }
}
