/* BizBuyPro brand: navy #003C5B, teal #316664, rust #8B3311, orange #FF5C26; Figtree headings, Poppins body. */
:root {
  color-scheme: light;
  --navy:#003C5B; --teal:#316664; --rust:#8B3311; --orange:#FF5C26;
  --bg:#F3F6F8; --fg:#1B1B1B; --muted:#5B6670; --card:#fff; --line:#E1E8ED; --err:#b3261e;
  --side:#003C5B; --side-fg:#C7D6E0; --accent:#003C5B; --bar:#003C5B;
  --warn-bg:#FFF1EA; --warn-fg:#8B3311;
  --up-bg:#E2F1EC; --up-fg:#1F6B57; --down-bg:#FBE9E4; --down-fg:#A63A1A;
  --shadow:0 1px 2px rgba(0,60,91,.05), 0 6px 18px -10px rgba(0,60,91,.18);
  --head:Figtree, "Poppins", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin:0; font:14px/1.55 Poppins, system-ui, sans-serif; background:var(--bg); color:var(--fg); -webkit-font-smoothing:antialiased; }
h1, h2, h3, h4, .big, .brand { font-family:var(--head); }

.app { display:flex; min-height:100vh; }
.side { width:232px; flex:none; background:var(--side); color:var(--side-fg); padding:0 0 20px; position:sticky; top:0; align-self:flex-start; min-height:100vh; }
.brand { background:#fff; padding:18px 20px; border-bottom:4px solid var(--orange); }
.brand img { display:block; width:100%; max-width:170px; height:auto; }
.brand span { display:block; margin-top:8px; font-size:10.5px; letter-spacing:.16em; text-transform:uppercase; color:var(--teal); font-weight:600; font-family:Poppins, sans-serif; }
#nav { display:flex; flex-direction:column; gap:4px; padding:18px 12px 0; }
#nav a { color:var(--side-fg); text-decoration:none; padding:10px 14px; border-radius:6px; font-weight:500; border-left:3px solid transparent; transition:background .15s, color .15s; }
#nav a:hover { background:rgba(255,255,255,.08); color:#fff; }
#nav a.active { background:rgba(255,255,255,.12); color:#fff; border-left-color:var(--orange); }

.content { flex:1; min-width:0; }
header { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; padding:18px 28px; background:#fff; border-bottom:1px solid var(--line); position:sticky; top:0; z-index:5; }
h1 { margin:0; font-size:26px; font-weight:700; color:var(--navy); letter-spacing:-.01em; }
h3 { margin:0 0 14px; font-size:16px; font-weight:700; color:var(--navy); }
.controls { display:flex; gap:8px; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.custom { display:flex; gap:6px; align-items:center; }
.custom[hidden] { display:none; }
button, select, input[type=date] { padding:8px 14px; border:1px solid var(--line); background:#fff; color:var(--fg); border-radius:6px; font:inherit; font-weight:500; }
select { padding-right:10px; color:var(--navy); font-weight:600; border-color:#C9D6DE; }
button { cursor:pointer; }
button:hover { border-color:var(--navy); }
#refresh { background:var(--navy); color:#fff; border-color:var(--navy); font-weight:600; }
#refresh:hover { background:var(--teal); border-color:var(--teal); }
.period { padding:14px 28px 0; font-size:13px; font-weight:500; }
main { padding:18px 28px 48px; display:flex; flex-direction:column; gap:18px; }

.card { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:20px; overflow-x:auto; box-shadow:var(--shadow); }
.muted { color:var(--muted); }
.small { font-size:12px; }
.left { text-align:left; margin:0; }
.error { color:var(--err); }
.warn { background:var(--warn-bg); color:var(--warn-fg); border-radius:8px; padding:11px 16px; font-size:13.5px; border-left:4px solid var(--orange); }

.banner { font-family:var(--head); color:var(--navy); font-size:18px; font-weight:700; padding:6px 0 10px; margin:10px 0 0; border-bottom:1px solid var(--line); position:relative; }
.banner::after { content:""; position:absolute; left:0; bottom:-1px; width:48px; height:3px; background:var(--orange); }
.tiles { display:grid; gap:14px; grid-template-columns:repeat(auto-fill, minmax(210px, 1fr)); }
.tile { background:var(--card); border:1px solid var(--line); border-top:3px solid var(--teal); border-radius:10px; padding:16px 16px 14px; box-shadow:var(--shadow); }
.tile h4 { margin:0; font-family:Poppins, sans-serif; font-size:11.5px; font-weight:600; text-transform:uppercase; letter-spacing:.07em; color:var(--muted); text-align:center; }
.big { font-size:34px; font-weight:700; text-align:center; padding:8px 0 4px; color:var(--navy); letter-spacing:-.02em; line-height:1.15; }
.tile .small { text-align:center; color:var(--muted); }
.delta { text-align:center; margin-top:4px; }
.pill { font-size:12px; font-weight:600; padding:2px 9px; border-radius:10px; }
.pill.up { background:var(--up-bg); color:var(--up-fg); }
.pill.down { background:var(--down-bg); color:var(--down-fg); }

.chart { width:100%; height:auto; min-width:520px; }
.chart .grid { stroke:var(--line); stroke-width:1; }
.chart .axis { fill:var(--muted); font-size:11px; }
.chart .bar { fill:var(--bar); }
.chart .bar:hover { opacity:.8; }
.chart .line { fill:none; stroke:var(--bar); stroke-width:2; }
.chart .dot { fill:var(--bar); }
.chart.hbars { min-width:0; }

.bullet { margin-top:8px; }
.bullet-track { position:relative; height:8px; background:var(--line); border-radius:4px; overflow:visible; }
.bullet-track div:first-child { height:100%; background:var(--bar); border-radius:4px; }
.bullet-track div:first-child.over { background:var(--up-fg); }
.bullet-target { position:absolute; top:-3px; left:100%; width:2px; height:14px; background:var(--fg); }
.bullet .muted { margin-top:3px; text-align:center; }

.warn ul.gaps { margin:6px 0 0; padding-left:18px; }
.warn ul.gaps li { margin:2px 0; }

table { width:100%; border-collapse:collapse; font-size:14px; }
th, td { padding:10px 12px; text-align:left; border-bottom:1px solid var(--line); }
th { color:var(--muted); font-weight:600; font-size:11.5px; text-transform:uppercase; letter-spacing:.06em; background:#F7FAFB; }
tbody tr:hover td { background:#F7FAFB; }
th.sortable { cursor:pointer; user-select:none; white-space:nowrap; }
th.sortable:hover { color:var(--fg); }
th.r, td.r { text-align:right; font-variant-numeric:tabular-nums; }
tr.unassigned td { color:var(--warn-fg); font-style:italic; }
.meter { width:120px; height:8px; background:var(--line); border-radius:4px; overflow:hidden; }
.meter div { height:100%; background:var(--bar); }

@media (max-width: 760px) {
  .app { flex-direction:column; }
  .side { width:auto; min-height:0; position:static; padding:0; display:flex; align-items:center; gap:8px; overflow-x:auto; }
  .brand { padding:8px 12px; border-bottom:0; border-right:4px solid var(--orange); flex:none; }
  .brand img { width:110px; }
  .brand span { display:none; }
  #nav { flex-direction:row; padding:0 8px; }
  #nav a { border-left:0; border-bottom:3px solid transparent; white-space:nowrap; padding:12px 10px; border-radius:0; }
  #nav a.active { border-bottom-color:var(--orange); }
  header { position:static; padding:14px 14px; }
  h1 { font-size:22px; }
  .period, main { padding-left:14px; padding-right:14px; }
}

.seg { display:inline-flex; border:1px solid var(--line); border-radius:6px; overflow:hidden; align-self:flex-start; }
.seg button { border:0; border-radius:0; background:#fff; }
.seg button.on { background:var(--navy); color:#fff; }

.search { display:flex; gap:8px; flex-wrap:wrap; }
.search input { flex:1; min-width:200px; max-width:420px; padding:7px 12px; border:1px solid var(--line); background:var(--card); color:var(--fg); border-radius:6px; font:inherit; }
a.link { color:var(--teal); font-weight:500; text-decoration:none; }
a.link:hover { text-decoration:underline; }
.chip { display:inline-block; font-size:12px; padding:1px 8px; border-radius:10px; }
.chip.good { background:var(--up-bg); color:var(--up-fg); }
.chip.bad { background:var(--down-bg); color:var(--down-fg); }
.chip.info { background:var(--card); color:var(--muted); border:1px solid var(--line); }
button.more { margin-top:12px; }
.pager { display:flex; align-items:center; gap:10px; margin-top:14px; }
.pager button:disabled { opacity:.4; cursor:default; }

/* ---- Analytics: a distinct, calmer "glance at it once" style ---- */
.analytics-page {
  --a-bg:transparent; --a-card:#fff; --a-fg:#1B1B1B; --a-muted:#5B6670; --a-line:#E1E8ED;
  --a-accent:#316664; --a-accent-soft:#DDEBEA; --a-up:#1F6B57; --a-down:#A63A1A; --a-shadow:0 1px 2px rgba(0,60,91,.05), 0 6px 18px -10px rgba(0,60,91,.18);
  background:var(--a-bg); color:var(--a-fg); margin:0; padding:0; border-radius:0;
  display:flex; flex-direction:column; gap:16px;
}
.analytics-page .a-hero { display:grid; gap:14px; grid-template-columns:repeat(auto-fit, minmax(220px, 1fr)); }
.analytics-page .a-tile { background:var(--a-card); border-radius:12px; border-top:3px solid var(--a-accent); box-shadow:var(--a-shadow); padding:20px 22px; }
.analytics-page .a-tile h4 { margin:0 0 10px; font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:.06em; color:var(--a-muted); }
.analytics-page .a-big { font-family:var(--head); color:var(--navy); font-size:36px; font-weight:700; letter-spacing:-.01em; line-height:1.1; }
.analytics-page .a-delta { display:inline-flex; align-items:center; gap:4px; font-size:13px; font-weight:600; margin-top:6px; }
.analytics-page .a-delta.up { color:var(--a-up); }
.analytics-page .a-delta.down { color:var(--a-down); }
.analytics-page .a-target-row { display:flex; align-items:center; gap:8px; margin-top:14px; }
.analytics-page .a-target-track { position:relative; flex:1; height:4px; background:var(--a-line); border-radius:2px; }
.analytics-page .a-target-fill { height:100%; background:var(--a-accent); border-radius:2px; }
.analytics-page .a-target-dot { position:absolute; top:50%; width:9px; height:9px; border-radius:50%; background:var(--a-accent); border:2px solid var(--a-card); transform:translate(-50%,-50%); }
.analytics-page .a-target-label { font-size:12px; color:var(--a-muted); white-space:nowrap; }
.analytics-page .a-source { margin-top:14px; font-size:12px; color:var(--a-muted); }

.analytics-page .a-card { background:var(--a-card); border-radius:12px; box-shadow:var(--a-shadow); padding:22px; }
.analytics-page .a-card h3 { margin:0; font-size:16px; font-weight:700; color:var(--navy); }
.analytics-page .a-card-head { display:flex; justify-content:space-between; align-items:baseline; gap:12px; flex-wrap:wrap; margin-bottom:14px; }
.analytics-page .a-card-note { font-size:12px; color:var(--a-muted); }

.analytics-page .a-area { width:100%; height:auto; }
.analytics-page .a-area .a-grid { stroke:var(--a-line); stroke-width:1; }
.analytics-page .a-area .a-axis { fill:var(--a-muted); font-size:11px; }
.analytics-page .a-area .a-fill { fill:url(#analyticsAreaGrad); }
.analytics-page .a-area .a-line { fill:none; stroke:var(--a-accent); stroke-width:2.5; stroke-linecap:round; stroke-linejoin:round; }
.analytics-page .a-area .a-dot { fill:var(--a-accent); }
.analytics-page .a-area .a-target-line { stroke:var(--a-muted); stroke-width:1; stroke-dasharray:4 4; }
.analytics-page .a-area .a-target-text { fill:var(--a-muted); font-size:11px; }

.analytics-page .a-row2 { display:grid; gap:16px; grid-template-columns:1.1fr 1fr; }
@media (max-width:820px) { .analytics-page .a-row2 { grid-template-columns:1fr; } }

.analytics-page .a-sliders { display:flex; flex-direction:column; gap:16px; }
.analytics-page .a-slider-label { display:flex; justify-content:space-between; font-size:13px; margin-bottom:6px; }
.analytics-page .a-slider-label .name { font-weight:500; }
.analytics-page .a-slider-label .val { color:var(--a-muted); font-variant-numeric:tabular-nums; }
.analytics-page .a-slider-track { position:relative; height:3px; background:var(--a-line); border-radius:2px; }
.analytics-page .a-slider-fill { position:relative; height:100%; background:var(--a-accent); border-radius:2px; }
.analytics-page .a-slider-dot { position:absolute; top:50%; right:-5px; width:10px; height:10px; border-radius:50%; background:var(--a-accent); transform:translateY(-50%); }

.analytics-page .a-table { width:100%; border-collapse:collapse; font-size:13px; }
.analytics-page .a-table th { text-align:left; color:var(--a-muted); font-weight:600; font-size:11px; text-transform:uppercase; letter-spacing:.05em; padding:0 0 10px; border-bottom:1px solid var(--a-line); }
.analytics-page .a-table th.r, .analytics-page .a-table td.r { text-align:right; font-variant-numeric:tabular-nums; }
.analytics-page .a-table td { padding:9px 0; border-bottom:1px solid var(--a-line); }
.analytics-page .a-table tr:last-child td { border-bottom:0; }
.analytics-page .a-table-note { margin:10px 0 0; font-size:12px; color:var(--a-muted); }

.analytics-page .a-funnel { display:flex; flex-direction:column; gap:10px; }
.analytics-page .a-funnel-row { display:grid; grid-template-columns:120px 1fr 130px; align-items:center; gap:10px; font-size:13px; }
.analytics-page .a-funnel-label { color:var(--a-muted); }
.analytics-page .a-funnel-track { height:20px; background:var(--a-accent-soft); border-radius:5px; overflow:hidden; }
.analytics-page .a-funnel-fill { height:100%; background:var(--a-accent); border-radius:5px; }
.analytics-page .a-funnel-val { text-align:right; font-variant-numeric:tabular-nums; }
.analytics-page .a-funnel-val .pct { color:var(--a-muted); font-size:12px; margin-left:4px; }

.analytics-page .a-foot { font-size:12px; color:var(--a-muted); }
.analytics-page .a-foot summary { cursor:pointer; font-weight:500; }
.analytics-page .a-foot ul { margin:8px 0 0; padding-left:18px; }
.analytics-page .a-foot li { margin:3px 0; }

/* Multi-section pages */
.part { display:flex; flex-direction:column; gap:16px; }
.part-body { display:flex; flex-direction:column; gap:16px; }
.part-title { margin:18px 0 0; font-size:20px; font-weight:700; color:var(--navy); padding-bottom:10px; border-bottom:1px solid var(--line); position:relative; }
.part-title::after { content:""; position:absolute; left:0; bottom:-1px; width:56px; height:3px; background:var(--orange); }
.part:first-child .part-title { margin-top:0; }

/* Closer leaderboard */
.leaders { display:flex; flex-direction:column; gap:14px; }
.leader { display:grid; grid-template-columns:200px 1fr 190px; align-items:center; gap:14px; }
.leader-who { display:flex; align-items:center; gap:12px; min-width:0; }
.leader-rank { flex:none; width:28px; height:28px; border-radius:50%; display:grid; place-items:center; font:700 13px var(--head); background:var(--bg); color:var(--navy); border:1px solid var(--line); }
.leader.first .leader-rank { background:var(--orange); color:#fff; border-color:var(--orange); }
.leader-name { font-weight:600; color:var(--navy); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.leader-bar { height:12px; background:var(--bg); border-radius:6px; overflow:hidden; }
.leader-bar div { height:100%; background:var(--teal); border-radius:6px; }
.leader.first .leader-bar div { background:var(--navy); }
.leader-nums { display:flex; flex-direction:column; text-align:right; line-height:1.3; }
.leader-nums strong { font:700 16px var(--head); color:var(--navy); }
@media (max-width:760px) { .leader { grid-template-columns:1fr; gap:6px; } .leader-nums { text-align:left; flex-direction:row; gap:10px; align-items:baseline; } }
.card-head { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.card-head h3 { margin:0; }
