:root {
  --bg: #0b0f19;
  --surface: #111827;
  --surface2: #161f33;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #6366f1;
  --accent2: #3b82f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; height:100%; background:var(--bg); color:var(--text); font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.hidden { display:none !important; }
.muted { color:var(--muted); }
.small { font-size:12px; }

.auth-overlay { position:fixed; inset:0; background:var(--bg); display:flex; align-items:center; justify-content:center; padding:20px; z-index:50; }
.auth-card { width:100%; max-width:380px; background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:28px; text-align:center; box-shadow:0 20px 60px rgba(0,0,0,0.5); }
.logo-badge { font-size:40px; margin-bottom:8px; }
.auth-card input { width:100%; margin:14px 0 12px; }

input, textarea, select {
  background:#0d1322; border:1px solid #334155; color:var(--text); border-radius:10px; padding:10px 12px; font-size:14px; font-family:inherit; width:100%;
}
input:focus, textarea:focus, select:focus { outline:none; border-color:var(--accent); }

button { cursor:pointer; font-family:inherit; border-radius:10px; border:none; font-weight:600; transition:opacity .15s, transform .1s; }
button:active { transform:scale(0.98); }
.btn-primary { background:linear-gradient(135deg, var(--accent), var(--accent2)); color:#fff; padding:10px 16px; font-size:14px; }
.btn-accent { background:#1e1b4b; color:#c7d2fe; border:1px solid #4338ca; padding:10px 12px; width:100%; }
.btn-ghost { background:transparent; color:var(--muted); border:1px solid var(--border); padding:8px 12px; font-size:13px; }
.btn-sm { padding:6px 10px; font-size:12px; }

.app-shell { display:flex; height:100vh; overflow:hidden; }
.sidebar { width:260px; background:var(--surface); border-right:1px solid var(--border); display:flex; flex-direction:column; padding:18px 14px; gap:14px; }
.brand { display:flex; align-items:center; gap:10px; padding:4px 6px; }
.brand-icon { font-size:28px; }
.brand-name { font-weight:700; font-size:17px; }
.brand-sub { font-size:11px; color:var(--muted); }

.nav-list { display:flex; flex-direction:column; gap:6px; }
.nav-btn { text-align:left; background:transparent; color:var(--muted); padding:10px 12px; font-size:14px; border-radius:10px; }
.nav-btn:hover { background:var(--surface2); color:#fff; }
.nav-btn.active { background:linear-gradient(135deg, rgba(99,102,241,0.22), rgba(59,130,246,0.18)); color:#fff; border:1px solid rgba(99,102,241,0.4); }

.sidebar-stats { margin-top:auto; display:flex; flex-direction:column; gap:6px; }
.stat-pill { display:flex; justify-content:space-between; font-size:12px; background:var(--surface2); padding:8px 10px; border-radius:8px; color:var(--muted); }
.stat-pill strong { color:#fff; }
.sidebar-footer { display:flex; flex-direction:column; gap:8px; }

.main-area { flex:1; display:flex; flex-direction:column; height:100%; overflow:hidden; }
.mobile-header { display:none; align-items:center; justify-content:space-between; padding:12px 16px; background:var(--surface); border-bottom:1px solid var(--border); font-weight:700; }
.bottom-nav { display:none; }

.tab-panel { display:none; flex:1; flex-direction:column; height:100%; overflow-y:auto; padding:20px; gap:14px; }
.tab-panel.active { display:flex; }
.panel-header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.panel-header h2 { margin:0; font-size:20px; }

.banner-warn { background:rgba(245,158,11,0.12); border:1px solid rgba(245,158,11,0.4); color:#fde68a; padding:10px 14px; border-radius:10px; font-size:13px; }
.banner-warn a { color:#fff; font-weight:700; }
.err-msg { background:rgba(239,68,68,0.15); border:1px solid rgba(239,68,68,0.4); color:#fecaca; padding:10px; border-radius:8px; margin-top:10px; font-size:13px; }
.ok-msg { background:rgba(34,197,94,0.15); border:1px solid rgba(34,197,94,0.4); color:#bbf7d0; padding:8px 12px; border-radius:8px; margin-top:10px; font-size:13px; }

.chat-messages { flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:12px; padding-right:4px; }
.msg { max-width:85%; padding:12px 15px; border-radius:14px; line-height:1.55; font-size:14px; white-space:pre-wrap; word-break:break-word; }
.msg.user { align-self:flex-end; background:linear-gradient(135deg, var(--accent), var(--accent2)); color:#fff; border-bottom-right-radius:4px; }
.msg.assistant { align-self:flex-start; background:var(--surface); border:1px solid var(--border); border-bottom-left-radius:4px; }

.msg-meta { display:flex; align-items:center; gap:8px; margin-top:8px; flex-wrap:wrap; }
.trace-toggle { background:var(--surface2); color:#a5b4fc; padding:4px 8px; font-size:11px; border-radius:6px; border:1px solid #312e81; }
.trace-box { margin-top:8px; background:#090d16; border:1px solid var(--border); border-radius:8px; padding:10px; font-size:12px; color:#cbd5e1; overflow-x:auto; }
.fb-btn { background:transparent; color:var(--muted); font-size:13px; padding:2px 6px; border:1px solid var(--border); border-radius:6px; }
.fb-btn.active { border-color:var(--accent); color:#fff; }

.quick-prompts { display:flex; gap:8px; flex-wrap:wrap; }
.chip { background:var(--surface2); color:#cbd5e1; border:1px solid var(--border); padding:6px 10px; font-size:12px; border-radius:999px; }
.chat-input-bar { display:flex; gap:10px; align-items:flex-end; background:var(--surface); border:1px solid var(--border); padding:10px; border-radius:14px; }
.chat-input-bar textarea { border:none; background:transparent; resize:none; max-height:140px; padding:6px; }

.card-box { background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:16px; display:flex; flex-direction:column; gap:10px; }
.card-box h3 { margin:0; font-size:16px; }
.two-col { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.cards-stack, .items-list { display:flex; flex-direction:column; gap:10px; }
.item-card { background:var(--surface2); border:1px solid var(--border); border-radius:10px; padding:12px; display:flex; justify-content:space-between; align-items:flex-start; gap:10px; }
.badge { display:inline-block; padding:2px 8px; border-radius:999px; font-size:11px; font-weight:700; text-transform:uppercase; }
.badge.pending { background:rgba(245,158,11,0.18); color:#fcd34d; }
.badge.in_progress { background:rgba(59,130,246,0.2); color:#93c5fd; }
.badge.completed { background:rgba(34,197,94,0.2); color:#86efac; }
.badge.failed { background:rgba(239,68,68,0.2); color:#fca5a5; }

.inline-add, .copy-row { display:flex; gap:8px; align-items:center; }
.row-end { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.inline-lbl { display:flex; align-items:center; gap:8px; font-size:13px; white-space:nowrap; }
.inline-lbl input { width:70px; }
.checkbox-lbl { display:flex; align-items:center; gap:8px; font-size:13px; margin:8px 0; cursor:pointer; }
.checkbox-lbl input { width:auto; }
.code-box { background:#090d16; border:1px solid var(--border); border-radius:10px; padding:10px; font-size:12px; overflow-x:auto; }
.code-box pre { margin:6px 0 0; white-space:pre-wrap; color:#a5b4fc; }

@media (max-width: 820px) {
  .sidebar { display:none; }
  .mobile-header { display:flex; }
  .bottom-nav { display:flex; position:fixed; bottom:0; left:0; right:0; background:var(--surface); border-top:1px solid var(--border); justify-content:space-around; padding:6px 0; z-index:20; }
  .bottom-nav .nav-btn { font-size:18px; padding:8px 14px; }
  .tab-panel { padding:14px 14px 76px; }
  .two-col { grid-template-columns:1fr; }
  .msg { max-width:94%; }
}
