:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --success: #16a34a;
  --info: #2563eb;
  --warning: #f59e0b;
  --danger: #dc2626;
  --gold: #b7791f;
  --muted: #64748b;
  --bg: #f4f7f8;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --soft: #f8fafc;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.09);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  direction: rtl;
  font-family: "Tajawal", "Cairo", sans-serif;
  background:
    radial-gradient(circle at 10% 12%, rgba(15, 118, 110, 0.10), transparent 26%),
    linear-gradient(180deg, #fbfdfe 0%, var(--bg) 45%, #eef3f5 100%);
  color: var(--text);
}

button, input, select { font: inherit; }

.hero {
  position: relative;
  display: grid;
  gap: 20px;
  min-height: 520px;
  padding: 30px clamp(18px, 5vw, 72px) 56px;
  color: #fff;
  background: url("assets/hero-customer360.png") center/cover;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(2, 6, 23, 0.86), rgba(6, 78, 59, 0.66), rgba(2, 6, 23, 0.38)),
    radial-gradient(circle at 78% 32%, rgba(16, 185, 129, 0.24), transparent 36%);
  z-index: 1;
}

.hero > * {
  position: relative;
  z-index: 2;
}

.hero.compact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 205px;
}
.hero h1 { margin: 10px 0; font-size: clamp(2.6rem, 5vw, 4.8rem); letter-spacing: 0; line-height: 1.05; }
.hero p { margin: 0; color: rgba(255, 255, 255, 0.84); font-size: 17px; line-height: 1.8; }
.eyebrow { color: #a7f3d0 !important; font-weight: 700; }
.eyebrow.dark { color: var(--primary) !important; margin: 0 0 6px; }

.hero-topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 48px;
}
.hero-topbar > div:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.hero-topbar strong { font-size: 18px; font-weight: 800; }
.hero-topbar span { color: rgba(255, 255, 255, 0.72); }
.update-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(8px);
}
.update-badge i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, .15);
}
.update-badge strong { font-size: 14px; font-weight: 700; }

.hero-main {
  display: grid;
  grid-template-columns: minmax(0, .94fr) minmax(420px, .96fr);
  gap: clamp(22px, 4vw, 54px);
  align-items: center;
}
.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.hero-copy > p:not(.eyebrow) { max-width: 620px; }
.developer-card {
  width: min(390px, 100%);
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,.18);
  border-right: 4px solid #22c55e;
  border-radius: var(--radius);
  background: rgba(2, 6, 23, .42);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 36px rgba(2, 6, 23, .20);
}
.developer-card span {
  display: block;
  color: rgba(255,255,255,.70);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 5px;
}
.developer-card strong {
  display: block;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
}
.developer-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.developer-card a {
  display: inline-flex;
  color: #a7f3d0;
  text-decoration: none;
  direction: ltr;
  font-weight: 800;
}
.hero-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.hero-mini-card, .mini-skeleton {
  min-height: 88px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.18);
  padding: 12px;
}
.hero-mini-card span, .hero-mini-card small { display: block; color: rgba(255,255,255,.72); }
.hero-mini-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 24px;
  direction: ltr;
  text-align: right;
}
.hero-chart-card {
  width: min(100%, 590px);
  justify-self: end;
  min-height: 360px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.90);
  backdrop-filter: blur(14px);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0,0,0,.20);
  padding: 18px;
}
.chart-card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.chart-card-head span { color: var(--muted); font-size: 13px; }
.chart-card-head h2 { margin: 3px 0 0; font-size: 20px; }
.chart-subtitle {
  margin: 5px 0 0 !important;
  color: #64748b !important;
  font-size: 12px !important;
  line-height: 1.55 !important;
}
.chart-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  background: #fff7ed;
  color: #c2410c !important;
  border: 1px solid #fed7aa;
  font-size: 12px !important;
  font-weight: 800;
}
.chart-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.chart-tabs button {
  padding: 8px 10px;
  background: #f1f5f9;
  color: #334155;
  font-size: 13px;
}
.chart-tabs button.active {
  background: var(--primary);
  color: #fff;
}
.hero-chart-notice {
  margin: 8px 0 10px !important;
  padding: 9px 11px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  background: #eff6ff;
  color: #1e40af !important;
  font-size: 12px !important;
  line-height: 1.55 !important;
}
.hero-chart-more-panel {
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
}
.hero-chart-more-panel > span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 7px;
}
.hero-chart-more-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hero-chart-more-buttons button {
  padding: 7px 9px;
  background: #fff;
  color: #334155;
  border: 1px solid var(--border);
  box-shadow: none;
  font-size: 12px;
}
.hero-chart-more-buttons button:hover {
  transform: none;
  box-shadow: none;
  background: #ecfdf5;
}
.hero-chart-more-buttons button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.chart-reading-note {
  margin: 0 0 10px !important;
  padding: 9px 11px;
  border-right: 3px solid var(--warning);
  border-radius: var(--radius);
  background: #fff7ed;
  color: #9a3412 !important;
  font-size: 12px !important;
  line-height: 1.55 !important;
}
.chart-wrap {
  height: 218px;
  min-height: 218px;
  position: relative;
}
.chart-insight {
  margin: 10px 0 0 !important;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #f8fafc;
  color: #475569 !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
}

main { width: min(1240px, calc(100% - 32px)); margin: 32px auto 48px; }

.last-update, .upload-box, .toolbar, .modal-panel, .empty-state {
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.last-update { padding: 18px 22px; min-width: 210px; }
.last-update span { display: block; color: var(--muted); margin-bottom: 5px; }

.kpi-grid, .insight-grid, .customer-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.kpi-card, .insight-card, .customer-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.kpi-card {
  min-height: 118px;
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: #ecfdf5;
  color: var(--primary-dark);
  font-weight: 800;
  flex: 0 0 auto;
}
.kpi-card strong { display: block; margin: 7px 0 4px; font-size: 25px; direction: ltr; text-align: right; }
.kpi-card small { color: #94a3b8; line-height: 1.5; }
.insight-card { position: relative; padding: 18px 18px 18px; overflow: hidden; }
.kpi-card span, .insight-card span, .meta, .result-count { color: var(--muted); }

.section-title { margin: 30px 0 14px; display: flex; align-items: center; justify-content: space-between; }
.section-title h2 { margin: 0; font-size: 22px; }
.insight-marker {
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--info));
}
.insight-card strong { display: block; margin: 10px 0 8px; font-size: 20px; line-height: 1.4; }
.insight-card p { margin: 0; direction: ltr; text-align: right; color: var(--primary-dark); font-size: 22px; font-weight: 800; }

.toolbar {
  margin: 24px 0 16px;
  padding: 18px;
  position: relative;
  z-index: 3;
}

.toolbar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.toolbar-head h2 { margin: 0 0 4px; font-size: 20px; }
.toolbar-head p { margin: 0; color: var(--muted); line-height: 1.6; }
.toolbar-head .result-count {
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f0fdfa;
  color: var(--primary-dark);
  white-space: nowrap;
}

.toolbar-grid {
  display: grid;
  grid-template-columns: minmax(300px, 1.55fr) minmax(280px, 1.35fr) minmax(170px, .75fr) auto;
  gap: 12px;
  align-items: end;
}

.search-field, .filter-group {
  display: grid;
  gap: 7px;
}
.search-field > span, .filter-group > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.search-field > div {
  position: relative;
  display: flex;
  align-items: center;
}
.search-field i {
  position: absolute;
  right: 12px;
  color: var(--muted);
  font-style: normal;
  font-size: 17px;
  z-index: 1;
}
.search-field input {
  padding-right: 38px;
  padding-left: 38px;
  height: 46px;
}
.search-field button {
  display: none;
  position: absolute;
  left: 7px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
}
.search-field button.visible { display: inline-flex; }
.search-field button:hover { transform: none; box-shadow: none; background: #cbd5e1; }
.filter-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.custom-dropdown { position: relative; min-width: 0; }
.custom-dropdown > button {
  width: 100%;
  height: 46px;
  justify-content: space-between;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  padding: 0 12px;
}
.custom-dropdown > button::after {
  content: "⌄";
  color: var(--muted);
  font-size: 15px;
}
.custom-dropdown.open > button,
.custom-dropdown > button:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}
.custom-dropdown > button:hover { transform: none; box-shadow: none; background: #f8fafc; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  width: min(260px, 90vw);
  max-height: 245px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
  padding: 6px;
  z-index: 20;
}
.sort-group .dropdown-menu { width: 240px; }
.custom-dropdown.open .dropdown-menu { display: grid; gap: 2px; }
.dropdown-menu button {
  width: 100%;
  justify-content: space-between;
  background: #fff;
  color: var(--text);
  box-shadow: none;
  padding: 9px 10px;
  font-size: 14px;
}
.dropdown-menu button:hover { background: #f8fafc; transform: none; box-shadow: none; }
.dropdown-menu button i { visibility: hidden; color: var(--primary); font-style: normal; }
.dropdown-menu button.selected {
  background: #ecfdf5;
  color: var(--primary-dark);
  font-weight: 800;
}
.dropdown-menu button.selected i { visibility: visible; }
.dropdown-group {
  padding: 9px 10px 5px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 800;
}

.reset-button {
  height: 46px;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.reset-button:hover { background: #e2e8f0; box-shadow: none; }

.active-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
  min-height: 30px;
  color: var(--muted);
  font-size: 13px;
}
.active-filters > span { font-weight: 700; }
.active-filters button {
  padding: 6px 9px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid var(--border);
  font-size: 12px;
  box-shadow: none;
}
.active-filters button:hover { background: #fff7ed; border-color: #fed7aa; color: #9a3412; transform: none; box-shadow: none; }
.active-filters b { margin-right: 4px; }

input, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 13px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13); }

button, .ghost-link, .empty-state a {
  border: 0;
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

button:hover, .ghost-link:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(15, 23, 42, 0.12); }
.ghost-link { background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.28); }
.result-count { margin: 14px 2px 16px; font-size: 15px; }
.result-count strong { color: var(--text); }

.customer-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.customer-card {
  position: relative;
  overflow: hidden;
  padding: 16px;
  cursor: pointer;
  border-top: 3px solid #cbd5e1;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.customer-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: rgba(15, 118, 110, 0.35); }
.customer-card:focus { outline: 3px solid rgba(37, 99, 235, 0.18); }
.customer-card.status-excellent { border-top-color: rgba(22, 163, 74, .72); }
.customer-card.status-good { border-top-color: rgba(37, 99, 235, .70); }
.customer-card.status-gold { border-top-color: rgba(183, 121, 31, .72); }
.customer-card.status-warning { border-top-color: rgba(245, 158, 11, .78); }
.customer-card.status-danger { border-top-color: rgba(220, 38, 38, .75); }
.customer-card.status-gray { border-top-color: #94a3b8; }

.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.customer-title { min-width: 0; }
.card-head h3 { margin: 0 0 5px; font-size: 20px; line-height: 1.32; font-weight: 800; }
.meta { margin: 0 0 9px; line-height: 1.45; font-size: 13px; }
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #e5e7eb;
  color: #374151;
  line-height: 1.3;
}
.badge.good { background: #dbeafe; color: #1d4ed8; }
.badge.excellent { background: #dcfce7; color: #15803d; }
.badge.gold { background: #fef3c7; color: #92400e; }
.badge.warning { background: #ffedd5; color: #c2410c; }
.badge.danger { background: #fee2e2; color: #b91c1c; }
.badge.gray { background: #e5e7eb; color: #4b5563; }
.badge.action { background: #f1f5f9; color: #334155; }

.score-badge {
  position: relative;
  flex: 0 0 auto;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 4px;
  border: 0;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(226, 232, 240, .95);
}
.score-badge {
  background: conic-gradient(var(--primary) var(--score), #e8edf3 0);
}
.score-badge strong, .score-badge span {
  position: relative;
  z-index: 1;
}
.score-badge::after {
  content: "";
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
}
.score-badge strong { font-size: 18px; line-height: 1; direction: ltr; color: var(--text); }
.score-badge span { font-size: 9px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .02em; }
.score-badge.excellent { background: conic-gradient(var(--success) var(--score), #e8edf3 0); }
.score-badge.good { background: conic-gradient(var(--info) var(--score), #e8edf3 0); }
.score-badge.gold { background: conic-gradient(var(--gold) var(--score), #e8edf3 0); }
.score-badge.warning { background: conic-gradient(var(--warning) var(--score), #e8edf3 0); }
.score-badge.danger { background: conic-gradient(var(--danger) var(--score), #e8edf3 0); }
.score-badge.gray { background: conic-gradient(#94a3b8 var(--score), #e8edf3 0); }

.score-track {
  height: 5px;
  margin: 12px 0;
  background: #edf2f7;
  border-radius: 999px;
  overflow: hidden;
}
.score-track i, .bar i { display: block; height: 100%; border-radius: inherit; }
.excellent { background-color: var(--success); }
.good { background-color: var(--info); }
.gold { background-color: var(--gold); }
.warning { background-color: var(--warning); }
.danger { background-color: var(--danger); }
.gray { background-color: #94a3b8; }

.card-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.metric {
  background: var(--soft);
  border: 1px solid #edf2f7;
  border-radius: var(--radius);
  padding: 9px 10px;
  min-width: 0;
  min-height: 64px;
  transition: background .2s ease, border-color .2s ease;
}
.metric:hover { background: #fff; border-color: #dbe3ee; }
.metric span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.metric strong { display: block; font-size: 16px; direction: ltr; text-align: right; overflow-wrap: anywhere; font-weight: 800; }
.tone-positive strong { color: var(--success); }
.tone-danger strong { color: var(--danger); }
.tone-warning strong { color: #b45309; }
.tone-sales strong { color: var(--primary-dark); }

.date-strip {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid #edf2f7;
  color: var(--muted);
  font-size: 11px;
}
.date-strip strong { color: var(--text); font-weight: 700; }
.reason-box {
  margin-top: 10px;
  padding: 10px 11px;
  border-radius: var(--radius);
  background: #f8fafc;
  border: 1px solid #edf2f7;
  border-right: 3px solid rgba(15, 118, 110, .32);
}
.reason-box span {
  display: block;
  margin-bottom: 3px;
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
}
.reason-box p {
  margin: 0;
  color: #475569;
  line-height: 1.6;
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.modal { position: fixed; inset: 0; z-index: 10; }
.modal.hidden, .hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.58); }
.modal-panel {
  position: absolute;
  inset: 28px 50% 28px auto;
  transform: translateX(50%);
  width: min(1040px, calc(100% - 28px));
  max-height: calc(100vh - 56px);
  overflow: auto;
  padding: 22px;
}
.modal-close-row {
  position: sticky;
  top: -22px;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  padding: 0 0 8px;
  background: linear-gradient(180deg, #fff 70%, rgba(255,255,255,0));
}
.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 28px;
  background: #111827;
}

.executive-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 4px 0 18px;
  border-bottom: 1px solid var(--border);
}
.executive-head h2 { margin: 0 0 8px; font-size: clamp(30px, 4vw, 46px); line-height: 1.25; }
.score-ring {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--primary) var(--score), #e2e8f0 0);
}
.score-ring > div {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  align-content: center;
}
.score-ring strong { font-size: 34px; direction: ltr; line-height: 1; }
.score-ring span { font-size: 12px; color: var(--muted); margin-top: 6px; }
.score-ring.excellent { background: conic-gradient(var(--success) var(--score), #e2e8f0 0); }
.score-ring.good { background: conic-gradient(var(--info) var(--score), #e2e8f0 0); }
.score-ring.gold { background: conic-gradient(var(--gold) var(--score), #e2e8f0 0); }
.score-ring.warning { background: conic-gradient(var(--warning) var(--score), #e2e8f0 0); }
.score-ring.danger { background: conic-gradient(var(--danger) var(--score), #e2e8f0 0); }
.score-ring.gray { background: conic-gradient(#94a3b8 var(--score), #e2e8f0 0); }

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}
.summary-strip div {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
}
.summary-strip span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.summary-strip strong { line-height: 1.5; }

.executive-insight {
  position: relative;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  border-right: 5px solid var(--primary);
  border-radius: var(--radius);
  padding: 17px 18px;
  line-height: 1.9;
}
.executive-insight span { color: var(--primary-dark); font-weight: 800; }
.executive-insight p { margin: 6px 0 0; color: #164e3b; }

.modal-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 6px;
  padding: 6px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.modal-tabs button {
  flex: 1 1 140px;
  padding: 10px 12px;
  background: transparent;
  color: #475569;
  box-shadow: none;
  font-weight: 800;
}
.modal-tabs button:hover { transform: none; box-shadow: none; background: #eef2f7; }
.modal-tabs button.active {
  background: var(--primary);
  color: #fff;
}
.modal-tab-panel { display: none; }
.modal-tab-panel.active { display: block; }

.detail-section { margin-top: 24px; }
.detail-section h3 { margin: 0 0 12px; font-size: 20px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.finance-grid .metric { min-height: 82px; }
.empty-note {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
}

.score-list {
  display: grid;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.score-row {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 72px 1.5fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius);
  background: #fff;
}
.score-row.featured {
  border: 1px solid rgba(15, 118, 110, .25);
  background: #f0fdfa;
  font-size: 17px;
  padding: 14px;
}
.score-name span {
  display: block;
  color: var(--text);
  font-weight: 800;
  text-align: right;
}
.score-name small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  direction: ltr;
  text-align: right;
  font-weight: 700;
}
.score-row strong { direction: ltr; text-align: right; }
.bar { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.score-section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.score-section-head h3 { margin-bottom: 5px; }
.score-section-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}
.method-toggle {
  flex: 0 0 auto;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border);
  box-shadow: none;
}
.method-toggle:hover { transform: none; box-shadow: none; background: #e2e8f0; }
.score-methodology {
  display: none;
  margin-bottom: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.score-methodology.open { display: block; }
.score-methodology ul {
  margin: 0;
  padding: 0 18px 0 0;
  line-height: 1.9;
  color: #475569;
}
.score-methodology strong { color: var(--text); }
.modal-actions { margin-top: 24px; display: flex; justify-content: flex-start; }

.timeline-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.timeline-status {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  background: #f8fafc;
  border-top: 3px solid #94a3b8;
}
.timeline-status span,
.timeline-event span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}
.timeline-status strong { display: block; font-size: 18px; margin-bottom: 3px; }
.timeline-status small { color: #64748b; line-height: 1.5; }
.timeline-status.tone-purchase { border-top-color: var(--info); }
.timeline-status.tone-collection { border-top-color: var(--success); }
.timeline-status.tone-discount { border-top-color: var(--warning); }
.timeline-status.tone-danger { border-top-color: rgba(220, 38, 38, .76); background: #fff7f7; }
.timeline-status.tone-muted { border-top-color: #94a3b8; }

.customer-timeline {
  position: relative;
  display: grid;
  gap: 12px;
  padding-right: 18px;
}
.customer-timeline::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  right: 6px;
  width: 2px;
  background: #e2e8f0;
}
.timeline-event {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
}
.timeline-dot {
  position: relative;
  z-index: 1;
  width: 14px;
  height: 14px;
  margin-top: 14px;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: 0 0 0 5px #f8fafc;
}
.timeline-event > div:last-child {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
}
.timeline-event strong {
  display: block;
  font-size: 18px;
  margin-bottom: 5px;
}
.timeline-event strong.missing { color: #94a3b8; }
.timeline-event p { margin: 0; color: #475569; line-height: 1.7; }
.timeline-event.tone-purchase .timeline-dot { background: var(--info); }
.timeline-event.tone-collection .timeline-dot { background: var(--success); }
.timeline-event.tone-discount .timeline-dot { background: var(--warning); }
.timeline-event.tone-danger .timeline-dot { background: var(--danger); }
.timeline-event.tone-muted .timeline-dot { background: #94a3b8; }

.empty-state, .upload-box { padding: 30px; text-align: center; }
.upload-main { max-width: 720px; }
.file-drop { display: grid; place-items: center; gap: 10px; min-height: 180px; border: 2px dashed #b8c4d6; border-radius: var(--radius); background: #f8fafc; cursor: pointer; }
.file-drop span { font-size: 22px; font-weight: 800; }
#fileInput { margin: 18px 0; }
.upload-status { margin-top: 18px; text-align: right; background: #f8fafc; border-radius: var(--radius); padding: 14px; line-height: 1.8; }
.upload-status pre { white-space: pre-wrap; margin: 0; font-family: inherit; }
.upload-status .error { color: var(--danger); }

.skeleton {
  min-height: 108px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #eef2f7, #fff, #eef2f7);
  background-size: 220% 100%;
  animation: pulse 1.3s infinite;
}
@keyframes pulse { to { background-position: -220% 0; } }

@media (max-width: 1080px) {
  .hero-main { grid-template-columns: 1fr; }
  .hero-chart-card { justify-self: stretch; width: 100%; min-height: 340px; }
  .customer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid, .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar-grid { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .hero { width: 100%; padding: 22px 14px 34px; min-height: auto; background-position: center top; }
  .hero.compact { min-height: 205px; }
  .hero-topbar, .chart-card-head, .executive-head { flex-direction: column; align-items: stretch; }
  .hero-topbar { gap: 10px; min-width: 0; }
  .hero-topbar > div:first-child { display: grid; gap: 3px; min-width: 0; text-align: right; }
  .hero-topbar strong { font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
  .hero-topbar span { font-size: 14px; line-height: 1.5; }
  .update-badge { width: 100%; max-width: 100%; justify-content: center; flex-wrap: wrap; border-radius: 16px; padding: 8px 10px; text-align: center; }
  .update-badge strong { font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
  .hero-main { gap: 18px; min-width: 0; }
  .hero-copy { align-items: stretch; text-align: right; }
  .eyebrow { font-size: 14px; }
  .hero h1 { font-size: clamp(2rem, 10vw, 2.55rem); line-height: 1.12; overflow-wrap: anywhere; }
  .hero p { font-size: 15px; line-height: 1.75; }
  .developer-card { width: 100%; margin-top: 14px; padding: 11px 12px; }
  .developer-card strong { font-size: 17px; }
  .developer-links { gap: 8px; }
  .developer-card a { font-size: 14px; }
  .hero-mini-grid { grid-template-columns: 1fr; gap: 8px; }
  .hero-mini-card, .mini-skeleton { min-height: auto; padding: 12px; }
  .hero-mini-card strong { font-size: 22px; }
  .hero-chart-card { width: 100%; min-width: 0; padding: 12px; border-radius: 16px; min-height: auto; }
  .chart-card-head h2 { font-size: 20px; line-height: 1.35; }
  .chart-tabs { justify-content: stretch; }
  .chart-tabs button { flex: 1 1 calc(50% - 6px); padding: 9px 8px; font-size: 12px; }
  .hero-chart-more-buttons button { flex: 1 1 calc(50% - 6px); }
  .chart-wrap { height: 230px; min-height: 230px; }
  main { width: min(100% - 20px, 1240px); margin-top: 24px; }
  .toolbar-head { flex-direction: column; }
  .toolbar-head .result-count { width: 100%; text-align: center; }
  .kpi-grid, .insight-grid, .customer-grid, .toolbar-grid, .filter-controls, .card-metrics, .detail-grid, .summary-strip, .timeline-summary { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .dropdown-menu, .sort-group .dropdown-menu { width: 100%; }
  .modal-tabs { display: grid; grid-template-columns: 1fr; }
  .date-strip { flex-direction: column; }
  .modal-panel {
    inset: 0 50% 0 auto;
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  .modal-close-row { top: -22px; }
  .score-ring { width: 132px; height: 132px; }
  .score-ring > div { width: 100px; height: 100px; }
  .score-section-head { flex-direction: column; }
  .method-toggle { width: 100%; }
  .score-row { grid-template-columns: 1fr 58px; }
  .score-row .bar { grid-column: 1 / -1; }
}

@media (max-width: 420px) {
  .hero { padding-inline: 10px; }
  .hero h1 { font-size: 1.85rem; }
  .hero-topbar strong { font-size: 15px; }
  .developer-links { display: grid; gap: 4px; }
  .chart-tabs button,
  .hero-chart-more-buttons button { flex-basis: 100%; }
  .chart-wrap { height: 210px; min-height: 210px; }
}
