@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── TOKENS ──────────────────────────────────── */
:root {
  --sidebar-width: 232px;
  --header-height: 64px;

  --sb-bg:         #0f172a;
  --sb-border:     #1e293b;
  --sb-hover:      #1e293b;
  --sb-active-bg:  rgba(20,184,166,.12);
  --sb-active-acc: #14b8a6;
  --sb-text:       #94a3b8;
  --sb-text-on:    #f1f5f9;

  --page-bg:   #f8fafc;
  --card-bg:   #ffffff;
  --card-bdr:  #e2e8f0;

  --text-h:  #0f172a;
  --text-b:  #334155;
  --text-m:  #64748b;
  --text-f:  #94a3b8;

  --green:     #059669; --green-bg:  #d1fae5;
  --red:       #dc2626; --red-bg:    #fee2e2;
  --amber:     #d97706; --amber-bg:  #fef3c7;
  --blue:      #2563eb; --blue-bg:   #dbeafe;

  --accent:   #0d9488;
  --teal:     #14b8a6;
  --emerald:  #10b981;
  --amber-a:  #f59e0b;
  --pink:     #ec4899;
  --purple:   #8b5cf6;

  --sh:    0 1px 3px 0 rgb(0 0 0/.06), 0 1px 2px -1px rgb(0 0 0/.04);
  --sh-m:  0 4px 16px -2px rgb(0 0 0/.1), 0 2px 4px -2px rgb(0 0 0/.06);
  --r:     10px;
}

/* ── RESET ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text-b);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; border: none; }
select { font-family: inherit; }

/* ━━━━━━━━━━━━━━━━━ LOGIN ━━━━━━━━━━━━━━━━━ */
.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 55%, #0f172a 100%);
}
.login-card {
  display: flex;
  width: 860px; max-width: 96vw;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0,0,0,.45);
}
.login-left {
  flex: 1;
  background: linear-gradient(145deg, #0d9488 0%, #0f172a 100%);
  padding: 44px 36px;
  display: flex; flex-direction: column; justify-content: space-between;
  color: #fff;
  min-width: 0;
}
.ll-logo { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.ll-logo-icon {
  width: 34px; height: 34px; border-radius: 8px;
  background: rgba(255,255,255,.2); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800; flex-shrink: 0;
}
.ll-body h1 { font-size: 26px; font-weight: 700; line-height: 1.3; margin-bottom: 12px; letter-spacing: -.5px; }
.ll-body p  { font-size: 13.5px; opacity: .75; line-height: 1.65; }
.ll-stats { display: flex; gap: 28px; }
.ll-stat-val { font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.ll-stat-lbl { font-size: 11px; opacity: .6; margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }

.login-right { width: 380px; flex-shrink: 0; padding: 44px 36px; display: flex; flex-direction: column; justify-content: center; }
.lr-head { margin-bottom: 28px; }
.lr-head h2 { font-size: 21px; font-weight: 700; color: var(--text-h); letter-spacing: -.3px; margin-bottom: 5px; }
.lr-head p  { font-size: 13px; color: var(--text-m); }

.form-group  { margin-bottom: 16px; }
.form-label  { display: block; font-size: 12.5px; font-weight: 500; color: #374151; margin-bottom: 5px; }
.form-input  {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid #e5e7eb; border-radius: 7px;
  font-size: 14px; color: var(--text-h); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,148,136,.12); }

.btn-primary {
  width: 100%; padding: 11px;
  background: var(--accent); color: #fff;
  border-radius: 7px; font-size: 14px; font-weight: 600;
  letter-spacing: .1px; transition: background .15s;
}
.btn-primary:hover { background: #0f766e; }

.login-hint {
  margin-top: 18px; padding: 11px 14px;
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 7px;
  font-size: 12px; color: var(--text-m); line-height: 1.65;
}
.login-hint strong { color: var(--text-b); }
.login-err { font-size: 12.5px; color: var(--red); margin-top: 6px; display: none; }
.login-err.show { display: block; }

@media (max-width: 680px) {
  .login-left { display: none; }
  .login-right { width: 100%; padding: 36px 28px; }
}

/* ━━━━━━━━━━━━━━━━━ APP SHELL ━━━━━━━━━━━━━━━━━ */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ━━━━━━━━━━━━━━━━━ SIDEBAR ━━━━━━━━━━━━━━━━━ */
.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--sb-border);
}
.sb-brand-icon {
  width: 30px; height: 30px; border-radius: 7px;
  background: linear-gradient(135deg,#0d9488,#14b8a6);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: #fff; flex-shrink: 0;
}
.sb-brand-name { font-size: 14px; font-weight: 700; color: #f9fafb; letter-spacing: -.3px; }
.sb-brand-name em { color: #2dd4bf; font-style: normal; }

.sb-nav { flex: 1; overflow-y: auto; padding: 6px 0 8px; scrollbar-width: none; }
.sb-nav::-webkit-scrollbar { display: none; }

.sb-section-lbl {
  font-size: 9.5px; font-weight: 600; letter-spacing: 1.1px;
  text-transform: uppercase; color: #4b5563;
  padding: 14px 16px 5px;
}
.sb-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; margin: 1px 8px;
  border-radius: 6px; cursor: pointer;
  color: var(--sb-text); font-size: 13px; font-weight: 500;
  transition: background .12s, color .12s; user-select: none;
}
.sb-item:hover { background: var(--sb-hover); color: var(--sb-text-on); }
.sb-item.active {
  background: var(--sb-active-bg); color: #2dd4bf;
  border-left: 2px solid var(--sb-active-acc);
  margin-left: 6px; padding-left: 10px;
}
.sb-item svg { flex-shrink: 0; }
.sb-item.active svg { opacity: 1; }

.sb-cat-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; margin: 1px 8px;
  border-radius: 6px; cursor: pointer;
  color: var(--sb-text); font-size: 13px; font-weight: 500;
  transition: background .12s, color .12s; user-select: none;
}
.sb-cat-hd:hover { background: var(--sb-hover); color: var(--sb-text-on); }
.sb-cat-hd.open   { color: var(--sb-text-on); }
.sb-cat-left { display: flex; align-items: center; gap: 9px; }
.sb-caret { transition: transform .18s; flex-shrink: 0; margin-right: 2px; }
.sb-cat-hd.open .sb-caret { transform: rotate(90deg); }

.sb-sub { display: none; padding: 2px 0 4px 22px; }
.sb-sub.open { display: block; }
.sb-sub-item {
  display: block; padding: 7px 10px; margin: 1px 8px;
  border-radius: 5px; font-size: 12.5px; color: #6b7280;
  cursor: pointer; transition: background .12s, color .12s; user-select: none;
}
.sb-sub-item:hover  { background: var(--sb-hover); color: #9ca3af; }
.sb-sub-item.active { color: #2dd4bf; background: rgba(20,184,166,.09); }

.sb-footer {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--sb-border);
}
.sb-footer-lbl {
  font-size: 9.5px; font-weight: 600; letter-spacing: 1px;
  text-transform: uppercase; color: #4b5563;
  margin-bottom: 7px; padding: 0 2px;
}
.province-sel {
  width: 100%; padding: 8px 28px 8px 10px;
  background: #1f2937; border: 1px solid #374151; border-radius: 6px;
  color: #d1d5db; font-size: 12.5px; outline: none;
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  transition: border-color .12s;
}
.province-sel:focus { border-color: var(--accent); }

/* ━━━━━━━━━━━━━━━━━ MAIN ━━━━━━━━━━━━━━━━━ */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ━━━━━━━━━━━━━━━━━ TOP STRIP  (logo + company · avatar) ━━━━━━━━━━━━━━━━━ */
.tb-topstrip {
  flex-shrink: 0; height: 52px;
  background: #fff; border-bottom: 1px solid var(--card-bdr);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.tb-co { display: flex; align-items: center; gap: 10px; }
.tb-co svg { display: block; flex-shrink: 0; }
.tb-co-name { font-size: 15px; font-weight: 700; color: var(--text-h); letter-spacing: -.4px; }
.avatar-btn {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg,#0d9488,#14b8a6);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: opacity .15s;
}
.avatar-btn:hover { opacity: .82; }

/* ━━━━━━━━━━━━━━━━━ FILTER BAR  (summary left · controls right) ━━━━━━━━━━━━━━━━━ */
.filter-bar {
  flex-shrink: 0;
  background: #fff; border-bottom: 1px solid var(--card-bdr);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px 12px;
}
.fb-summary { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.fb-summary svg { display: block; flex-shrink: 0; }
.fb-summary-text { display: flex; flex-direction: column; gap: 1px; }
.fb-summary-curr { font-size: 13px; font-weight: 600; color: var(--text-h); line-height: 1.4; }
.fb-summary-comp { font-size: 11.5px; color: var(--text-f); line-height: 1.4; }
.fb-controls { display: flex; align-items: flex-end; gap: 8px; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label {
  font-size: 10px; font-weight: 600; color: var(--text-f);
  text-transform: uppercase; letter-spacing: .7px;
}
.filter-range {
  display: flex; align-items: center; gap: 6px;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 7px;
  padding: 0 12px; font-size: 12.5px; color: #334155;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: border-color .15s; height: 34px;
  box-shadow: 0 1px 2px rgb(0 0 0/.03);
}
.filter-range:hover { border-color: var(--teal); background: #fff; }
.filter-range svg { color: #94a3b8; flex-shrink: 0; }
.filter-select {
  padding: 0 28px 0 10px; height: 34px;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 7px;
  font-size: 12.5px; color: #334155; font-family: inherit;
  cursor: pointer; outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  transition: border-color .15s;
}
.filter-select:focus { border-color: var(--accent); outline: none; }
.filter-vs {
  font-size: 11px; font-weight: 600; color: var(--text-f);
  padding-bottom: 9px; flex-shrink: 0;
}
.filter-divider {
  width: 1px; height: 28px; background: #e2e8f0;
  align-self: flex-end; margin: 0 4px 3px; flex-shrink: 0;
}

/* date picker modal */
.dp-overlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.18);
}
.dp-overlay.open { display: block; }
.dp-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 18px 20px; box-shadow: var(--sh-m);
  display: flex; flex-direction: column; gap: 12px;
  white-space: nowrap;
}
.dp-col { display: flex; flex-direction: column; gap: 6px; }
.dp-col label { font-size: 11px; font-weight: 600; color: var(--text-f); text-transform: uppercase; letter-spacing: .5px; }
.dp-col input[type=date] {
  padding: 8px 10px; border: 1.5px solid #e5e7eb; border-radius: 7px;
  font-size: 13px; font-family: inherit; color: var(--text-h); outline: none;
}
.dp-col input[type=date]:focus { border-color: var(--accent); }
.dp-actions { display: flex; gap: 8px; margin-top: 4px; }
.dp-btn {
  padding: 8px 16px; border-radius: 7px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid #e5e7eb; background: #fff; color: var(--text-b);
}
.dp-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.dp-btn.primary:hover { background: #0f766e; }

/* ━━━━━━━━━━━━━━━━━ CONTENT ━━━━━━━━━━━━━━━━━ */
.content { flex: 1; overflow-y: auto; padding: 22px 24px 32px; }
.content::-webkit-scrollbar { width: 5px; }
.content::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 99px; }

.page { display: none; }
.page.active { display: block; }

.section-lbl {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-f);
  margin: 20px 0 10px; padding-left: 2px;
}
.kpi-hint { font-size: 11px; color: var(--text-f); margin-top: 6px; }

.derived-row:nth-child(even) { background: #e8f0f5; }
.derived-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  margin: 0 -10px;
}
.derived-row:last-child { border-bottom: none; }
.derived-lbl { flex: 1; color: var(--text-b); }
.derived-val { font-weight: 600; color: var(--text-h); min-width: 70px; text-align: right; }
.derived-vs  { font-size: 11px; min-width: 90px; text-align: right; }
.derived-vs.pos { color: var(--green); }
.derived-vs.neg { color: var(--red); }

.page-hd { margin-bottom: 18px; }
.page-hd h1 { font-size: 19px; font-weight: 700; color: var(--text-h); letter-spacing: -.4px; }
.page-hd p  { font-size: 12.5px; color: var(--text-m); margin-top: 3px; }

/* ── Page hero banner (CF-style blue header with icon + diamond accents) ── */
.page-hero {
  background: #006097;
  border-radius: 8px;
  padding: 20px 28px 18px;
  border: 1px solid #005485;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: 0 2px 8px rgba(0,96,151,.18);
}
.page-hero::after {
  content: ''; position: absolute;
  right: -50px; top: -60px;
  width: 200px; height: 200px;
  background: rgba(255,255,255,.07);
  transform: rotate(45deg); border-radius: 20px;
  pointer-events: none;
}
.page-hero::before {
  content: ''; position: absolute;
  right: 80px; top: -80px;
  width: 130px; height: 130px;
  background: rgba(255,255,255,.04);
  transform: rotate(45deg); border-radius: 14px;
  pointer-events: none;
}
.ph-icon {
  width: 46px; height: 46px; min-width: 46px;
  background: rgba(255,255,255,.18);
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
}
.ph-icon svg {
  width: 22px; height: 22px;
  fill: none;
  stroke: rgba(255,255,255,.92);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}
.ph-body { flex: 1; min-width: 0; }
.ph-section { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; color: rgba(255,255,255,.55); margin-bottom: 6px; }
.ph-title   { font-size: 20px; font-weight: 700; color: #ffffff; letter-spacing: -.4px; line-height: 1.2; }
.ph-desc    { font-size: 12px; color: rgba(255,255,255,.7); margin-top: 5px; line-height: 1.5; }

/* ── Store Map ── */
.map-metric-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.map-btn {
  padding: 5px 13px; font-size: 12px; font-weight: 500;
  border: 1.5px solid #e2e8f0; border-radius: 6px;
  background: #fff; color: #64748b; cursor: pointer;
  transition: all .15s;
}
.map-btn:hover  { border-color: #006097; color: #006097; }
.map-btn.active { background: #006097; border-color: #006097; color: #fff; }
.map-legend {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; font-size: 11.5px; color: #64748b;
  border-top: 1px solid #e2e8f0; flex-wrap: wrap;
}
.map-legend-bar {
  width: 120px; height: 8px; border-radius: 4px;
  background: linear-gradient(to right, #93c5fd, #006097);
  flex-shrink: 0;
}
/* Leaflet popup theme override */
.leaflet-popup-content-wrapper {
  border-radius: 8px !important;
  box-shadow: 0 4px 20px rgba(0,0,0,.18) !important;
  padding: 0 !important;
  overflow: hidden;
  min-width: 210px;
}
.leaflet-popup-content { margin: 0 !important; width: auto !important; }
.leaflet-popup-tip-container { display: none; }
.mp-head { background: #006097; padding: 10px 14px 9px; }
.mp-name { font-size: 13px; font-weight: 700; color: #fff; line-height: 1.3; }
.mp-state-lbl { font-size: 10px; color: rgba(255,255,255,.65); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.mp-body { padding: 8px 14px 10px; }
.mp-row { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 0; border-bottom: 1px solid #f1f5f9; gap: 12px; }
.mp-row:last-child { border-bottom: none; }
.mp-lbl { font-size: 11.5px; color: #64748b; }
.mp-val { font-size: 12.5px; font-weight: 600; color: #0f172a; white-space: nowrap; }

/* ━━━━━━━━━━━━━━━━━ KPI ROW ━━━━━━━━━━━━━━━━━ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
/* Equal-width uniform compact strip — all cards same size */
.kpi-row-equal {
  grid-template-columns: repeat(var(--kpi-cols, 5), 1fr);
}
.kpi-card {
  background: var(--card-bg);
  border-radius: 6px;
  padding: 16px 18px;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #e2e8f0;
  box-shadow: 0 1px 3px rgb(0 0 0/.04);
  overflow: hidden;
}
.kpi-row .kpi-card:nth-child(even) { background: #e8f0f5 !important; }
.sb-metrics .sb-metric:nth-child(even) { background: #ffffff; }
/* CF Market Mall palette — primary #006097, secondary #4472c4, navy #0a2240 */
.kc-teal   { border-left-color: #006097; }
.kc-blue   { border-left-color: #4472c4; }
.kc-green  { border-left-color: #059669; }
.kc-amber  { border-left-color: #d97706; }
.kc-purple { border-left-color: #006097; }
.kc-pink   { border-left-color: #c0392b; }
.kc-cyan   { border-left-color: #4472c4; }

.kpi-lbl   { font-size: 9px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 1.4px; margin-bottom: 8px; }
.kpi-val   { font-size: 24px; font-weight: 700; color: var(--text-h); letter-spacing: -1.2px; line-height: 1; }
.kpi-val.md{ font-size: 20px; letter-spacing: -.5px; }
.kpi-val.sm{ font-size: 16px; letter-spacing: -.3px; }
.kpi-foot  { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; min-height: 18px; }
.kpi-bdg   { font-size: 10.5px; font-weight: 600; padding: 2px 6px; border-radius: 20px; display: inline-flex; align-items: center; gap: 2px; }
.kpi-bdg.up  { background: var(--green-bg); color: var(--green); }
.kpi-bdg.dn  { background: var(--red-bg);   color: var(--red);   }
.kpi-bdg.neu { background: #f1f5f9; color: var(--text-m); }
.kpi-vs    { font-size: 11px; color: var(--text-f); }
/* Mini sparkline inside KPI card — wrapper controls height, canvas fills it */
.kpi-spark-wrap { position: relative; height: 40px; margin-top: 8px; width: 100%; }
/* Compact row */
.kpi-row-sm .kpi-card { padding: 12px 14px; }
.kpi-row-sm .kpi-foot { margin-top: 4px; min-height: 14px; }
/* Progress bar inside KPI card */
.kpi-prog-wrap { height: 5px; background: #f1f5f9; border-radius: 99px; margin-top: 10px; overflow: hidden; }
.kpi-prog      { height: 100%; border-radius: 99px; transition: width .5s ease; }
.kpi-prog-teal { background: #006097; }

/* ━━━━━━━━━━━━━━━━━ MULTICARD ━━━━━━━━━━━━━━━━━ */
.multicard {
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgb(0 0 0/.04);
  margin-bottom: 16px;
  overflow: hidden;
}
/* Header — CF primary blue band + geometric accents */
.mc-header {
  display: flex; align-items: baseline; justify-content: space-between;
  background: #006097;
  padding: 16px 24px 15px;
  border-bottom: 1px solid #005485;
  position: relative;
  overflow: hidden;
}
.mc-header::after {
  content: '';
  position: absolute;
  right: -40px; top: -50px;
  width: 160px; height: 160px;
  background: rgba(255,255,255,.07);
  transform: rotate(45deg);
  border-radius: 16px;
  pointer-events: none;
}
.mc-header::before {
  content: '';
  position: absolute;
  right: 70px; top: -70px;
  width: 110px; height: 110px;
  background: rgba(255,255,255,.04);
  transform: rotate(45deg);
  border-radius: 12px;
  pointer-events: none;
}
.mc-title { font-size: 13px; font-weight: 600; color: #ffffff; letter-spacing: -.1px; }
.mc-meta  { font-size: 9px; font-weight: 700; color: rgba(255,255,255,.55); text-transform: uppercase; letter-spacing: 1.4px; }
/* Grid rows */
.mc-grid {
  display: grid; border-bottom: 1px solid #e8ecf0;
}
.mc-grid-4 { grid-template-columns: repeat(4, 1fr); }
/* Cells */
.mc-cell {
  padding: 20px 24px;
  border-right: 1px solid #e8ecf0;
}
.mc-cell:last-child { border-right: none; }
.mc-cell-lbl {
  font-size: 9px; font-weight: 700; color: #64748b;
  text-transform: uppercase; letter-spacing: 1.4px; margin-bottom: 10px;
}
.mc-cell-val {
  font-size: 28px; font-weight: 700; color: #0f172a;
  letter-spacing: -1.2px; line-height: 1; margin-bottom: 6px;
}
.mc-cell-val.sm { font-size: 20px; letter-spacing: -.6px; }
.mc-cell-chg { font-size: 11px; font-weight: 500; line-height: 1.3; color: #94a3b8; }
.mc-cell-chg.pos { color: var(--green); }
.mc-cell-chg.neg { color: var(--red); }
.mc-cell-chg.neu { color: #94a3b8; }
/* Smaller secondary row */
.mc-row-sm .mc-cell { padding: 14px 24px; background: #e8f0f5; }
/* Chart row */
.mc-chart-row { padding: 18px 24px 22px; }
.mc-chart-lbl {
  font-size: 9px; font-weight: 700; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 1.4px;
  text-transform: uppercase; letter-spacing: .6px; margin-bottom: 12px;
}

/* ━━━━━━━━━━━━━━━━━ SECTION BLOCK ━━━━━━━━━━━━━━━━━ */
.block {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 20px 22px;
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgb(0 0 0/.04);
}
.block-hd { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; gap: 8px; flex-direction: column; }
.block-title { font-size: 13px; font-weight: 600; color: var(--text-h); letter-spacing: -.1px; line-height: 1.35; max-width: 100%; }
.block-meta  { font-size: 9.5px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 1.1px; margin-top: -3px; }

/* section-level KPI stats (inside blocks) */
.blk-kpi-row { display: flex; gap: 36px; flex-wrap: wrap; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid #f3f4f6; }
.blk-kpi .kpi-lbl { margin-bottom: 5px; }
.blk-kpi .kpi-val { font-size: 22px; letter-spacing: -.5px; }

/* ━━━━━━━━━━━━━━━━━ CHART ━━━━━━━━━━━━━━━━━ */
.chart-wrap { position: relative; width: 100%; }

/* ━━━━━━━━━━━━━━━━━ GRIDS ━━━━━━━━━━━━━━━━━ */
.g2   { display: grid; grid-template-columns: 1fr 1fr;     gap: 16px; margin-bottom: 16px; }
.g3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.g21  { display: grid; grid-template-columns: 2fr 1fr;     gap: 16px; margin-bottom: 16px; }
.g2 > .block, .g3 > .block, .g21 > .block { margin-bottom: 0; }

/* ━━━━━━━━━━━━━━━━━ TABLES ━━━━━━━━━━━━━━━━━ */
.tbl-wrap { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dt th {
  padding: 9px 13px; text-align: left;
  font-size: 10.5px; font-weight: 600; color: var(--text-f);
  text-transform: uppercase; letter-spacing: .6px;
  border-bottom: 1px solid #f1f5f9; white-space: nowrap; background: #f8fafc;
}
table.dt td { padding: 11px 13px; border-bottom: 1px solid #f8fafc; color: var(--text-b); }
table.dt tr:last-child td { border-bottom: none; }
table.dt tr:hover td { background: #f8fafc; }
table.dt .r  { text-align: right; font-variant-numeric: tabular-nums; }
table.dt .b  { font-weight: 600; color: var(--text-h); }
table.dt .sm { font-size: 11.5px; color: var(--text-f); }
table.dt.dt-sm th { padding: 6px 10px; font-size: 10px; }
table.dt.dt-sm td { padding: 6px 10px; font-size: 12px; }
table.dt.dt-sm .bar-wrap { height: 4px; }
table.dt.dt-sm .bar { height: 4px; }

/* ━━━━━━━━━━━━━━━━━ BADGES ━━━━━━━━━━━━━━━━━ */
.bdg { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px; display: inline-block; white-space: nowrap; }
.bdg-ok   { background: var(--green-bg);  color: var(--green); }
.bdg-low  { background: var(--amber-bg);  color: var(--amber); }
.bdg-crit { background: var(--red-bg);    color: var(--red);   }
.bdg-info { background: var(--blue-bg);   color: var(--blue);  }
.bdg-gray { background: #f3f4f6; color: var(--text-m); }

/* ━━━━━━━━━━━━━━━━━ MISC COMPONENTS ━━━━━━━━━━━━━━━━━ */
.rank { width: 22px; height: 22px; border-radius: 50%; background: #f3f4f6; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #6b7280; }
.r1   { background: #fef3c7; color: #d97706; }
.r2   { background: #f3f4f6; color: #6b7280; }
.r3   { background: #fff7ed; color: #c2410c; }

.av   { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg,#0d9488,#14b8a6); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 10.5px; font-weight: 700; flex-shrink: 0; }

.bar-wrap { height: 5px; background: #f3f4f6; border-radius: 99px; overflow: hidden; min-width: 70px; }
.bar      { height: 100%; border-radius: 99px; background: var(--accent); }

.bar.teal  { background: var(--teal); }
.bar.green { background: var(--emerald); }
.bar.amber { background: var(--amber-a); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* flex utils */
.fx   { display: flex; }
.fxc  { align-items: center; }
.g8   { gap: 8px; }
.g12  { gap: 12px; }
.fw6  { font-weight: 600; }
.fw7  { font-weight: 700; }
.ch   { color: var(--text-h); }
.cm   { color: var(--text-m); }
.mt8  { margin-top: 8px; }
.mt14 { margin-top: 14px; }
.tr   { text-align: right; }

/* ━━━━━━━━━━━━━━━━━ RESPONSIVE ━━━━━━━━━━━━━━━━━ */
@media (max-width: 1080px) {
  .g2, .g21 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar  { display: none; }
  .kpi-row  { grid-template-columns: repeat(2, 1fr); }
  .kpi-row-equal { grid-template-columns: repeat(2, 1fr) !important; }
  .g3       { grid-template-columns: 1fr 1fr; }
  .tb-topstrip { padding: 0 16px; }
  .filter-bar  { padding: 10px 16px 12px; flex-wrap: wrap; }
  .content  { padding: 16px; }
}
@media (max-width: 1200px) {
  .kpi-row-equal[style*="--kpi-cols:5"] { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ━━━━━━━━━━━━━━━━━━━━ STORY BLOCKS  (CF Market Mall style) ━━━━━━━━━━━━━━━━━━━━ */
.story-block {
  border-radius: 8px;
  border: 1px solid #dde3ea;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgb(0 0 0/.06);
}
/* ── CF primary blue header band + geometric diamond accents ── */
.sb-top {
  background: #006097;
  padding: 22px 28px 20px;
  border-bottom: 1px solid #005485;
  position: relative;
  overflow: hidden;
}
/* Large diamond top-right */
.sb-top::after {
  content: '';
  position: absolute;
  right: -50px; top: -60px;
  width: 200px; height: 200px;
  background: rgba(255,255,255,.07);
  transform: rotate(45deg);
  border-radius: 20px;
  pointer-events: none;
}
/* Smaller offset diamond */
.sb-top::before {
  content: '';
  position: absolute;
  right: 80px; top: -80px;
  width: 130px; height: 130px;
  background: rgba(255,255,255,.04);
  transform: rotate(45deg);
  border-radius: 14px;
  pointer-events: none;
}
.sb-section {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,.55);
  margin-bottom: 9px;
}
.sb-headline {
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -.15px;
  line-height: 1.4;
  margin-bottom: 6px;
}
.sb-narrative {
  font-size: 12px;
  color: rgba(255,255,255,.7);
  line-height: 1.65;
}
/* ── Stat band (CF's SHOPPER PROFILE grid — #e8f0f5 light blue tint) ── */
.sb-metrics {
  display: flex;
  background: #e8f0f5;
  border-bottom: 1px solid #d0dfe9;
}
.sb-metric {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 26px;
  border-right: 1px solid #d0dfe9;
  min-width: 0;
}
.sb-metric:last-child { border-right: none; }
.sbm-left {
  min-width: 0;
  flex: 1;
}
.sbm-right {
  flex-shrink: 0;
  text-align: right;
}
.sbm-lbl {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: #64748b;
  margin-bottom: 8px;
}
.sbm-val {
  font-size: 28px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -1.4px;
  line-height: 1;
}
.sbm-delta {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}
.sbm-delta.up { color: #059669; }
.sbm-delta.dn { color: #e11d48; }
.sbm-delta.neu { color: #94a3b8; }
.sbm-vs {
  font-size: 10px;
  color: #94a3b8;
  white-space: nowrap;
}
/* ── Chart area below stats ── */
.sb-chart-area {
  background: #ffffff;
  padding: 18px 28px 24px;
}
.sb-chart-lbl {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: #94a3b8;
  margin-bottom: 14px;
}

/* ━━━━━━━━━━━━━━━━━ HORIZONTAL GAUGE ━━━━━━━━━━━━━━━━━ */
.hg-block {
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgb(0 0 0/.04);
}
.hg-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  background: #006097;
  padding: 18px 24px 16px;
  border-bottom: 1px solid #005485;
  position: relative;
  overflow: hidden;
}
.hg-header::after {
  content: '';
  position: absolute;
  right: -40px; top: -50px;
  width: 160px; height: 160px;
  background: rgba(255,255,255,.07);
  transform: rotate(45deg);
  border-radius: 16px;
  pointer-events: none;
}
.hg-header::before {
  content: '';
  position: absolute;
  right: 70px; top: -70px;
  width: 110px; height: 110px;
  background: rgba(255,255,255,.04);
  transform: rotate(45deg);
  border-radius: 12px;
  pointer-events: none;
}
.hg-section { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; color: rgba(255,255,255,.55); margin-bottom: 9px; }
.hg-title   { font-size: 15px; font-weight: 600; color: #ffffff; letter-spacing: -.15px; line-height: 1.4; margin-bottom: 4px; }
.hg-desc    { font-size: 12px; color: rgba(255,255,255,.7); max-width: 500px; line-height: 1.5; }
.hg-right { text-align: right; flex-shrink: 0; padding-left: 16px; }
.hg-val   { display: block; font-size: 42px; font-weight: 700; color: #ffffff; letter-spacing: -2px; line-height: 1; }
.hg-chg   { font-size: 12px; color: rgba(255,255,255,.65); margin-top: 6px; display: block; }
/* Track area below dark header */
.hg-track-below { background: #fff; padding: 20px 24px 18px; }

.hg-track-wrap { margin-bottom: 8px; padding-top: 20px; }
.hg-track {
  position: relative;
  height: 16px;
  border-radius: 8px;
  background: #e2e8f0;
  overflow: visible;
}
.hg-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: #006097;
  border-radius: 8px 0 0 8px;
  transition: width .65s cubic-bezier(.4,0,.2,1);
}
.hg-needle {
  position: absolute;
  top: -6px; bottom: -6px;
  width: 3px; border-radius: 2px;
  background: #0a2240;
  /* dark needle contrasts against both white track and blue fill */
  transform: translateX(-50%);
  box-shadow: 0 0 0 2px #fff;
  transition: left .65s cubic-bezier(.4,0,.2,1);
}
.hg-target-line {
  position: absolute;
  left: 45%;
  top: -12px; bottom: -12px;
  width: 0;
  border-left: 2px dashed #64748b;
  transform: translateX(-50%);
  opacity: .7;
}
.hg-target-tip {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 600; color: #475569;
  white-space: nowrap; background: #fff;
  padding: 2px 7px; border-radius: 4px;
  border: 1px solid #e2e8f0;
  box-shadow: var(--sh);
}

.hg-ticks {
  display: flex; justify-content: space-between;
  font-size: 10.5px; color: var(--text-f);
  margin-bottom: 8px;
}
.hg-zones { display: flex; gap: 4px; }
.hgz {
  font-size: 11px; font-weight: 500; padding: 4px 10px;
  border-radius: 5px; text-align: center; white-space: nowrap;
}
/* IBCS: neutral zone labels — no semantic color coding */
.hgz-red   { background: #f8fafc; color: #475569; border: 1px solid #e2e8f0; }
.hgz-amber { background: #f8fafc; color: #475569; border: 1px solid #e2e8f0; }
.hgz-green { background: #f8fafc; color: #1e293b; border: 1px solid #e2e8f0; font-weight: 600; }

/* ━━━━━━━━━━━━━━━━━ FUNNEL ━━━━━━━━━━━━━━━━━ */
.fn-row {
  display: flex; align-items: center;
  gap: 10px; padding: 6px 0;
}
.fn-lbl {
  width: 128px; flex-shrink: 0;
  font-size: 12px; color: var(--text-m); text-align: right;
  line-height: 1.3;
}
.fn-body  { flex: 1; display: flex; align-items: center; gap: 8px; }
.fn-bg    { flex: 1; height: 28px; background: #f1f5f9; border-radius: 5px; overflow: hidden; }
.fn-fill  {
  height: 100%; border-radius: 5px;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 8px; min-width: 48px;
  transition: width .5s ease;
}
.fn-num   { font-size: 11.5px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.fn-right {
  width: 68px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 1px;
}
.fn-conv  { font-size: 10.5px; color: var(--text-f); line-height: 1.3; min-height: 14px; }
.fn-pct   { font-size: 11px; font-weight: 600; color: var(--text-m); }
