/* AIBotForMe Unified Platform — Design System */
:root {
  --bg:       #F2F4F8;
  --bg2:      #FFFFFF;
  --bg3:      #E8ECF1;
  --bg4:      #D8DEE6;
  --border:   #D0D7E0;
  --text:     #1D2433;
  --text2:    #5A6578;
  --text3:    #8B95A5;
  --accent:   #3B82F6;
  --accent2:  #2563EB;
  --green:    #16A34A;
  --red:      #DC2626;
  --amber:    #CA8A04;
  --purple:   #7C3AED;
  --cyan:     #0891B2;
  --rail-w:   220px;
  --radius:   10px;
  --shadow:   0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

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

html, body { height: 100%; background: var(--bg); color: var(--text); font: 15px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

#app { min-height: 100vh; display: flex; flex-direction: column; }
#root { min-height: 100vh; display: flex; flex-direction: column; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); border: none;
  font-size: 14px; font-weight: 500; cursor: pointer; transition: all .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--accent2); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg4); }
.btn-ghost  { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg3); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-full { width: 100%; justify-content: center; }
.btn:hover { opacity: .85; }
.btn:active { transform: scale(.97); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px;
  padding: 9px 12px; outline: none; transition: border-color .15s; font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 90px; }
.form-help { font-size: 0.78rem; color: var(--text3); margin-top: 4px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.card-sm { padding: 16px; }
.card-title { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); margin-bottom: 10px; }
.card-sub   { font-size: 0.83rem; color: var(--text2); }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.container { max-width: 900px; margin: 0 auto; padding: 0 20px; }
.container-sm { max-width: 520px; margin: 0 auto; padding: 0 20px; }
.container-wide { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ── App Shell with Sidebar ──────────────────────────────────────────────── */
.app-shell { height: 100vh; display: flex; }
.main-layout { display: flex; width: 100%; height: 100vh; }
.app-layout { display: flex; width: 100%; height: 100vh; overflow: hidden; }

/* ── Sidebar nav ─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--rail-w); min-height: 100vh;
  background: var(--bg2); border-right: 1px solid var(--border);
  padding: 16px 8px; display: flex; flex-direction: column; flex-shrink: 0;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 16px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
}
.sidebar-brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.sidebar-brand-name { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar-footer { padding-top: 12px; border-top: 1px solid var(--border); margin-top: 8px; }
.sidebar-mode-widget { padding: 8px 12px 12px; border-top: 1px solid var(--border); margin-bottom: 4px; }
.smw-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.smw-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }
.smw-row .smw-active { color: var(--text); font-weight: 600; }
.switch.switch-sm { transform: scale(0.75); transform-origin: left; }

/* ── Nav section labels ──────────────────────────────────────────────────── */
.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted, #888);
  padding: 12px 8px 4px;
  display: block;
}
.nav-section-label:first-child { padding-top: 4px; }

.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; color: var(--text2);
  font-size: 14px; cursor: pointer; transition: all .12s;
}
.sidebar-link:hover, .sidebar-link.active { background: var(--bg3); color: var(--text); }
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Page area ───────────────────────────────────────────────────────────── */
.page-area { flex: 1; overflow-y: auto; padding: 28px 32px; }
.main-content { flex: 1; padding: 28px; overflow: auto; }
.page-header { margin-bottom: 24px; }
.page-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.page-sub   { color: var(--text2); font-size: 0.88rem; margin-bottom: 24px; }

/* ── Top nav (fallback/wizard mode) ─────────────────────────────────────── */
.topnav {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.topnav-brand { font-size: 1rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 10px; }
.topnav-brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.topnav-links { display: flex; gap: 4px; }
.nav-link { padding: 6px 12px; border-radius: 6px; color: var(--text2); font-size: 14px; cursor: pointer; }
.nav-link:hover, .nav-link.active { background: var(--bg3); color: var(--text); }
.topnav-right { display: flex; gap: 8px; align-items: center; }

/* ── Wizard ──────────────────────────────────────────────────────────────── */
.wizard-wrap {
  min-height: 100vh; display: flex; align-items: flex-start;
  justify-content: center; padding: 40px 20px;
}
.wizard-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; padding: 40px; width: 100%; max-width: 680px;
}
.wizard-step-label { font-size: 0.78rem; color: var(--accent); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 8px; }
.wizard-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.wizard-sub   { color: var(--text2); margin-bottom: 32px; font-size: 0.92rem; }
.wizard-progress { height: 4px; background: var(--bg3); border-radius: 2px; margin-bottom: 36px; }
.wizard-progress-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s; }
.wizard-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 32px; }

/* ── Connector tiles ─────────────────────────────────────────────────────── */
.connector-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
.connector-tile {
  background: var(--bg3); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 16px; cursor: pointer;
  transition: all .15s; display: flex; flex-direction: column; gap: 8px;
}
.connector-tile:hover { border-color: var(--accent); }
.connector-tile.selected { border-color: var(--accent); background: rgba(59,130,246,.08); }
.connector-tile.connected { border-color: var(--green); }
.connector-tile.error { border-color: var(--red); }
.connector-tile-name { font-size: 0.92rem; font-weight: 600; }
.connector-tile-desc { font-size: 0.78rem; color: var(--text2); line-height: 1.4; }
.connector-tile-status { font-size: 0.75rem; font-weight: 500; }
.connector-tile-status.ok   { color: var(--green); }
.connector-tile-status.err  { color: var(--red); }
.connector-tile-status.none { color: var(--text3); }

/* ── Capability tiles ────────────────────────────────────────────────────── */
.cap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cap-tile {
  background: var(--bg3); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 18px; cursor: pointer; transition: all .15s;
}
.cap-tile:hover { border-color: var(--accent); }
.cap-tile.selected { border-color: var(--accent); background: rgba(59,130,246,.08); }
.cap-tile-title { font-weight: 600; margin-bottom: 4px; font-size: 0.92rem; }
.cap-tile-desc  { font-size: 0.8rem; color: var(--text2); }

/* ── Platform choice ─────────────────────────────────────────────────────── */
.platform-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.platform-tile {
  background: var(--bg3); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 24px 16px;
  cursor: pointer; text-align: center; transition: all .15s;
}
.platform-tile:hover { border-color: var(--accent); }
.platform-tile.selected { border-color: var(--accent); background: rgba(59,130,246,.08); }
.platform-tile-icon { font-size: 2rem; margin-bottom: 10px; }
.platform-tile-name { font-weight: 600; font-size: 0.95rem; }
.platform-tile-desc { font-size: 0.78rem; color: var(--text2); margin-top: 4px; }

/* ── Grid layouts ────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 900px) { .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-2, .cap-grid, .platform-grid, .grid-3 { grid-template-columns: 1fr; } }

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-label { font-size: 0.78rem; color: var(--text2); margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-value.cyan { color: var(--cyan); }
.stat-value.purple { color: var(--purple); }
.stat-value.green { color: var(--green); }
.stat-value.amber { color: var(--amber); }

/* ── Status pill ─────────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 3px 10px; font-size: 0.75rem; font-weight: 600; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.live { background: rgba(63,185,80,.12); color: var(--green); }
.pill.testing { background: rgba(210,153,34,.12); color: var(--amber); }
.pill.pending { background: rgba(248,81,73,.12); color: var(--red); }
.pill.approved { background: rgba(63,185,80,.12); color: var(--green); }

/* ── Chat ────────────────────────────────────────────────────────────────── */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 56px - 56px); }
.chat-log  { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.bubble { max-width: 75%; padding: 12px 16px; border-radius: 12px; font-size: 0.92rem; line-height: 1.5; }
.bubble.user      { background: var(--accent2); align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.assistant { background: var(--bg3); align-self: flex-start; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble-sources { font-size: 0.72rem; color: var(--text3); margin-top: 6px; }
.bubble-time { font-size: 0.7rem; color: var(--text3); margin-top: 4px; }
.chat-input-row { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.chat-input { flex: 1; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 10px 14px; font-size: 14px; outline: none; }
.chat-input:focus { border-color: var(--accent); }

/* ── Connector health badges ─────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-green  { background: rgba(63,185,80,.15); color: var(--green); }
.badge-red    { background: rgba(248,81,73,.15);  color: var(--red); }
.badge-amber  { background: rgba(210,153,34,.15); color: var(--amber); }
.badge-gray   { background: var(--bg3); color: var(--text3); border: 1px solid var(--border); }

/* ── Auth page ───────────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 40px; width: 100%; max-width: 420px; }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-mark { width: 44px; height: 44px; background: var(--accent2); border-radius: 12px; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.auth-title { font-size: 1.25rem; font-weight: 700; text-align: center; margin-bottom: 4px; }
.auth-sub   { text-align: center; color: var(--text2); font-size: 0.85rem; margin-bottom: 28px; }

/* ── Connect login screen ────────────────────────────────────────────────── */
.login-screen { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 100; }
.login-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 40px 36px; width: 360px; text-align: center; box-shadow: var(--shadow); }
.login-logo { display: flex; gap: 8px; justify-content: center; margin-bottom: 20px; }
.login-card h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.login-sub { color: var(--text2); margin-bottom: 28px; font-size: 0.9rem; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; color: var(--text); font-size: 0.95rem; outline: none; transition: border .15s; }
.login-card input:focus { border-color: var(--cyan); }
.login-error { color: var(--red); font-size: 0.85rem; margin-top: 4px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast-area, #toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 18px; font-size: 14px;
  box-shadow: var(--shadow); animation: slideIn .2s ease; min-width: 220px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.section-label { font-size: 0.78rem; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.empty { text-align: center; padding: 60px 20px; color: var(--text3); font-size: 0.92rem; }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; }
.empty h3 { color: var(--text2); font-size: 1rem; margin-bottom: 6px; }
.empty p { font-size: 0.85rem; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.section-gap { margin-bottom: 24px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap { display: flex; gap: 10px; align-items: center; }
.mt-16 { margin-top: 16px; }
.text-sm { font-size: 0.8rem; color: var(--text2); }

/* ── Ollama status ───────────────────────────────────────────────────────── */
.ollama-status { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); }
.status-dot.up { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.down { background: var(--red); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
td { padding: 12px 14px; border-bottom: 1px solid rgba(0,0,0,.06); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,.03); }
.row-link { cursor: pointer; }

/* ── Info banner ─────────────────────────────────────────────────────────── */
.info-banner { background: rgba(59,130,246,.06); border: 1px solid rgba(59,130,246,.15); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 14px 18px; font-size: 0.875rem; color: var(--text2); line-height: 1.6; }
.info-banner strong { color: var(--text); }

/* ── Getting started steps ───────────────────────────────────────────────── */
.steps { display: flex; flex-direction: column; gap: 12px; }
.step { display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px; background: var(--bg3); border-radius: 8px; border: 1px solid var(--border); }
.step-num { width: 28px; height: 28px; border-radius: 50%; background: var(--cyan); color: #000; font-size: 0.8rem; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-body strong { display: block; font-size: 0.9rem; color: var(--text); margin-bottom: 2px; }
.step-body span { font-size: 0.82rem; color: var(--text2); }

/* ── Queue cards ─────────────────────────────────────────────────────────── */
.queue-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.queue-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.queue-contact { font-weight: 600; font-size: 0.95rem; }
.queue-tenant { font-size: 0.75rem; color: var(--cyan); margin-top: 2px; }
.queue-time { font-size: 0.75rem; color: var(--text3); }
.queue-inbound { background: var(--bg3); border-radius: 7px; padding: 10px 12px; font-size: 0.875rem; color: var(--text2); margin-bottom: 10px; }
.queue-inbound-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); margin-bottom: 4px; }
.queue-draft-wrap { position: relative; }
.queue-draft { width: 100%; background: rgba(59,130,246,.06); border: 1px solid rgba(59,130,246,.20); border-radius: 7px; padding: 10px 12px; color: var(--text); font-size: 0.9rem; resize: vertical; min-height: 64px; font-family: inherit; outline: none; }
.queue-draft:focus { border-color: var(--accent); }
.queue-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ── Playground ──────────────────────────────────────────────────────────── */
.playground-wrap { display: grid; grid-template-columns: 320px 1fr; gap: 20px; height: calc(100vh - 140px); }
.playground-config { overflow-y: auto; }
.playground-chat { display: flex; flex-direction: column; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.playground-messages { flex: 1; overflow-y: auto; padding: 20px; }
.playground-input { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); background: var(--bg3); }
.playground-input input { flex: 1; background: var(--bg2); border: 1px solid var(--border); border-radius: 7px; padding: 9px 12px; color: var(--text); font-size: 0.9rem; outline: none; }
.playground-input input:focus { border-color: var(--cyan); }

/* ── Client detail tabs ──────────────────────────────────────────────────── */
.back-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--text2); font-size: 0.85rem; cursor: pointer; margin-bottom: 20px; }
.back-btn:hover { color: var(--text); }
.tabs { display: flex; gap: 4px; margin-bottom: 22px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab { padding: 9px 16px; border: none; background: transparent; color: var(--text2); font-size: 0.875rem; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s; }
.tab.active { color: var(--cyan); border-bottom-color: var(--cyan); }
.tab:hover { color: var(--text); }

/* ── Upload zone ─────────────────────────────────────────────────────────── */
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--cyan); background: rgba(68,215,255,.04); }
.upload-zone p { color: var(--text2); font-size: 0.875rem; margin-top: 10px; }

/* ── Toggle switch ───────────────────────────────────────────────────────── */
.mode-toggle { display: flex; align-items: center; gap: 10px; }
.mode-toggle label { font-size: 0.85rem; color: var(--text2); }
.switch { position: relative; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--bg3); border: 1px solid var(--border); border-radius: 24px; cursor: pointer; transition: background .2s; }
.slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: var(--text3); border-radius: 50%; transition: transform .2s, background .2s; }
input:checked + .slider { background: rgba(63,185,80,.2); border-color: var(--green); }
input:checked + .slider::before { transform: translateX(20px); background: var(--green); }

/* ── Conn cards ──────────────────────────────────────────────────────────── */
.conn-card { transition: transform .12s; }
.conn-card:hover { transform: translateY(-2px); }
.oauth-connect-btn {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
  cursor: pointer; transition: all .15s; width: 100%; margin-bottom: 10px;
}
.oauth-connect-btn:hover { border-color: var(--accent); background: var(--bg4); }
.oauth-connect-btn.connected { border-color: var(--green); }
.oauth-connect-btn .btn-label { flex: 1; text-align: left; }
.oauth-connect-btn .btn-label strong { display: block; font-size: 0.93rem; }
.oauth-connect-btn .btn-label span  { font-size: 0.78rem; color: var(--text2); }
.oauth-connect-btn .status { font-size: 0.8rem; font-weight: 600; }
.oauth-connect-btn .status.ok  { color: var(--green); }
.oauth-connect-btn .status.no  { color: var(--text3); }
.oauth-big-btn {
  background: var(--bg3); border: 2px solid var(--border);
  border-radius: 12px; padding: 24px 20px; cursor: pointer;
  text-align: center; transition: all .15s; min-width: 180px;
  display: flex; flex-direction: column; align-items: center;
}
.oauth-big-btn:hover { border-color: var(--accent); }
.oauth-big-btn.connected { border-color: var(--green); }

/* ── Wizard logo tiles ───────────────────────────────────────────────────── */
.wiz-logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 16px; }
.wiz-logo-tile {
  background: var(--bg3); border: 2px solid var(--border);
  border-radius: 12px; padding: 20px 14px; cursor: pointer;
  text-align: center; transition: all .15s;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.wiz-logo-tile:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.wiz-logo-tile.selected { border-color: var(--accent); background: rgba(59,130,246,.1); }
.wiz-logo-tile.connected { border-color: var(--green); }
.wiz-logo-icon { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; }
.wiz-logo-name { font-weight: 700; font-size: 0.88rem; }
.wiz-logo-desc { font-size: 0.75rem; color: var(--text2); line-height: 1.4; }

/* ── Social Calendar ─────────────────────────────────────────────────────── */
.social-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-header {
  background: var(--bg2); text-align: center;
  font-size: 0.72rem; font-weight: 600; color: var(--text3);
  padding: 6px 0; text-transform: uppercase; letter-spacing: .04em;
}
.cal-cell {
  background: var(--bg);
  min-height: 72px; padding: 6px 8px; cursor: pointer;
  transition: background .1s; position: relative;
}
.cal-cell:hover { background: var(--bg2); }
.cal-cell.cal-empty { background: var(--bg2); cursor: default; }
.cal-cell.cal-today .cal-day-num {
  background: var(--accent); color: #000; border-radius: 50%;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.cal-day-num { font-size: 0.78rem; color: var(--text2); margin-bottom: 4px; line-height: 22px; }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 6px; color: white; transition: transform .1s; }
.cal-dot:hover { transform: scale(1.4); }

/* ── Momentum ────────────────────────────────────────────────────────────── */
.mo-layout { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: flex-start; }
@media (max-width: 900px) { .mo-layout { grid-template-columns: 1fr; } }
.mo-push-card {
  background: linear-gradient(135deg, #E8ECF1 0%, #F2F4F8 100%);
  border: 1px solid var(--border); border-radius: 14px; padding: 20px;
  margin-bottom: 20px; position: relative; overflow: hidden;
}
.mo-push-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #3B82F6, #7C3AED, #16A34A);
}
.mo-push-header { display: flex; align-items: center; justify-content: space-between; font-size: 0.8rem; font-weight: 600; color: var(--text2); margin-bottom: 12px; text-transform: uppercase; letter-spacing: .04em; }
.mo-push-text { font-size: 0.97rem; line-height: 1.65; color: var(--text); margin-bottom: 12px; }
.mo-affirmation { font-size: 0.85rem; color: var(--purple); font-style: italic; line-height: 1.5; padding: 10px 12px; background: rgba(124,58,237,.06); border-left: 3px solid var(--purple); border-radius: 0 6px 6px 0; margin-bottom: 10px; }
.mo-challenge { font-size: 0.84rem; color: var(--text2); line-height: 1.5; padding: 10px 12px; background: rgba(59,130,246,.06); border-radius: 8px; }
.mo-challenge-label { display: block; font-size: 0.72rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.mo-goal-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; transition: border-color .15s; }
.mo-goal-card:hover { border-color: var(--accent); }
.mo-progress-track { height: 5px; background: var(--bg4); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.mo-progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 3px; transition: width .3s; }
.mo-progress-slider { width: 100%; height: 4px; -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; outline: none; }
.mo-progress-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
.mo-right { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; height: calc(100vh - 180px); min-height: 480px; position: sticky; top: 72px; }
.mo-chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; margin-bottom: 12px; }
.mo-style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.mo-style-tile { background: var(--bg3); border: 2px solid var(--border); border-radius: 12px; padding: 18px 14px; cursor: pointer; text-align: center; transition: all .15s; }
.mo-style-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.mo-style-tile.selected { border-color: var(--accent); background: rgba(59,130,246,.1); }
.mo-style-emoji { font-size: 1.8rem; margin-bottom: 8px; }
.mo-style-name  { font-weight: 700; font-size: 0.88rem; margin-bottom: 4px; }
.mo-style-desc  { font-size: 0.75rem; color: var(--text2); line-height: 1.4; }

/* ── Layout: right-col + topbar ─────────────────────────────────────────────── */
.right-col { display: flex; flex-direction: column; flex: 1; min-width: 0; overflow: hidden; }
.app-topbar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 52px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.main-content { flex: 1; padding: 28px; overflow-y: auto; min-height: 0; }
.topbar-client-name {
  font-size: .82rem; color: var(--text2); font-weight: 500;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-mode-row { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text2); }
.topbar-mode-active { color: var(--text); font-weight: 600; }
#topbar-tenant-select {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 4px 8px; font-size: .82rem;
}

/* ── Usage & billing tables ──────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.data-table th {
  text-align: left; color: var(--text3); font-weight: 500;
  padding: 6px 8px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 7px 8px; border-bottom: 1px solid var(--bg3); color: var(--text2); }
.data-table tr:last-child td { border-bottom: none; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Usage bar chart ─────────────────────────────────────────────────────────── */
.usage-chart { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.usage-bar-row { display: flex; align-items: center; gap: 10px; }
.usage-bar-label { width: 40px; font-size: .75rem; color: var(--text3); flex-shrink: 0; }
.usage-bar-track { flex: 1; background: var(--bg3); border-radius: 3px; height: 12px; }
.usage-bar-fill { height: 100%; background: var(--accent2, #6366f1); border-radius: 3px; min-width: 2px; }
.usage-bar-val { width: 72px; font-size: .75rem; color: var(--text2); text-align: right; flex-shrink: 0; }

/* ── Draft / queued message bubble ──────────────────────────────────────────── */
.bubble-draft { border: 2px dashed var(--border) !important; opacity: .75; }
.bubble-draft-label {
  font-size: .7rem; color: var(--text3);
  display: block; margin-top: 2px;
}

/* ── Contact modal tab ────────────────────────────────────────────────────────── */
.cd-tab-btn:hover { color: var(--text) !important; background: var(--bg3); }

/* ── Today Page ─────────────────────────────────────────────────────────────── */
.today-section { margin-bottom: 28px; }
.today-section-title { font-size: 0.72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text3); margin-bottom: 12px; }
.today-briefing-body { font-size: 0.93rem; line-height: 1.7; color: var(--text); white-space: pre-wrap; }
.today-queue-mini { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 8px; }
.today-schedule-row { display: flex; gap: 14px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.today-schedule-row:last-child { border-bottom: none; }
.today-ai-stat { font-size: 2.5rem; font-weight: 700; color: var(--text); line-height: 1; }
.today-skeleton { height: 18px; background: var(--bg3); border-radius: 4px; animation: skeleton-pulse 1.4s ease-in-out infinite; margin-bottom: 8px; }
@keyframes skeleton-pulse { 0%,100%{opacity:.5} 50%{opacity:1} }

/* ── Collapsed Navigation (Phase 3) ─────────────────────────────────────────── */
.nav-primary-link { font-size: 1rem; font-weight: 600; padding: 10px 14px; }
.nav-more-toggle { border: none; }
.nav-more-toggle summary.nav-more-summary { font-size: 0.78rem; color: var(--text3); padding: 8px 14px; cursor: pointer; list-style: none; user-select: none; }
.nav-more-toggle summary.nav-more-summary::-webkit-details-marker { display: none; }
.nav-more-content { padding-left: 4px; }
.nav-settings-section { margin-top: auto; border-top: 1px solid var(--border); padding-top: 8px; }
.nav-settings-indicator { font-size: 0.78rem; color: var(--text3); padding: 8px 14px; cursor: pointer; }
.nav-settings-indicator:hover { color: var(--text2); }
.nav-settings-content .nav-link { font-size: 0.82rem; }

/* ── Milestone Cards (Phase 4) ───────────────────────────────────────────────── */
.today-milestone-card { border-left: 3px solid #f5a623; background: rgba(245,166,35,.08); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
.today-milestone-card .milestone-title { font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; color: var(--text); }

/* ── Chat Chips (Phase 5) ────────────────────────────────────────────────────── */
.chat-chips-row { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 12px; scrollbar-width: none; }
.chat-chips-row::-webkit-scrollbar { display: none; }
.chat-chip { background: transparent; border: 1px solid var(--border); color: var(--text2); border-radius: 20px; padding: 6px 14px; font-size: 0.82rem; cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: border-color .15s, color .15s; }
.chat-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ── Tab buttons (shared) ───────────────────────────────────────────────────── */
.tab-btn { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text3); padding: 8px 16px; cursor: pointer; font-size: 0.88rem; font-weight: 500; transition: color .15s, border-color .15s; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover { color: var(--text); }

/* ── Firecrawl ───────────────────────────────────────────────────────────────── */
.fc-result { background:var(--bg2);border:1px solid var(--border);border-radius:8px;padding:16px;margin-top:16px;max-height:500px;overflow:auto;font-family:'SF Mono',monospace;font-size:0.82rem;white-space:pre-wrap;word-break:break-word }
.fc-actions { display:flex;gap:8px;margin-top:8px }
.fc-url-list { list-style:decimal;padding-left:24px;font-size:0.85rem;line-height:1.8 }
.fc-url-list a { color:var(--accent);text-decoration:none }
.fc-url-list a:hover { text-decoration:underline }

/* ── Unified Conversation Layout ────────────────────────────────────────── */
.unified-layout {
  display: grid;
  grid-template-columns: 240px 1fr 220px;
  height: calc(100vh - 60px);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
}

.unified-contacts-panel {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  overflow: hidden;
}

.unified-contacts-header {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.unified-contacts-list {
  flex: 1;
  overflow-y: auto;
}

.unified-contact-item {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  align-items: center;
}
.unified-contact-item:hover { background: var(--bg3); }
.unified-contact-item.selected { background: var(--bg3); border-left: 3px solid var(--cyan); }

.unified-contact-checkbox {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 18px;
}
.cm-item:hover { background: var(--bg3); }

.unified-contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text2);
  flex-shrink: 0;
}

.unified-contact-info { flex: 1; min-width: 0; }
.unified-contact-name { font-weight: 600; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unified-contact-preview { font-size: 0.78rem; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

.unified-contact-meta { text-align: right; flex-shrink: 0; }
.unified-contact-time { font-size: 0.7rem; color: var(--text3); }
.unified-contact-channels { display: flex; gap: 3px; justify-content: flex-end; margin-top: 3px; }

.channel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* Thread Panel */
.unified-thread-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

.unified-thread-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text3);
  text-align: center;
}
.unified-thread-empty h3 { color: var(--text2); margin: 0 0 8px; }
.unified-thread-empty p { font-size: 0.85rem; }

.unified-thread-header {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.unified-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #fff;
}

.unified-compose-area {
  border-top: 1px solid var(--border);
  padding: 8px 14px;
}

.channel-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.channel-tab {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  transition: all 0.15s;
}
.channel-tab:hover { background: var(--bg3); }
.channel-tab.active { background: var(--cyan); color: #fff; border-color: var(--cyan); }

.unified-compose-row {
  display: flex;
  gap: 8px;
}

.unified-compose-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}

.channel-badge-inline {
  font-size: 0.7rem;
  font-weight: 600;
}

/* iPhone-style message bubbles */
.bubble.imessage-out { background: #007AFF; color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.imessage-out .bubble-time { color: rgba(255,255,255,.65); }
.bubble.sms-out { background: #34C759; color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.sms-out .bubble-time { color: rgba(255,255,255,.65); }
.bubble.whatsapp-out { background: #25D366; color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.whatsapp-out .bubble-time { color: rgba(255,255,255,.65); }
.bubble.email-out { background: #5A6978; color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.email-out .bubble-time { color: rgba(255,255,255,.65); }
.bubble.inbound { background: #E9E9EB; color: #1c1c1e; align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.inbound .bubble-time { color: #8e8e93; }

/* Activity Panel */
.unified-activity-panel {
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  overflow: hidden;
}

.unified-activity-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.unified-activity-body {
  flex: 1;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.activity-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; }
.activity-content { flex: 1; min-width: 0; }
.activity-title { font-size: 0.82rem; font-weight: 500; }
.activity-detail { font-size: 0.75rem; color: var(--text2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.activity-time { font-size: 0.7rem; color: var(--text3); margin-top: 3px; }

/* Notification Bell */
.notif-bell-wrap {
  position: relative;
  margin-left: 12px;
}

.notif-bell-btn {
  position: relative;
  padding: 6px;
}

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--red);
  color: #fff;
  font-size: 0.65rem;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.notif-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 340px;
  max-height: 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  z-index: 300;
  overflow: hidden;
}

.notif-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.notif-dropdown-body {
  overflow-y: auto;
  max-height: 360px;
}

.notif-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  align-items: flex-start;
}
.notif-item:hover { background: var(--bg3); }
.notif-icon { font-size: 1.2rem; flex-shrink: 0; }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 0.82rem; font-weight: 500; }
.notif-preview { font-size: 0.75rem; color: var(--text2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-time { font-size: 0.7rem; color: var(--text3); margin-top: 3px; }

/* Responsive: collapse activity panel on medium screens */
@media (max-width: 1100px) {
  .unified-layout { grid-template-columns: 220px 1fr; }
  .unified-activity-panel { display: none; }
}
@media (max-width: 768px) {
  .unified-layout { grid-template-columns: 1fr; }
  .unified-contacts-panel { max-height: 200px; }
}
