/* BOIP Sales Dashboard — scoped to avoid changing other BOIP modules. */
#sales-view {
  --sd-ink: #05322B;
  --sd-muted: #6B8B84;
  --sd-line: #DDE7E5;
  --sd-soft: #F4F7F6;
  --sd-indigo: #018374;
  --sd-teal: #02BC94;
  --sd-amber: #d97706;
  --sd-rose: #e11d48;
  --sd-shadow: 0 12px 32px rgba(5, 50, 43, 0.08);
  color: var(--sd-ink);
}

.app-shell:not(.home-active) #sales-view.view {
  width: min(1760px, calc(100% - 32px));
  padding-top: 0;
  margin-bottom: 48px;
}

#sales-view .sd-shell {
  width: 100%;
  min-width: 0;
  padding: 20px 0 0;
}

#sales-view .sd-pagebar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 4px 2px 18px;
}

#sales-view .sd-pagebar h2 {
  margin: 3px 0 5px;
  color: var(--sd-ink);
  font-size: clamp(25px, 2vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

#sales-view .sd-pagebar p {
  margin: 0;
  color: var(--sd-muted);
  font-size: 14px;
}

#sales-view .sd-eyebrow {
  color: #5eead4;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

#sales-view .sd-page-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

#sales-view .sd-data-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 9px;
  background: rgba(5, 31, 54, 0.3);
  color: #fff;
}

#sales-view .sd-status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.16);
}

#sales-view .sd-data-status.sample .sd-status-dot {
  background: #fbbf24;
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.17);
}

#sales-view .sd-data-status > span:last-child {
  display: grid;
  gap: 1px;
}

#sales-view .sd-data-status strong {
  font-size: 12px;
  line-height: 1.2;
}

#sales-view .sd-data-status small {
  color: rgba(255, 255, 255, 0.74);
  font-size: 10px;
  white-space: nowrap;
}

#sales-view .sd-scope-label {
  display: grid;
  gap: 4px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#sales-view .sd-scope-label select {
  min-width: 155px;
  height: 46px;
  padding: 0 34px 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: var(--sd-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  text-transform: none;
}

#sales-view #refresh-sales-btn {
  min-height: 46px;
  padding-inline: 18px;
  border-radius: 9px;
}

#sales-view .sd-layout {
  display: grid;
  grid-template-columns: 226px minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

#sales-view .sd-nav {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 5px;
  padding: 16px 12px 13px;
  border: 1px solid rgba(221, 228, 237, 0.92);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--sd-shadow);
}

#sales-view .sd-nav-caption {
  margin: 1px 8px 8px;
  color: var(--sd-muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#sales-view .sd-nav .sales-menu-item {
  width: 100%;
  min-height: 43px;
  justify-content: flex-start;
  gap: 10px;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #485870;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
  text-align: left;
  box-shadow: none;
}

#sales-view .sd-nav .sales-menu-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#sales-view .sd-nav .sales-menu-item:hover {
  border-color: #e0e5f9;
  background: #f7f8ff;
  color: var(--sd-indigo);
}

#sales-view .sd-nav .sales-menu-item.active {
  border-color: var(--primary-border);
  background: var(--primary-light);
  color: var(--bh-dark-green);
  box-shadow: inset 3px 0 0 var(--bh-medium-green);
}

#sales-view .sd-result-count,
#sales-view .sd-panel-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid var(--primary-border);
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--bh-medium-green);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

#sales-view .sd-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

#sales-view .sd-kpi {
  position: relative;
  min-width: 0;
  min-height: 96px;
  padding: 10px 12px;
  overflow: hidden;
  border: 1px solid var(--sd-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(5, 50, 43, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

#sales-view .sd-kpi::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--bh-medium-green);
  content: '';
}

#sales-view .sd-kpi-teal::before { background: var(--bh-light-green); }
#sales-view .sd-kpi-amber::before { background: var(--sd-amber); }
#sales-view .sd-kpi-rose::before { background: var(--sd-rose); }

#sales-view .sd-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#sales-view .sd-kpi-label {
  color: var(--sd-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#sales-view .sd-kpi-badge {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--bh-medium-green);
  font-size: 9px;
  font-weight: 700;
}

#sales-view .sd-kpi-val {
  margin: 2px 0 0;
  color: var(--sd-ink);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  font-feature-settings: "tnum" 1;
}

#sales-view .sd-kpi-sub {
  margin: 2px 0 0;
  color: var(--sd-muted);
  font-size: 10px;
}
  color: var(--sd-muted);
  font-size: 9px;
}

#sales-view .sd-kpi-value {
  display: block;
  margin-top: 13px;
  overflow: hidden;
  color: var(--sd-ink);
  font-size: clamp(23px, 2vw, 31px);
  line-height: 1;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#sales-view .sd-kpi-help {
  display: block;
  margin-top: 9px;
  color: var(--sd-muted);
  font-size: 10px;
}

#sales-view .sd-grid {
  display: grid;
  align-items: stretch;
  gap: 14px;
}

#sales-view .sd-grid-wide { grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.8fr); }
#sales-view .sd-grid-yearly { grid-template-columns: minmax(360px, 0.85fr) minmax(0, 1.15fr); }
#sales-view .sd-grid-models { grid-template-columns: minmax(300px, 0.66fr) minmax(0, 1.34fr); }

#sales-view .sd-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--sd-line);
  border-radius: 11px;
  background: #fff;
  box-shadow: var(--sd-shadow);
}

#sales-view .sd-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 63px;
  padding: 13px 17px;
  border-bottom: 1px solid #e8edf3;
}

#sales-view .sd-panel-head > div:first-child {
  display: grid;
  gap: 2px;
}

#sales-view .sd-panel-head span:first-child {
  color: var(--sd-muted);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#sales-view .sd-panel-head h4 {
  margin: 0;
  color: var(--sd-ink);
  font-size: 16px;
}

#sales-view .sd-chart {
  position: relative;
  height: 315px;
  padding: 18px 14px 12px;
}

#sales-view .sd-chart canvas {
  position: relative;
  z-index: 1;
}

#sales-view .sd-chart-empty {
  position: absolute;
  inset: 20px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--sd-muted);
  font-size: 12px;
}

#sales-view .sd-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  min-height: 71px;
  padding: 13px 15px;
  border-bottom: 1px solid #e8edf3;
  background: #fbfcfe;
}

#sales-view .sd-toolbar-fields {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

#sales-view .sd-search {
  position: relative;
  display: block;
  width: min(480px, 100%);
  min-width: 240px;
  flex: 1;
}

#sales-view .sd-search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  fill: none;
  stroke: #8a98aa;
  stroke-width: 1.8;
  stroke-linecap: round;
}

#sales-view .sd-search input,
#sales-view .sd-filter-label select {
  width: 100%;
  height: 39px;
  border: 1px solid #ccd5e1;
  border-radius: 7px;
  outline: none;
  background: #fff;
  color: var(--sd-ink);
  font: inherit;
  font-size: 12px;
}

#sales-view .sd-search input {
  padding: 0 12px 0 38px;
}

#sales-view .sd-search input:focus,
#sales-view .sd-filter-label select:focus,
#sales-view .sd-scope-label select:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.13);
}

#sales-view .sd-filter-label {
  display: grid;
  min-width: 155px;
  gap: 4px;
  color: var(--sd-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#sales-view .sd-filter-label select {
  min-width: 155px;
  padding: 0 30px 0 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
}

#sales-view .sd-export-btn,
#sales-view .sd-text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 37px;
  padding: 8px 11px;
  border: 1px solid #cfd7e3;
  border-radius: 7px;
  background: #fff;
  color: #43526a;
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

#sales-view .sd-export-btn:hover,
#sales-view .sd-text-btn:hover {
  border-color: #a5b4fc;
  color: #4338ca;
  background: #f7f7ff;
}

#sales-view .sd-export-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#sales-view .sd-text-btn {
  min-height: 31px;
  color: var(--sd-indigo);
}

#sales-view .sd-table-wrap {
  width: 100%;
  max-height: 560px;
  overflow: auto;
  scrollbar-color: #c4ceda transparent;
  scrollbar-width: thin;
}

#sales-view .sd-table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
}

#sales-view .sd-table th {
  position: sticky;
  z-index: 2;
  top: 0;
  padding: 11px 13px;
  border-bottom: 1px solid #dbe3ec;
  background: #f5f7fa;
  color: #5a687d;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.055em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

#sales-view .sd-table td {
  padding: 11px 13px;
  border-bottom: 1px solid #edf1f5;
  color: #344156;
  vertical-align: middle;
}

#sales-view .sd-table tbody tr:last-child td { border-bottom: 0; }
#sales-view .sd-table tbody tr:hover td { background: #fafbff; }
#sales-view .sd-table .sd-number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#sales-view .sd-table .sd-code { color: #3730a3; font-family: "Cascadia Mono", Consolas, monospace; font-size: 10px; font-weight: 700; white-space: nowrap; }
#sales-view .sd-empty { height: 180px; color: var(--sd-muted) !important; text-align: center !important; }

#sales-view .sd-loading,
#sales-view .sd-error {
  display: flex;
  min-height: 360px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px;
  border: 1px solid var(--sd-line);
  border-radius: 11px;
  background: #fff;
  color: var(--sd-muted);
  box-shadow: var(--sd-shadow);
}

#sales-view .sd-loading span {
  width: 18px;
  height: 18px;
  border: 2px solid #d6d9ff;
  border-top-color: var(--sd-indigo);
  border-radius: 50%;
  animation: sd-spin 650ms linear infinite;
}

@keyframes sd-spin { to { transform: rotate(360deg); } }

#sales-view .sd-error {
  flex-direction: column;
  text-align: center;
}

#sales-view .sd-error strong { color: var(--sd-ink); font-size: 18px; }
#sales-view .sd-error span { max-width: 620px; }

@media (max-width: 1280px) {
  #sales-view .sd-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #sales-view .sd-grid-wide,
  #sales-view .sd-grid-yearly,
  #sales-view .sd-grid-models { grid-template-columns: 1fr; }
  #sales-view .sd-grid-models .sd-chart-panel { min-height: 370px; }
}

@media (max-width: 960px) {
  .app-shell:not(.home-active) #sales-view.view { width: min(100% - 20px, 1760px); }
  #sales-view .sd-pagebar { align-items: flex-start; flex-direction: column; }
  #sales-view .sd-page-actions { width: 100%; justify-content: flex-start; }
  #sales-view .sd-layout { grid-template-columns: 1fr; }
  #sales-view .sd-nav {
    position: static;
    display: flex;
    padding: 9px;
    overflow-x: auto;
    scrollbar-width: thin;
  }
  #sales-view .sd-nav-caption,
  #sales-view .sd-nav-footer { display: none; }
  #sales-view .sd-nav .sales-menu-item { width: auto; min-width: max-content; }
}

@media (max-width: 640px) {
  #sales-view .sd-shell { padding-top: 12px; }
  #sales-view .sd-pagebar { padding-bottom: 12px; }
  #sales-view .sd-pagebar p { font-size: 12px; }
  #sales-view .sd-page-actions { display: grid; grid-template-columns: 1fr auto; }
  #sales-view .sd-data-status { grid-column: 1 / -1; }
  #sales-view .sd-scope-label select { min-width: 0; width: 100%; }
  #sales-view .sd-kpis { grid-template-columns: 1fr; }
  #sales-view .sd-kpi { min-height: 112px; }
  #sales-view .sd-view-heading { padding: 15px; }
  #sales-view .sd-result-count { display: none; }
  #sales-view .sd-toolbar { align-items: stretch; flex-direction: column; }
  #sales-view .sd-search { width: 100%; min-width: 0; }
  #sales-view .sd-filter-label { width: 100%; }
  #sales-view .sd-export-btn { width: 100%; }
  #sales-view .sd-chart { height: 270px; }
}

@media (prefers-reduced-motion: reduce) {
  #sales-view .sd-view { animation: none; }
  #sales-view .sd-loading span { animation-duration: 1.4s; }
}