/* ============================================================
   WAVHub theme tokens.
   --brand / --accent / --font are set at runtime from Company
   Settings (colors can be extracted from the uploaded logo).
   Everything else derives from them.
   ============================================================ */
:root {
  --brand: #f5c518;
  --accent: #b6f518;
  --accent2: #ff8a3d;
  --on-brand: #111111;   /* text on brand backgrounds — set from luminance at runtime */
  --brand-ink: #8a6d00;  /* darker brand for links/text on light surfaces — set at runtime */
  --link: var(--brand-ink);
  --font: 'Inter';
  --heading-font: 'Montserrat';
  --brand-50: color-mix(in srgb, var(--brand) 8%, var(--card));
  --brand-100: color-mix(in srgb, var(--brand) 18%, var(--card));
  --brand-grad: linear-gradient(120deg, var(--accent), var(--brand) 55%, var(--accent2));
  --bg: #f4f4f2;
  --card: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f1f3f7;
  --hover: color-mix(in srgb, var(--brand) 6%, #ffffff);
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-2: #d1d5db;
  /* Sidebar: default "dark" style is WAVHub charcoal */
  --side: #161616;
  --side-2: #262626;
  --side-text: #d4d4d4;
  --side-muted: #8a8a8a;
  --side-active: var(--brand-grad);
  --ok: #059669; --ok-bg: #ecfdf5;
  --warn: #d97706; --warn-bg: #fffbeb;
  --bad: #dc2626; --bad-bg: #fef2f2;
  --info: #2563eb; --info-bg: #eff6ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);
  color-scheme: light;
  font-size: 14px;
}
/* Sidebar style variants */
:root[data-sidebar="brand"] { --side: color-mix(in srgb, var(--brand) 30%, #111); --side-2: color-mix(in srgb, var(--brand) 40%, #1a1a1a); --side-text: #f5f5f5; --side-muted: color-mix(in srgb, var(--brand) 45%, #bbb); }
:root[data-sidebar="light"] { --side: var(--card); --side-2: var(--brand-50); --side-text: var(--text-2); --side-muted: var(--muted); }
:root[data-sidebar="light"] .sidebar { border-right: 1px solid var(--border); }
:root[data-sidebar="light"] .logo, :root[data-sidebar="light"] .side-foot .who b, :root[data-sidebar="light"] .nav a:hover { color: var(--text); }
:root[data-sidebar="light"] .nav a.active { color: var(--on-brand); }
/* Dark mode */
:root[data-theme="dark"] {
  --card: #2a2a2a;
  --bg: #1f1f1f;
  --surface-2: #313131;
  --surface-3: #363636;
  --hover: color-mix(in srgb, var(--brand) 7%, #2a2a2a);
  --text: #f5f5f5;
  --text-2: #d0d0d0;
  --muted: #a3a3a3;
  --border: #3a3a3a;
  --border-2: #4a4a4a;
  --side: #161616;
  --link: var(--brand);
  --ok-bg: rgba(5, 150, 105, .15); --warn-bg: rgba(217, 119, 6, .15); --bad-bg: rgba(220, 38, 38, .15); --info-bg: rgba(37, 99, 235, .15);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}
:root[data-theme="dark"] .badge.ok, :root[data-theme="dark"] .alert.ok { color: #34d399; }
:root[data-theme="dark"] .badge.warn, :root[data-theme="dark"] .alert.warn { color: #fbbf24; }
:root[data-theme="dark"] .badge.bad, :root[data-theme="dark"] .alert.bad { color: #f87171; }
:root[data-theme="dark"] .badge.info, :root[data-theme="dark"] .alert.info { color: #60a5fa; }
:root[data-theme="dark"] .alert { border-color: var(--border); }
:root[data-theme="dark"] .tag { background: var(--brand-100); color: var(--text); }
:root[data-theme="dark"] .login-form { background: var(--card); }
:root[data-theme="dark"] .ev-meeting, :root[data-theme="dark"] .ev-call, :root[data-theme="dark"] .ev-email, :root[data-theme="dark"] .ev-sms, :root[data-theme="dark"] .ev-whatsapp, :root[data-theme="dark"] .ev-visit, :root[data-theme="dark"] .ev-todo { background: var(--surface-3); color: var(--text); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.55 var(--font), Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .kpi .val, .logo, .page-head h1 { font-family: var(--heading-font), var(--font), sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
svg.lucide { width: 16px; height: 16px; stroke-width: 2; vertical-align: -3px; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 16px; }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 16px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; color: #fff; font-weight: 800; font-size: 17px; letter-spacing: .2px; }
.logo .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand-grad); display: grid; place-items: center; color: #111; font-size: 15px; box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 50%, transparent); }
.logo small { display: block; font-weight: 500; font-size: 10.5px; color: var(--side-muted); letter-spacing: .14em; }
.logo img.brand-logo { max-height: 38px; max-width: 180px; object-fit: contain; }
.logo.has-img { padding: 18px 18px 14px; }
.logo-chip { background: #fff; border-radius: 10px; padding: 6px 10px; display: inline-flex; }
.logo .mark-img { width: 36px; height: 36px; border-radius: 9px; object-fit: cover; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.login-art h2 span { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-art .logo { font-size: 22px; padding: 0; }
.login-art .logo .mark-img { width: 48px; height: 48px; border-radius: 12px; }
.nav { padding: 6px 12px; flex: 1; }
.nav .section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--side-muted); padding: 16px 10px 6px; font-weight: 700; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: var(--side-text); font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--side-active); color: #111; font-weight: 650; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 35%, transparent); }
.nav a .count { margin-left: auto; background: #ef4444; color: #fff; font-size: 11px; border-radius: 10px; padding: 0 7px; font-weight: 700; }
.side-foot { padding: 14px; border-top: 1px solid var(--side-2); display: flex; align-items: center; gap: 10px; }
.side-foot .who { flex: 1; min-width: 0; }
.side-foot .who b { color: #fff; display: block; font-size: 13px; }
.side-foot .who span { font-size: 11px; color: var(--side-muted); text-transform: capitalize; }
.side-foot button { background: none; border: 0; color: var(--side-muted); cursor: pointer; padding: 6px; border-radius: 6px; }
.side-foot button:hover { background: var(--side-2); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--brand-grad); opacity: .85; }
.topbar { height: 60px; background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; padding: 0 24px; position: sticky; top: 0; z-index: 20; }
.topbar .burger { display: none; }
.search { position: relative; width: 380px; max-width: 45vw; }
.search input { padding-left: 34px; background: var(--surface-3); border-color: transparent; }
.search input:focus { background: var(--card); }
.search > svg { position: absolute; left: 11px; top: 11px; color: var(--muted); }
.search-results { position: absolute; top: 44px; left: 0; right: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 420px; overflow: auto; z-index: 30; }
.search-results .grp { font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 10px 14px 4px; font-weight: 700; letter-spacing: .05em; }
.search-results a { display: block; padding: 8px 14px; color: var(--text); }
.search-results a:hover { background: var(--bg); text-decoration: none; }
.icon-btn { position: relative; background: none; border: 1px solid transparent; width: 38px; height: 38px; border-radius: 9px; cursor: pointer; color: var(--text-2); display: grid; place-items: center; }
.icon-btn:hover { background: var(--bg); }
.icon-btn .dot { position: absolute; top: 4px; right: 4px; background: #ef4444; color: #fff; border-radius: 9px; font-size: 10px; min-width: 17px; height: 17px; display: grid; place-items: center; font-weight: 700; padding: 0 4px; }
.content { padding: 24px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Components ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.card-h { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card-h h3 { font-size: 14.5px; font-weight: 700; }
.card-h .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-b { padding: 18px; }
.card-b.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi .lbl { color: var(--muted); font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 26px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.kpi .meta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; align-items: center; }
.kpi .ico { position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; }
.kpi .ico svg { width: 18px; height: 18px; }
.delta.up { color: var(--ok); font-weight: 700; } .delta.down { color: var(--bad); font-weight: 700; }
.tone-brand { background: var(--brand-50); color: var(--brand); }
.tone-ok { background: var(--ok-bg); color: var(--ok); }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-bad { background: var(--bad-bg); color: var(--bad); }
.tone-info { background: var(--info-bg); color: var(--info); }
.tone-violet { background: #f5f3ff; color: #7c3aed; }
.tone-pink { background: #fdf2f8; color: #db2777; }
.tone-teal { background: #f0fdfa; color: #0d9488; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border-2); background: var(--card); color: var(--text-2); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 30%, transparent); }
.btn.primary:hover { filter: brightness(.93); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn.xs { height: 26px; padding: 0 9px; font-size: 12px; gap: 4px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 999px 0 0 999px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 999px 999px 0; }
.btn-group .btn.active { background: var(--brand); color: var(--on-brand); border-color: var(--brand); z-index: 1; }

input, select, textarea { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border-2); border-radius: 8px; font: inherit; color: var(--text); background: var(--card); }
textarea { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--brand); vertical-align: -3px; }
input[type=color] { padding: 3px; width: 60px; }
select.inline, input.inline { width: auto; }
label.f { display: block; }
label.f > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
label.f > small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 4px; }
label.chk { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form .full { grid-column: 1 / -1; }
.form h4 { grid-column: 1 / -1; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr:hover td { background: var(--hover); }
table.t th.chk, table.t td.chk { width: 36px; padding-right: 0; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.name-cell { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.name-cell b { display: block; color: var(--text); }
.name-cell span { font-size: 12px; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 650; white-space: nowrap; background: var(--surface-3); color: #374151; }
.badge.ok { background: var(--ok-bg); color: #047857; }
.badge.warn { background: var(--warn-bg); color: #b45309; }
.badge.bad { background: var(--bad-bg); color: #b91c1c; }
.badge.info { background: var(--info-bg); color: #1d4ed8; }
.badge.brand { background: var(--brand-100); color: var(--link); }
.badge.violet { background: #f5f3ff; color: #6d28d9; }
.badge.teal { background: #f0fdfa; color: #0f766e; }
.badge.dark { background: #1f2937; color: #fff; }
.tag { display: inline-block; background: #eef2ff; color: #4338ca; border-radius: 5px; padding: 1px 7px; font-size: 11.5px; font-weight: 600; margin: 1px 2px 1px 0; }
.score { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 12px; }
.score.hot { color: #dc2626; } .score.warm { color: #d97706; } .score.cold { color: #6b7280; }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; color: #fff; flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; gap: 7px; align-items: center; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--link); border-bottom-color: var(--brand); }
.tabs .n { background: var(--surface-3); color: var(--text-2); border-radius: 10px; padding: 0 7px; font-size: 11px; }
.tabs button.active .n { background: var(--brand-100); color: var(--link); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { width: 260px; }
.toolbar select { width: auto; min-width: 140px; }
.bulkbar { display: flex; gap: 8px; align-items: center; background: var(--brand-50); border: 1px solid var(--brand-100); padding: 8px 12px; border-radius: 10px; margin-bottom: 12px; flex-wrap: wrap; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: #cbd5e1; margin-bottom: 10px; }
.empty h3 { color: var(--text); font-size: 15px; margin-bottom: 4px; }

.list-item { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); align-items: center; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t1 { font-weight: 600; color: var(--text); }
.list-item .t2 { font-size: 12px; color: var(--muted); }
.type-ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; }

.timeline { position: relative; padding-left: 8px; }
.tl-item { display: flex; gap: 12px; padding: 10px 0; position: relative; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 42px; bottom: -4px; width: 2px; background: var(--border); }
.tl-item .ti { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.tl-item .tb { flex: 1; min-width: 0; padding-top: 5px; }
.tl-item .tb .d { white-space: pre-wrap; word-break: break-word; }
.tl-item .tb .w { font-size: 12px; color: var(--muted); margin-top: 2px; }

.progress { height: 8px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); border-radius: 6px; }
.funnel-row { display: grid; grid-template-columns: 130px 1fr 90px; gap: 12px; align-items: center; padding: 7px 0; }
.funnel-row .bar { height: 26px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.funnel-row .bar > div { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), var(--accent)); min-width: 3px; }
.funnel-row .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.funnel-row .v small { color: var(--muted); font-weight: 500; }

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }

/* ---------- Modal / toast / dropdown ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 100; overflow-y: auto; animation: fade .12s; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); animation: pop .15s; }
.modal.lg { max-width: 820px; } .modal.xl { max-width: 1100px; } .modal.sm { max-width: 420px; }
.modal-h { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-h h3 { font-size: 16.5px; }
.modal-h .x { margin-left: auto; }
.modal-b { padding: 20px 22px; max-height: 70vh; overflow-y: auto; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 14px 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: #111827; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 260px; max-width: 400px; display: flex; gap: 10px; align-items: flex-start; animation: pop .2s; cursor: pointer; }
.toast.ok { background: #065f46; } .toast.bad { background: #991b1b; }
.toast b { display: block; }
.toast small { opacity: .85; }
.dropdown { position: absolute; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 50; }
.notif-panel { right: 16px; top: 56px; width: 380px; max-height: 520px; display: flex; flex-direction: column; }
.notif-panel .list { overflow-y: auto; }
.notif { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif:hover { background: var(--bg); }
.notif.unread { background: var(--brand-50); }
.notif .nb { flex: 1; min-width: 0; }
.notif .nb b { font-size: 13px; display: block; }
.notif .nb p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-2); }
.notif .nb small { color: var(--muted); font-size: 11.5px; }

/* ---------- Pipeline ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: 60vh; }
.kcol { flex: 0 0 290px; background: var(--surface-3); border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 210px); }
.kcol-h { padding: 12px 14px 8px; }
.kcol-h b { display: flex; gap: 8px; align-items: center; }
.kcol-h small { color: var(--muted); font-weight: 600; }
.kcol-b { padding: 6px 10px 12px; overflow-y: auto; flex: 1; min-height: 80px; border-radius: 0 0 12px 12px; transition: background .12s; }
.kcol-b.over { background: var(--brand-100); }
.kcard { background: var(--card); border-radius: 10px; padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: grab; border: 1px solid transparent; }
.kcard:hover { border-color: var(--brand-100); }
.kcard.dragging { opacity: .5; }
.kcard .t { font-weight: 650; }
.kcard .c { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kcard .f { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 12px; }
.kcard .v { font-weight: 800; color: var(--text); font-size: 13.5px; }
.stage-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal .dow { padding: 8px 10px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; color: var(--muted); background: var(--surface-2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal .day { min-height: 118px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; background: var(--card); cursor: pointer; position: relative; }
.cal .day:hover { background: var(--hover); }
.cal .day.other { background: var(--surface-2); }
.cal .day.other .dn { color: #c0c4cc; }
.cal .day .dn { font-size: 12.5px; font-weight: 700; color: var(--text-2); display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; }
.cal .day.today .dn { background: var(--brand); color: var(--on-brand); }
.cal .ev { display: block; font-size: 11.5px; padding: 2px 6px; border-radius: 5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; cursor: pointer; border-left: 3px solid; }
.cal .ev.done { opacity: .5; text-decoration: line-through; }
.cal .more { font-size: 11px; color: var(--muted); padding: 2px 6px; font-weight: 600; }
.ev-meeting { background: #eef2ff; color: #3730a3; border-color: #6366f1 !important; }
.ev-call { background: #ecfdf5; color: #065f46; border-color: #10b981 !important; }
.ev-email { background: #eff6ff; color: #1e40af; border-color: #3b82f6 !important; }
.ev-sms, .ev-whatsapp { background: #f0fdfa; color: #115e59; border-color: #14b8a6 !important; }
.ev-visit { background: #fff7ed; color: #9a3412; border-color: #f97316 !important; }
.ev-todo { background: var(--surface-3); color: #374151; border-color: #9ca3af !important; }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.editor textarea.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; min-height: 520px; line-height: 1.55; tab-size: 2; white-space: pre; }
.preview-frame { width: 100%; min-height: 560px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; font-size: 11.5px; cursor: pointer; font-family: ui-monospace, Consolas, monospace; color: var(--text-2); }
.chip:hover { background: var(--brand-100); border-color: var(--brand); color: var(--text); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tpl-card { display: flex; flex-direction: column; overflow: hidden; }
.tpl-card .thumb { height: 150px; background: var(--surface-3); overflow: hidden; position: relative; border-bottom: 1px solid var(--border); }
.tpl-card .thumb iframe { width: 200%; height: 300px; transform: scale(.5); transform-origin: 0 0; border: 0; pointer-events: none; }
.tpl-card .body { padding: 14px 16px; flex: 1; }
.tpl-card .foot { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; gap: 6px; }

/* ---------- Contact detail ---------- */
.profile { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.info-list { display: grid; gap: 12px; }
.info-list .ii { display: flex; gap: 10px; align-items: flex-start; }
.info-list .ii svg { color: var(--muted); margin-top: 2px; }
.info-list .ii div { min-width: 0; word-break: break-word; }
.info-list .ii small { display: block; color: var(--muted); font-size: 11.5px; }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.eng { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.eng span { display: inline-flex; gap: 4px; align-items: center; }
.eng .on { color: var(--ok); font-weight: 600; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(700px 420px at 105% 105%, color-mix(in srgb, var(--accent2) 45%, transparent), transparent 65%), radial-gradient(700px 480px at -10% -10%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 60%), radial-gradient(900px 600px at 60% 40%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 70%), #141414; position: relative; overflow: hidden; color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h2 { font-size: 34px; line-height: 1.15; max-width: 480px; letter-spacing: -.02em; }
.login-art ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.login-art li { display: flex; gap: 10px; align-items: center; opacity: .92; }
.login-form { display: grid; place-items: center; padding: 32px; background: var(--card); }
.login-form form { width: 100%; max-width: 380px; display: grid; gap: 16px; }
.login-form h1 { font-size: 24px; }

.alert { padding: 12px 14px; border-radius: 10px; display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.alert.warn { background: var(--warn-bg); color: #92400e; border: 1px solid #fde68a; }
.alert.info { background: var(--info-bg); color: #1e40af; border: 1px solid #bfdbfe; }
.alert.bad { background: var(--bad-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert.ok { background: var(--ok-bg); color: #065f46; border: 1px solid #a7f3d0; }

.perm-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; }
.perm-grid .grp { grid-column: 1 / -1; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 8px; }
.heat { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; }
.heat div { height: 32px; border-radius: 4px; background: var(--brand); }
.heat-labels { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; font-size: 10px; color: var(--muted); text-align: center; margin-top: 4px; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); }
.loading { display: grid; place-items: center; padding: 60px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } .profile { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 90; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .topbar .burger { display: grid; }
  .g2, .g3, .editor, .form { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; }
  .content { padding: 16px; }
  .search { width: auto; flex: 1; max-width: none; }
}
@media print { .sidebar, .topbar, .page-head .actions { display: none !important; } .shell { display: block; } }

/* ---------- Brand flourishes ---------- */
.wave-bg { position: absolute; left: -10%; right: -10%; bottom: -20px; height: 220px; opacity: .22; pointer-events: none; }
.login-art > * { position: relative; z-index: 1; }
.login-art .logo-chip img { max-height: 44px; max-width: 220px; }
.login-form .brand-mobile { display: none; }
@media (max-width: 900px) { .login-form .brand-mobile { display: block; margin-bottom: 8px; } }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand-grad); opacity: 0; transition: opacity .15s; }
.kpi:hover::before { opacity: 1; }
.theme-preview { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: grid; grid-template-columns: 120px 1fr; height: 190px; }
.theme-preview .tp-side { background: var(--side); padding: 12px 10px; display: grid; gap: 6px; align-content: start; }
.theme-preview .tp-side i { display: block; height: 8px; border-radius: 4px; background: var(--side-2); }
.theme-preview .tp-side i.on { background: var(--side-active); height: 18px; }
.theme-preview .tp-main { background: var(--bg); padding: 14px; display: grid; gap: 10px; align-content: start; }
.theme-preview .tp-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 9px; cursor: pointer; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--border); }
.swatch:hover { transform: scale(1.08); }
.logo-drop { border: 2px dashed var(--border-2); border-radius: 12px; padding: 20px; text-align: center; cursor: pointer; background: var(--surface-2); }
.logo-drop:hover, .logo-drop.over { border-color: var(--brand); background: var(--brand-50); }
.logo-drop img { max-height: 80px; max-width: 260px; }
:root[data-theme="dark"] .tone-violet { background: rgba(124, 58, 237, .18); color: #c4b5fd; }
:root[data-theme="dark"] .tone-pink { background: rgba(219, 39, 119, .18); color: #f9a8d4; }
:root[data-theme="dark"] .tone-teal { background: rgba(13, 148, 136, .18); color: #5eead4; }
:root[data-theme="dark"] .tone-brand { background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--brand); }
:root[data-theme="dark"] .badge.violet { background: rgba(124, 58, 237, .2); color: #c4b5fd; }
:root[data-theme="dark"] .badge.teal { background: rgba(13, 148, 136, .2); color: #5eead4; }
:root[data-theme="dark"] .badge { background: var(--surface-3); color: var(--text-2); }
:root[data-theme="dark"] .badge.ok { background: var(--ok-bg); }
:root[data-theme="dark"] .badge.warn { background: var(--warn-bg); }
:root[data-theme="dark"] .badge.bad { background: var(--bad-bg); }
:root[data-theme="dark"] .badge.info { background: var(--info-bg); }
:root[data-theme="dark"] .badge.brand { background: color-mix(in srgb, var(--brand) 20%, transparent); }
:root[data-theme="dark"] .kcol { background: #242424; }
