:root {
  --bg: #0d0d1a; --bg2: #13132a; --bg3: #1a1a35; --bg4: #202040;
  --border: rgba(255,255,255,0.07); --border2: rgba(255,255,255,0.12);
  --text: #e8e8f0; --text2: #9494b0; --text3: #5a5a78;
  --accent: #6C63FF; --accent2: #8B85FF; --accent-dim: rgba(108,99,255,0.15);
  --blue: #3B82F6; --amber: #F59E0B; --green: #10B981; --red: #EF4444; --teal: #14B8A6;
  --font-h: 'Syne', sans-serif; --font-b: 'DM Sans', sans-serif;
  --r: 12px; --rs: 8px; --rl: 16px; --sw: 240px; --th: 58px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; } body { font-family: var(--font-b); background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; } button { cursor: pointer; font-family: var(--font-b); } input, select, textarea { font-family: var(--font-b); }
::-webkit-scrollbar { width: 4px; height: 4px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 4px; }

/* ── LOGIN ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; overflow: hidden; position: relative; }
.login-bg { position: fixed; inset: 0; z-index: 0; }
.bg-orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .35; animation: drift 12s ease-in-out infinite; }
.orb1 { width: 500px; height: 500px; background: radial-gradient(circle, #6C63FF 0%, transparent 70%); top: -150px; left: -100px; }
.orb2 { width: 400px; height: 400px; background: radial-gradient(circle, #3B82F6 0%, transparent 70%); bottom: -100px; right: -50px; animation-delay: -6s; }
@keyframes drift { 0%,100%{transform:translate(0,0)} 50%{transform:translate(30px,-20px)} }
.bg-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px); background-size: 40px 40px; }
.login-wrap { position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font-family: var(--font-h); font-size: 22px; font-weight: 700; }
.brand-tag { font-size: 12px; color: var(--text2); }
.login-card { width: 100%; background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--rl); padding: 28px; }
.login-title { font-family: var(--font-h); font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-sub { font-size: 14px; color: var(--text2); margin-bottom: 22px; }
.login-error { display: none; padding: 10px 14px; background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); border-radius: var(--rs); font-size: 13px; color: var(--red); margin-bottom: 14px; }
.login-error.show { display: block; }
.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-group label { font-size: 12px; color: var(--text2); font-weight: 500; }
.field-group input { background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--rs); padding: 10px 14px; color: var(--text); font-size: 14px; transition: border-color .15s; outline: none; }
.field-group input:focus { border-color: var(--accent); }
.btn-login { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px; background: var(--accent); border: none; border-radius: var(--rs); color: #fff; font-size: 15px; font-weight: 600; font-family: var(--font-h); margin-top: 4px; transition: all .15s; }
.btn-login:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-login:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.login-footer-text { font-size: 12px; color: var(--text3); }
.register-link { font-size: 13px; color: var(--text2); text-align: center; margin-top: 6px; }
.register-link a { color: var(--accent); cursor: pointer; }

/* ── APP SHELL ── */
.sidebar { width: var(--sw); background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; transition: transform .25s ease; overflow-y: auto; }
.sb-brand { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sb-brand-name { font-family: var(--font-h); font-size: 17px; font-weight: 700; }
.sb-user { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.u-avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; font-family: var(--font-h); flex-shrink: 0; }
.u-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-role { font-size: 11px; color: var(--text2); }
.sb-nav { flex: 1; padding: 10px 0; }
.nav-sec-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text3); font-weight: 600; padding: 8px 20px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 20px; cursor: pointer; font-size: 13.5px; color: var(--text2); border-left: 2px solid transparent; transition: all .12s; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.03); }
.nav-item.active { color: var(--text); background: rgba(108,99,255,.1); border-left-color: var(--accent); }
.nav-item.locked { opacity: .3; cursor: not-allowed; pointer-events: none; }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; opacity: .7; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }
.sb-bottom { padding: 14px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }
.btn-logout { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2); background: none; border: none; transition: color .12s; width: 100%; padding: 6px 0; }
.btn-logout:hover { color: var(--red); }
.main-content { margin-left: var(--sw); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { height: var(--th); background: var(--bg2); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-family: var(--font-h); font-size: 18px; font-weight: 700; flex: 1; }
.topbar-scope { font-size: 12px; color: var(--text2); padding: 4px 10px; background: var(--bg3); border: 1px solid var(--border); border-radius: 20px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.scope-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 34px; height: 34px; border-radius: var(--rs); background: none; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text2); transition: all .12s; position: relative; }
.icon-btn:hover { background: var(--bg3); color: var(--text); }
.notif-dot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; background: var(--red); border-radius: 50%; }
.hamburger { display: none; }
.page-body { flex: 1; padding: 24px; }
.page-hdr { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-hdr h1 { font-family: var(--font-h); font-size: 22px; font-weight: 700; }
.page-hdr p { font-size: 13px; color: var(--text2); margin-top: 3px; }

/* ── METRICS ── */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.mc { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r); padding: 16px; position: relative; overflow: hidden; }
.mc::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.mc-blue::before { background: var(--accent); } .mc-green::before { background: var(--green); }
.mc-amber::before { background: var(--amber); } .mc-teal::before { background: var(--teal); }
.mc-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-bottom: 8px; }
.mc-value { font-family: var(--font-h); font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 6px; }
.mc-sub { font-size: 12px; color: var(--text2); }
.mc-up { color: var(--green); } .mc-down { color: var(--red); }

/* ── CARDS ── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r); padding: 20px; margin-bottom: 16px; }
.card-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-family: var(--font-h); font-size: 14px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── BARS ── */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-lbl { font-size: 12px; color: var(--text2); width: 72px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 6px; background: var(--bg4); border-radius: 3px; }
.bar-fill { height: 100%; border-radius: 3px; transition: width .6s cubic-bezier(.22,1,.36,1); }
.bar-pct { font-size: 12px; font-weight: 600; width: 38px; text-align: right; flex-shrink: 0; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { text-align: left; padding: 8px 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); color: var(--text2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.02); }
.col-name { color: var(--text) !important; font-weight: 500; }

/* ── BADGES ── */
.badge { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.b-purple { background: rgba(108,99,255,.15); color: #a5a0ff; }
.b-blue { background: rgba(59,130,246,.15); color: #7ab3f8; }
.b-amber { background: rgba(245,158,11,.15); color: #fbbf24; }
.b-green { background: rgba(16,185,129,.15); color: #34d399; }
.b-red { background: rgba(239,68,68,.15); color: #f87171; }
.b-gray { background: rgba(255,255,255,.07); color: var(--text2); }

/* ── BUTTONS ── */
.btn { padding: 8px 16px; border-radius: var(--rs); font-size: 13px; font-weight: 500; border: 1px solid var(--border2); background: var(--bg3); color: var(--text); transition: all .12s; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-family: var(--font-b); }
.btn:hover { background: var(--bg4); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── FORMS ── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.fg { display: flex; flex-direction: column; gap: 6px; }
.fg label { font-size: 12px; color: var(--text2); font-weight: 500; }
.fg input, .fg select, .fg textarea { background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--rs); padding: 9px 12px; color: var(--text); font-size: 13px; outline: none; transition: border-color .15s; }
.fg input:focus, .fg select:focus { border-color: var(--accent); }
.fg input[readonly] { opacity: .6; }
.fg select option { background: var(--bg3); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ── TABS ── */
.tab-bar { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-btn { padding: 9px 16px; font-size: 13px; background: none; border: none; color: var(--text2); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .12s; cursor: pointer; font-family: var(--font-b); }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── STATUS ── */
.status-row { display: flex; align-items: center; gap: 6px; }
.s-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.s-green { background: var(--green); } .s-amber { background: var(--amber); }
.s-red { background: var(--red); } .s-blue { background: var(--blue); }

/* ── ALERTS ── */
.alert-item { display: flex; gap: 12px; padding: 14px; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--rs); margin-bottom: 10px; }
.alert-icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.ai-red { background: rgba(239,68,68,.15); color: var(--red); }
.ai-amber { background: rgba(245,158,11,.15); color: var(--amber); }
.ai-blue { background: rgba(59,130,246,.15); color: var(--blue); }
.ai-green { background: rgba(16,185,129,.15); color: var(--green); }
.a-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 3px; }
.a-desc { font-size: 12px; color: var(--text2); line-height: 1.5; }
.a-time { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── TOAST ── */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 18px; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--r); font-size: 13px; display: flex; align-items: center; gap: 8px; z-index: 999; transform: translateY(80px); opacity: 0; transition: all .3s cubic-bezier(.22,1,.36,1); max-width: 320px; pointer-events: none; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { border-color: rgba(16,185,129,.4); }
.toast-warn { border-color: rgba(245,158,11,.4); }
.toast-error { border-color: rgba(239,68,68,.4); }
.t-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── OFFLINE ── */
.offline-banner { display: none; align-items: center; gap: 8px; padding: 8px 14px; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); border-radius: var(--rs); font-size: 12px; color: var(--amber); margin-bottom: 14px; }
.offline-banner.show { display: flex; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.4;transform:scale(.8)} }

/* ── ACCESS WALL ── */
.access-wall { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 360px; gap: 12px; text-align: center; }
.access-icon { width: 60px; height: 60px; border-radius: 50%; background: var(--bg3); border: 1px solid var(--border2); display: flex; align-items: center; justify-content: center; }
.access-title { font-family: var(--font-h); font-size: 18px; font-weight: 700; }
.access-desc { font-size: 13px; color: var(--text2); max-width: 280px; }

/* ── LOADING ── */
.loading-screen { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 999; flex-direction: column; gap: 16px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: var(--text2); }

/* ── TARGET INPUT ── */
.tgt-input { width: 80px; background: var(--bg3); border: 1px solid var(--border2); border-radius: 6px; padding: 5px 8px; color: var(--text); font-size: 13px; outline: none; transition: border-color .15s; }
.tgt-input:focus { border-color: var(--accent); }

/* ── CHART ── */
.chart-box { position: relative; height: 200px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.dl-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 8px; }
.dl-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.dl-val { font-weight: 600; font-size: 14px; }
.dl-name { color: var(--text2); }

/* ── RESPONSIVE ── */
.mob-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 99; }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); } .sidebar.open { transform: translateX(0); }
  .mob-overlay.show { display: block; } .main-content { margin-left: 0; }
  .hamburger { display: flex; } .grid2 { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; } .page-body { padding: 16px; }
  .topbar { padding: 0 16px; } .topbar-scope { display: none; }
}

/* ── ANIMATIONS ── */
@keyframes fadeUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
.page-body > * { animation: fadeUp .25s ease both; }
