/* ===== Sales-AI · mobile-first ===== */
:root {
  --bg: #f7f6f8;
  --panel: #ffffff;
  --ink: #1c1a22;
  --muted: #6b6776;
  --line: #e5e1ea;
  --brand: #5C2A50;
  --brand-2: #7c3a6f;
  --accent: #F39C12;
  --bubble-user: #5C2A50;
  --bubble-user-ink: #ffffff;
  --bubble-agent: #efeaf2;
  --bubble-agent-ink: #1c1a22;
  --term-bg: #1c1a22;
  --term-ink: #d4cce0;
  --term-ok: #7ad19a;
  --term-warn: #f1c47a;
  --term-err: #ef8888;
  --shadow: 0 4px 18px rgba(20, 12, 30, .12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  height: 100dvh; overflow: hidden; }

button, input, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ===== Login page ===== */
.login-body { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: var(--panel); border-radius: 18px;
  padding: 28px; box-shadow: var(--shadow); }
.brand { text-align: center; margin-bottom: 20px; }
.brand-logo { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 14px;
  background: var(--brand); color: white; display: grid; place-items: center;
  font-weight: 700; letter-spacing: .5px; }
.brand h1 { margin: 0 0 4px; font-size: 20px; }
.btn { display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: white; cursor: pointer; text-decoration: none; color: inherit; }
.btn-google { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 600; }
.btn-secondary { background: #efeaf2; border-color: transparent; }

/* ===== App layout ===== */
.topbar { position: sticky; top: 0; height: 52px; background: var(--brand); color: white;
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding: 0 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15); z-index: 30; }
.topbar .title { text-align: center; font-weight: 600; letter-spacing: .3px; }
.iconbtn { background: transparent; border: 0; color: inherit; width: 40px; height: 40px;
  display: grid; place-items: center; border-radius: 10px; cursor: pointer; }
.iconbtn:active { background: rgba(255,255,255,.12); }

.chat { padding: 12px 12px 0; height: calc(100dvh - 52px - 64px - env(safe-area-inset-bottom));
  overflow-y: auto; scroll-behavior: smooth; }
.bubble { max-width: 85%; padding: 10px 12px; margin: 6px 0; border-radius: 14px;
  white-space: pre-wrap; word-wrap: break-word; }
.bubble.user { background: var(--bubble-user); color: var(--bubble-user-ink);
  margin-left: auto; border-bottom-right-radius: 4px; }
.bubble.agent { background: var(--bubble-agent); color: var(--bubble-agent-ink);
  margin-right: auto; border-bottom-left-radius: 4px; }
.bubble img { max-width: 100%; border-radius: 8px; display: block; }
.bubble .meta { font-size: 11px; opacity: .65; margin-top: 4px; }

.composer { display: grid; grid-template-columns: 44px 1fr 44px 44px; gap: 6px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--panel);
  border-top: 1px solid var(--line); }
.composer textarea { min-height: 40px; max-height: 140px; resize: none;
  border-radius: 12px; border: 1px solid var(--line); padding: 8px 10px;
  background: #faf7fb; }
.send-btn, .voice-btn, .upload-btn { color: var(--brand); border: 1px solid var(--line);
  background: #faf7fb; }
.voice-btn.recording { color: white; background: var(--accent); border-color: var(--accent); }

/* ===== Drawers ===== */
.drawer { position: fixed; top: 0; bottom: 0; width: min(360px, 90vw);
  background: var(--panel); box-shadow: var(--shadow); z-index: 40;
  transform: translateX(0); transition: transform .25s ease; display: flex; flex-direction: column; }
.drawer-left { left: 0; border-right: 1px solid var(--line); transform: translateX(-110%); }
.drawer-right { right: 0; border-left: 1px solid var(--line); transform: translateX(110%); }
.drawer.open { transform: translateX(0); }
.drawer header { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--line); background: var(--brand); color: white; }
.drawer header .iconbtn { color: white; }
.drawer-body { padding: 12px 14px; overflow-y: auto; flex: 1; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.user-row img { width: 36px; height: 36px; border-radius: 50%; }

.drawer-body h3 { margin: 14px 0 6px; font-size: 12px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted); }
.row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center;
  gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.row-icon { font-size: 18px; }
.row-label { font-size: 14px; }
.mini { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #faf7fb; cursor: pointer; }

/* ===== Switch ===== */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d6d0dd; border-radius: 22px;
  cursor: pointer; transition: background .15s; }
.switch span::before { content:""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px;
  background: white; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(16px); }

/* ===== Terminal ===== */
.term { background: var(--term-bg); color: var(--term-ink); font-family: ui-monospace, SFMono-Regular,
  Menlo, Consolas, monospace; font-size: 12px; padding: 8px; height: 100%;
  overflow-y: auto; white-space: pre; }
.term .l-info { color: var(--term-ink); }
.term .l-ok   { color: var(--term-ok); }
.term .l-warn { color: var(--term-warn); }
.term .l-err  { color: var(--term-err); }

/* ===== Action bar (bottom icons, controlled by toggles) ===== */
.actionbar { position: fixed; bottom: 56px; right: 8px; display: flex; flex-direction: column;
  gap: 8px; z-index: 25; }
.actionbar .pill { width: 44px; height: 44px; border-radius: 50%; background: var(--panel);
  border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; place-items: center;
  font-size: 18px; cursor: pointer; user-select: none; }

/* Backdrop when drawer open */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35;
  display: none; }
.backdrop.show { display: block; }

/* ===== Credential modal ===== */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45); z-index: 60; padding: 14px; }
.modal.open { display: flex; }
.modal-card { width: min(440px, 100%); background: var(--panel); border-radius: 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: 92dvh; overflow: hidden; }
.modal-card header { padding: 12px 14px; background: var(--brand); color: white;
  display: flex; justify-content: space-between; align-items: center; }
.modal-card header .iconbtn { color: white; }
.modal-body { padding: 14px; overflow-y: auto; }
.modal-body .field { margin-bottom: 10px; display: block; }
.modal-body .field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.modal-body .field input, .modal-body .field select, .modal-body .field textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #faf7fb; box-sizing: border-box; }
.modal-body .field .help { font-size: 11px; color: var(--muted); margin-top: 4px; }
.modal-card footer { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); justify-content: flex-end; }
.btn-primary { background: var(--brand); color: white; border-color: var(--brand); }
.btn-primary:active { background: var(--brand-2); }
.btn { width: auto; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: white; cursor: pointer; }
.cred-status { padding: 0 14px 12px; min-height: 20px; font-size: 12px; }
.cred-status.ok  { color: #1f7a3a; }
.cred-status.err { color: #b53737; }
.pill.configured { box-shadow: 0 0 0 2px #4caf50, var(--shadow); }
