/* =============================================================
   HOTBOX SALES ENGINE — STRUCTURE & COMPONENTS
   Uses tokens from tokens.css only. No hardcoded brand values.
   ============================================================= */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--brand-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0 0 .4em; line-height: 1.2; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font: inherit; font-weight: var(--fw-semibold);
  padding: .55em 1em; border-radius: var(--radius-md);
  border: 1px solid transparent; cursor: pointer; transition: var(--t-fast);
  background: var(--surface-2); color: var(--text); white-space: nowrap;
}
.btn:hover { filter: brightness(.98); }
.btn-primary { background: var(--brand-primary); color: var(--brand-on-primary); }
.btn-primary:hover { background: var(--brand-primary-600); filter: none; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .4em .7em; font-size: var(--fs-sm); border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.icon-btn {
  background: transparent; border: none; cursor: pointer; font-size: 1.1rem;
  color: var(--text-muted); padding: .25em .45em; border-radius: var(--radius-sm); line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Inputs ---------- */
.input, select.input, textarea.input {
  width: 100%; font: inherit; color: var(--text);
  padding: .55em .7em; border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); background: var(--surface);
}
.input:focus { outline: 2px solid color-mix(in srgb, var(--brand-primary) 40%, transparent); outline-offset: 1px; border-color: var(--brand-primary); }
textarea.input { min-height: 84px; resize: vertical; }
.field { display: block; margin-bottom: .9rem; text-align: left; }
.field-label { display: block; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-muted); margin-bottom: .3em; }
.field-label .req { color: var(--danger); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }

/* ---------- Auth gate ---------- */
.auth-gate {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--brand-primary) 14%, var(--bg)), var(--bg));
  padding: 1.5rem;
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 2rem; text-align: center;
}
.auth-logo { margin-bottom: 1rem; }
.auth-title { font-size: var(--fs-xl); margin-bottom: .2em; }
.auth-sub { color: var(--text-muted); margin: 0 0 1.5rem; font-size: var(--fs-sm); }
.auth-error { color: var(--danger); font-size: var(--fs-sm); margin: .2rem 0 .6rem; }
.auth-hint { color: var(--text-faint); font-size: var(--fs-xs); margin-top: 1rem; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }
.sidebar {
  background: var(--sidebar-bg); color: var(--sidebar-ink);
  display: flex; flex-direction: column; padding: 1rem .8rem; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: .4rem .4rem 1.2rem; }
.brand .logo-mark { width: 34px; height: 34px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--brand-primary); color: var(--brand-on-primary); font-weight: var(--fw-bold); flex: none; }
.brand .logo-text { font-weight: var(--fw-bold); font-size: var(--fs-md); letter-spacing: .2px; }
.brand .logo-text small { display: block; font-weight: var(--fw-normal); font-size: var(--fs-xs); color: var(--sidebar-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group-label { text-transform: uppercase; letter-spacing: .08em; font-size: var(--fs-xs); color: var(--sidebar-muted); margin: 1rem .5rem .35rem; }
.nav-link {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .6rem;
  border-radius: var(--radius-md); color: var(--sidebar-ink); font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
}
.nav-link:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav-link.active { background: var(--brand-primary); color: var(--brand-on-primary); }
.nav-ico { width: 1.2em; text-align: center; }
.sidebar-foot { display: flex; gap: .4rem; padding-top: .8rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot .btn { flex: 1; color: var(--sidebar-muted); border-color: rgba(255,255,255,.14); }
.sidebar-foot .btn:hover { color: var(--sidebar-ink); background: rgba(255,255,255,.06); }

.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: .8rem;
  padding: 0 1.2rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: var(--fw-bold); font-size: var(--fs-lg); }
.topbar-spacer { flex: 1; }
.topbar-search { max-width: 280px; }
.who { display: flex; align-items: center; gap: .5rem; font-size: var(--fs-sm); color: var(--text-muted); }
.who .who-dot { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-accent); color: #fff; display: grid; place-items: center; font-weight: var(--fw-bold); font-size: var(--fs-xs); }
.only-mobile { display: none; }

.view { padding: 1.4rem; overflow-y: auto; flex: 1; }
.view-wrap { max-width: var(--maxw); margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-head h1 { font-size: var(--fs-xl); margin: 0; }
.page-head p { margin: .2rem 0 0; color: var(--text-muted); font-size: var(--fs-sm); }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar .grow { flex: 1; min-width: 160px; }
.muted { color: var(--text-muted); }
.placeholder-tag {
  display: inline-block; font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent);
  padding: .1em .5em; border-radius: var(--radius-pill); margin-left: .5rem; vertical-align: middle;
}

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 1.1rem 1.2rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: .35em; font-size: var(--fs-xs); font-weight: var(--fw-semibold); padding: .2em .6em; border-radius: var(--radius-pill); border: 1px solid var(--border); color: var(--text-muted); background: var(--surface-2); }
.badge .dot { width: .55em; height: .55em; border-radius: 50%; background: currentColor; }
.badge-product[data-product="pokemon"] { color: var(--product-pokemon); background: color-mix(in srgb, var(--product-pokemon) 10%, transparent); border-color: color-mix(in srgb, var(--product-pokemon) 30%, transparent); }
.badge-product[data-product="vape"] { color: var(--product-vape); background: color-mix(in srgb, var(--product-vape) 10%, transparent); border-color: color-mix(in srgb, var(--product-vape) 30%, transparent); }
.badge-stage { color: #fff; border: none; }
.badge-channel { text-transform: capitalize; }
.badge-21 { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.badge-21.no { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.chip-toggle { cursor: pointer; user-select: none; }
.chip-toggle[aria-pressed="true"] { background: var(--brand-primary); color: var(--brand-on-primary); border-color: var(--brand-primary); }

/* ---------- Dashboard ---------- */
.kpi { display: flex; flex-direction: column; gap: .2rem; }
.kpi .kpi-val { font-size: var(--fs-2xl); font-weight: var(--fw-bold); line-height: 1; }
.kpi .kpi-label { font-size: var(--fs-sm); color: var(--text-muted); }
.kpi .kpi-sub { font-size: var(--fs-xs); color: var(--text-faint); }
.kpi.accent .kpi-val { color: var(--brand-primary); }
.stage-bars { display: flex; flex-direction: column; gap: .6rem; }
.stage-bar-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: .6rem; font-size: var(--fs-sm); }
.stage-bar-track { background: var(--surface-2); border-radius: var(--radius-pill); height: 12px; overflow: hidden; border: 1px solid var(--border); }
.stage-bar-fill { height: 100%; border-radius: var(--radius-pill); min-width: 2px; }
.stage-bar-count { text-align: right; font-weight: var(--fw-semibold); }
.followup-list { display: flex; flex-direction: column; }
.followup-item { display: flex; align-items: center; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.followup-item:last-child { border-bottom: none; }
.followup-item:hover { background: var(--surface-2); }
.followup-when { font-size: var(--fs-xs); font-weight: var(--fw-semibold); padding: .2em .55em; border-radius: var(--radius-sm); white-space: nowrap; }
.followup-when.overdue { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.followup-when.today { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, transparent); }
.followup-main { flex: 1; min-width: 0; }
.followup-main .ft { font-weight: var(--fw-semibold); }
.followup-main .fs { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: .8rem; overflow-x: auto; padding-bottom: .6rem; align-items: flex-start; }
.kan-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 280px; flex: none; display: flex; flex-direction: column; max-height: calc(100vh - var(--topbar-h) - 150px); }
.kan-col.dragover { outline: 2px dashed var(--brand-primary); outline-offset: -3px; background: color-mix(in srgb, var(--brand-primary) 6%, var(--surface-2)); }
.kan-head { display: flex; align-items: center; gap: .5rem; padding: .7rem .8rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.kan-head .kan-dot { width: .7em; height: .7em; border-radius: 50%; }
.kan-head .kan-name { font-weight: var(--fw-bold); font-size: var(--fs-sm); }
.kan-head .kan-count { margin-left: auto; font-size: var(--fs-xs); color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: .05em .55em; }
.kan-body { padding: .6rem; display: flex; flex-direction: column; gap: .55rem; overflow-y: auto; }
.kan-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: var(--radius-md); padding: .65rem .7rem; box-shadow: var(--shadow-sm); cursor: grab; }
.kan-card:active { cursor: grabbing; }
.kan-card.dragging { opacity: .5; }
.kan-card .kc-top { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.kan-card .kc-name { font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.kan-card .kc-meta { font-size: var(--fs-xs); color: var(--text-muted); margin-top: .25rem; display: flex; flex-wrap: wrap; gap: .35rem .6rem; }
.kan-card .kc-next { font-size: var(--fs-xs); margin-top: .4rem; display: flex; align-items: center; gap: .35rem; }
.kan-empty { font-size: var(--fs-xs); color: var(--text-faint); text-align: center; padding: 1rem .5rem; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.tbl th, table.tbl td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface-2); }
table.tbl th .sort-ind { color: var(--brand-primary); }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl td.wrap { white-space: normal; max-width: 280px; }
.row-click { cursor: pointer; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .es-emoji { font-size: 2rem; }

/* ---------- Scripts / content ---------- */
.script-card { display: flex; flex-direction: column; }
.script-card .sc-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.script-card .sc-title { font-weight: var(--fw-bold); font-size: var(--fs-md); margin-right: auto; }
.script-card .sc-body { white-space: pre-wrap; font-size: var(--fs-sm); line-height: 1.5; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: .8rem .9rem; color: var(--text); }
.script-card .sc-foot { margin-top: .5rem; display: flex; gap: .4rem; align-items: center; }
.copy-ok { color: var(--success); font-size: var(--fs-xs); font-weight: var(--fw-semibold); }

.accordion { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.acc-item { border-bottom: 1px solid var(--border); }
.acc-item:last-child { border-bottom: none; }
.acc-q { width: 100%; text-align: left; background: var(--surface); border: none; cursor: pointer; padding: .9rem 1rem; font: inherit; font-weight: var(--fw-semibold); display: flex; gap: .6rem; align-items: center; }
.acc-q:hover { background: var(--surface-2); }
.acc-q .acc-ico { margin-left: auto; transition: var(--t-fast); color: var(--text-muted); }
.acc-item.open .acc-q .acc-ico { transform: rotate(180deg); }
.acc-a { padding: 0 1rem 1rem; font-size: var(--fs-sm); line-height: 1.55; color: var(--text); }
.acc-a .label-strong { font-weight: var(--fw-semibold); }

.prose { font-size: var(--fs-base); line-height: 1.6; max-width: 760px; }
.prose h2 { font-size: var(--fs-lg); margin-top: 1.6rem; }
.prose h3 { font-size: var(--fs-md); margin-top: 1.2rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: .3rem 0; }
.prose code { font-family: var(--font-mono); background: var(--surface-2); padding: .1em .4em; border-radius: var(--radius-sm); font-size: .9em; }
.callout { border-left: 3px solid var(--brand-accent); background: color-mix(in srgb, var(--brand-accent) 7%, transparent); padding: .8rem 1rem; border-radius: var(--radius-md); margin: 1rem 0; font-size: var(--fs-sm); }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1.2rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16,20,28,.55); }
.modal { position: relative; width: 100%; max-width: 640px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-height: 92vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.modal-title { font-size: var(--fs-lg); margin: 0; }
.modal-body { padding: 1.2rem; overflow-y: auto; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* lead detail */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1.2rem; margin-bottom: 1rem; }
.detail-grid .dl { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.detail-grid .dv { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.log { display: flex; flex-direction: column; gap: .5rem; max-height: 180px; overflow-y: auto; }
.log-item { font-size: var(--fs-sm); border-left: 2px solid var(--border); padding-left: .7rem; }
.log-item .lt { font-size: var(--fs-xs); color: var(--text-faint); }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: .7rem 1.1rem; border-radius: var(--radius-pill); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); font-weight: var(--fw-medium); z-index: 80; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 240px; transform: translateX(-100%); transition: transform var(--t-med); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .only-mobile { display: inline-flex; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
}
@media (max-width: 520px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- canon additions (product "Both", 21+ N/A, grouped form) ---------- */
.badge-product[data-product="both"] { color: var(--product-both); background: color-mix(in srgb, var(--product-both) 12%, transparent); border-color: color-mix(in srgb, var(--product-both) 30%, transparent); }
.badge-21.na { color: var(--text-muted); background: var(--surface-2); border-color: var(--border); }
.form-section { margin: 1.2rem 0 .5rem; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--brand-accent); font-weight: var(--fw-semibold); border-top: 1px solid var(--border); padding-top: .8rem; }
.form-section:first-of-type { border-top: none; padding-top: 0; margin-top: .2rem; }
.doc-links { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.doc-links a.btn { text-decoration: none; }
.brand .logo-mark img, .auth-logo img { display: block; }

/* ---------- in-app document viewer (light "paper" on the dark app) ---------- */
.doc-paper { background:#fff; color:#14181f; border:1px solid var(--border-strong); border-radius:var(--radius-md); padding:1.4rem 1.5rem; }
.doc-paper h2 { color:#08080f; font-size:var(--fs-xl); margin-top:0; }
.doc-paper h3 { color:#08080f; }
.doc-paper a { color:#0077B6; }
.doc-paper .muted { color:#51607a; }
.doc-paper em { color:#51607a; }
.doc-paper .callout { border-left:3px solid #0077B6; background:#eef7fb; color:#14181f; }

/* ---------- fix: native <button> text color on dark theme ---------- */
.acc-q { color: var(--text); }            /* objection questions were inheriting black */
button { color: inherit; }                /* safety net: no OS-default black on any button */

/* ---------- logo sizing (inline SVG hexagon + H) ---------- */
.hb-logo { display:block; width:auto; }
.brand .hb-logo { height:30px; }
.auth-logo .hb-logo { height:46px; margin:0 auto; }
