:root {
  --green: #105b3a;
  --green-dark: #0a4029;
  --green-mid: #247a50;
  --green-light: #eaf5ee;
  --text: #1c3528;
  --muted: #718176;
  --border: #e3ebe5;
  --surface: #ffffff;
  --background: #f4f7f4;
  --shadow: 0 5px 22px rgba(24, 65, 42, .055);
  --radius: 18px;
  --sidebar-width: 325px;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--background);
  color: var(--text); font-family: Tahoma, Arial, sans-serif;
  font-size: 13px; line-height: 1.6;
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(36, 122, 80, .24); outline-offset: 2px;
}
.topbar {
  min-height: 76px; padding: 12px 28px; display: flex; align-items: center;
  justify-content: space-between; gap: 20px; color: #fff;
  background: linear-gradient(110deg, var(--green-dark), var(--green));
  box-shadow: 0 4px 18px rgba(10, 64, 41, .15);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 46px; height: 46px; display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.3); border-radius: 14px;
  background: rgba(255,255,255,.13); font-size: 25px; font-weight: 900;
}
.brand h1 { margin: 0; font-size: 20px; font-weight: 900; line-height: 1.4; }
.brand p { margin: 2px 0 0; color: rgba(255,255,255,.76); font-size: 11px; }
.header-status { display: flex; align-items: center; gap: 9px; color: rgba(255,255,255,.9); font-size: 11px; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #7ee0a5; box-shadow: 0 0 0 4px rgba(126,224,165,.13); }
.app-shell { width: 100%; max-width: 1800px; margin: 0 auto; padding: 24px; }
.dashboard { margin-bottom: 22px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.eyebrow { display: block; color: var(--green-mid); font-size: 9px; font-weight: 900; letter-spacing: 1.1px; }
.page-heading h2, .panel-heading h2, .map-title h2 { margin: 3px 0; color: var(--text); font-size: 20px; font-weight: 900; line-height: 1.5; }
.page-heading p, .map-title p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.button {
  min-height: 37px; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 8px 13px; border: 1px solid transparent; border-radius: 10px;
  cursor: pointer; font-size: 11px; font-weight: 800; line-height: 1.4;
  text-decoration: none; transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.button:active { transform: translateY(1px); }
.button-light { color: var(--text); border-color: var(--border); background: #fff; }
.button-light:hover { border-color: #b8d1bf; background: #f7fbf8; }
.button-full { width: 100%; }
.kpi-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.kpi-card { position: relative; min-width: 0; padding: 17px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.kpi-card::after { position: absolute; inset-inline-end: 0; top: 0; width: 3px; height: 100%; background: #d5e8da; content: ""; }
.kpi-card.kpi-primary { color: #fff; border-color: var(--green); background: linear-gradient(135deg,var(--green),var(--green-dark)); }
.kpi-primary::after { background: #8ad2a2; }
.kpi-icon { width: 33px; height: 33px; display: grid; place-items: center; margin-bottom: 10px; border-radius: 10px; color: var(--green); background: var(--green-light); font-size: 19px; }
.kpi-primary .kpi-icon { color: #fff; background: rgba(255,255,255,.14); }
.kpi-label { color: var(--muted); font-size: 11px; font-weight: 700; }
.kpi-primary .kpi-label, .kpi-primary small { color: rgba(255,255,255,.76); }
.kpi-card strong { display: block; margin: 3px 0; color: var(--text); font-size: 27px; font-weight: 900; line-height: 1.4; font-variant-numeric: tabular-nums; }
.kpi-primary strong { color: #fff; }
.kpi-card small { color: var(--muted); font-size: 10px; }
.workspace { display: grid; grid-template-columns: var(--sidebar-width) minmax(0,1fr); align-items: start; gap: 18px; direction: ltr; }
.sidebar, .map-panel { min-width: 0; direction: rtl; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.sidebar { overflow: hidden; }
.sidebar-content { padding: 17px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.panel-heading h2 { font-size: 16px; }
.heading-icon, .map-title-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; color: var(--green); border-radius: 12px; background: var(--green-light); font-size: 23px; }
.search-wrap { display: flex; align-items: center; gap: 9px; padding: 0 12px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 11px; background: #fbfdfb; }
.search-wrap > span { color: var(--green); font-size: 20px; }
.search-wrap input { width: 100%; min-width: 0; height: 42px; padding: 0; color: var(--text); border: 0; outline: 0; background: transparent; font-size: 12px; }
.search-wrap:focus-within { border-color: #8ab99a; box-shadow: 0 0 0 3px rgba(36,122,80,.08); }
.filter-grid { display: grid; grid-template-columns: 1fr; gap: 6px; margin-bottom: 15px; }
.filter-grid label { margin-top: 5px; color: #4e6355; font-size: 11px; font-weight: 800; }
.filter-grid select { width: 100%; min-width: 0; height: 38px; padding: 0 10px; color: var(--text); border: 1px solid var(--border); border-radius: 9px; background: #fff; font-size: 11px; }
.filter-grid select:hover { border-color: #b8d1bf; }
.list-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 11px; padding-top: 16px; border-top: 1px solid var(--border); }
.list-heading h3 { margin: 0; color: var(--text); font-size: 14px; font-weight: 900; }
.list-heading p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.count-pill { min-width: 31px; padding: 4px 8px; color: var(--green); border-radius: 8px; background: var(--green-light); text-align: center; font-size: 11px; font-weight: 900; font-variant-numeric: tabular-nums; }
.customer-list { display: flex; flex-direction: column; gap: 8px; }
.customer-card { width: 100%; min-width: 0; padding: 12px; color: var(--text); text-align: right; border: 1px solid var(--border); border-radius: 12px; background: #fff; cursor: pointer; transition: border-color .15s ease,background .15s ease,box-shadow .15s ease; }
.customer-card:hover { border-color: #b8d1bf; background: #fbfdfb; box-shadow: 0 4px 12px rgba(24,65,42,.055); }
.customer-card.selected { border-color: var(--green-mid); background: #edf7ef; box-shadow: inset 0 0 0 1px var(--green-mid); }
.customer-card-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.customer-card-title strong { min-width: 0; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.customer-code { flex: 0 0 auto; padding: 2px 5px; color: var(--muted); border-radius: 5px; background: #f1f5f2; font-size: 9px; direction: ltr; }
.customer-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.customer-tag { max-width: 100%; padding: 3px 6px; color: #53685a; border-radius: 6px; background: #f3f7f4; font-size: 9px; overflow-wrap: anywhere; }
.customer-routes { margin-top: 8px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.list-footer { padding: 12px 0 2px; color: var(--muted); text-align: center; font-size: 10px; }
.list-empty { padding: 18px 12px; color: var(--muted); border: 1px dashed var(--border); border-radius: 10px; text-align: center; font-size: 11px; }
.map-panel { padding: 16px; overflow: hidden; }
.map-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.map-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.map-title h2 { font-size: 17px; }
.map-title p { font-size: 10px; }
.map-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 4px; border: 1px solid var(--border); border-radius: 11px; background: #f3f7f4; }
.segment { min-height: 31px; padding: 6px 12px; color: #5c6e61; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 10px; font-weight: 800; white-space: nowrap; }
.segment:hover { color: var(--green); }
.segment.active { color: #fff; background: var(--green); box-shadow: 0 2px 5px rgba(10,64,41,.12); }
.legend-panel { padding: 12px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 11px; background: #fbfdfb; }
.legend-panel[hidden] { display: none !important; }
.legend-panel > strong { display: block; margin-bottom: 9px; font-size: 11px; }
.legend-items { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: #506456; font-size: 10px; }
.legend-swatch { width: 10px; height: 10px; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.06); border-radius: 50%; }
.map-wrapper { position: relative; height: min(72vh,850px); min-height: 430px; overflow: hidden; border: 1px solid #dbe6de; border-radius: 14px; background: #eaf0eb; }
#customerMap { position: absolute; inset: 0; width: 100%; height: 100%; background: #eaf0eb; }
.map-status { position: absolute; z-index: 2; top: 12px; inset-inline-start: 12px; max-width: calc(100% - 24px); padding: 7px 11px; color: #355541; border: 1px solid rgba(213,229,216,.9); border-radius: 9px; background: rgba(255,255,255,.94); box-shadow: 0 3px 12px rgba(24,65,42,.08); font-size: 10px; pointer-events: none; }
.map-bottom-note { position: absolute; z-index: 2; right: 10px; bottom: 10px; padding: 5px 8px; color: #51675a; border: 1px solid rgba(223,233,225,.9); border-radius: 7px; background: rgba(255,255,255,.92); font-size: 9px; pointer-events: none; }
.details { padding: 16px; margin-top: 14px; border: 1px solid var(--border); border-radius: 13px; background: #fff; scroll-margin-top: 14px; }
.details > h3 { margin: 0 0 12px; color: var(--text); font-size: 14px; font-weight: 900; overflow-wrap: anywhere; }
.details > h3:not(:first-child) { margin-top: 18px; }
.details-empty { display: flex; flex-direction: column; align-items: center; padding: 18px 10px; text-align: center; }
.empty-icon { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 9px; color: var(--green); border-radius: 13px; background: var(--green-light); font-size: 23px; }
.details-empty strong { font-size: 13px; }
.details-empty p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.detail-item { min-width: 0; padding: 10px; border: 1px solid var(--border); border-radius: 9px; background: #fbfdfb; }
.detail-label, .detail-value { display: block; overflow-wrap: anywhere; }
.detail-label { margin-bottom: 4px; color: var(--muted); font-size: 10px; }
.detail-value { color: var(--text); font-size: 11px; font-weight: 800; }
.route-details { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.route-detail { min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fbfdfb; }
.route-detail strong { display: block; margin-bottom: 7px; color: var(--green); font-size: 11px; overflow-wrap: anywhere; }
.route-detail p { margin: 4px 0; color: #5d7062; font-size: 10px; overflow-wrap: anywhere; }
.map-link { display: inline-flex; margin-top: 14px; padding: 9px 12px; color: #fff; border-radius: 9px; background: var(--green); text-decoration: none; font-size: 11px; font-weight: 800; }
.map-link:hover { background: var(--green-dark); }
.classification-panel { padding: 18px; margin: 18px 0 22px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.classification-heading { color: var(--text); font-size: 16px; font-weight: 900; }
.classification-note { margin: 4px 0 15px; color: var(--muted); font-size: 11px; }
.classification-counts { display: grid; grid-template-columns: repeat(auto-fit,minmax(165px,1fr)); gap: 10px; }
.classification-count-card { display: grid; grid-template-columns: 10px minmax(0,1fr) auto; align-items: center; gap: 10px; width: 100%; min-width: 0; min-height: 62px; padding: 12px; color: var(--text); text-align: right; border: 1px solid var(--border); border-inline-start: 4px solid var(--group-color,var(--green)); border-radius: 12px; background: #fff; box-shadow: 0 2px 8px rgba(24,65,42,.035); cursor: pointer; transition: transform .16s ease,box-shadow .16s ease,border-color .16s ease; }
.classification-count-card:hover { transform: translateY(-2px); border-color: var(--group-color,var(--green)); box-shadow: 0 6px 15px rgba(24,65,42,.08); }
.classification-count-card:focus-visible { outline: 3px solid var(--group-color,#71b58c); outline-offset: 3px; }
.classification-count-card.selected { background: #edf7ef; box-shadow: inset 0 0 0 1px var(--group-color,var(--green)); }
.classification-dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 4px rgba(16,91,58,.07); }
.classification-name { min-width: 0; color: var(--text); font-size: 12px; font-weight: 800; line-height: 1.6; overflow-wrap: anywhere; }
.classification-number { min-width: 38px; padding: 5px 8px; color: var(--group-color,var(--green)); border-radius: 8px; background: #f1f5f2; text-align: center; font-size: 14px; font-weight: 900; font-variant-numeric: tabular-nums; }
.mobile-only { display: none; }
.map-toolbar .mobile-only { flex-shrink: 0; white-space: nowrap; }
.workspace.filters-collapsed { grid-template-columns: minmax(0,1fr); }
.workspace.filters-collapsed .sidebar { display: none; }
.workspace.filters-collapsed .map-panel { width: 100%; min-width: 0; }
.workspace.filters-collapsed .map-wrapper { height: min(78vh,950px); }
.maplibregl-ctrl-group { overflow: hidden; border: 1px solid rgba(220,231,222,.95) !important; border-radius: 10px !important; box-shadow: 0 2px 9px rgba(24,65,42,.1) !important; }
.maplibregl-ctrl-group button { background-color: #fff; }
.maplibregl-ctrl-attrib { font-size: 9px; }
@media (hover:hover) {
  .detail-item:hover, .route-detail:hover { border-color: #c9ddce; background: #f7fbf8; }
}
@media (max-width:1100px) {
  .app-shell { padding: 17px; }
  .workspace { grid-template-columns: 285px minmax(0,1fr); gap: 12px; }
  .kpi-grid { gap: 10px; }
  .kpi-card { padding: 13px; }
  .kpi-card strong { font-size: 23px; }
  .map-panel { padding: 12px; }
}
@media (min-width:761px) {
  .map-toolbar .mobile-only { display: inline-flex; }
  .workspace:not(.filters-collapsed) .map-wrapper { height: min(72vh,850px); }
}
@media (max-width:760px) {
  .topbar { min-height: 68px; padding: 11px 15px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand h1 { font-size: 17px; }
  .brand p { font-size: 10px; }
  .header-status { max-width: 44%; font-size: 9px; }
  .app-shell { padding: 13px; }
  .page-heading { align-items: flex-start; }
  .page-heading h2 { font-size: 18px; }
  .page-heading > .button { max-width: 45%; padding: 8px; font-size: 10px; }
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .kpi-card { padding: 12px; border-radius: 13px; }
  .kpi-icon { width: 29px; height: 29px; margin-bottom: 6px; }
  .kpi-card strong { font-size: 23px; }
  .kpi-label { font-size: 10px; }
  .kpi-card small { font-size: 9px; }
  .workspace { display: flex; flex-direction: column; gap: 12px; }
  .map-panel { order: 1; width: 100%; }
  .sidebar { order: 2; width: 100%; }
  .workspace.filters-collapsed .sidebar { display: none; }
  .workspace.filters-collapsed .map-panel { width: 100%; }
  .map-toolbar { align-items: center; gap: 8px; }
  .map-title { gap: 8px; }
  .map-title-icon { width: 33px; height: 33px; }
  .map-title h2 { font-size: 14px; }
  .map-toolbar .mobile-only { display: inline-flex; min-height: 34px; padding: 7px 9px; font-size: 10px; }
  .map-controls { gap: 6px; }
  .map-controls > .button { min-height: 33px; padding: 7px 9px; font-size: 10px; }
  .map-controls .segmented { width: 100%; justify-content: stretch; }
  .map-controls .segment { flex: 1 1 auto; padding-inline: 6px; font-size: 9px; }
  .map-wrapper, .workspace.filters-collapsed .map-wrapper { height: 64vh; min-height: 360px; max-height: 680px; }
  .classification-panel { padding: 13px; margin: 13px 0 17px; border-radius: 14px; }
  .classification-heading { font-size: 15px; }
  .classification-counts { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .classification-count-card { grid-template-columns: 8px minmax(0,1fr) auto; gap: 7px; min-height: 55px; padding: 9px 8px; }
  .classification-name { font-size: 11px; }
  .classification-number { min-width: 31px; padding: 4px 6px; font-size: 12px; }
  .classification-dot { width: 8px; height: 8px; }
  .detail-grid, .route-details { grid-template-columns: minmax(0,1fr); }
}
@media (max-width:390px) {
  .app-shell { padding: 9px; }
  .topbar { padding-inline: 10px; }
  .header-status { max-width: 40%; }
  .page-heading > .button { max-width: 48%; font-size: 9px; }
  .classification-counts { grid-template-columns: minmax(0,1fr); }
  .classification-count-card { min-height: 50px; }
  .map-toolbar .mobile-only { padding: 7px 8px; font-size: 9px; }
  .map-wrapper, .workspace.filters-collapsed .map-wrapper { min-height: 330px; }
}
.map-hover-popup .maplibregl-popup-content {
  padding: 10px 14px; border-radius: 9px; box-shadow: 0 3px 14px rgba(0,0,0,.2);
  border: 1px solid #dce8df; direction: rtl; text-align: right;
  font-family: Arial,sans-serif; min-width: 130px;
}
.map-hover-popup .maplibregl-popup-tip { border-top-color: #fff; }
.map-hover-content { display: flex; flex-direction: column; gap: 5px; color: #344f3c; font-size: 12px; line-height: 1.5; }
.map-hover-content strong { font-size: 13px; color: #105b3a; font-weight: 700; }
.map-hover-content div { color: #68766d; }
