:root {
  --bg: #f2f3fa;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e8eaf3;
  --border-soft: #eef0f7;
  --text: #171a26;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-soft: #eef0fe;
  --grad: linear-gradient(135deg, #6366f1, #8b5cf6);
  --grad-hover: linear-gradient(135deg, #5b5ef0, #7c4ff0);
  --green: #059669;
  --green-soft: #e7f6ef;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --red: #dc2626;
  --red-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 6px 20px rgba(26,24,75,.06);
  --shadow-lg: 0 16px 40px rgba(26,24,75,.13);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  background-image: radial-gradient(900px 480px at 100% -5%, #eae7fb 0%, rgba(234,231,251,0) 55%),
                    radial-gradient(760px 420px at -5% 0%, #e6ecfb 0%, rgba(230,236,251,0) 50%); }
h1,h2,h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Buttons ---------- */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 14px;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease; }
.btn:hover { background: var(--surface-2); border-color: #dcdfec; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--grad); border: none; color: #fff; box-shadow: 0 5px 16px rgba(79,70,229,.30); }
.btn-primary:hover { background: var(--grad-hover); transform: translateY(-1px); box-shadow: 0 9px 22px rgba(79,70,229,.40); }
.btn-primary:disabled { background: #c9cbe0; box-shadow: none; transform: none; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; transform: none; }
.btn-block { width: 100%; display: block; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
  background: #fbfbfe; color: var(--text); outline: none; transition: .15s; font-family: inherit; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary);
  background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }

.alert { padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 13.5px; }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-ok { background: var(--green-soft); color: var(--green); }
/* Needs attention but nothing is broken yet — e.g. a lapsed subscription still in grace. */
.alert-warn { background: var(--amber-soft); color: var(--amber); }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 50% -10%, #e9ecfb, var(--bg)); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand h1 { font-size: 22px; margin-top: 12px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--grad); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 15px; box-shadow: 0 6px 16px rgba(99,102,241,.35); }
.brand-mark.lg { width: 56px; height: 56px; font-size: 20px; margin: 0 auto; border-radius: 16px; }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: 256px minmax(0, 1fr); height: 100vh; }
/* Premium dark rail: a deep indigo gradient with a soft violet glow up top.
   Reads as a high-end console against the light content area. All text colours
   inside the sidebar are overridden below for contrast on the dark surface. */
.sidebar {
  background:
    radial-gradient(130% 78% at 12% -8%, rgba(139,92,246,.26), rgba(139,92,246,0) 55%),
    linear-gradient(185deg, #211d44 0%, #1a1733 55%, #17142b 100%);
  border-right: 1px solid rgba(255,255,255,.06);
  padding: 18px 14px; display: flex; flex-direction: column;
  box-shadow: 24px 0 60px -30px rgba(20,18,48,.45); }
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 6px 18px;
  margin-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-text { min-width: 0; }   /* lets a long name shrink instead of shoving the bell out */
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -.01em; color: #fff; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,.5); }

/* ---------- Alerts bell (platform owner) ---------- */
.bell-wrap { position: relative; margin-left: auto; }
.bell-btn { position: relative; display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid rgba(255,255,255,.14); border-radius: 10px; background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.72); cursor: pointer; transition: .15s; }
.bell-btn:hover { color: #fff; border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.12); }
.bell-dot { position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--red); color: #fff; font-size: 10px; font-weight: 800;
  line-height: 16px; text-align: center; box-shadow: 0 0 0 2px #1a1733; }
/* Opens rightward, over the content: the panel is wider than the 256px sidebar,
   so anchoring it to the bell's right edge would push it off-screen. */
.bell-pop { position: absolute; top: 40px; left: -4px; z-index: 60; width: 268px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0,0,0,.16); overflow: hidden; }
.bell-pop-head { padding: 10px 12px; font-size: 11px; font-weight: 800; letter-spacing: .4px;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
.bell-empty { padding: 14px 12px; font-size: 12.5px; color: var(--muted); }
.bell-item { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0;
  border-bottom: 1px solid var(--border); background: none; cursor: pointer; font-size: 13px;
  color: var(--text); }
.bell-item:last-child { border-bottom: 0; }
.bell-item:hover { background: var(--surface-2); }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px;
  color: rgba(255,255,255,.62); font-weight: 600; font-size: 13.5px; position: relative; transition: .16s; }
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.active { color: #fff;
  background: linear-gradient(90deg, rgba(139,92,246,.30), rgba(99,102,241,.12));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.09); }
.nav-link.active::before { content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--grad);
  box-shadow: 0 0 12px 1px rgba(139,92,246,.6); }
.nav-ic { display: inline-flex; align-items: center; justify-content: center; width: 20px; color: currentColor; opacity: .7; transition: opacity .16s; }
.nav-link:hover .nav-ic, .nav-link.active .nav-ic { opacity: 1; }
.signout-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  color: rgba(255,255,255,.72); }
.signout-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 8px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07); border-radius: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: #fff;
  display: grid; place-items: center; font-weight: 700; box-shadow: 0 4px 12px rgba(99,102,241,.4); }
.user-name { font-weight: 600; font-size: 13px; color: #fff; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
  padding: 1px 7px; border-radius: 20px; display: inline-block; }
.role-admin { background: var(--primary-soft); color: var(--primary); }
.role-manager { background: var(--amber-soft); color: var(--amber); }
.role-sales { background: var(--green-soft); color: var(--green); }

.content { overflow-y: auto; padding: 30px 36px; min-width: 0; }
/* Super-admin "viewing a tenant" banner + the pick-a-company gate. */
.viewing-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 18px; padding: 10px 16px; border-radius: 12px;
  background: linear-gradient(90deg, var(--primary-soft), rgba(238,240,254,.35));
  border: 1px solid var(--primary-soft); color: var(--text); font-size: 13.5px; }
.tenant-gate { max-width: 460px; margin: 8vh auto 0; text-align: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow); }
.tenant-gate-emoji { font-size: 40px; line-height: 1; }
.tenant-gate h3 { margin: 12px 0 6px; }
.tenant-gate p { margin: 0 0 18px; }
.page, .query-page { max-width: 980px; margin: 0 auto; }
.page-head { margin-bottom: 22px; }
.page-head h2 { font-size: 24px; letter-spacing: -.02em; }
.page-head p { margin: 5px 0 0; color: var(--muted); font-size: 13.5px; }

/* ---------- Query / chat ---------- */
.query-page { display: flex; flex-direction: column; height: 100%; max-width: 860px; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 4px 2px 12px; }
.empty-state { text-align: center; color: var(--muted); padding: 48px 0; }
.empty-emoji { font-size: 40px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 7px 14px;
  font-size: 13px; cursor: pointer; color: var(--text); }
.chip:hover { border-color: var(--primary); color: var(--primary); }

.turn { margin-bottom: 22px; }
.user-bubble { background: var(--primary); color: #fff; padding: 10px 15px; border-radius: 14px 14px 4px 14px;
  display: inline-block; max-width: 80%; font-weight: 500; margin-left: auto; float: right; clear: both; }
.answer { clear: both; background: var(--surface); border: 1px solid var(--border); border-radius: 4px 14px 14px 14px;
  padding: 16px 18px; margin-top: 10px; box-shadow: var(--shadow); }
.answer-empty { border-style: dashed; color: var(--muted); }
.loading-answer { color: var(--muted); }
.answer-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.handler-chip { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.handler-database { background: var(--green-soft); color: var(--green); }
.handler-rag { background: var(--amber-soft); color: var(--amber); }
.handler-llm { background: var(--primary-soft); color: var(--primary); }
.handler-memory { background: #eef2ff; color: #6366f1; }
.handler-fuzzy { background: var(--amber-soft); color: var(--amber); }
.handler-limit { background: var(--red-soft); color: var(--red); }
.handler-cached { background: var(--green-soft); color: var(--green); }
.handler-unverified { background: var(--red-soft); color: var(--red); font-weight: 700; }
.unverified-note { background: var(--red-soft); color: var(--red); font-size: 12.5px;
  padding: 9px 12px; border-radius: 8px; margin-bottom: 12px; border: 1px solid rgba(220,38,38,.25); }
.resolution-note { background: var(--amber-soft); color: var(--amber); font-size: 12.5px; font-weight: 600;
  padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }

.conf-badge { margin-left: auto; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
.conf-high { background: var(--green-soft); color: var(--green); }
.conf-mid { background: var(--amber-soft); color: var(--amber); }
.conf-low { background: var(--red-soft); color: var(--red); }

/* ---------- Blocks ---------- */
.block { margin-bottom: 16px; }
.block:last-child { margin-bottom: 0; }
.block-title { font-weight: 700; font-size: 13px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .03em; margin-bottom: 8px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); }
.data-table th { text-align: left; padding: 11px 14px; background: #f7f8fc; color: var(--muted);
  font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: #f8f9fe; }
.data-table tr:last-child td { border-bottom: none; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.info-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--surface); }
.info-card-head { font-weight: 700; font-size: 15px; }
.info-card-sub { color: var(--muted); font-size: 12.5px; margin: 3px 0 8px; }
.info-card-list { margin: 0; padding-left: 16px; }
.info-card-list li { margin: 3px 0; }

.timeline { border-left: 2px solid var(--border); margin-left: 6px; padding-left: 16px; }
.timeline-item { position: relative; padding: 6px 0; }
.timeline-dot { position: absolute; left: -23px; top: 11px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--surface); }
.timeline-label { font-size: 12px; color: var(--muted); }
.timeline-value { font-weight: 600; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: none; }
.check { color: var(--green); font-weight: 800; margin-right: 6px; }
.para { margin: 0; }
.char-count { text-align: right; font-size: 12px; margin: 0 6px 4px; }
.apikey-reveal { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.apikey-reveal code { background: var(--surface-2, #eef1f6); padding: 6px 10px; border-radius: 6px;
  font-size: 13px; word-break: break-all; }

/* Integrations */
.int-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
  margin: 14px 0 20px; }
.int-card { text-align: left; background: var(--card, #fff); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 4px;
  transition: border-color .15s, box-shadow .15s; }
.int-card:hover { border-color: var(--primary); }
.int-card-active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.int-ico { font-size: 24px; }
.int-name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.int-soon { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: #8a6d00; background: #fff2cc; border: 1px solid #f0d98a; border-radius: 999px; padding: 1px 7px; }
.int-blurb { font-size: 12.5px; color: var(--muted); }
.int-guide-wrap { border-top: 1px solid var(--border); padding-top: 16px; }
.int-guide-wrap h3 { margin: 0 0 14px; }
.int-guide { display: flex; flex-direction: column; gap: 16px; }
.wa-opts { display: flex; gap: 12px; flex-wrap: wrap; }
.wa-opt { display: flex; align-items: center; gap: 12px; text-align: left; border: 1.5px solid var(--border); border-radius: 12px; padding: 14px 16px; background: #fff; cursor: pointer; min-width: 220px; flex: 1; transition: border-color .15s, box-shadow .15s; }
.wa-opt.on { border-color: #6b46ff; box-shadow: 0 0 0 3px rgba(107, 70, 255, .14); }
.wa-opt .wa-ico { font-size: 24px; }
.wa-opt .wa-txt { display: flex; flex-direction: column; }
.wa-opt b { font-size: 14px; }
.int-step { display: flex; gap: 12px; }
.int-step-n { flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff;
  font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.int-step-body { flex: 1; min-width: 0; }
.int-step-body p { margin: 4px 0 0; }
.int-note { background: var(--surface, #f6f7fb); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; font-size: 13px; color: var(--muted); }
.code-block { position: relative; margin: 8px 0; }
.code-block pre { background: #1e2230; color: #e6e8ef; border-radius: 10px; padding: 14px; overflow-x: auto;
  font-size: 12.5px; line-height: 1.5; margin: 0; }
.code-block .btn { position: absolute; top: 8px; right: 8px; }
.int-greeting { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-top: 4px; }
.int-greeting p { margin: 4px 0 10px; }
.int-greeting textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; resize: vertical; margin-bottom: 10px; box-sizing: border-box; }

/* ---- 🤖 Assistant → Identity & Persona: form on the left, live preview on the right ---- */
.as-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .as-grid { grid-template-columns: minmax(0, 1fr); } }
.as-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.as-block { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface); }
.as-block .field { margin: 0; }
.as-block textarea { width: 100%; box-sizing: border-box; resize: vertical; }
.as-tag { font-size: 10px; font-weight: 700; letter-spacing: .3px; margin-left: 8px; padding: 2px 7px;
  border-radius: 999px; background: var(--primary-soft); color: var(--primary); text-transform: none; }

/* The preview follows you down the page — the point is to watch it change as you type. */
.as-preview { position: sticky; top: 12px; }
.as-prev-panel { border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  background: var(--surface); box-shadow: 0 10px 30px rgba(0, 0, 0, .10); }
.as-prev-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff; }
.as-prev-av { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255, 255, 255, .25) center/cover no-repeat; display: flex;
  align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: #fff; }
.as-prev-name { font-weight: 700; font-size: 14px; line-height: 1.2; }
.as-prev-status { font-size: 11px; opacity: .85; margin-top: 2px; }
.as-prev-body { padding: 14px; background: var(--surface-2); min-height: 110px; }
.as-prev-bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px;
  padding: 10px 12px; font-size: 13px; line-height: 1.5; color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Rendered LLM markdown (summary / general-knowledge answers). */
.markdown-body { font-size: 14.5px; line-height: 1.65; color: var(--text); }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0 0 10px; }
.markdown-body strong { font-weight: 700; color: var(--text); }
.markdown-body ul, .markdown-body ol { margin: 8px 0 10px; padding-left: 20px; }
.markdown-body li { margin: 4px 0; }
.markdown-body li::marker { color: var(--primary); }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  font-size: 15px; font-weight: 700; margin: 12px 0 6px; }
.markdown-body a { color: var(--primary); text-decoration: underline; }
.markdown-body code { background: var(--surface-2, #eef1f6); padding: 1px 5px; border-radius: 5px;
  font-size: 13px; }
.markdown-body blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--border);
  color: var(--muted); }

/* ---------- Citations ---------- */
.citations { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.citations-title { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.citation { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; padding: 3px 0; }
.cite-project { font-weight: 700; }
.cite-source { color: var(--muted); }
.cite-page, .cite-updated { color: var(--muted); background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.cite-conf { margin-left: auto; font-weight: 700; color: var(--green); }

/* ---------- Follow-up suggestions ---------- */
.followups { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.chip-sm { padding: 5px 11px; font-size: 12px; }

/* ---------- Composer ---------- */
.composer { display: flex; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.composer-input { flex: 1; padding: 12px 15px; border: 1px solid var(--border); border-radius: 11px; font-size: 14px; outline: none; }
.composer-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.mic-btn { padding: 0 14px; font-size: 16px; }
.mic-on { background: var(--red-soft); border-color: var(--red); color: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(220,38,38,.4);} 50%{ box-shadow: 0 0 0 6px rgba(220,38,38,0);} }

.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2){ animation-delay: .2s; } .dots i:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,100%{opacity:.3} 50%{opacity:1} }

/* ---------- Projects ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 18px; }
.search-bar input { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; outline: none; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px;
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; }
.project-card:hover { transform: translateY(-3px); border-color: transparent; box-shadow: var(--shadow-lg); }
.project-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.project-card h3 { font-size: 16px; }
.project-loc { color: var(--muted); font-size: 13px; margin-top: 8px; }
.project-poss { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.status-chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.chip-green { background: var(--green-soft); color: var(--green); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-gray { background: var(--surface-2); color: var(--muted); }
.chip-red { background: var(--red-soft); color: var(--red); }
.chip-blue { background: var(--primary-soft); color: var(--primary); }

/* ---- Platform: the tenant console ----
   Tenants used to be table rows with five inputs crammed into one cell. Cards
   give each company room to say how it's doing, and the payment form moved to
   a dialog where a money job belongs. ---- */
.pf-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
  margin-bottom: 14px; }
.pf-stat { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
  background: var(--surface); }
.pf-stat-v { font-size: 24px; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.pf-stat-sub { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.pf-stat-l { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.pf-stat-risk { border-color: var(--amber); background: var(--amber-soft); }
.pf-stat-risk .pf-stat-v, .pf-stat-risk .pf-stat-l { color: var(--amber); }
.pf-stat-hero { background: var(--grad); border-color: transparent; color: #fff;
  box-shadow: 0 10px 26px rgba(99, 102, 241, .3); }
.pf-stat-hero .pf-stat-l { color: rgba(255, 255, 255, .85); }
.pf-hint { font-size: 12.5px; color: var(--muted); line-height: 1.6; margin-bottom: 16px; }

.tenant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.tenant-card { border: 1px solid var(--border); border-radius: 16px; padding: 16px;
  background: var(--surface); display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow .18s, transform .18s; }
.tenant-card:hover { box-shadow: 0 12px 30px rgba(0, 0, 0, .09); transform: translateY(-2px); }
.tenant-card-risk { border-color: var(--amber); }

.tc-head { display: flex; align-items: center; gap: 10px; }
.tc-avatar { width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; background: var(--grad);
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.tc-id { min-width: 0; flex: 1; }
.tc-name { font-weight: 800; font-size: 14.5px; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-flag { font-size: 12px; font-weight: 700; color: var(--amber); background: var(--amber-soft);
  border-radius: 8px; padding: 6px 9px; }
.tc-meters { display: flex; flex-direction: column; gap: 9px; }
.tc-meter-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.tc-meter-n { font-size: 12.5px; font-weight: 700; }
.tc-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tc-plan { font-size: 12.5px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; max-width: 62%; }
.tc-paid { font-size: 12.5px; font-weight: 700; }
.tc-over { color: var(--red); font-weight: 700; }
.tc-note { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-radius: 8px;
  padding: 6px 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto;
  padding-top: 10px; border-top: 1px solid var(--border); }
.tc-access { margin-left: auto; font-size: 11px; }
.tc-off { color: var(--red); }
/* Deliberately understated until hovered — the only irreversible action here. */
.tc-delete { font-size: 11px; color: var(--muted); }
.tc-delete:hover { color: #c0392b; background: #fdecea; border-color: #f5c6c0; }

/* ---- Team list ----
   Was a seven-column table whose last action read "Toggle" — which told you
   neither what it did nor which way. Rows now carry a face, and every control
   says what it is. ---- */
.pf-stat-full { border-color: var(--red); background: var(--red-soft); }
.pf-stat-full .pf-stat-v, .pf-stat-full .pf-stat-l { color: var(--red); }

.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 13px; background: var(--surface);
  transition: box-shadow .15s, border-color .15s; }
.team-row:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .06); border-color: var(--primary-soft); }
.team-row-off { opacity: .62; }
.team-av { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: grid;
  place-items: center; font-weight: 800; font-size: 14px; }
/* The face is tinted by role, so a list of ten reads at a glance. */
.role-av-admin { background: var(--primary-soft); color: var(--primary); }
.role-av-manager { background: var(--amber-soft); color: var(--amber); }
.role-av-sales { background: var(--green-soft); color: var(--green); }
.team-id { flex: 1; min-width: 0; }
.team-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.team-role { flex-shrink: 0; }
.team-ctl { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; flex-shrink: 0; }
.team-ctl select { font-size: 12px; padding: 4px 7px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; }
.team-act { flex-shrink: 0; }
@media (max-width: 780px) {
  .team-row { flex-wrap: wrap; }
  .team-id { flex-basis: calc(100% - 50px); }
  .team-act { margin-left: auto; }
}

/* ---- Platform → Plans: where pricing lives ----
   Was a five-column table of bare number inputs, so the one thing an owner
   changes most — the price — looked like a spreadsheet cell. Cards make the
   price the headline, and the plan's reach visible next to it. ---- */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.plan-card { border: 1px solid var(--border); border-radius: 16px; padding: 16px; background: var(--surface);
  display: flex; flex-direction: column; gap: 12px; transition: box-shadow .18s; }
.plan-card:hover { box-shadow: 0 12px 30px rgba(0, 0, 0, .09); }
.plan-card-off { opacity: .62; border-style: dashed; }
/* An unsaved card announces itself, so a half-made change can't be walked away
   from without noticing. */
.plan-card-dirty { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.plan-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-card-name { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); }
.plan-toggle { border: 0; cursor: pointer; }
.plan-price { display: flex; align-items: center; gap: 5px; cursor: text; }
.plan-cur { font-size: 20px; font-weight: 800; }
.plan-per { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.plan-price-in { flex: 1; min-width: 0; font-size: 22px; font-weight: 800; padding: 5px 9px;
  border: 1px solid transparent; border-radius: 9px; background: var(--surface-2); color: var(--text);
  letter-spacing: -.02em; }
.plan-price-in:hover { border-color: var(--border); }
.plan-price-in:focus { border-color: var(--primary); background: var(--surface); outline: none; }
.plan-rows { display: flex; flex-direction: column; gap: 7px; }
.plan-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-row input { width: 88px; font-size: 13px; padding: 4px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: right; }
.plan-row input:focus { border-color: var(--primary); outline: none; }
.plan-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 12.5px; padding-top: 10px; border-top: 1px solid var(--border); margin-top: auto; }
.plan-foot-meta { min-width: 0; }
.plan-foot-actions { display: flex; gap: 6px; flex-shrink: 0; }
.plan-unsaved { color: var(--primary); font-weight: 700; }

/* ---- Modal ---- */
.modal-back { position: fixed; inset: 0; z-index: 200; background: rgba(15, 18, 28, .5);
  backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; }
.modal { width: 100%; max-width: 520px; background: var(--surface); border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .3); overflow: hidden;
  max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-title { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.modal-x { border: 0; background: none; color: var(--muted); font-size: 15px; cursor: pointer;
  padding: 2px 6px; border-radius: 7px; }
.modal-x:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px;
  border-top: 1px solid var(--border); background: var(--surface-2); }

/* ---- Billing (org admin: Plan & Usage) ---- */
.bill-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0; }
.bill-stat { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.bill-stat-v { font-size: 21px; font-weight: 800; color: var(--text); line-height: 1.2; }
.bill-stat-l { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.bill-bar { height: 5px; border-radius: 4px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.bill-bar span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.bill-bar-warn span { background: var(--amber); }

/* ---- Pricing cards ---- */
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 14px 0 16px; }
.price-card { position: relative; border: 1px solid var(--border); border-radius: 14px; padding: 18px;
  background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.price-card-current { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.price-badge { position: absolute; top: -9px; right: 14px; background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: .3px; padding: 3px 9px; border-radius: 999px; }
.price-name { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.price-amt { font-size: 27px; font-weight: 800; line-height: 1.1; }
.price-per { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.price-feats { list-style: none; padding: 0; margin: 2px 0 auto; font-size: 13px; line-height: 1.9; color: var(--muted); }
.price-feats li::before { content: "✓ "; color: var(--green); font-weight: 800; }

/* ---- Platform: plan-change requests waiting on the owner ---- */
.req-box { border: 1px solid var(--amber); background: var(--amber-soft); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 16px; }
.req-head { font-weight: 800; color: var(--amber); margin-bottom: 8px; font-size: 14px; }
.req-row { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap; padding: 8px 0; border-top: 1px solid rgba(0, 0, 0, .06); font-size: 13.5px; }
.req-row:first-of-type { border-top: 0; }
.tab-badge { display: inline-block; min-width: 17px; margin-left: 6px; padding: 1px 5px;
  border-radius: 999px; background: var(--red); color: #fff; font-size: 10px; font-weight: 800; }

/* ---- Platform: seed a tenant with starter projects (collapsed by default —
       it is an onboarding-day job, not something you look at daily) ---- */
.seed-box { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  margin-bottom: 16px; background: var(--surface); }
.seed-box summary { cursor: pointer; font-weight: 700; font-size: 13.5px; }
.seed-box[open] summary { margin-bottom: 4px; }
.seed-list { max-height: 190px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 10px; margin-top: 10px; }
.seed-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px;
  cursor: pointer; }

/* ---------- System Health ---------- */
.health-banner { padding: 14px 16px; border-radius: 10px; font-weight: 700; margin-bottom: 16px; }
.health-banner.ok { background: var(--green-soft); color: var(--green); }
.health-banner.bad { background: var(--red-soft); color: var(--red); }
.health-list { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.health-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.health-row:last-child { border-bottom: none; }
.health-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.health-dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.health-dot.off { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.health-name { font-weight: 600; min-width: 140px; }
.health-detail { flex: 1; font-size: 13px; }

/* ---------- Edit configs (price/stock update) ---------- */
.edit-config-list { display: flex; flex-direction: column; gap: 12px; }
.edit-config-row { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--surface); }
.ecr-title { font-weight: 700; margin-bottom: 10px; }
.ecr-fields { display: flex; flex-wrap: wrap; gap: 20px; }
.ecr-field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.ecr-inline { display: flex; gap: 6px; }
.ecr-inline input { width: 130px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.ecr-inline select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; min-width: 130px; }
.ecr-planprices { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.rise-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 700; letter-spacing: .02em; color: #6b4d0f; background: var(--primary-soft, #f6ecd2);
  border: 1px solid #e6cf94; white-space: nowrap; }
.launch-highlight { margin-top: 10px; padding: 8px 14px; border-radius: 10px; display: inline-block;
  background: linear-gradient(90deg, #fff7e6, #fdf0d0); border: 1px solid #e6cf94; color: #5c4409;
  font-size: 14px; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* Detail header: main info left, documents panel top-right on desktop; stacks on mobile. */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start;
  gap: 24px; flex-wrap: wrap; }
.detail-header-main { flex: 1 1 320px; min-width: 0; }
.detail-header-docs { flex: 0 0 auto; }
.detail-header-docs .doc-panel { margin-top: 0; }
@media (max-width: 760px) {
  .detail-header-docs { width: 100%; }
  .detail-header-docs .doc-panel { max-width: none; margin-top: 4px; }
}

/* Documents panel — brochure + cost sheet in one clean bordered card. */
.doc-panel { border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  margin: 14px 0 4px; max-width: 480px; background: var(--card, #fff); }
.doc-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; flex-wrap: wrap; }
.doc-row + .doc-row { border-top: 1px solid var(--border); }
.doc-row-main { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.doc-ico { font-size: 16px; }
.doc-name { font-weight: 600; }
.doc-sub { color: var(--muted); font-size: 13px; }
.doc-select { padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px; max-width: 170px; }
.doc-row-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.share-btn { background: none; border: none; cursor: pointer; color: #0f8a6f; padding: 5px;
  display: inline-flex; align-items: center; border-radius: 6px; }
.share-btn:hover:not(:disabled) { background: #e7f8f0; }
.share-btn:disabled { opacity: .5; cursor: default; }
.eye-btn { background: none; border: none; cursor: pointer; padding: 0 4px; line-height: 1;
  display: inline-flex; align-items: center; vertical-align: middle; color: inherit; }
.launch-highlight { display: inline-flex; align-items: center; gap: 4px; }
.existing-plans { margin-bottom: 16px; max-width: 420px; }
.existing-plan-row { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; }
.existing-plan-row span { font-weight: 600; }
.btn-danger { color: #c0392b; }
.btn-danger:hover { background: #fdecea; border-color: #f5c6c0; }

/* ---------- PDF brochure viewer ---------- */
.pdf-overlay { position: fixed; inset: 0; background: rgba(10,14,22,.6); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px; }
.pdf-loading { display: inline-flex; align-items: center; gap: 10px; background: var(--surface);
  border-radius: 14px; padding: 16px 22px; font-weight: 600; color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.pdf-spinner { width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: pdfspin .7s linear infinite; }
@keyframes pdfspin { to { transform: rotate(360deg); } }
/* Presentation video (YouTube) modal — responsive 16:9 player. */
.video-modal { background: var(--surface); border-radius: 14px; width: min(920px, 96vw);
  overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.video-frame-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.video-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pdf-modal { background: var(--surface); border-radius: 14px; width: min(900px, 96vw); height: 90vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.pdf-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.pdf-frame { flex: 1; width: 100%; border: none; }

/* ---------- Usage rows ---------- */
.usage-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.usage-name { width: 170px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.usage-count { width: 64px; text-align: right; font-weight: 700; font-size: 12.5px; }
.usage-over { color: var(--red); }
.tier-badge { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 5px; text-transform: uppercase; }
.tier-basic { background: var(--surface-2); color: var(--muted); }
.tier-advanced { background: var(--primary-soft); color: var(--primary); }

/* ---------- AI Import preview + queue ---------- */
.cell-highlight { background: var(--amber-soft); }
.cell-highlight input { font-weight: 700; color: var(--amber); }
.extract-preview { border-top: 1px dashed var(--border); padding-top: 12px; margin-top: 8px; }
.import-queue { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.queue-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface); }
.queue-item.status-saved { background: var(--green-soft); border-color: transparent; }
.queue-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.queue-name { font-weight: 600; flex: 1; min-width: 160px; }
.queue-row select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; min-width: 180px; }
.queue-title { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; min-width: 160px; flex: 1; }
.queue-actions { display: flex; gap: 4px; margin-left: auto; }
.queue-draft { margin-top: 6px; }
.index-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.index-toggle input { width: 16px; height: 16px; }

/* ---------- Tier limits box ---------- */
.tier-limits-box { border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 18px; }

/* ---------- Chip editor (doc types) ---------- */
.chip-editor { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.chip-x { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0 0 0 4px; }
.chip-x:hover { color: var(--red); }

.builder-line { color: var(--primary); font-weight: 600; font-size: 13.5px; margin: 2px 0 2px; }
.back-link { color: var(--muted); font-size: 13px; display: inline-block; margin-bottom: 12px; }
.back-link:hover { color: var(--primary); }
.detail-section { margin-top: 24px; }
.detail-section h3 { font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.source-tag { font-size: 10px; font-weight: 700; background: var(--green-soft); color: var(--green);
  padding: 1px 7px; border-radius: 6px; letter-spacing: .05em; }
.updated-note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat-card { border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; background: var(--surface); box-shadow: var(--shadow); }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-of { font-size: 15px; color: var(--muted); font-weight: 600; }
.stat-sub { font-size: 12px; color: var(--muted); }

/* ---------- Calculators / Admin ---------- */
.calc-tabs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 20px; }
.tab { border: 1px solid var(--border); background: var(--surface); padding: 8px 15px; border-radius: 10px;
  cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); transition: .15s; }
.tab:hover { border-color: #d6d9ea; color: var(--text); }
.tab-active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 5px 14px rgba(79,70,229,.30); }
.tab-active:hover { color: #fff; }

/* ---------- Admin: two-level category nav (premium) ---------- */
.admin-cats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 8px; box-shadow: var(--shadow); }
.admin-cat { display: inline-flex; align-items: center; gap: 8px; border: none; background: transparent;
  padding: 9px 15px; border-radius: 11px; cursor: pointer; font-weight: 700; font-size: 13.5px; color: var(--muted);
  transition: .15s; font-family: inherit; }
.admin-cat:hover { background: var(--surface-2); color: var(--text); }
.admin-cat-active { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.30); }
.admin-cat-active:hover { background: var(--grad); color: #fff; }
.admin-cat-ico { font-size: 15px; }
.admin-subtabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; padding: 0 2px; }
.admin-subtab { border: 1px solid var(--border); background: var(--surface); padding: 7px 13px; border-radius: 20px;
  cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--muted); transition: .15s; font-family: inherit; }
.admin-subtab:hover { border-color: var(--primary); color: var(--primary); }
.admin-subtab-active { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.calc-form, .admin-form { background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 24px; box-shadow: var(--shadow); }
.calc-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 16px; }
.calc-result { margin-top: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.result-key { color: var(--muted); text-transform: capitalize; font-weight: 600; }
.result-val { font-weight: 600; }
.nested-list { margin: 0; padding-left: 16px; font-weight: 400; }
.audit-action { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; }
.a-CREATE { background: var(--green-soft); color: var(--green); }
.a-UPDATE { background: var(--amber-soft); color: var(--amber); }
.a-DELETE { background: var(--red-soft); color: var(--red); }

/* ---------- AI Settings ---------- */
.settings-status { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: var(--surface-2); border-radius: 10px; margin-bottom: 16px; }
.status-line { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.settings-note { font-size: 12.5px; background: var(--grad-soft); color: #4338ca;
  padding: 12px 15px; border-radius: 12px; margin: 14px 0; border: 1px solid rgba(99,102,241,.14);
  line-height: 1.55; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; }

/* ---------- Dashboard ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-value { font-size: 28px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.kpi-warn .kpi-value { background: none; -webkit-text-fill-color: initial; color: var(--amber); }
.kpi-label { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar { width: 60%; min-height: 3px; background: linear-gradient(var(--primary-600), var(--primary)); border-radius: 5px 5px 0 0;
  display: flex; align-items: flex-start; justify-content: center; position: relative; }
.bar-val { position: absolute; top: -16px; font-size: 11px; font-weight: 700; color: var(--muted); }
.bar-label { font-size: 10.5px; color: var(--muted); margin-top: 5px; }
.hbar-row { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
.hbar-label { width: 110px; font-size: 12.5px; text-transform: capitalize; }
.hbar-track { flex: 1; background: var(--surface-2); border-radius: 6px; height: 12px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, var(--primary-600), var(--primary)); border-radius: 6px; }
.hbar-count { width: 26px; text-align: right; font-weight: 700; font-size: 12.5px; }
.list-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.pill { background: var(--primary-soft); color: var(--primary); font-weight: 700; padding: 1px 9px; border-radius: 20px; font-size: 12px; }
.miss-row { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--amber); }
.miss-row:last-child { border-bottom: none; }
.milestone-row { display: flex; gap: 8px; max-width: 380px; margin-bottom: 8px; }
.milestone-row input:first-child { flex: 1; }
.milestone-row input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.milestone-row input:nth-child(2) { width: 70px; }

/* ---------- Mobile / tablet navigation (drawer) ---------- */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }
.drawer-close { display: none; }

@media (max-width: 860px) {
  .dash-cols { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }

  .mobile-topbar {
    display: flex; align-items: center; gap: 10px;
    position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 60;
    background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 12px;
  }
  .hamburger { background: none; border: none; cursor: pointer; color: var(--text);
    display: inline-flex; align-items: center; padding: 6px; margin-right: 2px; }
  .mobile-brand { font-weight: 800; font-size: 15px; }

  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 264px; z-index: 80;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.28);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 70;
    background: rgba(10,14,22,.5); }

  .brand { position: relative; }
  .drawer-close { display: inline-flex; position: absolute; top: -2px; right: 0;
    background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; }

  .content { padding: 72px 16px 24px; overflow-x: hidden; }
  .query-page { height: auto; }
  /* iOS Safari zooms the WHOLE page when a focused input's font is under 16px,
     which then leaves the next screen looking zoomed-in and cut off. Pin form
     controls to 16px on mobile so focusing a field never triggers that zoom. */
  input, select, textarea { font-size: 16px; }
  /* Inputs given a sub-16px size via a class would still zoom (their selector
     out-specifies the bare `input` rule above). Re-assert 16px for each — equal
     specificity, but later in the cascade, so these win. The one deliberately
     large input (.plan-price-in, 22px) is intentionally left untouched. */
  .field input, .field select, .field textarea,
  .search-bar input, .composer-input, .team-ctl select, .plan-row input { font-size: 16px; }
}

/* ---- Insights (analytics) ---- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 16px 0 20px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px;
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-num { font-size: 26px; font-weight: 800; color: var(--text); }
.kpi-num.kpi-warn { color: #c0392b; }
.kpi-label { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.insight-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.insight-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow); }
.mini-bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 8px; }
.mini-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.mini-bar { width: 60%; min-height: 3px; background: var(--primary); border-radius: 4px 4px 0 0; transition: height .2s; }
.mini-bar-x { font-size: 11px; color: var(--muted); margin-top: 5px; }
@media (max-width: 760px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .insight-grid { grid-template-columns: 1fr; }
}

/* ---- Live chat (agent takeover) — premium ---- */
/* The page fills the viewport so the console (and its take-over/composer bar)
   is always fully on screen — only the messages scroll, never the page. */
.live-page { display: flex; flex-direction: column; height: 100%; }
.live-wrap { display: grid; grid-template-columns: 330px 1fr; grid-template-rows: minmax(0, 1fr);
  margin-top: 16px; flex: 1; min-height: 0; border: 1px solid var(--border); border-radius: 20px;
  overflow: hidden; background: var(--surface); box-shadow: 0 18px 50px rgba(26, 24, 75, .10); }

/* Inbox */
.live-list { border-right: 1px solid var(--border); overflow-y: auto; background: #fbfbfe;
  display: flex; flex-direction: column; min-height: 0; }
.live-list-head { position: sticky; top: 0; z-index: 1; background: #fbfbfe;
  padding: 16px 18px 10px; display: flex; justify-content: space-between; align-items: center;
  font-size: 11.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.live-count { background: linear-gradient(135deg, var(--primary), #7c5cff); color: #fff;
  border-radius: 20px; padding: 2px 10px; font-size: 11px; font-weight: 700; letter-spacing: 0; }
.live-item { display: flex; gap: 12px; width: 100%; text-align: left; border: none; background: transparent;
  padding: 13px 16px; cursor: pointer; align-items: center; border-bottom: 1px solid #f2f3f8;
  transition: background .15s; font-family: inherit; }
.live-item:hover { background: #f3f4fb; }
.live-item-active { background: linear-gradient(90deg, var(--primary-soft) 0%, rgba(238,240,254,0) 90%);
  box-shadow: inset 3px 0 0 var(--primary); }
.live-item-body { flex: 1; min-width: 0; }
.live-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.live-name { font-size: 13.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-item-time { font-size: 10.5px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.live-item-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 3px; }
.live-item-last { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-empty-inbox { padding: 30px 18px; text-align: center; color: var(--muted); font-size: 13px; }

/* Avatars + presence */
.live-ava { position: relative; width: 44px; height: 44px; border-radius: 15px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: 0 5px 12px rgba(99,102,241,.28); }
.live-ava svg { width: 20px; height: 20px; }
.live-ava-sm { width: 38px; height: 38px; border-radius: 13px; }
.live-presence { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%;
  background: #22c55e; border: 2.5px solid #fbfbfe; animation: livepulse 2s infinite; }
.live-presence.off { background: #cbd5e1; animation: none; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.45); } 70% { box-shadow: 0 0 0 6px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }

/* Mode pills */
.live-mode { font-size: 10px; font-weight: 800; padding: 3px 9px; border-radius: 20px; white-space: nowrap;
  background: var(--primary-soft); color: var(--primary); letter-spacing: .03em; flex-shrink: 0; }
.live-mode-human { background: var(--green-soft); color: var(--green); }

/* Conversation panel */
.live-convo { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.live-convo-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px;
  border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #fff 0%, #fafaff 100%); }
.live-head-left { display: flex; gap: 12px; align-items: center; min-width: 0; }
.live-head-name { font-weight: 800; font-size: 14.5px; color: var(--text); }
.live-status { font-size: 11.5px; margin-top: 1px; display: flex; align-items: center; gap: 5px; }
.live-status.on { color: #16a34a; font-weight: 600; }
.live-status.off { color: var(--muted); }
.live-status i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: currentColor; }

/* Messages */
.live-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(180deg, #f7f8fd 0%, #f2f3fa 100%); }
.live-row { display: flex; gap: 10px; align-items: flex-end; max-width: 76%; }
.live-row-visitor { align-self: flex-start; }
.live-row-team { align-self: flex-end; flex-direction: row-reverse; }
.live-mava { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center;
  justify-content: center; font-size: 13px; font-weight: 800; color: #fff; margin-bottom: 16px; }
.live-mava svg { width: 15px; height: 15px; }
.live-mava-user { background: linear-gradient(135deg, #94a3b8, #64748b); }
.live-mava-ai { background: linear-gradient(135deg, var(--primary), #7c5cff); }
.live-mava-agent { background: linear-gradient(135deg, #10b981, #059669); }
.live-mcol { min-width: 0; display: flex; flex-direction: column; }
.live-row-team .live-mcol { align-items: flex-end; }
.live-bubble { padding: 11px 15px; border-radius: 18px; font-size: 13.5px; line-height: 1.55;
  white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 3px rgba(16,24,40,.07); }
.live-bubble-user { background: #fff; border: 1px solid #e9eaf2; border-bottom-left-radius: 6px; color: var(--text); }
.live-bubble-ai { background: linear-gradient(135deg, #eef0fe, #f3eefe); border-bottom-right-radius: 6px; color: #2b2a52; }
.live-bubble-agent { background: linear-gradient(135deg, #e7f6ef, #ddf3e6); border-bottom-right-radius: 6px; color: #14532d; }
.live-msg-time { font-size: 10px; color: #9aa0b4; margin-top: 4px; padding: 0 4px; }

/* System divider */
.live-sysrow { display: flex; align-items: center; gap: 12px; align-self: stretch; margin: 2px 6px; }
.live-sysrow::before, .live-sysrow::after { content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, #dcdfeb, transparent); }
.live-sys { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Empty state */
.live-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: var(--muted); background: linear-gradient(180deg, #f7f8fd, #f2f3fa); }
.live-empty-ico { width: 68px; height: 68px; border-radius: 22px; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--primary-soft), #f1ebfe); display: flex; align-items: center;
  justify-content: center; font-size: 30px; box-shadow: 0 8px 20px rgba(79,70,229,.12); }
.live-empty b { color: var(--text); font-size: 15px; }

/* Actions / composer */
.live-actions { padding: 14px 18px; border-top: 1px solid var(--border); background: #fff; }
.live-takeover { width: 100%; border: none; border-radius: 14px; padding: 13px; font-weight: 700; font-size: 14px;
  color: #fff; cursor: pointer; font-family: inherit; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--primary), #7c5cff); box-shadow: 0 8px 22px rgba(79,70,229,.35);
  transition: transform .15s, box-shadow .15s; }
.live-takeover:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 11px 26px rgba(79,70,229,.45); }
.live-takeover:disabled { background: #e8eaf1; color: #9aa1b4; box-shadow: none; cursor: not-allowed; }
.live-composer { display: flex; gap: 10px; align-items: center; }
.live-composer input { flex: 1; padding: 12px 18px; border: 1px solid var(--border); border-radius: 26px;
  font-size: 14px; outline: none; background: #f6f7fc; transition: .15s; }
.live-composer input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
.live-send { width: 44px; height: 44px; border-radius: 50%; border: none; flex-shrink: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), #7c5cff); color: #fff; display: flex; align-items: center;
  justify-content: center; box-shadow: 0 6px 16px rgba(79,70,229,.35); transition: transform .15s; }
.live-send:hover:not(:disabled) { transform: scale(1.06); }
.live-send:disabled { background: #e8eaf1; color: #9aa1b4; box-shadow: none; cursor: not-allowed; }
.live-send svg { width: 18px; height: 18px; }
.live-return { border: none; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600;
  cursor: pointer; padding: 9px 12px; border-radius: 10px; white-space: nowrap; font-family: inherit; }
.live-return:hover { background: var(--surface-2); color: var(--text); }

@media (max-width: 760px) {
  .live-page { height: auto; }
  .live-wrap { grid-template-columns: 1fr; flex: none; min-height: 0; height: auto; }
  .live-list { max-height: 230px; }
  .live-msgs { min-height: 300px; max-height: 55vh; }
}

/* ---- API connection details (copy-ready endpoints) ---- */
.conn-card { border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; margin: 14px 0 18px;
  background: var(--surface); box-shadow: var(--shadow); }
.conn-card-new { border-color: #bbf7d0; background: linear-gradient(135deg, #f2fdf7, #f7fdfa); }
.conn-card-head { display: flex; justify-content: space-between; align-items: center; font-size: 14.5px; }
.conn-row { margin-bottom: 10px; }
.conn-row:last-child { margin-bottom: 0; }
.conn-label { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.conn-value { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.conn-value code { flex: 1; min-width: 220px; background: #f6f7fc; border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 12px; font-size: 13px; word-break: break-all; }
.conn-code { font-family: ui-monospace, Menlo, Consolas, monospace; }
/* Multi-line snippets (the widget script tag) must keep their line breaks. */
.conn-code-pre { display: block; white-space: pre; overflow-x: auto; line-height: 1.5;
  font-size: 12px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.conn-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.conn-hint code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* Per-key access picker — a full key is the risky one, so it reads as a warning. */
.scope-pick { font-size: 12px; padding: 4px 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.scope-pick-warn { border-color: var(--danger, #d94b4b); color: var(--danger, #d94b4b); font-weight: 600; }

/* ---- Assistant identity (name + avatar) ---- */
.persona-id-row { display: flex; gap: 14px; align-items: center; margin: 10px 0 6px; }
.persona-avatar { width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-soft) center/cover no-repeat; color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800;
  border: 2px solid var(--border); }
.persona-id-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
