/* Soaring OS — dashboard design, following the Soaring OS mockup.
   Light sidebar, off-white canvas, white cards, vivid orange brand (#FF6B00). */
:root {
  --orange: #FF6B00;
  --orange-dark: #e05e00;
  --orange-soft: #FDBA74;
  --orange-tint: #FFF1E6;
  --bg: #F9FAFB;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --divider: #F3F4F6;
  --text: #111827;
  --text-secondary: #4B5563;
  --text-muted: #9CA3AF;
  --green: #10B981; --green-bg: #D1FAE5; --green-text: #065F46;
  --red: #EF4444;   --red-bg: #FEE2E2;   --red-text: #991B1B;
  --blue: #3B82F6;
  --warn: #F59E0B;  --warn-bg: #FEF3C7;  --warn-text: #92400E;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 4px 16px rgba(16,24,40,.08);
  --radius: 12px;
  --sidebar-w: 244px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Plus Jakarta Sans", Inter, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
.num, .kpi-value, td, th { font-variant-numeric: tabular-nums; }

/* ── Layout ─────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  padding: 1.1rem .9rem;
  gap: 1.25rem;
}
.side-brand { display: flex; align-items: center; gap: .6rem; padding: .1rem .35rem .4rem; }
.side-brand img { width: 34px; height: 34px; object-fit: contain; }
.drawer-brand img { width: 30px; height: 30px; object-fit: contain; }
.brand-name { font-weight: 800; font-size: 15px; line-height: 1.1; letter-spacing: .2px; }
.brand-name em { font-style: normal; color: var(--orange); }
.brand-sub { font-size: 10.5px; color: var(--text-muted); letter-spacing: .4px; text-transform: uppercase; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-muted); padding: .5rem .55rem .3rem; }
.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .6rem; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-secondary);
  font-size: 13.5px; font-weight: 500; text-align: left; width: 100%;
  text-decoration: none;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--orange-tint); color: var(--orange-dark); font-weight: 700; }
.nav-badge { margin-left: auto; background: var(--red-bg); color: var(--red-text);
  font-size: 11px; font-weight: 700; border-radius: 20px; padding: 0 .45rem; line-height: 1.5; }

.side-promo {
  margin-top: auto;
  background: linear-gradient(135deg, #FF6B00, #FF9A3D);
  color: #fff; border-radius: var(--radius); padding: .9rem 1rem;
  font-size: 12px; line-height: 1.4; box-shadow: var(--shadow-lg);
}
.side-promo b { font-size: 13px; display: block; margin-bottom: 2px; }

.side-user { display: flex; align-items: center; gap: .6rem; padding: .7rem .35rem 0;
  border-top: 1px solid var(--divider); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--orange-tint);
  color: var(--orange-dark); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.side-user .who { min-width: 0; }
.side-user .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .status { width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-left: auto; box-shadow: 0 0 0 3px var(--green-bg); }
.side-logout { margin-left: auto; color: var(--text-muted); text-decoration: none; font-size: 12px; }
.side-logout:hover { color: var(--red-text); }

.main { flex: 1; min-width: 0; padding: 1.5rem 1.75rem 3rem; }

/* ── Header bar ─────────────────────────────────────────── */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  margin-bottom: 1.5rem; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.2px; }
.subtitle { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: .6rem; }
.live-pill { display: inline-flex; align-items: center; gap: .45rem; font-size: 12px; font-weight: 600;
  color: var(--green-text); background: var(--green-bg); padding: .35rem .7rem; border-radius: 20px; }
.live-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.updated { color: var(--text-muted); font-size: 12px; }
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
  padding: .5rem .9rem; border-radius: 8px; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: .4rem;
}
.btn:hover { border-color: var(--orange); color: var(--orange); }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); color: #fff; }
.btn.loading { opacity: .5; pointer-events: none; }

/* ── KPI cards ─────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow);
  border-top: 3px solid var(--orange);
}
.kpi-card.k-blue { border-top-color: var(--blue); }
.kpi-card.k-green { border-top-color: var(--green); }
.kpi-card.k-red { border-top-color: var(--red); }
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; display: flex; align-items: center; gap: .4rem; }
.kpi-label svg { width: 15px; height: 15px; }
.kpi-value { font-size: 24px; font-weight: 800; margin-top: 5px; letter-spacing: -.3px; color: var(--text); }
.kpi-sub { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.trend { font-size: 12px; font-weight: 700; }
.trend.up { color: var(--red); }
.trend.down { color: var(--green); }

/* ── Sections & cards ─────────────────────────────────── */
.section { margin-bottom: 1.75rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.section h2 { font-size: 16px; font-weight: 700; margin: 0; }
.section h2 .count { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 1rem; overflow: hidden;
}
.account-head { display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.2rem; cursor: pointer; gap: .75rem; flex-wrap: wrap; }
.account-head:hover { background: var(--bg); }
.account-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: .5rem; }
.account-stats { display: flex; gap: 1.25rem; font-size: 13px; color: var(--text-secondary); }
.account-stats b { color: var(--text); }
.caret { color: var(--text-muted); transition: transform .15s; font-size: 12px; }
.card.open .caret { transform: rotate(90deg); }
.account-body { display: none; border-top: 1px solid var(--divider); }
.card.open .account-body { display: block; }

/* ── Tables ───────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: .65rem .9rem; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; background: var(--bg); border-bottom: 1px solid var(--divider); white-space: nowrap; }
td { border-bottom: 1px solid var(--divider); font-size: 13px; color: var(--text-secondary); }
tr:last-child td { border-bottom: 0; }
tr.total-row td { font-weight: 700; color: var(--text); border-top: 2px solid var(--border); border-bottom: 0; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: .15rem .55rem;
  border-radius: 20px; white-space: nowrap; }
.badge-success { background: var(--green-bg); color: var(--green-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-danger { background: var(--red-bg); color: var(--red-text); }
.badge-gray { background: var(--bg); color: var(--text-secondary); }

/* ── Anomalies ────────────────────────────────────────── */
.anomaly-list { list-style: none; margin: 0; padding: 0; }
.anomaly-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .8rem 1.2rem; border-bottom: 1px solid var(--divider); font-size: 13px; }
.anomaly-list li:last-child { border-bottom: 0; }
.anom-main { min-width: 0; }
.anom-acct { font-weight: 700; color: var(--text); }
.anom-camp { color: var(--text-secondary); font-size: 12px; }
.anom-metric { text-transform: capitalize; }
.anom-pct { font-weight: 700; white-space: nowrap; }
.anom-pct.up { color: var(--red); }
.anom-pct.down { color: var(--green); }

/* ── Loading / empty ──────────────────────────────────── */
.loading { padding: 3rem; text-align: center; color: var(--text-muted); }
.empty { padding: 1.5rem 1.2rem; color: var(--text-muted); }

/* ── Mockup: two-column dashboard grid ───────────────── */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.5rem; align-items: start; }
.dash-main { min-width: 0; }
.dash-side { position: sticky; top: 1rem; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } .dash-side { position: static; } }

.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; margin-bottom: 1rem; }
.kpi-row.row2 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1300px) {
  .kpi-row, .kpi-row.row2 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .95rem 1.05rem; box-shadow: var(--shadow); border-top: 3px solid var(--orange); }
.kpi-card.k-blue { border-top-color: var(--blue); }
.kpi-card.k-green { border-top-color: var(--green); }
.kpi-card.k-red { border-top-color: var(--red); }
.kpi-label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.kpi-label svg { width: 15px; height: 15px; }
.kpi-value { font-size: 22px; font-weight: 800; margin-top: 5px; letter-spacing: -.3px; color: var(--text); }
.kpi-sub { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }
.trend { font-weight: 700; }
.trend-pos { color: var(--green); }
.trend-neg { color: var(--red); }

/* chart */
.chart-card { padding: 1.1rem 1.2rem; }
.chart-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .9rem; }
.chart-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.pill { font-size: 11.5px; font-weight: 600; color: var(--text-secondary); background: var(--bg);
  border: 1px solid var(--border); padding: .3rem .65rem; border-radius: 20px; }
.chart-tabs { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.chart-tabs button { border: 0; background: transparent; padding: .35rem .8rem; font-size: 12.5px;
  font-weight: 600; color: var(--text-secondary); border-radius: 6px; }
.chart-tabs button.active { background: var(--surface); color: var(--orange); box-shadow: var(--shadow); }
.trend-range { border: 1px solid var(--border); color: var(--text-muted); background: var(--surface); cursor: pointer; font: inherit; }
.trend-range:focus { outline: 2px solid var(--orange-tint); border-color: var(--orange); }
.chart-wrap { position: relative; }
.trend-svg { display: block; width: 100%; height: 220px; overflow: visible; }
.trend-svg { touch-action: none; }
.trend-svg { user-select: none; -webkit-user-select: none; }
.trend-tooltip { position: absolute; z-index: 3; min-width: 142px; padding: .55rem .65rem; border: 1px solid #FED7AA; border-radius: 8px; background: rgba(255,255,255,.97); box-shadow: 0 8px 22px rgba(31,41,55,.14); color: var(--text); font-size: 11px; line-height: 1.5; pointer-events: none; }
.trend-tooltip strong { color: var(--text); font-size: 12px; }
.trend-tooltip .tooltip-active { color: var(--orange-dark); font-weight: 800; }
.chart-wrap { width: 100%; height: 230px; position: relative; }
.chart-wrap svg { width: 100%; height: 100%; display: block; }
.chart-legend { display: flex; gap: 1.1rem; margin-top: .7rem; font-size: 12px; color: var(--text-secondary); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* campaign table */
.campaign-table th, .campaign-table td { padding: .7rem .9rem; }
/* CPL colour-code (mirrors the Discord Amalmedik card thresholds):
   green < RM20, amber RM20–50, red > RM50 (or 0 conv). */
.campaign-table td.ok { color: var(--green-text, #16a34a); font-weight: 700; }
.campaign-table td.warn { color: #d97706; font-weight: 700; }
.campaign-table td.bad { color: var(--red, #dc2626); font-weight: 700; }
.platform-badge { display: inline-flex; align-items: center; gap: .35rem; font-size: 11.5px; font-weight: 700;
  padding: .15rem .55rem; border-radius: 6px; }
.platform-badge.meta { background: var(--blue); color: #fff; }
.platform-badge.google { background: var(--orange); color: #fff; }
.status-live { background: var(--green-bg); color: var(--green-text); }

/* AI insights panel */
.ai-panel { padding: 1.1rem; }
.ai-panel .section-head { margin-bottom: 1rem; }
.ai-panel h2 { display: flex; align-items: center; gap: .4rem; font-size: 15px; font-weight: 700; }
.ai-head-link { font-size: 12.5px; color: var(--orange); font-weight: 600; text-decoration: none; }
.ai-head-link:hover { text-decoration: underline; }
.ai-card { border: 1px solid var(--border); border-radius: 10px; padding: .8rem .9rem; margin-bottom: .8rem; }
.ai-card:last-child { margin-bottom: 0; }
.ai-card .tag { display: inline-flex; align-items: center; gap: .35rem; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px; padding: .15rem .5rem; border-radius: 6px; }
.ai-card .when { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.ai-card .text { font-size: 12.5px; color: var(--text-secondary); margin: .55rem 0 .6rem; line-height: 1.45; }
.ai-card .text b { color: var(--text); }
.ai-card .btn { font-size: 12px; padding: .3rem .7rem; }
.ai-card.anomaly { border-left: 3px solid var(--red); }
.ai-card.anomaly .tag { background: var(--red-bg); color: var(--red-text); }
.ai-card.improvement { border-left: 3px solid var(--green); }
.ai-card.improvement .tag { background: var(--green-bg); color: var(--green-text); }
.ai-card.opportunity { border-left: 3px solid var(--blue); }
.ai-card.opportunity .tag { background: rgba(59,130,246,.12); color: var(--blue); }
/* Sales branch highlights: three stat rows inside each ai-card. */
.ai-card .mini-stats { display: flex; gap: .6rem; margin: .2rem 0 .5rem; flex-wrap: wrap; }
.ai-card .mini-stats > div { flex: 1 1 30%; min-width: 78px; }
.ai-card .mini-stats span { display: block; font-size: 13.5px; font-weight: 700; color: var(--text); }
.ai-card .mini-stats em { display: block; font-style: normal; font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .3px; margin-top: 2px; }
.ai-card .mini-note { font-size: 11px; color: var(--text-muted); border-top: 1px dashed var(--border); padding-top: .45rem; }
.ai-text { margin: .4rem 0 0; font-size: 13px; color: var(--text-secondary); line-height: 1.45; }

/* ── Client dashboard: branch performance ─────────────── */
.client-name { font-weight: 700; color: var(--text); font-size: 14px; }
.branch-list { padding: .3rem 1.2rem 1rem; display: flex; flex-direction: column; }
.branch-row { display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left;
  border: 0; border-bottom: 1px solid var(--divider); background: transparent; padding: .8rem .2rem;
  cursor: pointer; color: var(--text); }
.branch-row:last-child { border-bottom: 0; }
.branch-name { font-weight: 700; font-size: 14px; flex: 0 0 auto; }
.branch-meta { flex: 1; color: var(--text-muted); font-size: 12px; text-align: right; }
.branch-spend { font-weight: 700; font-size: 14px; white-space: nowrap; }
.client-list { padding: .3rem 1.2rem 1rem; display: flex; flex-direction: column; }
.client-row-link { display: flex; align-items: center; padding: .85rem .2rem; border-bottom: 1px solid var(--divider);
  color: var(--text); font-weight: 600; text-decoration: none; font-size: 14px; }
.client-row-link:hover { color: var(--orange); }
.client-row-link:last-child { border-bottom: 0; }
.ai-card.empty { color: var(--text-muted); text-align: center; font-size: 12.5px; border-left: 3px solid var(--border); }

/* ── Auth pages (premium light SaaS) ───────────────────── */
.auth-body {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: linear-gradient(180deg, #fff3e9 0%, #f5f7fb 55%, #eef2f8 100%);
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-brand { text-align: center; margin-bottom: 1.6rem; }
.auth-brand img { height: 48px; width: auto; object-fit: contain; }
.auth-brand .ab-name { font-weight: 800; font-size: 20px; color: #151b26; margin-top: .55rem; letter-spacing: -.3px; }
.auth-brand .ab-sub { font-size: 12px; color: #6b7280; letter-spacing: .5px; font-weight: 600; text-transform: uppercase; }

.auth-card {
  background: #ffffff;
  border: 1px solid #eceff4;
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(20,25,45,.10), 0 4px 12px rgba(20,25,45,.04);
  padding: 2.1rem 1.9rem;
}
.auth-card h1 { margin: 0 0 .25rem; font-size: 25px; font-weight: 800; color: #111827; letter-spacing: -.4px; }
.auth-hint { margin: 0 0 1.7rem; color: #6b7280; font-size: 14px; }
.auth-msg { background: #e8f9ef; color: #0c7a43; padding: .6rem .8rem; border-radius: 10px; font-size: 13px; margin-bottom: 1rem; }
.auth-error { background: #fdecec; color: #b3261e; padding: .6rem .8rem; border-radius: 10px; font-size: 13px; margin-bottom: 1rem; }
.auth-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 1rem; color: #374151; }
.auth-card input[type=text], .auth-card input[type=email], .auth-card input[type=password],
.auth-card input[type=tel] {
  width: 100%; padding: .9rem 1rem; margin-top: 6px; box-sizing: border-box;
  background: #fbfcfe; border: 1px solid #dbe1ea; border-radius: 12px; font-size: 15px;
  color: #111827; min-height: 50px;
}
.auth-card input::placeholder { color: #9aa3af; }
.auth-card input:focus { outline: 2px solid var(--orange); outline-offset: 1px; border-color: transparent; background: #fff; }
.auth-row { display: flex; justify-content: space-between; align-items: center; margin: .1rem 0 1.2rem; font-size: 13px; }
.auth-row label { display: flex; align-items: center; gap: .45rem; font-weight: 500; margin: 0; color: #374151; cursor: pointer; }
.auth-row input[type=checkbox] { accent-color: var(--orange); width: 16px; height: 16px; }
.auth-row a { color: var(--orange); font-weight: 700; text-decoration: none; }
.btn-login { width: 100%; padding: .95rem; border: 0; border-radius: 12px; font-size: 15px; font-weight: 700;
  color: #fff; background: var(--orange); box-shadow: 0 10px 24px rgba(255,107,0,.30);
  display: flex; align-items: center; justify-content: center; gap: .5rem; cursor: pointer; min-height: 52px; }
.btn-login:hover { background: var(--orange-dark); }
.btn-login:disabled { opacity: .55; cursor: not-allowed; }
.auth-divider { display: flex; align-items: center; gap: .8rem; margin: 1.5rem 0; color: #8a919e; font-size: 12.5px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: #e6e9ef; }
.auth-social { display: flex; flex-direction: column; gap: .7rem; }
.btn-social { display: flex; align-items: center; justify-content: center; gap: .6rem; padding: .85rem;
  background: #ffffff; border: 1px solid #d7dce3; border-radius: 12px; font-size: 14px; font-weight: 600;
  color: #1f2937; text-decoration: none; min-height: 50px; cursor: pointer; }
.btn-social:hover { border-color: #ff6b00; color: #111; }
.btn-social:disabled { opacity: .5; cursor: not-allowed; }
.btn-social img, .btn-social svg { width: 18px; height: 18px; }
.auth-foot { text-align: center; margin-top: 1.4rem; font-size: 13px; color: #6b7280; }
.auth-foot a { color: var(--orange); font-weight: 700; text-decoration: none; }

/* ── Account page ─────────────────────────────────────── */
.account-grid { max-width: 520px; }
.acct-card { padding: 1.4rem 1.5rem; }
.acct-card h2 { margin: 0 0 1.1rem; font-size: 15px; font-weight: 700; }
.acct-avatar { width: 150px; height: 150px; border-radius: 50%; object-fit: cover; background: var(--orange-tint);
  color: var(--orange-dark); display: grid; place-items: center; font-size: 44px; font-weight: 800;
  flex: 0 0 150px; }
.acct-row { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.2rem; }
.acct-field label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); display: block; margin-bottom: 5px; }
.acct-field input { width: 100%; padding: .7rem .85rem; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; }
.acct-field input:focus { outline: 2px solid var(--orange); outline-offset: 1px; border-color: transparent; }
.acct-actions { display: flex; gap: .6rem; margin-top: .5rem; }
.btn-acct { padding: .7rem 1.2rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 600; font-size: 14px; color: var(--text);
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; cursor: pointer; }
.btn-acct.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-acct.danger { color: var(--red-text); border-color: var(--red); background: transparent; }
.btn-acct:hover { filter: brightness(1.04); }
.acct-actions.stacked { flex-direction: column; align-items: stretch; }
.acct-actions.stacked .btn-acct { width: 100%; }
.acct-divider { height: 1px; background: var(--divider); margin: 1.4rem 0; }
.crop-box { margin-bottom: .6rem; }
.crop-box canvas { width: 150px; height: 150px; border-radius: 10px; display: block;
  cursor: grab; background: #111; border: 1px solid var(--border); }
.crop-box canvas:active { cursor: grabbing; }
.crop-controls { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; }
.crop-controls button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 16px; line-height: 1; cursor: pointer; }
.crop-controls input[type=range] { flex: 1; accent-color: var(--orange); }
.crop-hint { font-size: 11px; color: var(--text-muted); margin-top: .3rem; }
.upload-msg { font-size: 12px; color: var(--orange); font-weight: 600; margin-top: .5rem; }
.back-link { display: inline-flex; align-items: center; gap: .35rem; color: var(--text-muted);
  font-size: 13px; font-weight: 600; text-decoration: none; margin-bottom: .9rem; }
.back-link:hover { color: var(--orange); }

/* ── Greeting + profile menu ──────────────────────────── */
.greeting { margin-bottom: 1.25rem; }
.greeting-line { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.greeting-date { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
/* Client page (client-access only): greeting left, client name right, all on one
   horizontal line. align-items:flex-start puts the name on the SAME line as the
   greeting text (not centered against the taller block that includes the date). */
.greeting-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.25rem; }
.greeting-row .greeting { margin-bottom: 0; }
.greeting-row .greeting-client { padding-top: 2px; }
.client-plain-grand { font-size: 22px; font-weight: 800; letter-spacing: -.3px; color: var(--text); }
/* Refresh button above the AI Insights panel (right side, client page). */
.dash-side-refresh { display: flex; justify-content: flex-end; margin-bottom: .6rem; }
.avatar-img { object-fit: cover; border-radius: 50%; width: 30px; height: 30px; }
.profile-menu { position: absolute; top: calc(100% + 8px); right: .6rem; z-index: 80;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); min-width: 190px; padding: .5rem; display: none; }
.profile-menu.open { display: block; }
.pm-head { padding: .5rem .6rem .6rem; border-bottom: 1px solid var(--divider); margin-bottom: .3rem; }
.pm-name { font-weight: 700; font-size: 14px; }
.pm-email { font-size: 12px; color: var(--text-muted); word-break: break-all; }
.pm-item { display: block; padding: .55rem .6rem; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 13.5px; }
.pm-item:hover { background: var(--bg); }
.pm-item[href="/logout"] { color: var(--red-text); }

/* ── Modal ─────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(17,24,39,.45); padding: 1.5rem; }
.modal[hidden] { display: none; }
.modal-card { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 1.8rem 1.6rem; max-width: 340px; width: 100%; text-align: center; }
.modal-card h3 { margin: 0 0 .5rem; font-size: 19px; }
.modal-card p { margin: 0 0 1.4rem; color: var(--text-secondary); font-size: 14px; }

/* ── Admin: filter tabs + client selector ──────────────── */
.filter-tabs { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.ftab { padding: .5rem 1rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13.5px; font-weight: 600; color: var(--text-secondary); text-decoration: none; }
.ftab.active { background: var(--orange); border-color: var(--orange); color: #fff; }
.client-picker { display: flex; align-items: center; gap: .5rem; }
.client-picker select { padding: .5rem .7rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; }
.client-row { display: flex; align-items: center; gap: .5rem; margin: 0 0 1rem; }
.client-row label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.client-row select { padding: .45rem .7rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; }
.client-plain { font-size: 15px; font-weight: 700; color: var(--text); }

/* ── Dark mode ────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0F14;
    --surface: #141A21;
    --border: rgba(255,255,255,0.09);
    --divider: rgba(255,255,255,0.06);
    --text: #F3F5F7;
    --text-secondary: #B6BCC8;
    --text-muted: #7D8494;
    --orange-tint: rgba(255,107,0,0.15);
    --green-bg: rgba(16,185,129,0.16); --green-text: #6FD4A4;
    --red-bg: rgba(239,68,68,0.16);   --red-text: #F09696;
    --warn-bg: rgba(245,158,11,0.16); --warn-text: #F0B36A;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.35);
  }
  .nav-item:hover { background: var(--surface); }
  th { background: var(--surface); }
}

/* ── Mobile shell (hidden on desktop) ───────────────────── */
.mobile-top, .mobile-datebar, .bottom-nav, .mobile-drawer, .drawer-overlay { display: none; }

/* ── Responsive / Mobile ───────────────────────────────── */
@media (max-width: 760px) {
  .app { display: block; }
  .sidebar { display: none; }

  /* top app bar */
  .mobile-top {
    display: flex; align-items: center; gap: .75rem;
    position: fixed; top: 0; left: 0; right: 0; z-index: 40;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top));
  }
  .hamburger { border: 0; background: transparent; font-size: 22px; color: var(--text); padding: .2rem; line-height: 1; }
  .mobile-brand { display: flex; align-items: center; gap: .5rem; }
  .mobile-brand img { width: 30px; height: 30px; object-fit: contain; }
  .mb-name { font-weight: 800; font-size: 15px; line-height: 1.1; }
  .mb-sub { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
  .mobile-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
  .icon-btn { border: 0; background: transparent; font-size: 19px; position: relative; color: var(--text); padding: .2rem; }
  .icon-btn .nav-badge { position: absolute; top: -2px; right: -6px; }
  .shell-notification-menu { position: fixed; top: calc(52px + env(safe-area-inset-top)); right: .8rem; z-index: 70;
    width: min(320px, calc(100vw - 1.6rem)); background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
  .shell-notification-head { padding: .75rem .9rem; font-size: 14px; font-weight: 800; border-bottom: 1px solid var(--divider); }
  .shell-notification-item { display: block; padding: .7rem .9rem; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--divider); }
  .shell-notification-item:hover, .shell-notification-item.unread { background: var(--bg); }
  .shell-notification-item strong { display: block; font-size: 13px; }
  .shell-notification-item span { display: block; margin-top: .2rem; color: var(--text-secondary); font-size: 12px; line-height: 1.35; }
  .shell-notification-empty { padding: 1rem .9rem; color: var(--text-muted); font-size: 13px; }

  .main { padding: 5.7rem 1rem calc(5.5rem + env(safe-area-inset-bottom)); }
  .main { padding-top: calc(66px + env(safe-area-inset-top)); }
  .topbar { display: none; }

  /* fixed top section (greeting + date + client) with scrolling content — client + admin */
  .fixed-top {
    position: fixed; top: calc(50px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 30;
    background: var(--bg); padding: 0 1rem; border-bottom: 1px solid var(--border);
  }
  .fixed-top .greeting { margin-top: 1rem; }
  .client-back { margin-left: auto; color: var(--orange); text-decoration: none; font-size: 12.5px; font-weight: 600; }
  .main-top-fixed { padding-top: calc(300px + env(safe-area-inset-top)); }

  /* date navigator — now in-flow, between greeting and client selector */
  .mobile-datebar {
    display: flex; align-items: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: .35rem .4rem; margin-bottom: .9rem;
  }
  .date-strip { display: flex; gap: .5rem; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity; padding-bottom: .15rem; width: 100%; }
  .date-strip button { border: 0; background: transparent; display: flex; flex-direction: column;
    align-items: center; justify-content: center; flex: 0 0 auto; scroll-snap-align: start;
    min-width: 46px; padding: .35rem .4rem; border-radius: 10px; color: var(--text-secondary); }
  .date-strip button span { font-size: 10.5px; font-weight: 600; color: var(--text-muted); }
  .date-strip button .ds-num { font-size: 15px; font-weight: 700; color: var(--text); margin-top: 1px; }
  .date-strip button.active { background: var(--orange); box-shadow: 0 2px 8px rgba(255,107,0,.3); }
  .date-strip button.active span, .date-strip button.active .ds-num { color: #fff; }

  /* KPI cards: clean 2-column grid on mobile (not 9 forced into one row) */
  .kpi-row, .kpi-row.row2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: .85rem; }
  .kpi-row .kpi-card { flex: none; }
  .kpi-card { padding: .8rem .85rem; }
  .kpi-value { font-size: 19px; }

  .card { border-radius: 14px; }
  .chart-wrap { height: 190px; }
  .campaign-table { display: block; overflow-x: auto; }
  .campaign-table thead, .campaign-table tbody { display: table; width: 100%; }
  .dash-side { margin-top: .25rem; }

  /* drawer */
  .mobile-drawer {
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 60;
    background: var(--surface); border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform .22s ease;
    padding: 1rem; padding-top: calc(1rem + env(safe-area-inset-top));
    box-shadow: 4px 0 20px rgba(0,0,0,.12);
  }
  .mobile-drawer.open { transform: translateX(0); }
  .drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
  .drawer-nav { display: flex; flex-direction: column; gap: 4px; }
  .drawer-nav .nav-item { width: 100%; }
  .drawer-foot { margin-top: auto; }
  .drawer-logout { display: block; margin-top: .75rem; padding: .6rem .75rem; border-radius: 8px;
    background: var(--bg); color: var(--red-text); font-weight: 600; text-decoration: none; text-align: center; }
  .drawer-overlay {
    display: block;
    position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 50;
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .drawer-overlay.open { opacity: 1; pointer-events: auto; }

  /* bottom nav */
  .bottom-nav {
    display: flex; align-items: center; justify-content: space-around;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: .4rem .5rem calc(.4rem + env(safe-area-inset-bottom));
  }
  .bn-item { display: flex; flex-direction: column; align-items: center; gap: 2px;
    border: 0; background: transparent; color: var(--text-muted); font-size: 10px; font-weight: 600;
    padding: .3rem .55rem; border-radius: 8px; min-width: 56px; text-decoration: none; }
  .bn-item svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round; }
  .bn-item.active { color: var(--orange); }
  .bn-item.active svg { fill: none; }
  .bn-item .nav-badge { margin-left: 2px; }

  .account-stats { gap: .75rem; }
  table { font-size: 12px; }
  th, td { padding: .5rem .6rem; }
  .account-head { flex-direction: column; align-items: flex-start; }
}

/* ══ CLIENT-HOME — reference-driven composition (scoped to /client) ══
   Light, airy, single-column mobile stat-led stack. Uses existing Soaring
   tokens (orange brand, white cards, 12px radius, tabular nums). */
.client-home { max-width: 560px; margin: 0 auto; }

/* Client top section (name + calendar): pinned to the top like the admin header,
   so it stays visible while the content below scrolls. Sticky avoids the brittle
   fixed-height/padding-sync the admin's position:fixed header needs. */
.client-fixed {
  position: sticky; top: 1.5rem; z-index: 20;
  background: var(--bg); margin: 0 -1.75rem; padding: 0 1.75rem .25rem;
}
@media (max-width: 760px) {
  .client-fixed { top: calc(50px + env(safe-area-inset-top)); margin: 0 -1rem; padding: 0 1rem .25rem; }
}

/* Identity header: circular avatar, name, connected platform chips */
.client-hero { display: flex; align-items: center; gap: .85rem; padding: .6rem .1rem 1.1rem; }
.hero-avatar { width: 64px; height: 64px; border-radius: 50%; flex: 0 0 64px;
  display: grid; place-items: center; font-size: 26px; font-weight: 800;
  background: var(--orange-tint); color: var(--orange-dark); letter-spacing: -.5px; }
.hero-id { min-width: 0; }
.hero-name { font-size: 20px; font-weight: 800; letter-spacing: -.3px; line-height: 1.15; }
.hero-platforms { display: flex; gap: .45rem; margin-top: .45rem; flex-wrap: wrap; }
.platform-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .55rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.platform-chip svg { width: 12px; height: 12px; }
.platform-chip em { font-style: normal; }
.platform-chip.muted { color: var(--text-muted); }
.hero-sub { margin-left: auto; color: var(--text-muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.client-picker-select { margin-left: .5rem; padding: .35rem .5rem; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--text); }

/* Date selector: pill strip */
/* Date navigator: MTD + day buttons — same two-line treatment as the admin dashboard. */
.client-datebar { display: flex; align-items: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: .35rem .4rem; margin-bottom: .95rem; }
.client-datebar .date-strip { width: 100%; }
.client-datebar .date-strip button { border: 0; background: transparent; display: flex; flex-direction: column;
  align-items: center; justify-content: center; flex: 0 0 auto; scroll-snap-align: start;
  min-width: 46px; padding: .4rem .45rem; border-radius: 10px; color: var(--text-secondary); }
.client-datebar .date-strip button span { font-size: 10.5px; font-weight: 600; color: var(--text-muted); }
.client-datebar .date-strip button .ds-num { font-size: 15px; font-weight: 700; color: var(--text); margin-top: 1px; }
.client-datebar .date-strip button.active { background: var(--orange); box-shadow: 0 2px 8px rgba(255,107,0,.3); }
.client-datebar .date-strip button.active span,
.client-datebar .date-strip button.active .ds-num { color: #fff; }

/* Desktop topbar calendar (client view) — sits on the SAME line as the
   "Dashboard" title, in the topbar-actions. Its right edge is aligned to the
   KPI (dash-main) column — i.e. it stops left of the AI Insights sidebar
   (300px + gap), so it lines up over AOV/Reach, not the AI box. */
.topbar-client { position: relative; }
.topbar-client .topbar-actions { padding-right: calc(300px + 1.5rem); }
/* Refresh sits on the SAME line as the calendar, but over the AI Insights box
   (far right edge), via absolute positioning within the topbar. */
.topbar-client #refreshBtn { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
/* Below 1100px the AI sidebar stacks below the boxes, so remove the offset. */
@media (max-width: 1100px) {
  .topbar-client .topbar-actions { padding-right: 0; }
  .topbar-client #refreshBtn { position: static; transform: none; }
}
.cal-label { font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.topbar-cal { display: flex; align-items: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: .3rem .35rem;
  margin: 0; }
.topbar-cal .date-strip { display: flex; gap: .35rem; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: .1rem; }
.topbar-cal .date-strip button { border: 0; background: transparent; display: flex; flex-direction: column;
  align-items: center; justify-content: center; flex: 0 0 auto;
  min-width: 42px; padding: .3rem .35rem; border-radius: 10px; color: var(--text-secondary); }
.topbar-cal .date-strip button span { font-size: 10px; font-weight: 600; color: var(--text-muted); }
.topbar-cal .date-strip button .ds-num { font-size: 14px; font-weight: 700; color: var(--text); margin-top: 1px; }
.topbar-cal .date-strip button.active { background: var(--orange); box-shadow: 0 2px 8px rgba(255,107,0,.3); }
.topbar-cal .date-strip button.active span,
.topbar-cal .date-strip button.active .ds-num { color: #fff; }

/* Two large KPI cards — Canva filled-card treatment (icon circle + graphic + big value + trend chip).
   Single column: Total Leads full-width, Reach stacked below. */
.kpi2-row { display: grid; grid-template-columns: 1fr; gap: .85rem; margin-bottom: .9rem; }
.kpi2-card { background: var(--orange); color: #fff; border: 0; border-radius: 16px;
  padding: 1rem 1.05rem; box-shadow: 0 8px 20px rgba(255,107,0,.22); }
.kpi2-card.alt { background: var(--orange-tint); color: var(--text);
  box-shadow: var(--shadow); }
.kpi2-top { display: flex; align-items: center; justify-content: space-between; }
.kpi2-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
  opacity: .95; }
.kpi2-card.alt .kpi2-label { color: var(--orange-dark); }
.kpi2-ic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.92); color: var(--orange-dark); }
.kpi2-card.alt .kpi2-ic { background: #fff; color: var(--orange-dark); border: 1px solid var(--border); }
.kpi2-ic svg { width: 18px; height: 18px; }
.kpi2-fig { margin: .55rem 0 .35rem; }
.kpi2-fig .spark { display: block; width: 100%; height: 46px; }
.kpi2-mvf { display: flex; align-items: baseline; justify-content: space-between; gap: .4rem; }
.kpi2-value { font-size: 30px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi2-card.alt .kpi2-value { color: var(--text); }
.kpi2-chip { display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap;
  background: rgba(255,255,255,.2); border-radius: 999px; padding: .18rem .5rem; font-size: 11px; font-weight: 600; }
.kpi2-card.alt .kpi2-chip { background: #fff; border: 1px solid var(--border); }
.kpi2-chip .trend { margin: 0; font-size: 11px; }
.kpi2-chip em { font-style: normal; opacity: .85; font-size: 10.5px; color: var(--text); }
.kpi2-chip .trend-pos, .kpi2-chip .trend-neg { color: inherit; background: none; }
.kpi2-subs { display: flex; justify-content: space-between; gap: .5rem; margin-top: .55rem;
  padding-top: .5rem; border-top: 1px solid rgba(255,255,255,.35); font-size: 11.5px; opacity: .95; }
.kpi2-card.alt .kpi2-subs { border-top-color: var(--border); color: var(--text-secondary); }
.kpi2-subs b { font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi2-card.alt .kpi2-subs b { color: var(--text); }

/* Ad Campaigns donut + group list */
.ad-campaigns-card { margin-bottom: .9rem; }
.cg-wrap { display: flex; align-items: center; gap: 1rem; padding: .3rem 1.2rem 1.1rem; }
.cg-chart { flex: 0 0 auto; }
.donut { width: 168px; height: 168px; }
.donut-center { font-size: 12px; fill: var(--text-muted); font-weight: 600; }
.donut-center-val { font-size: 15px; fill: var(--text); font-weight: 800; }
.cg-list { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cg-row { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--divider); }
.cg-row:last-child { border-bottom: 0; }
.cg-swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 12px; }
.cg-name { font-weight: 700; font-size: 13.5px; }
.cg-meta { color: var(--text-muted); font-size: 11.5px; flex: 1; }
.cg-spend { font-weight: 700; font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Campaign Breakdown: filter pills + result rows */
.cb-card { margin-bottom: 1rem; }
.cb-pills { display: flex; gap: .5rem; padding: .7rem 1.2rem .5rem; overflow-x: auto; scrollbar-width: none; }
.cb-pills::-webkit-scrollbar { display: none; }
.cb-pill { flex: 0 0 auto; padding: .4rem .75rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.cb-pill.active { background: var(--orange); border-color: var(--orange); color: #fff; }
.cb-list { padding: .3rem 1.2rem 1rem; }
.cb-row { display: flex; align-items: center; gap: .8rem; padding: .8rem 0; border-bottom: 1px solid var(--divider); }
.cb-row:last-child { border-bottom: 0; }
.cb-info { flex: 1; min-width: 0; }
.cb-name { display: block; font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-sub { display: block; margin-top: .15rem; color: var(--text-muted); font-size: 11.5px; }
.cb-spend { font-weight: 700; font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  .client-home { max-width: none; padding-bottom: .5rem; }
  .hero-avatar { width: 56px; height: 56px; flex: 0 0 56px; font-size: 22px; }
  .hero-name { font-size: 18px; }
  .kpi2-value { font-size: 25px; }
  .cg-wrap { flex-direction: column; align-items: stretch; gap: .5rem; }
  .cg-chart { align-self: center; }
  .cg-list { width: 100%; }
}

/* ══════════════ Sales Dashboard (client) — matches the "Sales Dashboard" mockup ══════════════ */
/* The Sales view has its own header, so drop the shared topbar (title + calendar + refresh). */
body.sales-view .topbar.topbar-client { display: none; }
.sales-dash { }
.sales-title { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.sales-sub { font-size: 14px; color: var(--text-muted); margin: 2px 0 18px; }
.sales-tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.sales-tab { background: none; border: none; padding: 6px 2px 12px; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; position: relative; }
.sales-tab.active { color: var(--orange); font-weight: 700; }
.sales-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--orange); }

/* 8 KPI cards, 4 per row */
.sales-kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.sales-kpi { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px 14px; position: relative; overflow: hidden; }
.sales-kpi::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.sales-kpi.red::before { background: var(--red); }
.sales-kpi.blue::before { background: #3B82F6; }
.sales-kpi.green::before { background: var(--green); }
.sales-kpi .sk-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.sales-kpi .sk-value { font-size: 26px; font-weight: 800; color: var(--text); margin: 8px 0 4px; letter-spacing: -.5px; }
.sales-kpi .sk-sub { font-size: 12px; color: var(--text-muted); }
.sales-kpi .sk-ico { position: absolute; right: 16px; top: 18px; width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.sales-kpi.red .sk-ico { background: rgba(239,68,68,.10); color: var(--red); }
.sales-kpi.blue .sk-ico { background: rgba(59,130,246,.10); color: #3B82F6; }
.sales-kpi.green .sk-ico { background: rgba(22,163,74,.10); color: var(--green); }

/* Two-column layout: main (trend + treatments) | side (branch perf + insights) */
.sales-cols { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(0, 1.15fr); gap: 16px; align-items: start; }
.sales-card { padding: 18px 20px; min-width: 0; overflow: hidden; }
.sales-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sales-card-head h2 { font-size: 16px; font-weight: 700; color: var(--text); }
.sales-link { font-size: 12px; color: var(--orange); text-decoration: none; font-weight: 600; }
.sales-link:hover { text-decoration: underline; }
.sales-col-side .sales-card { margin-bottom: 16px; }
.sales-col-side .sales-card:last-child { margin-bottom: 0; }

/* Revenue Trend toggle + legend */
.trend-toggle { display: inline-flex; background: #F3F4F6; border-radius: 8px; padding: 3px; }
.trend-toggle button { background: none; border: none; padding: 5px 14px; font-size: 12px; font-weight: 600; color: var(--text-muted); border-radius: 6px; cursor: pointer; }
.trend-toggle button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.trend-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); margin: 4px 0 10px; }
.trend-legend .dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.trend-legend .dot.orange { background: var(--orange); }
.trend-legend .dot.dash { border: 2px dashed #94A3B8; background: transparent; }
.trend-legend .dot + .dot { margin-left: 14px; }

/* Top Treatments bars — name left, bar in middle, then spend */
.treat-head { display: grid; grid-template-columns: 130px 1fr 110px; gap: 12px; font-size: 12px; color: var(--text-muted); font-weight: 600; padding: 0 0 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.treat-head span:nth-child(3) { text-align: right; }
.treat-row { display: grid; grid-template-columns: 130px 1fr 110px; gap: 12px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); }
.treat-row:last-child { border-bottom: none; }
.treat-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.treat-bar-wrap { height: 16px; background: var(--border); border-radius: 4px; overflow: hidden; }
.treat-bar { display: block; height: 100%; background: var(--orange); border-radius: 4px; min-width: 3px; }
.treat-spend { text-align: right; font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; }
.treat-more { margin-top: 12px; font-size: 12px; padding: .45rem .9rem; }

/* Branch Performance status pills */
.branch-table th { white-space: nowrap; }
.status-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.status-pill.ahead, .status-pill.ontrack { background: rgba(22,163,74,.12); color: #16A34A; }
.status-pill.atrisk { background: rgba(245,158,11,.14); color: #B45309; }
.status-pill.behind { background: rgba(239,68,68,.12); color: #DC2626; }

/* Management Insights */
.mgmt-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.mgmt-row:last-child { border-bottom: none; }
.mgmt-row b { color: var(--text); }
.mgmt-ico { flex: 0 0 30px; width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.mgmt-ico.green { background: rgba(22,163,74,.12); }
.mgmt-ico.blue { background: rgba(59,130,246,.12); }
.mgmt-ico.amber { background: rgba(245,158,11,.14); }

/* ── Branch Performance tab ─────────────────────────────────────────── */
.rank-list { display: flex; flex-direction: column; }
.rank-row { display: grid; grid-template-columns: 22% 1fr 110px; gap: 12px; align-items: center; padding: 6px 0; }
.rank-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-bar { height: 20px; background: #F3F4F6; border-radius: 4px; overflow: hidden; }
.rank-bar-fill { height: 100%; background: var(--orange); border-radius: 4px; }
.rank-bar.aov { background: #F0FDF4; }
.rank-bar-fill.aov { background: #22C55E; }
.rank-val { font-size: 13px; font-weight: 700; color: var(--text); text-align: right; white-space: nowrap; }

/* Target Attainment by Branch — green actual + grey target stacked bars. */
.att-list { display: flex; flex-direction: column; gap: 8px; }
.att-row { display: grid; grid-template-columns: 1fr 74px; gap: 12px; align-items: center; padding: 4px 0; }
.att-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.att-bars .att-track { height: 12px; background: #F3F4F6; border-radius: 3px; overflow: hidden; margin-top: 3px; }
.att-actual { height: 100%; background: #22C55E; border-radius: 3px; }
.att-track.tgt { background: #EDF2F7; }
.att-target { height: 100%; background: #CBD5E1; border-radius: 3px; }
.att-pct { text-align: right; }
.att-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.att-pill.ahead, .att-pill.ontrack { background: rgba(22,163,74,.12); color: #16A34A; }
.att-pill.atrisk { background: rgba(245,158,11,.14); color: #B45309; }
.att-pill.behind { background: rgba(239,68,68,.12); color: #DC2626; }
.att-pill.na { background: rgba(148,163,184,.14); color: #64748B; }

/* Key Branch Insights cards */
.kbi-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.kbi-card:last-child { border-bottom: none; }
.kbi-card b { color: var(--text); font-size: 13.5px; }
.kbi-card p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
.chart-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); margin-top: 12px; }
.chart-legend .dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-legend .dot.orange { background: var(--orange); }
.chart-legend .dot.green { background: #22C55E; }
.chart-legend .dot.dash { border: 2px dashed #94A3B8; background: transparent; }
.chart-legend .dot + .dot { margin-left: 14px; }

/* Wide 9-column branch table shouldn't force horizontal page scroll. */
.branch-table { width: 100%; }
.branch-table th, .branch-table td { white-space: nowrap; }
.sales-col-side .table-wrap { overflow-x: auto; }

@media (max-width: 1100px) { .sales-kpi-grid { grid-template-columns: repeat(2, 1fr); } .sales-cols { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .sales-kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; } .sales-kpi .sk-value { font-size: 22px; } .treat-head, .treat-row { grid-template-columns: 1fr 90px 70px; } .sales-tabs { gap: 16px; overflow-x: auto; } }

