/* ═══════════════════════════════════════════════
   THEME VARIABLES
═══════════════════════════════════════════════ */
:root {
  --bg:       #080808;
  --bg2:      #0d0d0d;
  --bg3:      #111;
  --bg4:      #161616;
  --border:   rgba(255,255,255,0.06);
  --border2:  rgba(255,255,255,0.11);
  --text:     #e2e2e2;
  --text2:    #888;
  --text3:    #444;
  --accent:   #ff7c5c;
  --accent2:  #ff4d8f;
  --sidebar:  #090909;
  --input-bg: rgba(255,255,255,0.04);
  --font:     'Instrument Sans', system-ui, sans-serif;
  --mono:     'Geist Mono', monospace;
}
.light {
  --bg:       #fafafa;
  --bg2:      #f2f2f2;
  --bg3:      #ebebeb;
  --bg4:      #e5e5e5;
  --border:   rgba(0,0,0,0.07);
  --border2:  rgba(0,0,0,0.13);
  --text:     #111;
  --text2:    #555;
  --text3:    #aaa;
  --sidebar:  #f5f5f5;
  --input-bg: rgba(0,0,0,0.03);
}

/* ═══════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); }
body { font-family: var(--font); color: var(--text); font-size: 14px; line-height: 1.6; }

button { font-family: var(--font); cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: var(--font); }
a { color: var(--accent); text-decoration: none; }
svg { display: block; flex-shrink: 0; }

/* ═══════════════════════════════════════════════
   LAYOUT — 3-PANEL
═══════════════════════════════════════════════ */
#app {
  display: flex;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  transition: background .25s, color .25s;
}

/* ═══════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════ */
#sidebar {
  width: 240px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  transition: width .25s ease, min-width .25s ease, transform .25s ease;
  overflow: hidden;
  z-index: 40;
}
#sidebar.collapsed { width: 0; min-width: 0; }

.sb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-mark {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff; font-weight: 600;
}
.logo-text { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; letter-spacing: -.2px; }

.new-btn {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text3);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.new-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--border2); }

.sb-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .9px;
  padding: 13px 14px 5px;
}

.sb-history { flex: 1; overflow-y: auto; padding: 3px 8px; }
.sb-history::-webkit-scrollbar { width: 3px; }
.sb-history::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.hist-item {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid transparent;
  transition: all .15s;
  display: flex; align-items: center; gap: 7px;
}
.hist-item:hover { background: var(--bg3); color: var(--text); }
.hist-item.active { background: var(--bg3); color: var(--text); border-color: var(--border2); }
.hist-item svg { flex-shrink: 0; opacity: .5; }

.sb-bottom {
  padding: 10px 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Token bar */
.token-bar-wrap { padding: 8px 4px 10px; }
.token-bar-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; font-size: 11px; color: var(--text2); }
.token-bar-row span:last-child { color: var(--text3); font-size: 10px; }
.token-bar-bg { height: 3px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.token-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .4s ease; }

.user-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 8px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s;
}
.user-row:hover { background: var(--bg3); }
.avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 10px; color: var(--accent); font-weight: 500; }
.sb-actions { display: flex; gap: 4px; }
.sb-icon-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
  transition: all .15s;
}
.sb-icon-btn:hover { background: var(--bg3); color: var(--text2); }

/* ═══════════════════════════════════════════════
   MAIN CHAT
═══════════════════════════════════════════════ */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  min-width: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.menu-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--input-bg);
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.menu-btn:hover { background: var(--bg3); color: var(--text); }

.model-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px; font-weight: 500;
  transition: all .15s;
}
.model-btn:hover { background: var(--bg3); border-color: var(--border2); }
.model-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.model-dot.free { background: #22c55e; }
.model-dot.premium { background: var(--accent); }
.model-mult {
  font-size: 10px; font-weight: 700;
  background: rgba(255,124,92,.18);
  color: var(--accent);
  padding: 1px 5px; border-radius: 4px;
}

.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.hdr-balance {
  font-size: 11px; color: var(--text2);
  background: var(--bg3);
  padding: 3px 9px; border-radius: 6px;
  border: 1px solid var(--border);
  font-family: var(--mono);
}
.hdr-icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; font-size: 15px;
}
.hdr-icon-btn:hover { background: var(--bg3); color: var(--text); }

/* Messages area */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 2px; }

.messages-inner { padding: 24px 0; }

/* Welcome screen */
.welcome {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 70%;
  padding: 40px 20px;
  text-align: center;
}
.welcome-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
  margin: 0 auto 18px;
  box-shadow: 0 8px 32px rgba(255,124,92,.25);
}
.welcome h2 { font-size: 22px; font-weight: 600; color: var(--text); margin-bottom: 6px; letter-spacing: -.3px; }
.welcome p { font-size: 14px; color: var(--text2); margin-bottom: 28px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 480px; }
.suggestion {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--bg2);
  color: var(--text2);
  font-size: 13px;
  transition: all .15s;
}
.suggestion:hover { background: var(--bg3); color: var(--text); border-color: var(--border2); }

/* Messages */
.msg { display: flex; padding: 8px 20px; gap: 12px; }
.msg:hover .msg-actions { opacity: 1; }
.msg-user { flex-direction: row-reverse; }
.msg-user .bubble {
  background: rgba(255,124,92,.1);
  border: 1px solid rgba(255,124,92,.15);
  color: var(--text);
  max-width: 70%;
  border-radius: 16px 4px 16px 16px;
}
.msg-assistant .bubble {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  max-width: 80%;
  border-radius: 4px 16px 16px 16px;
}
.bubble {
  padding: 11px 15px;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}
.bubble p { margin-bottom: 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble code {
  font-family: var(--mono);
  background: rgba(255,255,255,.07);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}
.bubble pre {
  background: rgba(0,0,0,.4);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0;
}
.bubble pre code { background: none; padding: 0; font-size: 12px; }
.bubble h1,.bubble h2,.bubble h3 { margin: 10px 0 4px; font-weight: 600; }
.bubble ul,.bubble ol { padding-left: 20px; margin: 6px 0; }
.bubble li { margin-bottom: 3px; }

.msg-actions {
  opacity: 0;
  display: flex; gap: 3px; align-items: flex-end;
  transition: opacity .15s;
  padding-bottom: 4px;
  flex-shrink: 0;
}
.action-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
  transition: all .15s;
}
.action-btn:hover { background: var(--bg3); color: var(--text2); }
.action-btn.active { color: var(--accent); }

/* Thinking */
.thinking { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.thinking span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text3);
  animation: bounce .8s ease-in-out infinite;
}
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-6px)} }

/* Cursor blink */
.cursor {
  display: inline-block;
  width: 2px; height: 14px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* Input */
.input-area {
  border-top: 1px solid var(--border);
  padding: 12px 16px 14px;
  flex-shrink: 0;
}
.input-inner {
  max-width: 760px;
  margin: 0 auto;
}
.input-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 10px 10px 10px 14px;
  transition: border-color .15s;
}
.input-wrap:focus-within { border-color: rgba(255,124,92,.4); }
.chat-input {
  flex: 1; resize: none; background: none; border: none; outline: none;
  color: var(--text); font-size: 14px; line-height: 1.6;
  max-height: 160px; min-height: 22px;
}
.chat-input::placeholder { color: var(--text3); }
.send-btn {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) { background: #ff5c3a; transform: scale(1.05); }
.send-btn:disabled { background: var(--bg3); color: var(--text3); cursor: not-allowed; transform: none; }
.send-btn.stop { background: #ef4444; }

.input-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 0;
}
.input-model {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text2); cursor: pointer;
  padding: 2px 6px; border-radius: 5px;
  transition: all .15s;
}
.input-model:hover { background: var(--bg3); color: var(--text); }
.input-hint { font-size: 11px; color: var(--text3); }

/* ═══════════════════════════════════════════════
   MODEL SHEET
═══════════════════════════════════════════════ */
#model-sheet {
  position: fixed; inset: 0; z-index: 200;
  display: none;
}
#model-sheet.open { display: block; }
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
}
.sheet-panel {
  position: absolute;
  top: 52px; left: 50%;
  transform: translateX(-50%);
  width: 420px; max-height: 70vh;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: sheetIn .18s ease;
}
@keyframes sheetIn { from{opacity:0;transform:translateX(-50%) translateY(-8px)} to{opacity:1;transform:translateX(-50%) translateY(0)} }
.sheet-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.sheet-header span { font-size: 13px; font-weight: 600; color: var(--text); }
.sheet-search {
  flex: 1; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 8px; padding: 6px 10px;
  color: var(--text); font-size: 12px; outline: none;
}
.sheet-close {
  width: 26px; height: 26px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2); font-size: 14px;
  transition: all .15s;
}
.sheet-close:hover { background: var(--bg3); color: var(--text); }
.sheet-list { overflow-y: auto; padding: 8px; }
.sheet-list::-webkit-scrollbar { width: 4px; }
.sheet-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.provider-group { margin-bottom: 10px; }
.provider-label {
  font-size: 10px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .8px;
  padding: 4px 8px 6px;
}
.model-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; transition: background .12s;
}
.model-item:hover { background: var(--bg3); }
.model-item.selected { background: rgba(255,124,92,.1); }
.model-dot-sm { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.model-name { flex: 1; font-size: 13px; color: var(--text); }
.model-badge {
  font-size: 10px; font-weight: 600;
  background: rgba(255,124,92,.15);
  color: var(--accent);
  padding: 2px 6px; border-radius: 4px;
}

/* ═══════════════════════════════════════════════
   SETTINGS PANEL
═══════════════════════════════════════════════ */
#settings {
  position: fixed; inset: 0; z-index: 100;
  display: none; background: rgba(0,0,0,.65);
  backdrop-filter: blur(6px);
}
#settings.open { display: flex; align-items: center; justify-content: center; }
.sp-modal {
  width: 680px; height: 520px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 18px;
  display: flex; overflow: hidden;
  animation: spIn .2s ease;
}
@keyframes spIn { from{opacity:0;transform:scale(.96)} to{opacity:1;transform:scale(1)} }
.sp-sidebar {
  width: 195px; min-width: 195px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 10px;
}
.sp-header-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.sp-header-row span { font-size: 13px; font-weight: 600; color: var(--text); }
.sp-close { color: var(--text3); font-size: 16px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 5px; transition: all .15s; }
.sp-close:hover { background: var(--bg3); color: var(--text2); }
.sp-section-label {
  font-size: 9px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .9px;
  padding: 8px 8px 4px;
}
.sp-tab {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13px; color: var(--text2);
  transition: all .15s; width: 100%;
  cursor: pointer; text-align: left;
}
.sp-tab:hover { background: var(--bg3); color: var(--text); }
.sp-tab.active { background: rgba(255,124,92,.1); color: var(--accent); }
.sp-tab svg { flex-shrink: 0; }
.sp-tab-arrow { margin-left: auto; opacity: .4; }
.sp-version { font-size: 10px; color: var(--text3); padding: 12px 10px 0; margin-top: auto; }

.sp-content { flex: 1; overflow-y: auto; padding: 20px; }
.sp-content::-webkit-scrollbar { width: 4px; }
.sp-content::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.sp-pane { display: none; }
.sp-pane.active { display: block; }

/* Profile pane */
.profile-hero {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; background: var(--bg); border-radius: 12px;
  border: 1px solid var(--border); margin-bottom: 16px;
}
.profile-av {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.profile-name { font-size: 15px; font-weight: 600; color: var(--text); }
.profile-meta { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.plan-badge {
  font-size: 10px; font-weight: 700;
  background: rgba(255,124,92,.15); color: var(--accent);
  padding: 2px 7px; border-radius: 4px; text-transform: uppercase;
}
.profile-since { font-size: 11px; color: var(--text3); }

.stat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px;
}
.stat-card-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; }
.stat-card-val { font-size: 20px; font-weight: 700; color: var(--text); font-family: var(--mono); margin: 2px 0 8px; }

/* Form */
.sp-form-group { margin-bottom: 14px; }
.sp-label { font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.sp-input {
  width: 100%; padding: 9px 12px;
  background: var(--bg); border: 1px solid var(--border2);
  border-radius: 9px; color: var(--text); font-size: 13px; outline: none;
  transition: border-color .15s;
}
.sp-input:focus { border-color: rgba(255,124,92,.5); }
.sp-btn {
  padding: 9px 18px; border-radius: 9px;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600;
  transition: all .15s;
}
.sp-btn:hover { background: #ff5c3a; }

/* Plan cards */
.plan-cards { display: flex; flex-direction: column; gap: 8px; }
.plan-card {
  padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border2); background: var(--bg);
  cursor: pointer; transition: all .15s;
  display: flex; align-items: center; gap: 12px;
}
.plan-card:hover { border-color: var(--border2); background: var(--bg3); }
.plan-card.current { border-color: rgba(255,124,92,.4); background: rgba(255,124,92,.06); }
.plan-name { font-size: 13px; font-weight: 600; color: var(--text); }
.plan-tokens { font-size: 11px; color: var(--text2); }
.plan-price { margin-left: auto; font-size: 14px; font-weight: 700; color: var(--accent); font-family: var(--mono); }

/* Usage pane */
.usage-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 16px; }
.ustat {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px;
  text-align: center;
}
.ustat-val { font-size: 18px; font-weight: 700; color: var(--text); font-family: var(--mono); }
.ustat-label { font-size: 10px; color: var(--text2); margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }
.chart-wrap { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.chart-title { font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }

/* Auth button */
.oauth-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--border2); background: var(--bg);
  width: 100%; font-size: 13px; color: var(--text);
  transition: all .15s; cursor: pointer; margin-bottom: 8px;
}
.oauth-btn:hover { background: var(--bg3); border-color: var(--border2); }
.oauth-icon { width: 20px; height: 20px; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 13px; }

/* ═══════════════════════════════════════════════
   ADMIN PANEL
═══════════════════════════════════════════════ */
#admin {
  position: fixed; inset: 0; z-index: 150;
  display: none; background: var(--bg);
  overflow: hidden;
}
#admin.open { display: flex; }
.admin-sidebar {
  width: 220px; min-width: 220px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 10px;
}
.admin-logo {
  display: flex; align-items: center; gap: 8px;
  padding: 0 6px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.admin-logo-badge {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #7c5cff, #ff4d8f);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff; font-weight: 700;
}
.admin-logo-text { font-size: 13px; font-weight: 600; color: var(--text); }
.admin-nav-label {
  font-size: 9px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .9px;
  padding: 8px 8px 4px;
}
.admin-nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13px; color: var(--text2);
  cursor: pointer; transition: all .15s; margin-bottom: 2px;
}
.admin-nav-item:hover { background: var(--bg3); color: var(--text); }
.admin-nav-item.active { background: rgba(124,92,255,.12); color: #a78bfa; }
.admin-exit {
  margin-top: auto; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13px; color: var(--text2);
  cursor: pointer; transition: all .15s;
}
.admin-exit:hover { background: rgba(239,68,68,.1); color: #ef4444; }

.admin-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.admin-header {
  padding: 0 24px; height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.admin-header h2 { font-size: 15px; font-weight: 600; color: var(--text); }
.admin-content { flex: 1; overflow-y: auto; padding: 20px 24px; }
.admin-content::-webkit-scrollbar { width: 4px; }
.admin-content::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.admin-pane { display: none; }
.admin-pane.active { display: block; }

/* Admin stats cards */
.admin-stat-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 20px; }
.astat {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.astat-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; margin-bottom: 10px;
}
.astat-val { font-size: 22px; font-weight: 700; color: var(--text); font-family: var(--mono); }
.astat-label { font-size: 11px; color: var(--text2); margin-top: 2px; }
.astat-trend { font-size: 10px; margin-top: 4px; }
.astat-trend.up { color: #22c55e; }
.astat-trend.down { color: #ef4444; }

.admin-section-title { font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .7px; margin-bottom: 10px; }

/* Users table */
.users-table { width: 100%; border-collapse: collapse; }
.users-table th {
  font-size: 10px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .7px;
  padding: 8px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.users-table td {
  padding: 10px 12px; font-size: 13px; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.users-table tr:hover td { background: var(--bg3); }
.user-tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
}
.tag-basic { background: rgba(136,136,136,.15); color: var(--text2); }
.tag-pro { background: rgba(255,124,92,.15); color: var(--accent); }
.tag-enterprise { background: rgba(124,92,255,.15); color: #a78bfa; }
.tag-active { background: rgba(34,197,94,.15); color: #22c55e; }

/* Settings form admin */
.admin-form-group { margin-bottom: 16px; }
.admin-label { font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; display: block; }
.admin-input {
  width: 100%; padding: 10px 12px;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 9px; color: var(--text); font-size: 13px; outline: none;
  transition: border-color .15s;
}
.admin-input:focus { border-color: rgba(124,92,255,.5); }
.admin-textarea { min-height: 80px; resize: vertical; font-family: var(--mono); }
.admin-btn {
  padding: 9px 20px; border-radius: 9px;
  background: linear-gradient(135deg, #7c5cff, #a855f7);
  color: #fff; font-size: 13px; font-weight: 600;
  transition: all .15s;
}
.admin-btn:hover { opacity: .9; transform: translateY(-1px); }
.admin-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.admin-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; margin-bottom: 16px;
}
.admin-card-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 14px; }

/* Login page */
#login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 500;
}
.login-card {
  width: 360px; padding: 36px 32px;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 20px; text-align: center;
}
.login-logo {
  width: 52px; height: 52px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; margin: 0 auto 18px;
}
.login-card h2 { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 6px; letter-spacing: -.3px; }
.login-card p { font-size: 13px; color: var(--text2); margin-bottom: 24px; }
.login-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; }
.login-divider span { font-size: 11px; color: var(--text3); }
.login-divider::before, .login-divider::after { content:''; flex:1; height:1px; background: var(--border); }
.login-input-wrap { margin-bottom: 10px; }
.login-input {
  width: 100%; padding: 10px 14px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 10px; color: var(--text); font-size: 13px; outline: none;
  transition: border-color .15s;
}
.login-input:focus { border-color: rgba(255,124,92,.4); }
.login-btn {
  width: 100%; padding: 11px;
  border-radius: 10px; background: var(--accent);
  color: #fff; font-size: 14px; font-weight: 600;
  transition: all .15s; margin-top: 4px;
}
.login-btn:hover { background: #ff5c3a; }

/* Responsive */
@media (max-width: 640px) {
  #sidebar { position: fixed; transform: translateX(-100%); top:0;left:0;bottom:0; }
  #sidebar.mobile-open { transform: translateX(0); }
  .sp-modal { width: 95vw; height: 90vh; flex-direction: column; }
  .sp-sidebar { width: 100%; min-width: unset; border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; overflow-x: auto; padding: 8px; }
  .sp-section-label { display: none; }
  .admin-stat-row { grid-template-columns: 1fr 1fr; }
}