/* ═══════════════════════════════════════════════════════════════
   Marvel Bot — Premium Design System (2026)
   Light theme · enterprise AI SaaS · Linear/Vercel/Stripe inspired
   All class names preserved for full functional compatibility.
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
  /* Brand */
  --brand:        #6366f1;
  --brand-600:    #575ae6;
  --brand-700:    #4a4dd6;
  --brand-050:    #f0f1fe;
  --brand-100:    #e6e7fd;
  --brand-200:    #d4d6fb;
  --brand-grad:   linear-gradient(135deg, #7375fb 0%, #5c5ff2 100%);
  --brand-ring:   0 0 0 3px rgba(99, 102, 241, .16);

  /* Neutral canvas & surfaces (cool, premium) */
  --canvas:       #f7f8fb;
  --canvas-2:     #f2f3f7;
  --surface:      #ffffff;
  --surface-2:    #fbfbfd;
  --surface-3:    #f4f5f8;
  --glass:        rgba(255, 255, 255, .72);
  --glass-strong: rgba(255, 255, 255, .85);

  /* Borders */
  --border:       #ececf1;
  --border-2:     #e3e4ec;
  --border-strong:#d9dbe4;
  --hairline:     rgba(17, 18, 34, .06);

  /* Text */
  --ink:          #17181f;
  --ink-2:        #3c3f4a;
  --muted:        #6a6e7a;
  --faint:        #9aa0ad;
  --faintest:     #b8bcc7;

  /* Semantic */
  --green:        #16a34a;   --green-bg: #edfbf1;   --green-bd: #c4f0d1;   --green-ink: #157f3a;
  --amber:        #d97706;   --amber-bg: #fdf6e7;   --amber-bd: #f7e2ad;   --amber-ink: #9a6510;
  --red:          #e5484d;   --red-bg:   #fdf0f0;   --red-bd:   #f6c9cb;   --red-ink:  #c62f34;
  --blue:         #2563eb;   --blue-bg:  #eef4ff;   --blue-bd:  #cfe0fd;   --blue-ink: #1d54c9;

  /* Radii */
  --r-xs: 7px;  --r-sm: 9px;  --r: 12px;  --r-lg: 14px;  --r-xl: 18px;  --r-2xl: 22px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(18, 20, 40, .05);
  --shadow-sm: 0 1px 2px rgba(18, 20, 40, .05), 0 1px 3px rgba(18, 20, 40, .04);
  --shadow-md: 0 6px 16px -6px rgba(18, 20, 40, .12), 0 2px 6px -2px rgba(18, 20, 40, .06);
  --shadow-lg: 0 18px 42px -14px rgba(18, 20, 40, .20), 0 6px 16px -8px rgba(18, 20, 40, .08);
  --shadow-glass: 0 1px 0 rgba(255,255,255,.6) inset, 0 8px 30px -12px rgba(18, 20, 40, .12);

  /* Motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--canvas);
  background-image:
    radial-gradient(1200px 560px at 100% -10%, rgba(99,102,241,.06), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(124,120,255,.05), transparent 55%);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
}
a { text-decoration: none; cursor: pointer; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

::selection { background: var(--brand-100); color: var(--brand-700); }

/* Global refined scrollbars */
* { scrollbar-width: thin; scrollbar-color: #d4d6de transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d4d6de; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #bcbfca; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Layout ── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ═══════ Sidebar ═══════ */
.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--glass-strong);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}
.sb-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  font-weight: 700; font-size: 15.5px; color: var(--ink);
  letter-spacing: -.01em;
}
.sb-logo-icon {
  width: 32px; height: 32px;
  background: var(--brand-grad);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 17px;
  box-shadow: 0 4px 12px -2px rgba(99,102,241,.5), 0 1px 0 rgba(255,255,255,.4) inset;
}
.sb-nav { padding: 6px 12px 0; }
.sb-section-label {
  font-size: 10.5px; font-weight: 600; color: var(--faint);
  letter-spacing: .07em; text-transform: uppercase;
  padding: 10px 8px 6px;
  display: flex; align-items: center; gap: 6px;
}
.sb-count {
  background: var(--surface-3); color: var(--muted);
  font-size: 10.5px; padding: 1px 7px;
  border-radius: 10px; font-weight: 600;
  letter-spacing: 0; text-transform: none;
  border: 1px solid var(--border);
}
.sb-link {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--ink-2); font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
  margin-bottom: 2px;
}
.sb-link i { font-size: 18px; color: var(--faint); transition: color .15s var(--ease); }
.sb-link:hover { background: var(--surface-3); color: var(--ink); }
.sb-link:hover i { color: var(--ink-2); }
.sb-link.active {
  background: var(--brand-050); color: var(--brand-700); font-weight: 600;
}
.sb-link.active i { color: var(--brand); }
.sb-link.active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--brand);
}

.sb-bots-section { flex: 1; overflow-y: auto; padding: 6px 12px 12px; border-top: 1px solid var(--border); margin-top: 10px; }
.sb-bots-section::-webkit-scrollbar { width: 6px; }

.sb-bot-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--ink-2); cursor: pointer; font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease); margin-bottom: 2px;
}
.sb-bot-item:hover { background: var(--surface-3); color: var(--ink); }
.sb-bot-item.active { background: var(--brand-050); color: var(--brand-700); font-weight: 600; }
.sb-bot-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--faintest); flex-shrink: 0;
  transition: background .2s var(--ease);
}
.sb-bot-dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.16); }
.sb-bot-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-bot-company { font-size: 11px; color: var(--faint); }

.sb-new-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 9px 10px; margin-top: 8px;
  border-radius: var(--r-sm); border: 1px dashed var(--border-strong);
  background: none; color: var(--muted); font-size: 13px; font-weight: 500;
  transition: .18s var(--ease);
}
.sb-new-btn:hover { border-color: var(--brand); color: var(--brand-700); background: var(--brand-050); border-style: solid; }

.sb-footer { padding: 12px 14px; border-top: 1px solid var(--border); }
.sb-user {
  display: flex; align-items: center; gap: 10px; padding: 7px;
  border-radius: var(--r); transition: background .15s var(--ease);
}
.sb-user:hover { background: var(--surface-3); }
.sb-avatar {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; flex-shrink: 0;
  box-shadow: 0 3px 8px -2px rgba(99,102,241,.45);
}
.sb-user-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.sb-user-plan { font-size: 11px; color: var(--muted); }

/* ═══════ Main Area ═══════ */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 60px;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 28px; gap: 12px; flex-shrink: 0;
  z-index: 20;
}
.topbar-title {
  flex: 1; font-weight: 650; font-size: 16px; letter-spacing: -.01em;
  display: flex; align-items: center; gap: 10px; color: var(--ink);
}
.topbar-actions { display: flex; gap: 8px; }

.page-content { flex: 1; overflow-y: auto; padding: 32px 32px 56px; }

/* ═══════ Buttons ═══════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 550; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--ink-2);
  box-shadow: var(--shadow-xs);
  transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .12s var(--ease), color .15s var(--ease);
}
.btn i { font-size: 16px; }
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); color: var(--ink); }
.btn:active { transform: translateY(.5px); box-shadow: none; }

.btn-primary {
  background: var(--brand-grad); color: #fff; border-color: transparent;
  box-shadow: 0 4px 12px -3px rgba(99,102,241,.5), 0 1px 0 rgba(255,255,255,.25) inset;
}
.btn-primary:hover { background: var(--brand-grad); filter: brightness(1.04); color: #fff; box-shadow: 0 6px 18px -4px rgba(99,102,241,.6), 0 1px 0 rgba(255,255,255,.25) inset; }
.btn-primary:active { filter: brightness(.98); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); border-color: transparent; }

.btn-danger { background: var(--red-bg); color: var(--red-ink); border-color: var(--red-bd); box-shadow: none; }
.btn-danger:hover { background: #fbe3e4; color: var(--red-ink); border-color: #f0b6b8; }

.btn-success { background: var(--green-bg); color: var(--green-ink); border-color: var(--green-bd); box-shadow: none; }
.btn-success:hover { background: #e2f7e8; color: var(--green-ink); border-color: #a9e6bb; }

.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-sm i { font-size: 15px; }

/* ═══════ Cards ═══════ */
.card {
  background: var(--surface); border-radius: var(--r-lg);
  border: 1px solid var(--border); padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card-sm { background: var(--surface); border-radius: var(--r); border: 1px solid var(--border); padding: 15px 17px; box-shadow: var(--shadow-xs); }

/* ═══════ Stat Cards ═══════ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 30px; }
.stat-card {
  position: relative; overflow: hidden;
  background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--border);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s var(--ease);
}
.stat-card::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--brand-grad); opacity: 0; transition: opacity .2s var(--ease);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-2); }
.stat-card:hover::after { opacity: .9; }
.stat-num { font-size: 30px; font-weight: 720; color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat-change { font-size: 12px; margin-top: 10px; color: var(--green); display: flex; align-items: center; gap: 4px; font-weight: 500; }

/* ═══════ Bot Cards ═══════ */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.bot-card {
  position: relative;
  background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--border);
  padding: 20px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}
.bot-card:hover { border-color: var(--brand-200); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.bot-card-head { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 12px; }
.bot-avatar-lg {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 23px; flex-shrink: 0;
  box-shadow: var(--shadow-xs), 0 0 0 1px var(--hairline) inset;
}
.bot-info { flex: 1; min-width: 0; }
.bot-name { font-weight: 640; font-size: 14.5px; color: var(--ink); letter-spacing: -.01em; }
.bot-company { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-card-meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--border); }
.bot-meta-stat { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; font-weight: 500; }
.bot-meta-stat i { font-size: 14px; color: var(--faint); }

/* ═══════ Badges ═══════ */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2.5px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; letter-spacing: -.005em; line-height: 1.5; border: 1px solid transparent; text-transform: capitalize; }
.badge-green  { background: var(--green-bg); color: var(--green-ink); border-color: var(--green-bd); }
.badge-gray   { background: var(--surface-3); color: var(--muted); border-color: var(--border-2); }
.badge-blue   { background: var(--blue-bg); color: var(--blue-ink); border-color: var(--blue-bd); }
.badge-purple { background: var(--brand-050); color: var(--brand-700); border-color: var(--brand-200); }
.badge-yellow { background: var(--amber-bg); color: var(--amber-ink); border-color: var(--amber-bd); }

/* ═══════ Tabs ═══════ */
.tab-bar { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 26px; gap: 2px; overflow-x: auto; }
.tab-bar::-webkit-scrollbar { height: 0; }
.tab-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 15px; font-size: 13px; color: var(--muted); font-weight: 550;
  border-bottom: 2px solid transparent; cursor: pointer;
  white-space: nowrap; transition: color .15s var(--ease), border-color .15s var(--ease);
  border-left: none; border-right: none; border-top: none; background: none;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--brand-700); border-bottom-color: var(--brand); font-weight: 600; }
.tab-btn i { font-size: 16px; }

/* ═══════ Forms ═══════ */
.form-row { margin-bottom: 18px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; letter-spacing: -.005em; }
.req { color: var(--red); }
.form-input, .form-select {
  width: 100%; padding: 9px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); font-size: 13.5px;
  background: var(--surface); color: var(--ink); outline: none;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.form-input::placeholder { color: var(--faintest); }
.form-input:hover, .form-select:hover { border-color: var(--border-strong); }
.form-input:focus, .form-select:focus { border-color: var(--brand); box-shadow: var(--brand-ring); }
.form-select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa0ad' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
.form-textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); font-size: 13.5px;
  resize: vertical; min-height: 90px;
  background: var(--surface); color: var(--ink); outline: none;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  font-family: inherit; line-height: 1.6;
}
.form-textarea:focus { border-color: var(--brand); box-shadow: var(--brand-ring); }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 5px; line-height: 1.5; }
.form-hint i { font-size: 14px; color: var(--faint); flex-shrink: 0; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-2 .form-row { margin-bottom: 0; }

/* ═══════ Toggles ═══════ */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-info .toggle-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.toggle-info .toggle-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.toggle { position: relative; display: inline-block; width: 40px; height: 23px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track { position: absolute; cursor: pointer; inset: 0; background: var(--border-strong); transition: background .22s var(--ease); border-radius: 23px; }
.toggle-track:before { position: absolute; content: ''; height: 17px; width: 17px; left: 3px; bottom: 3px; background: #fff; transition: transform .22s var(--spring); border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
input:checked + .toggle-track { background: var(--brand); }
input:checked + .toggle-track:before { transform: translateX(17px); }

/* ═══════ Sliders ═══════ */
.slider-row { margin-bottom: 16px; }
.slider-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.slider-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.slider-val { font-size: 12.5px; font-weight: 650; color: var(--brand-700); background: var(--brand-050); padding: 2px 9px; border-radius: 6px; font-variant-numeric: tabular-nums; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 3px; background: var(--surface-3); outline: none; cursor: pointer; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 1.5px solid var(--brand); box-shadow: 0 1px 5px rgba(99,102,241,.4); transition: transform .12s var(--ease); }
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.12); }
.slider-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 4px; }

/* ═══════ Color Picker ═══════ */
.color-picker-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 2px; }
.cp-swatch { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong), var(--shadow-xs); transition: transform .14s var(--spring), box-shadow .14s var(--ease); }
.cp-swatch:hover { transform: scale(1.14); }
.cp-swatch.selected { box-shadow: 0 0 0 2px var(--ink), var(--shadow-sm); transform: scale(1.14); }
.cp-custom { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border-strong); cursor: pointer; padding: 0; background: none; overflow: hidden; }

/* ═══════ File Upload ═══════ */
.drop-zone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--r);
  padding: 36px; text-align: center; cursor: pointer;
  background: var(--surface-2);
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--brand); background: var(--brand-050); border-style: solid; }
.drop-zone-icon { font-size: 38px; color: var(--faintest); display: block; margin-bottom: 10px; }
.drop-zone-title { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.drop-zone-sub { font-size: 12.5px; color: var(--faint); }

.file-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; background: var(--surface); border-radius: var(--r-sm);
  margin-top: 9px; border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.file-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.file-icon { font-size: 19px; color: var(--brand); }
.file-name { flex: 1; font-size: 13px; font-weight: 550; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12px; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.file-del { background: none; border: none; color: var(--faintest); padding: 4px; border-radius: 6px; display: flex; transition: color .14s var(--ease), background .14s var(--ease); }
.file-del:hover { color: var(--red); background: var(--red-bg); }
.upload-progress { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.upload-progress-bar { height: 100%; background: var(--brand-grad); border-radius: 3px; transition: width .35s var(--ease); }
.kb-progress-panel { margin-top: 10px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); }
.kb-progress-label { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.kb-progress-label .spin { color: var(--brand); }
.kb-progress-meta { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* ═══════ Code Block ═══════ */
.code-wrap { position: relative; background: #0e1017; border-radius: var(--r); overflow: hidden; border: 1px solid #1c1f2b; box-shadow: var(--shadow-md); }
.code-pre {
  padding: 22px; font-family: 'JetBrains Mono', 'Fira Mono', monospace;
  font-size: 12.5px; color: #b7bfe0; overflow-x: auto;
  white-space: pre; line-height: 1.8;
}
.code-pre::-webkit-scrollbar { height: 6px; }
.code-pre::-webkit-scrollbar-thumb { background: #2a2f42; border-radius: 6px; }
.code-copy-btn {
  position: absolute; top: 11px; right: 11px;
  background: rgba(255,255,255,.06); color: #c3cae6; border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-xs); padding: 6px 12px; font-size: 12px; font-weight: 550;
  display: flex; align-items: center; gap: 5px; cursor: pointer;
  backdrop-filter: blur(6px);
  transition: .16s var(--ease);
}
.code-copy-btn:hover { background: rgba(255,255,255,.13); color: #fff; }

/* ═══════ Chat Preview ═══════ */
.chat-preview-wrap { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-md); }
.chat-preview-header { padding: 15px 17px; display: flex; align-items: center; gap: 11px; }
.chat-preview-header .ph-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.5); }
.chat-preview-header .ph-dot.on { background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.25); }
.chat-preview-header .ph-name { font-size: 14.5px; font-weight: 650; color: #fff; }
.chat-preview-header .ph-sub { font-size: 11.5px; color: rgba(255,255,255,.82); display: flex; align-items: center; gap: 5px; margin-top: 1px; }
.chat-preview-msgs { padding: 16px; display: flex; flex-direction: column; gap: 11px; background: var(--surface-2); min-height: 170px; }
.preview-msg-bot { background: #fff; border: 1px solid var(--border); border-radius: 4px 14px 14px 14px; padding: 10px 14px; font-size: 13px; max-width: 82%; color: var(--ink-2); box-shadow: var(--shadow-xs); line-height: 1.5; }
.preview-msg-user { background: var(--brand); color: #fff; border-radius: 14px 4px 14px 14px; padding: 10px 14px; font-size: 13px; max-width: 82%; align-self: flex-end; box-shadow: var(--shadow-sm); line-height: 1.5; }
.chat-preview-input { padding: 11px; background: #fff; border-top: 1px solid var(--border); display: flex; gap: 9px; }
.chat-preview-input input { flex: 1; padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); font-size: 13px; outline: none; }
.preview-send { width: 36px; height: 36px; border-radius: var(--r-sm); color: #fff; border: none; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); flex-shrink: 0; }

/* ═══════ Theme buttons ═══════ */
.theme-options { display: flex; gap: 10px; }
.theme-opt { flex: 1; padding: 12px; border-radius: var(--r-sm); border: 1.5px solid var(--border-2); text-align: center; cursor: pointer; font-size: 12.5px; font-weight: 550; color: var(--muted); background: var(--surface); transition: .16s var(--ease); }
.theme-opt:hover { border-color: var(--brand-200); color: var(--brand-700); }
.theme-opt.selected { border-color: var(--brand); color: var(--brand-700); background: var(--brand-050); font-weight: 600; }

/* ═══════ Emoji picker ═══════ */
.emoji-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.emoji-btn { width: 38px; height: 38px; border-radius: var(--r-sm); border: 1.5px solid var(--border-2); background: var(--surface); font-size: 19px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: .14s var(--spring); }
.emoji-btn:hover { border-color: var(--brand-200); background: var(--brand-050); transform: translateY(-1px); }
.emoji-btn.selected { border-color: var(--brand); background: var(--brand-050); box-shadow: var(--brand-ring); }

/* ═══════ Deploy steps ═══════ */
.embed-steps { margin-top: 22px; display: flex; flex-direction: column; gap: 14px; }
.embed-step { display: flex; align-items: flex-start; gap: 13px; font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.step-num { width: 26px; height: 26px; background: var(--brand-grad); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; box-shadow: 0 3px 8px -2px rgba(99,102,241,.5); }

/* ═══════ Alert boxes ═══════ */
.alert { border-radius: var(--r-sm); padding: 13px 15px; font-size: 13px; display: flex; align-items: flex-start; gap: 10px; line-height: 1.55; }
.alert i { font-size: 17px; margin-top: 1px; flex-shrink: 0; }
.alert-green  { background: var(--green-bg); color: var(--green-ink); border: 1px solid var(--green-bd); }
.alert-yellow { background: var(--amber-bg); color: var(--amber-ink); border: 1px solid var(--amber-bd); }
.alert-red    { background: var(--red-bg); color: var(--red-ink); border: 1px solid var(--red-bd); }
.alert-blue   { background: var(--blue-bg); color: var(--blue-ink); border: 1px solid var(--blue-bd); }

/* ═══════ Modal ═══════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(19, 20, 33, .38);
  display: flex; align-items: center; justify-content: center; z-index: 9000; padding: 20px;
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  animation: overlayIn .2s var(--ease);
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: var(--r-xl); width: 500px; max-width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: modalIn .28s var(--spring);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-lg { width: 640px; }
.modal-sm { width: 400px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 0; }
.modal-title { font-size: 16.5px; font-weight: 650; display: flex; align-items: center; gap: 9px; color: var(--ink); letter-spacing: -.01em; }
.modal-title i { color: var(--brand); }
.modal-close { background: none; border: none; color: var(--faint); font-size: 19px; padding: 5px 7px; border-radius: var(--r-xs); display: flex; transition: color .14s var(--ease), background .14s var(--ease); }
.modal-close:hover { color: var(--ink); background: var(--surface-3); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 4px 24px 22px; display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }

/* ═══════ Toast ═══════ */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 99999;
  background: rgba(23, 24, 31, .96); color: #fff; padding: 12px 18px;
  border-radius: var(--r); font-size: 13.5px; font-weight: 500;
  display: flex; align-items: center; gap: 9px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(10px);
  transform: translateY(70px) scale(.96); opacity: 0;
  transition: transform .32s var(--spring), opacity .3s var(--ease);
}
.toast.show { transform: translateY(0) scale(1); opacity: 1; }
.toast i { font-size: 17px; }
.toast.error i { color: #f87171; }
.toast.success i { color: #4ade80; }

/* ═══════ Empty state ═══════ */
.empty-state { text-align: center; padding: 68px 24px; color: var(--muted); }
.empty-state i {
  font-size: 30px; color: var(--faint); display: inline-flex; margin-bottom: 18px;
  width: 68px; height: 68px; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-sm);
}
.empty-state h3 { font-size: 16.5px; font-weight: 650; color: var(--ink); margin-bottom: 7px; letter-spacing: -.01em; }
.empty-state p { font-size: 13.5px; color: var(--muted); max-width: 440px; margin: 0 auto; line-height: 1.6; }

/* ═══════ Global progress ═══════ */
#app-progress-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100000;
  pointer-events: none; opacity: 0; transition: opacity .22s var(--ease);
}
#app-progress-bar.active { opacity: 1; }
#app-progress-bar .app-progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 50%, #6366f1 100%);
  background-size: 200% 100%;
  animation: progress-shimmer 1.1s linear infinite;
  transition: width .35s var(--ease);
  box-shadow: 0 0 12px rgba(99,102,241,.45);
}
@keyframes progress-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

#app-progress-status {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%) translateY(-10px);
  z-index: 99999; display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
  font-size: 13px; font-weight: 550; color: var(--ink-2);
  opacity: 0; pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
#app-progress-status.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.app-progress-spin { animation: spin .75s linear infinite; font-size: 15px; color: var(--brand); }

body.app-is-busy { cursor: progress; }
body.app-is-busy .btn:not(.btn-loading):not(:disabled) { opacity: .72; }
.btn.btn-loading { position: relative; pointer-events: none; opacity: .92; }
.btn.btn-loading .app-progress-spin,
.btn.btn-loading .spin { margin-right: 2px; }

/* ═══════ Usage quota cards ═══════ */
.usage-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 22px; }
.usage-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px 20px; box-shadow: var(--shadow-xs); transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.usage-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.usage-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.usage-card-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; font-weight: 500; }
.usage-card-icon {
  width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.usage-card-icon.tokens { background: var(--brand-050); color: var(--brand); }
.usage-card-icon.bots { background: var(--blue-bg); color: var(--blue); }
.usage-card-values { display: flex; align-items: baseline; gap: 6px; margin-bottom: 12px; }
.usage-card-used { font-size: 28px; font-weight: 720; letter-spacing: -.03em; color: var(--ink); }
.usage-card-limit { font-size: 14px; color: var(--muted); }
.usage-bar { height: 8px; background: var(--surface-3); border-radius: 5px; overflow: hidden; margin-bottom: 8px; }
.usage-bar-fill { height: 100%; border-radius: 5px; transition: width .6s var(--ease); }
.usage-bar-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.usage-card.warn { border-color: var(--amber-bd); background: linear-gradient(180deg, #fff 0%, var(--amber-bg) 100%); }
.usage-card.danger { border-color: var(--red-bd); background: linear-gradient(180deg, #fff 0%, var(--red-bg) 100%); }
.usage-unlimited { font-size: 22px; font-weight: 700; color: var(--green); }

/* ═══════ Loading ═══════ */
.loading { display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-size: 13.5px; padding: 40px; }
.spin { animation: spin 1s linear infinite; display: inline-block; font-size: 20px; color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════ Section header ═══════ */
.section-head { margin-bottom: 26px; }
.section-head h2 { font-size: 22px; font-weight: 720; letter-spacing: -.022em; color: var(--ink); }
.section-head p { font-size: 14px; color: var(--muted); margin-top: 5px; }

/* ═══════ Divider ═══════ */
.divider { border: none; border-top: 1px solid var(--border); margin: 22px 0; }

/* ═══════ Perf bar ═══════ */
.perf-bar-wrap { margin-bottom: 16px; }
.perf-bar-header { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 7px; }
.perf-bar { background: var(--surface-3); border-radius: 5px; height: 8px; overflow: hidden; }
.perf-bar-fill { height: 100%; border-radius: 5px; transition: width .7s var(--ease); background-image: linear-gradient(90deg, rgba(255,255,255,.18), rgba(255,255,255,0)); }

/* ═══════ Two-col layout ═══════ */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.two-col-lg { display: grid; grid-template-columns: 3fr 2fr; gap: 22px; align-items: start; }

/* ═══════ Editor action bars ═══════ */
.editor-action-bar {
  position: sticky; bottom: 0; margin-top: 26px;
  background: var(--glass-strong);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; box-shadow: var(--shadow-md); z-index: 10;
}
.editor-action-hint { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.editor-action-btns { display: flex; gap: 9px; flex-wrap: wrap; }
.card-footer-actions { display: flex; gap: 9px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ═══════ Tables ═══════ */
table { font-variant-numeric: tabular-nums; }
tbody tr { transition: background .14s var(--ease); }
tbody tr:hover { background: var(--surface-2); }

/* ═══════ Responsive ═══════ */
@media (max-width: 1000px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .two-col-lg { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .usage-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .page-content { padding: 20px 16px 44px; }
  .topbar { padding: 0 16px; height: 56px; }
  .topbar-title { font-size: 15px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .bot-grid { grid-template-columns: 1fr; }
  .section-head h2 { font-size: 19px; }
  .modal { border-radius: var(--r-lg); }
  .editor-action-bar { flex-direction: column; align-items: stretch; }
  .editor-action-btns { justify-content: stretch; }
  .editor-action-btns .btn { flex: 1; }
}
@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
