/* ═══════════════════════════════════════
   STELLA ADMIN PANEL — style.css
   C-Tech Innovations
═══════════════════════════════════════ */

/* ── DESIGN TOKENS ── */
:root {
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --green-glow: rgba(34, 197, 94, 0.3);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.12);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --trans: 0.2s ease;

  --topbar-h: 58px;
  --nav-h: 64px;
  --sidebar-w: 230px;
}

/* ── DARK THEME (default) ── */
[data-theme="dark"] {
  --bg: #0d1117;
  --bg2: #161b26;
  --bg3: #1e2535;
  --bg4: #252d3f;
  --bg5: #2d3748;
  --border: rgba(255, 255, 255, 0.07);
  --border2: rgba(255, 255, 255, 0.12);
  --text: #f0f4ff;
  --text2: #8b96b0;
  --text3: #3a4560;
  --shadow: rgba(0, 0, 0, 0.4);
}

/* ── LIGHT THEME ── */
[data-theme="light"] {
  --bg: #f0f4f8;
  --bg2: #ffffff;
  --bg3: #edf2f7;
  --bg4: #e2e8f0;
  --bg5: #cbd5e0;
  --border: rgba(0, 0, 0, 0.07);
  --border2: rgba(0, 0, 0, 0.13);
  --text: #1a202c;
  --text2: #4a5568;
  --text3: #a0aec0;
  --shadow: rgba(0, 0, 0, 0.08);
}

/* ── RESET ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  transition: background var(--trans), color var(--trans);
}

/* ── APP SHELL ── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ══════════════════════════════════════
   TOPBAR
══════════════════════════════════════ */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0);
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
  transition: background var(--trans), border-color var(--trans);
}

@media (min-width: 768px) {
  .topbar { padding: 0 24px; }
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #22c55e, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 3px 12px var(--green-glow);
}

.logo-text { flex: 1; min-width: 0; }

.logo-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logo-sub {
  font-size: 10px;
  color: var(--text2);
  margin-top: 1px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 99px;
  background: var(--bg3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--trans), background var(--trans);
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover { border-color: var(--border2); background: var(--bg4); }

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: all var(--trans);
}

.sdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all var(--trans);
}

.sdot.open {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.sdot.closed {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

/* ══════════════════════════════════════
   BODY AREA
══════════════════════════════════════ */
.body-area {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: none;
  flex-direction: column;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  transition: background var(--trans), border-color var(--trans);
}

@media (min-width: 768px) {
  .sidebar { display: flex; }
}

.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sb-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #22c55e, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sb-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.sb-sub {
  font-size: 10px;
  color: var(--text2);
  margin-top: 2px;
}

.snav {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  flex: 1;
}

.sn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  background: none;
  border: none;
  border-left: 2px solid transparent;
  cursor: pointer;
  text-align: left;
  font-family: 'DM Sans', system-ui, sans-serif;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.sn:hover {
  background: var(--bg3);
  color: var(--text);
}

.sn.active {
  color: var(--text);
  border-left-color: var(--green);
  background: var(--bg3);
}

.sn-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.sn-label { flex: 1; }

.sn-badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  display: none;
}

.sn-badge.show { display: inline-block; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.stella-credit {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 6px;
}

.stella-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.shortcut-hint {
  font-size: 10px;
  color: var(--text3);
}

/* ══════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════ */
.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 16px;
  padding-bottom: calc(var(--nav-h) + 24px);
}

@media (min-width: 768px) {
  .main {
    padding: 28px 32px;
    padding-bottom: 40px;
    max-width: 860px;
  }
}

@media (min-width: 1200px) {
  .main { padding: 32px 48px; }
}

/* ── PAGES ── */
.page { display: none; }
.page.active { display: block; }

/* ── SECTION LABEL ── */
.slabel {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 12px;
}

.section { margin-bottom: 28px; }

/* ── CARDS ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
  transition: background var(--trans), border-color var(--trans);
}

/* ══════════════════════════════════════
   DASHBOARD
══════════════════════════════════════ */
.peace-header {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin-bottom: 22px;
  text-align: center;
  transition: all var(--trans);
}

.peace-icon { font-size: 38px; margin-bottom: 10px; }

.peace-title {
  font-size: 24px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  color: var(--green);
}

.peace-sub {
  font-size: 13px;
  color: var(--text2);
  margin-top: 5px;
}

/* STAT GRID */
.stat-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 16px;
}

@media (min-width: 560px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all var(--trans);
}

.stat-card.accent-green {
  border-color: rgba(34, 197, 94, 0.2);
  background: var(--green-dim);
}

.stat-card.accent-red {
  border-color: rgba(239, 68, 68, 0.2);
  background: var(--red-dim);
}

.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { border-color: var(--border2); transform: translateY(-1px); }

.stat-num {
  font-size: 30px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  line-height: 1;
}

.stat-num.green { color: var(--green); }
.stat-num.red { color: var(--red); }
.stat-num.blue { color: var(--blue); }

.stat-label {
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
}

.stat-desc {
  font-size: 11px;
  color: var(--text2);
  margin-top: 3px;
  line-height: 1.4;
}

.stat-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  margin-top: 8px;
}

.tag-green { background: var(--green-dim); color: var(--green); }
.tag-red { background: var(--red-dim); color: var(--red); }
.tag-blue { background: var(--blue-dim); color: var(--blue); }
.tag-amber { background: var(--amber-dim); color: var(--amber); }

/* BOT ACTIVITY */
.bot-activity { display: flex; flex-direction: column; gap: 12px; }

.act-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.act-label { font-size: 13px; color: var(--text2); }

/* CLINIC INFO */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child { border-bottom: none; }

.info-label {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}

.info-val {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

/* ══════════════════════════════════════
   STATUS PAGE
══════════════════════════════════════ */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.t-name { font-size: 14px; font-weight: 600; }

.t-desc {
  font-size: 12px;
  color: var(--text2);
  margin-top: 3px;
  line-height: 1.4;
}

/* TOGGLE */
.tog {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
  margin-top: 2px;
}

.tog input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.knob {
  position: absolute;
  inset: 0;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 99px;
  cursor: pointer;
  transition: 0.25s;
}

.knob::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  top: 2px;
  background: var(--text2);
  border-radius: 50%;
  transition: 0.25s;
}

input:checked + .knob { background: var(--green); border-color: var(--green); }
input:checked + .knob::before { transform: translateX(22px); background: #fff; }

.c-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: none;
}

.c-block.show { display: block; }

.c-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
}

.c-area {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: 'DM Sans', system-ui, sans-serif;
  resize: vertical;
  outline: none;
  line-height: 1.5;
  min-height: 80px;
  transition: border-color var(--trans);
}

.c-area:focus { border-color: var(--green); }

/* ══════════════════════════════════════
   SCHEDULE PAGE
══════════════════════════════════════ */
.sched-loading {
  font-size: 13px;
  color: var(--text2);
  text-align: center;
  padding: 20px;
}

.sched-table {
  width: 100%;
  border-collapse: collapse;
}

.sched-table tr { border-bottom: 1px solid var(--border); }
.sched-table tr:last-child { border-bottom: none; }
.sched-table td { padding: 12px 0; vertical-align: middle; }

.d-name-cell {
  width: 110px;
  font-size: 13px;
  font-weight: 500;
  padding-right: 12px;
}

.t-pair {
  display: flex;
  align-items: center;
  gap: 6px;
}

.t-in {
  width: 88px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  outline: none;
  text-align: center;
  transition: border-color var(--trans);
}

.t-in:focus { border-color: var(--green); }
.t-in:disabled { opacity: 0.35; pointer-events: none; }

.t-sep { font-size: 11px; color: var(--text3); }

.tog-cell { width: 50px; text-align: right; }

.tog-sm {
  position: relative;
  width: 36px;
  height: 20px;
  display: inline-block;
}

.tog-sm input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.knob-sm {
  position: absolute;
  inset: 0;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 99px;
  cursor: pointer;
  transition: 0.2s;
}

.knob-sm::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  background: var(--text3);
  border-radius: 50%;
  transition: 0.2s;
}

input:checked + .knob-sm { background: var(--green); border-color: var(--green); }
input:checked + .knob-sm::before { transform: translateX(16px); background: #fff; }

/* ══════════════════════════════════════
   BUTTONS & TOASTS
══════════════════════════════════════ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--green);
  color: #052e12;
  font-weight: 700;
  font-size: 13px;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', system-ui, sans-serif;
  margin-top: 16px;
  transition: background var(--trans), transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover { background: #16a34a; }
.btn-primary:active { transform: scale(0.98); }

.toast {
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
  margin-top: 8px;
  display: none;
}

/* ══════════════════════════════════════
   FLAGGED PAGE
══════════════════════════════════════ */
.logs-empty {
  text-align: center;
  padding: 48px 24px;
}

.logs-empty-icon { font-size: 48px; margin-bottom: 14px; }

.logs-empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--green);
}

.logs-empty-sub {
  font-size: 13px;
  color: var(--text2);
  margin-top: 6px;
  line-height: 1.5;
}

.flag-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  animation: slidein 0.3s ease;
  transition: all var(--trans);
}

.flag-card.resolved {
  border-left-color: var(--green);
  opacity: 0.5;
}

@keyframes slidein {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.flag-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.flag-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--red-dim);
  border: 1px solid rgba(239, 68, 68, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.flag-avatar.resolved-av {
  background: var(--green-dim);
  border-color: rgba(34, 197, 94, 0.25);
}

.flag-info { flex: 1; min-width: 0; }

.flag-name { font-size: 14px; font-weight: 700; }

.flag-time {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

.flag-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  flex-shrink: 0;
  margin-top: 2px;
}

.badge-emergency { background: var(--red-dim); color: var(--red); }
.badge-urgent { background: var(--amber-dim); color: var(--amber); }
.badge-resolved { background: var(--green-dim); color: var(--green); }

.flag-msg {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.flag-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.flag-btn {
  flex: 1;
  min-width: 80px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'DM Sans', system-ui, sans-serif;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.flag-btn:hover { background: var(--bg4); }
.flag-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.flag-btn.call {
  background: var(--green-dim);
  border-color: rgba(34, 197, 94, 0.25);
  color: var(--green);
}

.flag-btn.call:hover { background: rgba(34, 197, 94, 0.2); }

.reply-box { margin-top: 12px; display: none; }
.reply-box.show { display: block; }

.reply-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: 'DM Sans', system-ui, sans-serif;
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color var(--trans);
}

.reply-input:focus { border-color: var(--green); }

.reply-send {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  background: var(--green);
  color: #052e12;
  font-weight: 700;
  font-size: 12px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'DM Sans', system-ui, sans-serif;
  transition: background var(--trans);
}

.reply-send:hover { background: #16a34a; }

/* ══════════════════════════════════════
   BOTTOM NAV (mobile only)
══════════════════════════════════════ */
.bot-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
  padding: 6px 0 max(10px, env(safe-area-inset-bottom, 10px));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

@media (min-width: 768px) {
  .bot-nav { display: none; }
}

.nb {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.nb-icon { font-size: 20px; line-height: 1; }

.nb-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  transition: color 0.15s;
}

.nb.active .nb-label { color: var(--green); }

.nb-dot {
  position: absolute;
  top: 2px;
  right: calc(50% - 14px);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--bg2);
  display: none;
}

.nb-dot.show { display: block; }

/* ══════════════════════════════════════
   STELLA FAB
══════════════════════════════════════ */
.ai-fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  right: 20px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  z-index: 49;
  background: linear-gradient(135deg, #22c55e, #3b82f6);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px var(--green-glow), 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
  -webkit-tap-highlight-color: transparent;
  animation: fabpulse 3s ease-in-out infinite;
}

@media (min-width: 768px) {
  .ai-fab { bottom: 24px; }
}

.ai-fab:hover { transform: scale(1.08); }

.fab-icon {
  font-size: 22px;
  color: #fff;
  line-height: 1;
}

@keyframes fabpulse {
  0%, 100% { box-shadow: 0 6px 24px var(--green-glow), 0 2px 8px rgba(0, 0, 0, 0.3); }
  50% { box-shadow: 0 6px 36px rgba(34, 197, 94, 0.55), 0 2px 8px rgba(0, 0, 0, 0.3); }
}

/* ══════════════════════════════════════
   OVERLAY
══════════════════════════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 60;
  display: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.overlay.show { display: block; }

/* ══════════════════════════════════════
   STELLA DRAWER
══════════════════════════════════════ */
.ai-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border2);
  border-radius: 20px 20px 0 0;
  z-index: 65;
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .ai-drawer {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: 380px;
    border-radius: 20px;
    max-height: 540px;
    border: 1px solid var(--border2);
    box-shadow: 0 20px 60px var(--shadow);
  }
}

.ai-drawer.open { transform: translateY(0); }

@media (min-width: 768px) {
  .ai-drawer.open { transform: none; }
}

.drag-handle {
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: var(--border2);
  margin: 10px auto 0;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .drag-handle { display: none; }
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.d-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, #22c55e, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 3px 10px var(--green-glow);
}

.d-title { font-size: 14px; font-weight: 700; }
.d-sub { font-size: 11px; color: var(--text2); }

.d-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--green);
  font-weight: 600;
  margin-left: auto;
}

.d-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 16px;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--trans);
  margin-left: 6px;
}

.d-close:hover { background: var(--bg4); }

.ai-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.ai-msgs::-webkit-scrollbar { width: 3px; }
.ai-msgs::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

.am {
  max-width: 87%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  animation: msgIn 0.2s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.am.bot {
  background: var(--bg3);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.am.user {
  background: var(--green);
  color: #052e12;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.am.loading {
  opacity: 0.6;
  font-style: italic;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text2);
  animation: dot-bounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.ai-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
}

.ai-in {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  transition: border-color var(--trans);
}

.ai-in:focus { border-color: var(--green); }

.ai-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green);
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #052e12;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--trans), transform 0.1s;
}

.ai-send:hover { background: #16a34a; }
.ai-send:active { transform: scale(0.95); }
.ai-send:disabled { opacity: 0.5; cursor: not-allowed; }