:root {
  --bg: #f2f2f7;
  --panel: #ffffff;
  --line: rgba(60, 60, 67, 0.16);
  --line-strong: rgba(60, 60, 67, 0.30);
  --text: #1c1c1e;
  --muted: rgba(60, 60, 67, 0.60);
  --soft: rgba(60, 60, 67, 0.32);
  --green: #34c759;
  --green-text: #248a3d;
  --green-soft: rgba(52, 199, 89, 0.16);
  --blue: #007aff;
  --blue-soft: rgba(0, 122, 255, 0.14);
  --amber: #ff9500;
  --amber-text: #b25e00;
  --amber-soft: rgba(255, 149, 0, 0.18);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.15);
  --indigo: #5856d6;
  --indigo-soft: rgba(88, 86, 214, 0.14);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.20);
  --surface: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 30px rgba(0, 0, 0, 0.06);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, Inter, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  min-height: 50px;
  display: grid;
  grid-template-columns: minmax(180px, max-content) minmax(0, 1fr);
  grid-template-areas: "brand actions";
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  grid-area: brand;
  flex: 0 0 auto;
  min-width: 180px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 780;
  font-size: 16px;
}

.brand-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scope-badge {
  flex: 0 0 auto;
  height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-text);
  font-size: 11px;
  font-weight: 760;
  white-space: nowrap;
}

.scope-badge[hidden] {
  display: none;
}

.top-nav {
  grid-area: nav;
  min-width: 0;
  display: none;
  align-items: center;
}

.nav-dashboard-link {
  min-width: 0;
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 13px;
  font-weight: 680;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-dashboard-link svg {
  flex: 0 0 auto;
}

.menu-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #223042;
  display: inline-grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
}

.menu-btn:hover,
.menu-btn[aria-expanded="true"] {
  background: var(--fill);
}

.hamburger {
  width: 20px;
}

.dashboard-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 18px;
  z-index: 100;
  width: min(280px, calc(100vw - 28px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  display: grid;
  gap: 4px;
}

.dashboard-menu[hidden] {
  display: none;
}

.dashboard-menu-item {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 680;
  text-decoration: none;
}

.dashboard-menu-item:hover,
.dashboard-menu-item:focus-visible {
  background: var(--fill);
}

.dashboard-menu-item.active {
  background: var(--green-soft);
  color: var(--green-text);
}

.bolt {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #34c388;
}

.top-actions {
  grid-area: actions;
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(260px, 620px) auto auto auto auto auto;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: #334155;
  font-size: 13px;
  white-space: nowrap;
}

.language-toggle {
  min-width: 52px;
  white-space: nowrap;
}

.icon-btn,
.date-select-wrap,
.pill-btn,
.ghost-btn {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.88);
  color: #263548;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 640;
  cursor: pointer;
}

.date-select-wrap {
  cursor: default;
  flex: 0 1 auto;
  min-width: 0;
  max-width: none;
  overflow: hidden;
}

.period-controls {
  width: 100%;
  min-width: 0;
  max-width: 620px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-range-button {
  min-width: 0;
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.92);
  color: #263548;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 720;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.pill-btn,
.avatar,
.icon-btn {
  flex: 0 0 auto;
  min-width: max-content;
}

.date-range-button:disabled {
  color: #64748b;
  cursor: not-allowed;
  opacity: 1;
}

.period-summary {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.period-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: min(580px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  display: grid;
  gap: 10px;
}

.period-popover[hidden] {
  display: none;
}

.period-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.period-popover-title {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 820;
}

.period-close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: var(--fill);
  color: #334155;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.period-row,
.period-date-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

.period-date-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.period-popover select {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 680;
}

.period-date-control {
  display: grid;
  grid-template-columns: minmax(46px, 0.8fr) auto minmax(46px, 0.8fr) auto minmax(74px, 1.25fr);
  align-items: end;
  min-height: 48px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.period-date-control:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.period-date-control.is-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.period-date-segment {
  display: grid;
  grid-template-rows: 15px 28px;
  min-width: 0;
  padding: 3px 4px 2px;
  text-align: center;
}

.period-date-segment > span {
  color: #94a3b8;
  font-size: 9px;
  font-weight: 820;
  line-height: 15px;
}

.period-date-segment input {
  width: 100%;
  min-width: 0;
  height: 28px;
  border: 0;
  border-radius: 6px;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 0 3px;
  text-align: center;
  font-size: 14px;
  font-weight: 760;
}

.period-date-segment input:focus {
  background: #eff6ff;
}

.period-date-segment input::placeholder {
  color: #94a3b8;
  opacity: 1;
}

.period-date-divider {
  align-self: end;
  height: 30px;
  color: #94a3b8;
  font-size: 16px;
  font-weight: 700;
  line-height: 28px;
}

.period-date-error {
  min-height: 13px;
  margin: 0;
  color: #b91c1c;
  font-size: 9px;
  font-weight: 680;
  line-height: 13px;
}

.period-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
  border-top: 1px solid #e8eef5;
}

.period-action {
  min-width: 72px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.period-action-secondary {
  background: #fff;
  color: #334155;
}

.period-action-primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.period-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 560px) {
  .period-popover {
    position: fixed;
    top: max(72px, env(safe-area-inset-top));
    right: 10px;
    left: 10px;
    width: auto;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
  }

  .period-date-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .period-date-control {
    grid-template-columns: minmax(52px, 0.8fr) auto minmax(52px, 0.8fr) auto minmax(88px, 1.3fr);
  }
}

.date-select-wrap.period-field {
  flex: 1 1 320px;
  min-width: 250px;
}

.date-select-wrap.range-field {
  flex: 0 1 150px;
  min-width: 130px;
}

.range-separator {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.date-select-wrap svg {
  flex: 0 0 auto;
}

.date-select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}

input.date-select {
  min-width: 0;
  appearance: auto;
}

.date-select:disabled {
  color: #64748b;
  cursor: not-allowed;
  opacity: 1;
}

.icon-btn {
  flex: 0 0 auto;
  width: 34px;
  justify-content: center;
  padding: 0;
  border-color: transparent;
  background: transparent;
}

.pill-btn,
.avatar {
  flex: 0 0 auto;
}

.pill-btn svg {
  flex: 0 0 auto;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #edf1f5;
  color: #344255;
  font-size: 12px;
  font-weight: 760;
  position: relative;
}

.avatar::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid #fff;
}

.statusbar {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: #263548;
}

.status-left,
.status-right {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.status-left {
  flex: 1 1 auto;
}

.dashboard-scope-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  color: #697586;
  font-weight: 760;
}

.dashboard-scope-filter[hidden] {
  display: none;
}

.dashboard-scope-filter select {
  height: 26px;
  border: 1px solid #d8e1eb;
  border-radius: 8px;
  background: #f8fafc;
  color: #152234;
  font-weight: 800;
  padding: 0 28px 0 10px;
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.status-item strong {
  color: var(--green);
  font-weight: 760;
}

.status-item[data-tone="bad"] {
  color: #b42318;
  background: #fff1f0;
  border-color: #fda29b;
  font-weight: 700;
}

.status-item[data-tone="good"] {
  color: var(--green-text);
}

.divider {
  width: 1px;
  height: 20px;
  background: var(--line-strong);
}

.content {
  padding: 10px 18px 14px;
  display: grid;
  gap: 8px;
}

.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.filter-left,
.filter-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf1f5;
}

.segmented button,
.chip,
.select-like {
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #526071;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 720;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.segmented button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

.chip,
.select-like {
  border: 1px solid var(--line);
  background: #fff;
  color: #344255;
}

.scorecards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}

.scorecard {
  min-height: 74px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.scorecard:last-child {
  border-right: 1px solid var(--line);
}

.score-icon {
  width: 36px;
  height: 36px;
  border: 2px solid currentColor;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--green);
}

.scorecard.blue .score-icon {
  color: var(--blue);
}

.score-label {
  margin: 0 0 4px;
  color: #344255;
  font-size: 11px;
  line-height: 1.1;
  font-weight: 760;
}

.score-value {
  margin: 0;
  color: #0f172a;
  font-size: 21px;
  line-height: 1;
  font-weight: 790;
  letter-spacing: 0;
}

.score-delta {
  margin-top: 6px;
  color: var(--green);
  font-size: 11px;
  line-height: 1.15;
  font-weight: 720;
  white-space: nowrap;
}

.score-delta.negative {
  color: var(--red);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 8px;
  align-items: stretch;
}

.trend-grid,
.summary-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.summary-grid {
  align-items: stretch;
}

.summary-grid .panel {
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

.panel {
  min-width: 0;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
}

.trend-panel .panel-head {
  height: 58px;
  align-items: stretch;
  flex-direction: column;
  gap: 7px;
  padding: 8px 12px;
}

.trend-panel .panel-tools {
  width: 100%;
}

.trend-panel .trend-primary {
  flex: 1 1 170px;
}

.trend-panel .trend-filter {
  flex: 0 0 112px;
}

.trend-panel .metric-toggle {
  flex: 0 0 auto;
}

.top-panel .panel-head {
  height: 58px;
  align-items: stretch;
  flex-direction: column;
  gap: 7px;
  padding: 8px 12px;
}

.top-panel .panel-tools {
  width: 100%;
}

.top-panel .mini-select {
  min-width: 0;
}

.top-panel .top-group {
  flex: 1 1 108px;
}

.top-panel .top-filter {
  flex: 0 1 102px;
}

.top-panel .top-sort {
  flex: 1 1 130px;
}

.panel-title {
  margin: 0;
  color: #101827;
  font-size: 14px;
  line-height: 1;
  font-weight: 790;
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #5a6777;
  font-size: 12px;
  white-space: nowrap;
}

.mini-select {
  height: 26px;
  min-width: 118px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  color: #334155;
  font-size: 12px;
  font-weight: 650;
}

.trend-primary {
  min-width: 150px;
}

.trend-filter {
  min-width: 112px;
}

body[data-access-scope="kl_only"] #topLocationFilter,
body[data-access-scope="kl_only"] #customerLocation,
body[data-access-scope="kl_only"] #codeTrendLocation {
  display: none;
}

.metric-toggle {
  height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #edf1f5;
}

.metric-toggle button {
  height: 20px;
  min-width: 42px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #526071;
  font-size: 11px;
  font-weight: 760;
  cursor: pointer;
  padding: 0 8px;
}

.metric-toggle button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

.th-control {
  min-width: 104px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #263548;
  font-size: 11px;
  font-weight: 760;
}

.sort-header {
  width: 100%;
  border: 0;
  background: transparent;
  color: #263548;
  display: inline-flex;
  justify-content: flex-end;
  gap: 4px;
  padding: 0;
  font-size: 11px;
  font-weight: 780;
  cursor: pointer;
}

.chart-wrap {
  height: 208px;
  padding: 8px 12px 6px;
  position: relative;
}

.daily-wrap {
  height: 164px;
}

.trend-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  gap: 8px;
  align-items: stretch;
  min-width: 0;
}

.trend-main {
  min-width: 0;
}

.trend-average {
  margin: 8px 10px 8px 0;
  padding: 10px;
  border-left: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.82);
  border-radius: 8px;
  min-width: 0;
}

.trend-average-title {
  margin: 0;
  color: #101827;
  font-size: 12px;
  line-height: 1.1;
  font-weight: 820;
}

.trend-average-sub,
.trend-average-empty {
  margin: 4px 0 9px;
  color: #8b929c;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 700;
}

.trend-average-row {
  display: grid;
  gap: 4px;
  padding: 8px 0;
  border-top: 1px solid rgba(223, 228, 234, 0.9);
}

.trend-average-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: #253248;
  font-size: 11px;
  font-weight: 820;
}

.trend-average-label i {
  width: 14px;
  height: 3px;
  border-radius: 99px;
  background: var(--green);
  flex: 0 0 auto;
}

.trend-average-label i.blue {
  background: var(--blue);
}

.trend-average-label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trend-average-values {
  display: grid;
  gap: 2px;
}

.trend-average-values strong {
  color: #111827;
  font-size: 17px;
  line-height: 1;
  font-weight: 850;
}

.trend-average-values span {
  color: #7b8490;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 700;
}

.trend-average-delta {
  width: fit-content;
  padding: 2px 6px;
  border-radius: 999px;
  background: #eef2f7;
  color: #526071;
  font-size: 10px;
  font-weight: 820;
}

.trend-average-delta.up {
  background: #dcfce7;
  color: #15803d;
}

.trend-average-delta.down {
  background: #fee2e2;
  color: #b91c1c;
}

.legend {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 12px 0;
  color: #334155;
  font-size: 12px;
  font-weight: 650;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend i {
  width: 18px;
  height: 3px;
  border-radius: 99px;
  background: var(--green);
  display: inline-block;
}

.legend .blue-line {
  background: var(--blue);
}

svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-point {
  outline: none;
}

.chart-hit {
  fill: #fff;
  fill-opacity: 0.01;
  stroke: transparent;
  cursor: crosshair;
  pointer-events: all;
}

.chart-popover {
  position: absolute;
  min-width: 176px;
  max-width: 240px;
  padding: 7px 10px 8px;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.94);
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.72);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 120ms ease;
  z-index: 8;
  white-space: normal;
}

.chart-popover.visible {
  opacity: 1;
}

.chart-popover .title {
  color: rgba(255, 255, 255, 0.82);
  font-size: 10px;
  font-weight: 700;
}

.chart-popover .value {
  color: #fff;
  font-size: 13px;
  font-weight: 820;
  line-height: 1.25;
  white-space: nowrap;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.table-scroll {
  overflow: auto;
  scrollbar-width: thin;
}

.top-scroll {
  max-height: 254px;
}

.top-scroll .table {
  min-width: 0;
}

.customer-scroll {
  max-height: 170px;
}

.customer-scroll .table {
  min-width: 0;
}

.summary-grid .top-scroll,
.summary-grid .customer-scroll {
  flex: 1 1 auto;
  max-height: none;
  min-height: 430px;
}

.summary-grid .customer-summary {
  flex: 0 0 auto;
}

.table-scroll::-webkit-scrollbar,
.records-wrap::-webkit-scrollbar,
.queue-list::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-scroll::-webkit-scrollbar-thumb,
.records-wrap::-webkit-scrollbar-thumb,
.queue-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(60, 60, 67, 0.24);
  border: 2px solid rgba(255, 255, 255, 0.78);
}

.table th,
.table td {
  height: 24px;
  padding: 0 9px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.table th:last-child,
.table td:last-child {
  border-right: 0;
}

.table th {
  background: #fbfcfd;
  color: #263548;
  font-size: 11px;
  font-weight: 780;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table th > span {
  display: block;
  line-height: 1.02;
}

.table tr:last-child td {
  border-bottom: 0;
}

.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.rank {
  width: 44px;
  text-align: center !important;
}

.bar-cell {
  min-width: 112px;
}

.bar-row {
  display: grid;
  grid-template-columns: 36px minmax(54px, 1fr);
  gap: 6px;
  align-items: center;
}

.bar-track {
  height: 8px;
  border-radius: 99px;
  background: #edf1f5;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.bar-fill.blue {
  background: var(--blue);
}

.summary-grid .table {
  table-layout: fixed;
  font-size: 11px;
}

.summary-grid .table th,
.summary-grid .table td {
  height: 22px;
  padding: 0 5px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-grid .table th {
  font-size: 10px;
  line-height: 1.06;
}

.summary-grid .bar-cell {
  min-width: 0;
}

.summary-grid .bar-row {
  grid-template-columns: 32px minmax(34px, 1fr);
  gap: 4px;
}

#topItemsTable [data-column="rank"],
#customerTable [data-column="rank"] {
  width: 5%;
}

#topItemsTable [data-column="group"] {
  width: 24%;
}

#topItemsTable [data-column="previousQty"],
#topItemsTable [data-column="averageQty"],
#topItemsTable [data-column="customerCount"] {
  width: 8%;
}

#topItemsTable [data-column="qty"] {
  width: 6%;
}

#topItemsTable [data-column="clicks"] {
  width: 8%;
}

#topItemsTable [data-column="latest"] {
  width: 13%;
}

#topItemsTable [data-column="share"] {
  width: 10%;
}

#customerTable [data-column="customer"] {
  width: 43%;
}

#customerTable [data-column="previousQty"] {
  width: 9%;
}

#customerTable [data-column="value"] {
  width: 8%;
}

#customerTable [data-column="colourCount"] {
  width: 7%;
}

#customerTable [data-column="share"] {
  width: 10%;
}

#customerTable [data-column="cumulative"] {
  width: 10%;
}

.column-hidden {
  display: none !important;
}

.column-table th[data-column] {
  position: relative;
}

.column-table th.sales-draggable-column {
  cursor: grab;
  user-select: none;
}

.column-table th.sales-column-dragging {
  opacity: 0.48;
}

.column-table th.sales-column-drop-before::before,
.column-table th.sales-column-drop-after::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 7;
  width: 3px;
  background: var(--blue);
}

.column-table th.sales-column-drop-before::before {
  left: 0;
}

.column-table th.sales-column-drop-after::after {
  right: 0;
}

.sales-col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  z-index: 8;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.sales-col-resizer:hover,
body.sales-resizing-column .sales-col-resizer {
  background: rgba(21, 103, 216, 0.16);
}

body.sales-resizing-column,
body.sales-resizing-column * {
  cursor: col-resize !important;
  user-select: none !important;
}

.column-context-menu {
  position: fixed;
  z-index: 90;
  min-width: 176px;
  padding: 6px;
  border: 1px solid rgba(60, 60, 67, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.16);
}

.column-context-menu button {
  width: 100%;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #111827;
  font: inherit;
  font-size: 12px;
  font-weight: 720;
  text-align: left;
  padding: 0 10px;
  cursor: pointer;
}

.column-context-menu button:hover,
.column-context-menu button:focus {
  outline: 0;
  background: var(--fill);
}

.top-code-button {
  max-width: 100%;
  border: 0;
  background: transparent;
  color: #111827;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  font: inherit;
  font-weight: 790;
  cursor: pointer;
}

.top-code-button:hover,
.top-code-button:focus {
  color: var(--blue);
  outline: 0;
}

.top-code-chevron {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: #64748b;
  background: var(--fill);
  font-size: 10px;
  line-height: 1;
  transform: rotate(-90deg);
  transition: transform 120ms ease;
}

.top-code-button[aria-expanded="true"] .top-code-chevron {
  transform: rotate(0deg);
  background: var(--blue-soft);
  color: var(--blue);
}

.top-expand-row td {
  height: auto;
  padding: 0;
  background: #fbfcfd;
  border-bottom-color: rgba(60, 60, 67, 0.22);
}

.top-customer-breakdown {
  padding: 9px 12px 10px 64px;
  display: grid;
  gap: 7px;
}

.top-breakdown-title {
  color: #334155;
  font-size: 11px;
  font-weight: 780;
}

.top-breakdown-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 58px 76px minmax(128px, 190px);
  gap: 8px;
  align-items: center;
  color: #111827;
  font-size: 12px;
}

.top-breakdown-grid.header {
  color: var(--muted);
  font-size: 10px;
  font-weight: 780;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.top-breakdown-customer {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 720;
}

.top-breakdown-toggle,
.customer-expand-toggle,
.customer-name-button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  cursor: pointer;
}

.top-breakdown-toggle,
.customer-expand-toggle {
  width: fit-content;
  color: var(--blue);
  font-size: 11px;
  font-weight: 790;
}

.top-breakdown-toggle:hover,
.top-breakdown-toggle:focus,
.customer-expand-toggle:hover,
.customer-expand-toggle:focus,
.customer-name-button:hover,
.customer-name-button:focus {
  color: var(--blue);
  outline: 0;
}

.customer-name-button {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-align: left;
}

.customer-chevron {
  width: 15px;
  height: 15px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: #64748b;
  background: var(--fill);
  font-size: 9px;
  line-height: 1;
  transform: rotate(-90deg);
  transition: transform 120ms ease;
  flex: 0 0 auto;
}

.customer-name-button[aria-expanded="true"] .customer-chevron {
  transform: rotate(0deg);
  background: var(--blue-soft);
  color: var(--blue);
}

.customer-expand-row td {
  height: auto;
  padding: 0;
  background: #fbfcfd;
  border-bottom-color: rgba(60, 60, 67, 0.22);
}

.customer-item-breakdown {
  padding: 9px 12px 10px 64px;
  display: grid;
  gap: 7px;
}

.customer-item-grid {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 58px 58px 68px 76px minmax(120px, 180px);
  gap: 8px;
  align-items: center;
  color: #111827;
  font-size: 12px;
}

.customer-item-grid.header {
  color: var(--muted);
  font-size: 10px;
  font-weight: 780;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.customer-item-code,
.customer-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 760;
  color: #0f172a;
}

.mid-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 8px;
}

.customer-summary {
  border-top: 1px solid var(--line);
  background: #fbfcfd;
  font-size: 12px;
  font-weight: 760;
}

.customer-summary div {
  padding: 8px 12px;
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  gap: 7px 18px;
  align-items: center;
}

.customer-detail {
  display: grid;
  gap: 8px;
}

.customer-detail .panel-head {
  height: auto;
  min-height: 52px;
  padding: 9px 12px;
}

.customer-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.customer-search-wrap {
  position: relative;
  width: 220px;
  flex: 0 0 220px;
}

.customer-input {
  width: 100%;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  color: #111827;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 690;
}

.customer-input::placeholder {
  color: rgba(60, 60, 67, 0.45);
}

.customer-input:focus {
  outline: 3px solid rgba(0, 122, 255, 0.16);
  border-color: rgba(0, 122, 255, 0.45);
}

.customer-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 220px;
  overflow: auto;
  padding: 4px;
  border: 1px solid rgba(60, 60, 67, 0.28);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
}

.customer-suggestions[hidden] {
  display: none;
}

.customer-suggestion {
  width: 100%;
  min-height: 28px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #111827;
  display: block;
  padding: 6px 8px;
  text-align: left;
  font-size: 12px;
  font-weight: 680;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.customer-suggestion:hover,
.customer-suggestion:focus {
  outline: 0;
  background: rgba(0, 122, 255, 0.12);
  color: #0f172a;
}

.customer-suggestion.empty {
  cursor: default;
  color: rgba(60, 60, 67, 0.72);
  font-weight: 600;
}

.bitly-signal {
  margin: 8px 12px 0;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  overflow: hidden;
}

.bitly-decision-panel {
  margin: 0;
}

.bitly-signal[hidden] {
  display: none;
}

.bitly-signal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px 7px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.bitly-signal-head > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.signal-eyebrow {
  color: #64748b;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.bitly-signal-head strong {
  color: #111827;
  font-size: 13px;
  line-height: 1.15;
  font-weight: 850;
}

.bitly-signal-head small,
.bitly-table small {
  display: block;
  color: #64748b;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.25;
}

.signal-status {
  flex: 0 0 auto;
  border: 1px solid rgba(47, 155, 105, 0.22);
  border-radius: 999px;
  background: rgba(47, 155, 105, 0.1);
  color: #146c45;
  padding: 5px 8px;
  font-size: 10px;
  font-weight: 820;
  white-space: nowrap;
}

.bitly-kpi-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.8fr);
  gap: 8px;
  padding: 8px 10px;
}

.bitly-branch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.bitly-branch-card {
  min-width: 0;
  border: 1px solid rgba(15, 23, 42, 0.09);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.92);
  padding: 8px;
  display: grid;
  gap: 7px;
}

.bitly-branch-card.hot {
  border-color: rgba(0, 122, 255, 0.24);
  background: rgba(239, 246, 255, 0.88);
}

.bitly-branch-card.warm,
.bitly-branch-card.watch {
  border-color: rgba(245, 158, 11, 0.22);
  background: rgba(255, 251, 235, 0.9);
}

.bitly-branch-card.risk {
  border-color: rgba(220, 38, 38, 0.22);
  background: rgba(254, 242, 242, 0.88);
}

.bitly-branch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.bitly-branch-head span {
  color: #111827;
  font-size: 13px;
  line-height: 1;
  font-weight: 900;
}

.bitly-branch-head strong {
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: #334155;
  padding: 3px 6px;
  font-size: 9px;
  line-height: 1;
  font-weight: 850;
  white-space: nowrap;
}

.bitly-branch-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.bitly-branch-metrics div {
  min-width: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
  padding: 5px 6px;
}

.bitly-branch-metrics span {
  display: block;
  color: #64748b;
  font-size: 8px;
  font-weight: 850;
  line-height: 1.1;
  text-transform: uppercase;
}

.bitly-branch-metrics strong {
  display: block;
  color: #111827;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 880;
  overflow-wrap: anywhere;
}

.bitly-context-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.bitly-kpi {
  min-height: 54px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.86);
  padding: 7px 8px;
  display: grid;
  align-content: center;
  gap: 2px;
}

.bitly-kpi span {
  color: #64748b;
  font-size: 9px;
  font-weight: 850;
  text-transform: uppercase;
}

.bitly-kpi strong {
  color: #111827;
  font-size: 16px;
  line-height: 1;
  font-weight: 850;
}

.bitly-kpi small {
  color: #2f9b69;
  font-size: 9px;
  font-weight: 720;
  overflow-wrap: anywhere;
}

.bitly-action-wrap {
  max-height: 238px;
  overflow: auto;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.bitly-table th,
.bitly-table td {
  padding-top: 7px;
  padding-bottom: 7px;
}

.bitly-table td:first-child,
.bitly-table td:last-child {
  min-width: 84px;
}

.bitly-table td:nth-child(2) {
  min-width: 104px;
}

.bitly-location-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: #111827;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 880;
}

.bitly-action {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 820;
  white-space: nowrap;
}

.bitly-action.hot {
  background: rgba(0, 122, 255, 0.12);
  color: #0756a4;
}

.bitly-action.warm,
.bitly-action.watch {
  background: rgba(245, 158, 11, 0.14);
  color: #92400e;
}

.bitly-action.risk {
  background: rgba(220, 38, 38, 0.12);
  color: #991b1b;
}

.bitly-action.neutral {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
}

.detail-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 12px 0;
}

.detail-kpi {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.74);
  padding: 8px 10px;
  display: grid;
  align-content: center;
  gap: 3px;
}

.detail-kpi span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-kpi strong {
  color: var(--text);
  font-size: 17px;
  line-height: 1;
  font-weight: 840;
  white-space: nowrap;
}

.detail-kpi small {
  color: var(--green);
  font-size: 10px;
  font-weight: 730;
  white-space: nowrap;
}

.category-quantity-panel .panel-head {
  height: auto;
  min-height: 46px;
  padding: 7px 10px;
}

.category-quantity-heading {
  display: grid;
  gap: 2px;
}

.detail-quantity-compare {
  color: var(--blue);
  font-size: 11px;
  font-weight: 820;
  white-space: nowrap;
}

.detail-quantity-scroll {
  max-height: none;
}

.detail-quantity-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.detail-quantity-summary-item {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.detail-quantity-summary-item span {
  font-size: 10px;
  font-weight: 850;
}

.detail-quantity-summary-item strong {
  font-size: 17px;
  font-weight: 880;
}

.detail-quantity-summary-item.kl {
  border-color: rgba(0, 122, 255, 0.28);
  background: rgba(0, 122, 255, 0.08);
  color: #075fbd;
}

.detail-quantity-summary-item.pg {
  border-color: rgba(20, 138, 90, 0.28);
  background: rgba(20, 138, 90, 0.08);
  color: #0f7a51;
}

.detail-quantity-summary-item.gap {
  border-color: rgba(202, 138, 4, 0.3);
  background: rgba(250, 204, 21, 0.1);
  color: #9a6700;
}

.detail-quantity-table {
  min-width: 2050px;
  table-layout: fixed;
}

.detail-quantity-table .category-col-material,
.detail-quantity-table .category-col-tier {
  width: 4.5%;
}

.detail-quantity-table .category-col-prefix {
  width: 7%;
}

.detail-quantity-table .category-col-history-branch {
  width: 5.3%;
}

.detail-quantity-table .category-col-kl,
.detail-quantity-table .category-col-pg {
  width: 5.3%;
}

.detail-quantity-table .category-col-total {
  width: 3.5%;
}

.detail-quantity-table .category-col-gap {
  width: 6.3%;
}

.detail-quantity-table th,
.detail-quantity-table td {
  height: 28px;
  padding-top: 3px;
  padding-bottom: 3px;
}

.detail-quantity-table tbody tr:nth-child(4) td {
  border-top: 2px solid var(--line-strong);
}

.detail-quantity-material {
  color: var(--green-text);
  font-size: 11px;
  font-weight: 850;
}

.detail-quantity-code-group .code {
  display: inline-flex;
  white-space: nowrap;
}

.detail-quantity-month-row th {
  height: 24px;
  text-align: center;
}

.detail-quantity-branch-row th {
  height: 26px;
}

.detail-quantity-month-group {
  border-left: 1px solid var(--line-strong);
  color: #475569;
  font-weight: 850;
}

.detail-quantity-current-group {
  border-left: 3px solid #64748b;
  color: var(--text);
  font-weight: 850;
}

.detail-quantity-table .detail-quantity-history-kl,
.detail-quantity-table .detail-quantity-history-pg {
  font-size: 12px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  white-space: nowrap;
}

.detail-quantity-history-kl {
  border-left: 1px solid var(--line-strong);
  background: rgba(0, 122, 255, 0.055);
  color: #075fbd;
}

.detail-quantity-history-pg {
  background: rgba(20, 138, 90, 0.055);
  color: #0f7a51;
}

.detail-quantity-total {
  color: var(--blue);
  font-weight: 850;
}

.detail-quantity-table .detail-quantity-kl {
  min-width: 92px;
  border-left: 3px solid #64748b;
  background: rgba(0, 122, 255, 0.07);
  color: #075fbd;
  font-size: 12px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  white-space: nowrap;
}

.detail-quantity-table .detail-quantity-pg {
  min-width: 92px;
  background: rgba(20, 138, 90, 0.07);
  color: #0f7a51;
  font-size: 12px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  white-space: nowrap;
}

.detail-quantity-share-value {
  font-weight: 550;
}

.detail-quantity-share-separator {
  font-weight: 450;
  opacity: 0.72;
}

.detail-quantity-share-percent {
  font-weight: 900;
}

.detail-quantity-gap {
  display: inline-flex;
  min-width: 58px;
  height: 22px;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.detail-quantity-gap.kl {
  background: rgba(0, 122, 255, 0.12);
  color: #075fbd;
}

.detail-quantity-gap.pg {
  background: rgba(20, 138, 90, 0.12);
  color: #0f7a51;
}

.detail-quantity-gap.even {
  background: rgba(100, 116, 139, 0.12);
  color: #64748b;
}

.detail-quantity-table tfoot th {
  background: var(--panel-soft);
  color: var(--text);
  font-weight: 850;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 8px;
  padding: 8px 12px 12px;
}

.detail-brand-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 0 12px 12px;
}

.code-trend-panel {
  margin-bottom: 8px;
}

.code-trend-panel .panel-head {
  min-height: 42px;
  height: auto;
  padding: 8px 12px;
  align-items: center;
}

.code-trend-panel .panel-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.code-trend-grid {
  padding-top: 8px;
}

.code-trend-scroll {
  max-height: 360px;
}

.code-trend-scroll .table {
  min-width: 820px;
}

body[data-access-scope="kl_only"] .code-trend-pg-col {
  display: none;
}

.trend-sparkline {
  display: inline-block;
  width: 96px;
  height: 26px;
  vertical-align: middle;
}

.trend-change {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 54px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 820;
}

.trend-change.up {
  color: #188144;
  background: rgba(47, 155, 105, 0.14);
}

.trend-change.down {
  color: #b42318;
  background: rgba(220, 38, 38, 0.12);
}

.trend-change.flat {
  color: var(--muted);
  background: rgba(60, 60, 67, 0.1);
}

.trend-change.new {
  color: #0b63ce;
  background: var(--blue-soft);
}

.mini-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.76);
  overflow: hidden;
}

.mini-panel-head {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
}

.mini-title {
  margin: 0;
  font-size: 12px;
  font-weight: 820;
  color: var(--text);
  white-space: nowrap;
}

.detail-scroll {
  max-height: 156px;
  overflow: auto;
  scrollbar-width: thin;
}

.detail-scroll .table {
  min-width: 640px;
}

.detail-scroll.detail-quantity-scroll {
  max-height: none;
  overflow-x: auto;
  overflow-y: visible;
}

.detail-scroll .detail-quantity-table {
  width: 2050px;
  min-width: 2050px;
}

.category-quantity-panel[data-location-view="KL"] .detail-quantity-summary,
.category-quantity-panel[data-location-view="PG"] .detail-quantity-summary {
  grid-template-columns: minmax(0, 1fr);
}

.category-quantity-panel [data-category-header-location][hidden],
.category-quantity-panel [data-category-col-location][hidden],
.category-quantity-panel [data-category-comparison-head][hidden],
.category-quantity-panel [data-category-comparison-col][hidden] {
  display: none;
}

.category-quantity-panel[data-location-view="KL"] .detail-quantity-table,
.category-quantity-panel[data-location-view="PG"] .detail-quantity-table {
  width: 100%;
  min-width: 1080px;
}

.category-quantity-panel[data-location-view="KL"] .category-col-material,
.category-quantity-panel[data-location-view="PG"] .category-col-material,
.category-quantity-panel[data-location-view="KL"] .category-col-tier,
.category-quantity-panel[data-location-view="PG"] .category-col-tier {
  width: 10%;
}

.category-quantity-panel[data-location-view="KL"] .category-col-prefix,
.category-quantity-panel[data-location-view="PG"] .category-col-prefix {
  width: 16%;
}

.category-quantity-panel[data-location-view="KL"] .category-col-history-branch,
.category-quantity-panel[data-location-view="PG"] .category-col-history-branch {
  width: 9%;
}

.category-quantity-panel[data-location-view="KL"] .category-col-kl,
.category-quantity-panel[data-location-view="PG"] .category-col-pg {
  width: 10%;
}

.detail-month .table {
  min-width: 560px;
}

.brand-detail-scroll .table {
  min-width: 580px;
}

.brand-detail-scroll {
  max-height: 330px;
}

.brand-pill {
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 820;
}

.brand-pill.denzo {
  color: var(--green);
  background: var(--green-soft);
}

.brand-pill.luxor {
  color: var(--blue);
  background: var(--blue-soft);
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.queue-list {
  height: 174px;
  overflow: auto;
}

.queue-row {
  min-height: 35px;
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) 72px 70px 88px 62px;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.queue-row.header {
  min-height: 30px;
  background: #fbfcfd;
  color: #263548;
  font-size: 11px;
  font-weight: 780;
  position: sticky;
  top: 0;
  z-index: 2;
}

.queue-row:not(.header):last-child {
  border-bottom: 0;
}

.issue-title {
  display: grid;
  gap: 2px;
}

.issue-title strong {
  font-size: 12px;
  line-height: 1.15;
  font-weight: 730;
}

.issue-title span {
  color: var(--muted);
  font-size: 11px;
}

.severity {
  width: max-content;
  min-width: 58px;
  height: 22px;
  border-radius: 99px;
  display: inline-grid;
  place-items: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 760;
  border: 1px solid;
}

.severity.high {
  color: var(--red);
  border-color: #f6b0b0;
  background: var(--red-soft);
}

.severity.medium {
  color: var(--amber);
  border-color: #f2cc8f;
  background: var(--amber-soft);
}

.severity.low {
  color: var(--green);
  border-color: #a6d7bb;
  background: var(--green-soft);
}

.action-link {
  border: 0;
  background: transparent;
  color: #175cd3;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.records-wrap {
  height: 300px;
  overflow: auto;
}

.records-wrap .table {
  min-width: 1180px;
}

.tag {
  height: 21px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 760;
}

.tag.review {
  color: var(--amber);
  background: var(--amber-soft);
}

.tag.return {
  color: var(--red);
  background: var(--red-soft);
}

.panel-foot {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  color: #344255;
  font-size: 12px;
}

.note {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1320px) {
  body {
    min-width: 1040px;
  }

  .score-value {
    font-size: 20px;
  }

  .scorecard {
    grid-template-columns: 42px minmax(0, 1fr);
    padding: 12px 10px;
  }

  .score-icon {
    width: 36px;
    height: 36px;
  }
}
/* ============================================================
   iOS / iPhone THEME LAYER
   Appended last so it reskins the dashboard into Apple's
   design language without touching the HTML or JS.
   ============================================================ */

html { -webkit-text-size-adjust: 100%; }

body {
  min-width: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  background:
    radial-gradient(1100px 560px at 100% -8%, rgba(0, 122, 255, 0.07), transparent 60%),
    radial-gradient(960px 560px at -6% 2%, rgba(88, 86, 214, 0.06), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

/* ---- Top bar: translucent, blurred, hairline (iOS large nav bar) ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  min-height: 54px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: -0.022em; gap: 12px; }
.brand > span:last-child { font-size: 17px; }
.bolt { color: var(--green); }
.menu-btn { color: var(--text); opacity: 0.86; }

/* ---- Buttons: iOS tinted / plain ---- */
.icon-btn, .date-select-wrap, .pill-btn, .ghost-btn {
  height: 32px;
  border-radius: 10px;
  border: 0.5px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  font-weight: 590;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.03);
  transition: transform 0.12s ease, background 0.15s ease;
}
.icon-btn { border: 0; background: transparent; box-shadow: none; color: var(--blue); }
.pill-btn, .ghost-btn {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: transparent;
  box-shadow: none;
}
.pill-btn:active, .ghost-btn:active, .date-select-wrap:active, .icon-btn:active { transform: scale(0.96); }

/* ---- Avatar (iOS account bubble) ---- */
.avatar {
  background: linear-gradient(180deg, #0a84ff, #0060df);
  color: #fff;
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.avatar::after { background: var(--green); border: 2px solid rgba(255, 255, 255, 0.96); }

/* ---- Status bar ---- */
.statusbar {
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
  color: var(--muted);
}
.status-item { color: var(--muted); font-weight: 500; }
.status-item strong { color: var(--green-text); font-weight: 600; }
.divider { width: 0.5px; height: 16px; background: var(--line); }

/* ---- Spacing rhythm ---- */
.content {
  gap: 14px;
  padding: 16px 20px 30px;
  max-width: 1520px;
  margin: 0 auto;
}
.grid, .mid-grid, .bottom-grid, .detail-grid, .detail-brand-grid, .code-trend-grid { gap: 14px; }

/* ---- KPI scorecards as iOS home-screen widgets ---- */
.scorecards { gap: 14px; }
.scorecard, .scorecard:last-child {
  border: 0;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 26px rgba(0, 0, 0, 0.06);
  padding: 14px 16px;
}
.score-icon {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 13px;                 /* squircle app-icon tile */
  background: var(--green-soft);
  color: var(--green-text);
}
.scorecard.blue .score-icon { background: var(--blue-soft); color: var(--blue); }
.score-label { color: var(--muted); font-weight: 600; font-size: 12px; }
.score-value { color: var(--text); font-weight: 700; font-size: 25px; letter-spacing: -0.03em; }
.score-delta { color: var(--green-text); font-weight: 600; }
.score-delta.negative, .score-delta.down { color: var(--red); }

/* ---- Panels as grouped iOS cards ---- */
.panel, .mini-panel {
  border: 0.5px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.035), 0 10px 30px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}
.panel-head, .mini-panel-head {
  background: transparent;
  border-bottom: 0.5px solid var(--line);
}
.panel-title, .mini-title {
  color: var(--text);
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.panel-tools { color: var(--muted); }
.panel-foot { border-top: 0.5px solid var(--line); color: var(--muted); }
.note { color: var(--muted); }

/* ---- Dropdowns: iOS menu buttons (filled, chevron) ---- */
.mini-select, .th-control {
  border: 0;
  border-radius: 9px;
  background: var(--fill);
  color: var(--text);
  font-weight: 590;
  -webkit-appearance: none;
  appearance: none;
  padding: 0 26px 0 10px;
  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='%238e8e93' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 11px;
}
.mini-select:focus, .th-control:focus { outline: 2px solid var(--blue-soft); }

/* ---- Segmented controls (iOS UISegmentedControl) ---- */
.metric-toggle, .segmented {
  border: 0;
  border-radius: 9px;
  background: var(--fill);
  padding: 2px;
  gap: 0;
}
.metric-toggle button, .segmented button {
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-weight: 590;
}
.metric-toggle button.active, .segmented button.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14), 0 1px 1px rgba(0, 0, 0, 0.04);
}

/* ---- Tables -> inset grouped lists (no vertical rules, hairline rows) ---- */
.table th, .table td {
  border-right: 0 !important;
  height: 30px;
  padding: 0 14px;
}
.table td { border-bottom: 0.5px solid var(--line); color: var(--text); font-size: 13px; }
.table th {
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 0.5px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(0, 122, 255, 0.045); }

/* ---- Progress bars ---- */
.bar-track { background: var(--fill); height: 7px; }
.bar-fill { background: var(--green); }
.bar-fill.blue { background: var(--blue); }

/* ---- Mono code chips ---- */
.code {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--fill);
  padding: 1px 6px;
  border-radius: 6px;
}

/* ---- Badges / pills (iOS tinted capsules) ---- */
.tag, .severity, .brand-pill {
  border: 0 !important;
  border-radius: 999px;
  height: auto;
  padding: 2px 9px;
  line-height: 1.55;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.tag { background: var(--green-soft); color: var(--green-text); }
.tag.review { background: var(--amber-soft); color: var(--amber-text); }
.tag.return { background: var(--red-soft); color: var(--red); }
.tag.luxor, .brand-pill.luxor { background: var(--blue-soft); color: var(--blue); }
.tag.denzo, .tag.denzol, .brand-pill.denzo, .brand-pill.denzol { background: var(--green-soft); color: var(--green-text); }
.tag.cai, .brand-pill.cai { background: var(--indigo-soft); color: var(--indigo); }
.severity.high { background: var(--red-soft); color: var(--red); }
.severity.medium { background: var(--amber-soft); color: var(--amber-text); }
.severity.low { background: var(--green-soft); color: var(--green-text); }

/* ---- Customer-detail block ---- */
.customer-input {
  border: 0;
  border-radius: 10px;
  background: var(--fill);
  color: #111827;
  font-weight: 500;
}
.customer-input:focus { outline: 2px solid var(--blue-soft); background: #fff; }
.customer-input::placeholder { color: var(--soft); }
.detail-kpi { border: 0; border-radius: 14px; background: var(--fill); }
.detail-kpi span { color: var(--muted); font-weight: 600; }
.detail-kpi strong { color: var(--text); font-weight: 700; letter-spacing: -0.02em; }
.detail-kpi small { color: var(--soft); }
.customer-summary { border-color: var(--line); }

/* ---- Action queue rows ---- */
.queue-row { border-bottom: 0.5px solid var(--line); }
.queue-row.header {
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}
.issue-title strong { color: var(--text); font-weight: 650; }
.issue-title span { color: var(--muted); }
.action-link { color: var(--blue); font-weight: 590; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.30);
  z-index: 50;
}

.modal-backdrop.open {
  display: flex;
}

.quality-modal {
  width: min(720px, 100%);
  max-height: min(680px, 90vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.22);
}

.quality-modal-head,
.quality-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.quality-modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.quality-modal-title {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 760;
}

.quality-modal-body {
  display: grid;
  gap: 12px;
  padding: 16px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.quality-modal-body code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--fill);
  color: var(--text);
  font-weight: 700;
}

.mfa-modal {
  width: min(520px, 100%);
}

.mfa-eyebrow {
  margin: 0 0 4px;
  color: var(--green-text);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.mfa-modal-body {
  justify-items: stretch;
}

.mfa-description,
.mfa-qr-wrap p,
.mfa-status {
  margin: 0;
}

.mfa-description,
.mfa-qr-wrap p {
  color: var(--muted);
}

.mfa-qr-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--fill);
  text-align: center;
}

.mfa-qr-wrap[hidden],
.mfa-secret-wrap[hidden],
.mfa-code-field[hidden],
.mfa-modal-foot [hidden] {
  display: none;
}

.mfa-qr {
  width: min(240px, 72vw);
  aspect-ratio: 1;
  border: 10px solid #fff;
  border-radius: 10px;
  background: #fff;
}

.mfa-secret-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--muted);
}

.mfa-secret-wrap summary {
  cursor: pointer;
  font-weight: 700;
}

.mfa-secret-wrap code {
  display: block;
  margin-top: 10px;
  overflow-wrap: anywhere;
  user-select: all;
}

.mfa-code-field {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 720;
}

.mfa-code-field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 20px;
  font-weight: 760;
  letter-spacing: 0.18em;
}

.mfa-code-field input:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(11, 115, 246, 0.14);
}

.mfa-status {
  min-height: 20px;
  color: var(--muted);
  font-weight: 680;
}

.mfa-status.error {
  color: #b42318;
}

.mfa-modal-foot {
  flex-wrap: wrap;
}

.mfa-verify {
  background: var(--blue);
  color: #fff;
}

@media (max-width: 560px) {
  .mfa-modal-foot > button {
    flex: 1 1 100%;
    justify-content: center;
  }
}

.fix-grid {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 8px 12px;
}

.fix-grid span:nth-child(odd) {
  color: var(--muted);
  font-weight: 680;
}

.fix-steps {
  margin: 0;
  padding-left: 18px;
}

.fix-steps li {
  margin: 5px 0;
}

/* ---- Legend ---- */
.legend { color: var(--muted); font-weight: 500; }

/* ---- Scrollbars (thin, iOS overlay feel) ---- */
.table-scroll::-webkit-scrollbar-thumb,
.records-wrap::-webkit-scrollbar-thumb,
.queue-list::-webkit-scrollbar-thumb {
  background: rgba(60, 60, 67, 0.26);
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ---- Focus ring ---- */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; border-radius: 8px; }

/* Dock-launched Safari Web Apps have less horizontal room than a full Safari tab. */
@media (max-width: 1280px) {
  body { min-width: 0; }
  .topbar {
    width: 100%;
    min-width: 0;
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "actions";
    align-content: center;
    gap: 7px;
    min-height: 88px;
    padding: 7px 14px;
  }
  .brand {
    min-width: 0;
    width: 100%;
    height: 28px;
    overflow: visible;
  }
  .brand-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .top-nav {
    display: none;
  }
  .top-actions {
    width: 100%;
    min-width: 0;
    grid-template-columns: 34px minmax(0, 1fr) 36px 36px 32px;
    justify-content: stretch;
    gap: 6px;
  }
  .period-controls {
    max-width: none;
  }
  .pill-btn {
    width: 36px;
    min-width: 36px;
    justify-content: center;
    gap: 0;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }
  .pill-btn svg { flex: 0 0 auto; }
  .avatar {
    width: 32px;
    height: 32px;
  }
  .trend-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .trend-average {
    margin: 0 12px 10px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .trend-average-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }
  .trend-average-values {
    grid-column: 1;
  }
  .trend-average-delta {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

@media (display-mode: standalone) {
  body { min-width: 0; }
  .topbar {
    width: 100%;
    min-width: 0;
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "actions";
    align-content: center;
    gap: 7px;
    min-height: 88px;
    padding: 7px 14px;
  }
  .brand {
    min-width: 0;
    width: 100%;
    height: 28px;
    overflow: visible;
  }
  .brand-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .top-nav {
    display: none;
  }
  .top-actions {
    width: 100%;
    min-width: 0;
    grid-template-columns: 34px minmax(0, 1fr) 36px 36px 32px;
    justify-content: stretch;
    gap: 6px;
  }
  .period-controls {
    max-width: none;
  }
  .pill-btn {
    width: 36px;
    min-width: 36px;
    justify-content: center;
    gap: 0;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }
  .pill-btn svg { flex: 0 0 auto; }
  .avatar {
    width: 32px;
    height: 32px;
  }
  .trend-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .trend-average {
    margin: 0 12px 10px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .trend-average-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }
  .trend-average-values {
    grid-column: 1;
  }
  .trend-average-delta {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

/* ---- Narrow screens: behave like a phone (stack + scrollable tables) ---- */
@media (max-width: 820px) {
  body { min-width: 0; }
  .content { padding: 12px 12px 24px; }
  .statusbar { display: none; }
  .scorecards { grid-template-columns: repeat(2, 1fr); }
  .grid, .mid-grid, .bottom-grid, .detail-grid, .detail-brand-grid, .code-trend-grid { grid-template-columns: 1fr; }
  .detail-kpis { grid-template-columns: repeat(2, 1fr); }
  .bitly-kpi-grid,
  .bitly-branch-grid,
  .bitly-context-grid { grid-template-columns: minmax(0, 1fr); }
  .bitly-branch-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bitly-signal-head { align-items: flex-start; flex-direction: column; }
  .topbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "actions";
    gap: 8px;
    padding: 8px 12px;
  }
  .brand { min-width: 0; }
  .top-nav { display: none; }
  .top-actions {
    grid-template-columns: auto minmax(220px, 1fr) auto auto auto;
    justify-content: stretch;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .brand > span:last-child { font-size: 15px; }
  .period-controls { min-width: 220px; max-width: none; gap: 6px; }
  .date-select-wrap.period-field { min-width: 220px; }
  .date-select-wrap.range-field { min-width: 118px; }
  .pill-btn { padding: 0 8px; }
  .trend-body { grid-template-columns: minmax(0, 1fr); }
  .trend-average { margin: 0 12px 10px; border-left: 0; border-top: 1px solid var(--line); }
  .trend-average-row { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .trend-average-values { grid-column: 1; }
  .trend-average-delta { grid-column: 2; grid-row: 1 / span 2; }
}

/* Slowest-moving stock is an isolated, additive Sales Dashboard module. */
.slow-stock-panel {
  overflow: hidden;
}

.slow-stock-head {
  min-height: 62px;
  padding: 10px 14px;
}

.slow-stock-heading {
  min-width: 0;
}

.slow-stock-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.slow-stock-scope {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-text);
  font-size: 11px;
  font-weight: 820;
  white-space: nowrap;
}

.slow-stock-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.slow-stock-card {
  min-width: 0;
  min-height: 150px;
  padding: 12px;
  border: 1px solid #e1e7ef;
  border-top: 3px solid var(--blue);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.055);
}

.slow-stock-card.no-movement {
  border-top-color: var(--amber);
  background: linear-gradient(180deg, #fffdf8 0%, #ffffff 100%);
}

.slow-stock-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.slow-stock-rank,
.slow-stock-brand {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 840;
  line-height: 1;
}

.slow-stock-rank {
  padding: 0 7px;
  background: var(--amber-soft);
  color: var(--amber-text);
}

.slow-stock-brand {
  max-width: 86px;
  padding: 0 7px;
  overflow: hidden;
  background: #eef2f7;
  color: #64748b;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slow-stock-card h3 {
  margin: 9px 0 8px;
  overflow: hidden;
  color: #111827;
  font-size: 18px;
  font-weight: 860;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slow-stock-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.slow-stock-metrics > span {
  min-width: 0;
  padding: 7px 8px;
  border-radius: 8px;
  background: #f1f5f9;
}

.slow-stock-metrics small,
.slow-stock-metrics strong {
  display: block;
}

.slow-stock-metrics small {
  color: #7b8794;
  font-size: 9px;
  font-weight: 760;
  line-height: 1;
}

.slow-stock-metrics strong {
  margin-top: 4px;
  overflow: hidden;
  color: #172033;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 840;
  line-height: 1;
  text-overflow: ellipsis;
}

.slow-stock-metrics em {
  color: #64748b;
  font-size: 8px;
  font-style: normal;
  font-weight: 780;
}

.slow-stock-buyers {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid #e8edf3;
}

.slow-stock-buyers-label {
  display: block;
  margin-bottom: 5px;
  color: #87919d;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.slow-stock-buyer-list {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.slow-stock-buyer {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 5px;
  border-radius: 6px;
  background: #eef2f7;
  color: #475569;
  font-size: 9px;
  font-weight: 720;
}

.slow-stock-buyer-name {
  display: block;
  min-width: 0;
  max-width: 78px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slow-stock-top-customer {
  flex: 0 0 auto;
  padding: 2px 3px;
  border-radius: 4px;
  background: var(--green-soft);
  color: var(--green-text);
  font-size: 7px;
  font-weight: 900;
  line-height: 1;
}

.slow-stock-more,
.slow-stock-no-buyers {
  flex: 0 0 auto;
  color: #77808c;
  font-size: 9px;
  font-weight: 760;
  white-space: nowrap;
}

.slow-stock-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}

.slow-stock-foot {
  min-height: 34px;
  padding: 8px 14px;
  font-size: 10px;
}

@media (max-width: 1180px) {
  .slow-stock-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .slow-stock-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    height: auto;
  }

  .slow-stock-heading p {
    max-width: 260px;
    line-height: 1.35;
  }

  .slow-stock-scope {
    align-self: flex-start;
  }

  .slow-stock-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
  }

  .slow-stock-card {
    min-height: 148px;
    padding: 10px;
  }

  .slow-stock-card h3 {
    font-size: 16px;
  }

  .slow-stock-metrics > span {
    padding: 6px;
  }

  .slow-stock-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .slow-stock-stock-days {
    grid-column: 1 / -1;
  }

  .slow-stock-metrics strong {
    font-size: 14px;
  }

  .slow-stock-buyer-list {
    align-items: flex-start;
    flex-direction: column;
  }

  .slow-stock-buyer-name {
    max-width: 92px;
  }
}

/* Phone users authenticate before the dashboard is revealed. */
.mobile-auth-gate {
  display: none;
}

@media (max-width: 820px) {
  body[data-auth-state="checking"],
  body[data-auth-state="signed-out"] {
    overflow: hidden;
  }

  body[data-auth-state="checking"] .mobile-auth-gate,
  body[data-auth-state="signed-out"] .mobile-auth-gate {
    position: fixed;
    inset: 0;
    z-index: 4500;
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100dvh;
    padding:
      max(18px, env(safe-area-inset-top))
      22px
      max(20px, env(safe-area-inset-bottom));
    overflow-y: auto;
    background: #f3f5f9;
  }

  .mobile-auth-language {
    justify-self: end;
    width: 44px;
    height: 36px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
  }

  .mobile-auth-content {
    align-self: center;
    width: min(100%, 390px);
    margin: 0 auto;
    text-align: center;
  }

  .mobile-auth-mark {
    width: 70px;
    height: 70px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--green);
    box-shadow: var(--shadow);
  }

  .mobile-auth-mark svg {
    width: 42px;
    height: 42px;
  }

  .mobile-auth-eyebrow {
    margin: 0 0 7px;
    color: var(--green-text);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0;
  }

  .mobile-auth-content h1 {
    margin: 0;
    color: var(--text);
    font-size: 30px;
    line-height: 1.15;
    letter-spacing: 0;
  }

  .mobile-auth-copy {
    max-width: 290px;
    margin: 12px auto 26px;
    color: #64748b;
    font-size: 15px;
    line-height: 1.55;
  }

  .mobile-auth-login {
    width: 100%;
    min-height: 54px;
    border: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 18px;
    background: var(--blue);
    color: #fff;
    box-shadow: 0 8px 20px rgba(11, 115, 246, 0.2);
    font-size: 16px;
    font-weight: 820;
  }

  .mobile-auth-login:disabled {
    cursor: wait;
    opacity: 0.62;
  }

  body[data-auth-state="signed-out"] .mobile-auth-login:disabled {
    cursor: not-allowed;
  }

  .mobile-auth-login svg {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
  }

  .mobile-auth-status {
    min-height: 18px;
    margin: 12px 0 0;
    color: #64748b;
    font-size: 12px;
    font-weight: 650;
  }

  .mobile-auth-security {
    margin: 20px 0 0;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 650;
    text-align: center;
  }
}

/* All devices enter through the same authenticated landing page. */
body[data-auth-state="checking"],
body[data-auth-state="signed-out"] {
  overflow: hidden;
}

body[data-auth-state="checking"] .app > :not(.mobile-auth-gate),
body[data-auth-state="signed-out"] .app > :not(.mobile-auth-gate) {
  visibility: hidden;
}

body[data-auth-state="checking"] .mobile-auth-gate,
body[data-auth-state="signed-out"] .mobile-auth-gate {
  position: fixed;
  inset: 0;
  z-index: 4500;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100dvh;
  padding:
    max(24px, env(safe-area-inset-top))
    clamp(22px, 4vw, 64px)
    max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
  background:
    radial-gradient(circle at 15% 15%, rgba(47, 155, 105, 0.12), transparent 32%),
    radial-gradient(circle at 85% 80%, rgba(11, 115, 246, 0.10), transparent 34%),
    #eef2f6;
}

.mobile-auth-language {
  justify-self: end;
  width: 46px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.88);
  color: #334155;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.mobile-auth-content {
  align-self: center;
  width: min(100%, 460px);
  margin: 28px auto;
  padding: 40px;
  border: 1px solid rgba(199, 209, 222, 0.9);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
  text-align: center;
}

.mobile-auth-mark {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  border: 1px solid rgba(47, 155, 105, 0.22);
  border-radius: 18px;
  background: rgba(240, 253, 247, 0.9);
  color: var(--green);
}

.mobile-auth-mark svg {
  width: 44px;
  height: 44px;
}

.mobile-auth-eyebrow {
  margin: 0 0 7px;
  color: var(--green-text);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.mobile-auth-content h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(30px, 4vw, 38px);
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.mobile-auth-copy {
  max-width: 330px;
  margin: 13px auto 18px;
  color: #64748b;
  font-size: 15px;
  line-height: 1.55;
}

.auth-access-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin: 0 0 24px;
}

.auth-access-list span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--fill);
  color: #475569;
  font-size: 11px;
  font-weight: 760;
}

.mobile-auth-login {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 24px rgba(11, 115, 246, 0.22);
  font-size: 16px;
  font-weight: 820;
}

.mobile-auth-login:disabled {
  cursor: wait;
  opacity: 0.62;
}

body[data-auth-state="signed-out"] .mobile-auth-login:disabled {
  cursor: not-allowed;
}

.mobile-auth-login svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.mobile-auth-status {
  min-height: 18px;
  margin: 12px 0 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 650;
}

.mobile-auth-security {
  margin: 20px 0 0;
  color: #7b8ba1;
  font-size: 11px;
  font-weight: 650;
  text-align: center;
}

@media (max-width: 560px) {
  body[data-auth-state="checking"] .mobile-auth-gate,
  body[data-auth-state="signed-out"] .mobile-auth-gate {
    padding:
      max(18px, env(safe-area-inset-top))
      18px
      max(20px, env(safe-area-inset-bottom));
  }

  .mobile-auth-content {
    margin: 18px auto;
    padding: 28px 22px;
    border-radius: 18px;
  }
}

/* ---- Sales operations redesign: compact, high-scan dashboard ---- */
:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --line: #d8e0ea;
  --line-strong: #c7d1de;
  --text: #172033;
  --muted: #77808c;
  --soft: #a3abb5;
  --green: #22c55e;
  --green-text: #15803d;
  --green-soft: #dcfce7;
  --blue: #0b73f6;
  --blue-soft: #eaf2ff;
  --amber: #f59e0b;
  --amber-text: #b45309;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --fill: #eef2f7;
  --fill-2: #e3e9f1;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.055);
  --radius: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
}

.topbar {
  min-height: 56px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 17px;
  font-weight: 760;
}

.menu-btn {
  color: #334155;
}

.bolt {
  color: var(--green);
}

.top-actions {
  grid-template-columns: auto minmax(320px, 660px) auto auto auto;
  gap: 10px;
}

.icon-btn,
.date-range-button,
.pill-btn,
.ghost-btn {
  border-radius: 8px;
  border-color: var(--line);
  background: #ffffff;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.02);
}

.pill-btn {
  background: #dbeafe;
  color: var(--blue);
  border: 0;
  font-weight: 760;
}

.statusbar {
  min-height: 38px;
  padding: 0 22px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.status-item {
  color: #6b7280;
  font-weight: 620;
}

.status-item strong {
  color: var(--green-text);
  font-weight: 780;
}

.dashboard-scope-filter {
  gap: 6px;
  color: #64748b;
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
}

.dashboard-scope-filter select {
  height: 28px;
  min-width: 86px;
  border: 0;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 820;
  text-align: center;
}

.content {
  max-width: 1680px;
  padding: 16px 22px 28px;
  gap: 14px;
}

.grid,
.mid-grid,
.summary-grid,
.bottom-grid,
.detail-grid,
.detail-brand-grid,
.code-trend-grid {
  gap: 14px;
}

.scorecards {
  gap: 14px;
}

.scorecard,
.scorecard:last-child {
  min-height: 86px;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #e3e9f1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.score-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green-text);
}

.scorecard.blue .score-icon {
  background: var(--blue-soft);
  color: var(--blue);
}

.score-label {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.score-value {
  color: var(--text);
  font-size: 28px;
  font-weight: 820;
  letter-spacing: 0;
  white-space: nowrap;
}

.score-value-sales {
  font-size: 0.6em;
  font-weight: 780;
  letter-spacing: 0;
}

.kl-sales-amount-cell {
  display: none;
}

body[data-kl-sales-amounts="true"] .kl-sales-amount-cell {
  display: table-cell;
}

.score-delta {
  margin-top: 6px;
  color: var(--green-text);
  font-size: 11px;
  font-weight: 760;
}

.panel,
.mini-panel {
  border: 1px solid #dfe6ef;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.panel-head,
.mini-panel-head {
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.trend-panel .panel-head,
.top-panel .panel-head,
.customer-panel .panel-head {
  height: 64px;
  align-items: stretch;
  flex-direction: column;
  gap: 8px;
  padding: 9px 14px;
}

.customer-panel .panel-tools,
.top-panel .panel-tools,
.trend-panel .panel-tools {
  width: 100%;
}

.summary-grid .top-panel .panel-head,
.summary-grid .customer-panel .panel-head {
  height: auto;
  min-height: 76px;
  flex: 0 0 auto;
  overflow: visible;
}

.summary-grid .top-panel .panel-tools,
.summary-grid .customer-panel .panel-tools {
  min-height: 30px;
  flex: 0 0 30px;
}

.panel-title,
.mini-title {
  color: #111827;
  font-size: 15px;
  font-weight: 820;
  letter-spacing: 0;
}

.panel-tools {
  gap: 8px;
}

.mini-select,
.th-control {
  height: 30px;
  border: 0;
  border-radius: 8px;
  background-color: #eef2f7;
  color: #172033;
  font-size: 12px;
  font-weight: 760;
}

.metric-toggle,
.segmented {
  min-height: 30px;
  border-radius: 8px;
  background: #eef2f7;
  padding: 2px;
}

.metric-toggle button,
.segmented button {
  height: 26px;
  border-radius: 7px;
  font-weight: 760;
}

.metric-toggle button.active,
.segmented button.active {
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.trend-grid,
.summary-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.trend-grid .panel {
  min-height: 300px;
}

.trend-body {
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 10px;
}

.trend-average {
  margin: 10px 10px 10px 0;
  border: 1px solid #e3e9f1;
  border-left: 1px solid #e3e9f1;
  border-radius: 8px;
  background: #f8fafc;
}

.trend-average-title {
  color: #111827;
  font-size: 12px;
  font-weight: 840;
}

.trend-average-row {
  padding: 8px 0;
}

.chart-wrap {
  height: 208px;
  padding: 8px 16px 8px;
}

.daily-wrap {
  height: 190px;
}

.legend {
  padding: 7px 16px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.chart-popover {
  background: rgba(255, 255, 255, 0.98);
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.16);
}

.chart-popover .title {
  color: #667085;
}

.chart-popover .value {
  color: var(--text);
}

.summary-grid .panel {
  height: clamp(520px, 66vh, 640px);
  min-height: 540px;
}

.summary-grid .top-scroll,
.summary-grid .customer-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.summary-grid .top-scroll .table th,
.summary-grid .customer-scroll .table th {
  top: 0;
  z-index: 4;
  box-shadow: 0 1px 0 var(--line);
}

.customer-summary {
  background: #ffffff;
  border-top: 1px solid var(--line);
}

.table {
  font-size: 12px;
  border-collapse: separate;
  border-spacing: 0;
}

.summary-grid .table {
  table-layout: fixed;
  font-size: 12px;
}

.table th,
.table td,
.summary-grid .table th,
.summary-grid .table td {
  height: 31px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  border-right: 0 !important;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.table th,
.summary-grid .table th {
  background: #ffffff;
  color: #7b828d;
  font-size: 10.5px;
  font-weight: 820;
  letter-spacing: 0;
  text-transform: uppercase;
}

.table tbody tr:nth-child(even) td {
  background: #f6f8fb;
}

.table tbody tr:hover td {
  background: #edf5ff !important;
}

.top-code-button,
.customer-row-toggle,
.customer-colour-toggle,
.customer-name-text {
  color: #111827;
}

.top-code-button,
.customer-row-toggle {
  font-weight: 820;
}

.top-code-button .expand-icon,
.customer-expand-icon {
  background: #eef2f7;
  color: #64748b;
}

.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

#topItemsTable [data-column="rank"],
#customerTable [data-column="rank"] {
  width: 5%;
}

#topItemsTable [data-column="group"] {
  width: 23%;
}

#topItemsTable [data-column="previousQty"],
#topItemsTable [data-column="averageQty"],
#topItemsTable [data-column="customerCount"] {
  width: 8.5%;
}

#topItemsTable [data-column="qty"] {
  width: 6.5%;
}

#topItemsTable [data-column="clicks"] {
  width: 8%;
}

#topItemsTable [data-column="latest"] {
  width: 13%;
}

#topItemsTable [data-column="share"] {
  width: 10.5%;
}

#customerTable [data-column="customer"] {
  width: 42%;
}

#customerTable [data-column="sales"] {
  width: 9%;
}

#customerTable [data-column="previousQty"] {
  width: 9%;
}

#customerTable [data-column="value"] {
  width: 8%;
}

#customerTable [data-column="colourCount"] {
  width: 7%;
}

#customerTable [data-column="share"] {
  width: 10%;
}

#customerTable [data-column="cumulative"] {
  width: 10%;
}

.bar-track {
  background: #e8edf4;
}

.tag,
.severity,
.brand-pill {
  border-radius: 999px;
  font-weight: 760;
}

.tag.luxor,
.brand-pill.luxor {
  background: var(--blue-soft);
  color: var(--blue);
}

.tag.denzo,
.tag.denzol,
.brand-pill.denzo,
.brand-pill.denzol {
  background: var(--green-soft);
  color: var(--green-text);
}

.detail-kpi {
  border-radius: 8px;
  background: #f1f4f8;
}

@media (display-mode: standalone) {
  .topbar {
    min-height: 94px;
  }
  .scorecard,
  .scorecard:last-child,
  .panel,
  .mini-panel {
    border-radius: 8px;
  }
}

@media (max-width: 1180px) {
  .scorecards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .trend-grid,
  .summary-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .summary-grid .panel {
    min-height: 480px;
  }
}

@media (max-width: 820px) {
  .scorecards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .bitly-kpi-grid,
  .bitly-branch-grid,
  .bitly-context-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .bitly-branch-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .bitly-signal-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .trend-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .trend-average {
    margin: 0 12px 10px;
    border-left: 1px solid #e3e9f1;
    border-top: 1px solid #e3e9f1;
  }
}

/* Phone summary tables keep labels readable without compressing every value. */
@media (max-width: 820px) {
  .summary-grid .top-panel .panel-head,
  .summary-grid .customer-panel .panel-head {
    height: auto;
    min-height: 0;
    padding: 11px 14px 10px;
    overflow: visible;
  }

  .summary-grid .panel-tools {
    width: 100%;
    min-height: 32px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .summary-grid .panel-tools::-webkit-scrollbar {
    display: none;
  }

  .summary-grid .panel-tools > * {
    flex: 0 0 auto;
  }

  .summary-grid .top-scroll,
  .summary-grid .customer-scroll {
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #topItemsTable {
    width: 748px;
    min-width: 748px;
  }

  #customerTable {
    width: 600px;
    min-width: 600px;
  }

  #topItemsTable [data-column="rank"],
  #customerTable [data-column="rank"] {
    width: 36px;
    min-width: 36px;
    padding-right: 4px;
    padding-left: 4px;
  }

  #topItemsTable [data-column="group"] {
    width: 128px;
    min-width: 128px;
    padding-right: 6px;
    padding-left: 6px;
  }

  #topItemsTable [data-column="previousQty"] {
    width: 76px;
  }

  #topItemsTable [data-column="qty"] {
    width: 66px;
  }

  #topItemsTable [data-column="clicks"] {
    width: 68px;
    min-width: 68px;
  }

  #topItemsTable [data-column="averageQty"] {
    width: 76px;
  }

  #topItemsTable [data-column="customerCount"] {
    width: 76px;
  }

  #topItemsTable [data-column="latest"] {
    width: 126px;
  }

  #topItemsTable [data-column="share"] {
    width: 92px;
  }

  #customerTable [data-column="customer"] {
    width: 160px;
    min-width: 160px;
    padding-right: 6px;
    padding-left: 6px;
  }

  #customerTable [data-column="previousQty"],
  #customerTable [data-column="value"] {
    width: 78px;
  }

  #customerTable [data-column="sales"] {
    width: 78px;
  }

  body[data-kl-sales-amounts="true"] #customerTable {
    width: 678px;
    min-width: 678px;
  }

  #customerTable [data-column="colourCount"] {
    width: 68px;
  }

  #customerTable [data-column="share"],
  #customerTable [data-column="cumulative"] {
    width: 88px;
  }

  #topItemsTable td.num,
  #customerTable td.num {
    overflow: visible;
    text-overflow: clip;
  }

  #topItemsTable th[data-column="rank"],
  #topItemsTable td[data-column="rank"],
  #customerTable th[data-column="rank"],
  #customerTable td[data-column="rank"] {
    position: sticky;
    left: 0;
  }

  #topItemsTable th[data-column="group"],
  #topItemsTable td[data-column="group"],
  #customerTable th[data-column="customer"],
  #customerTable td[data-column="customer"] {
    position: sticky;
    left: 36px;
    box-shadow: 1px 0 0 var(--line);
  }

  #topItemsTable thead th[data-column="rank"],
  #topItemsTable thead th[data-column="group"],
  #customerTable thead th[data-column="rank"],
  #customerTable thead th[data-column="customer"] {
    z-index: 7;
    background: #ffffff;
  }

  #topItemsTable tbody td[data-column="rank"],
  #topItemsTable tbody td[data-column="group"],
  #customerTable tbody td[data-column="rank"],
  #customerTable tbody td[data-column="customer"] {
    z-index: 2;
    background: #ffffff;
  }

  #topItemsTable tbody tr:nth-child(even) td[data-column="rank"],
  #topItemsTable tbody tr:nth-child(even) td[data-column="group"],
  #customerTable tbody tr:nth-child(even) td[data-column="rank"],
  #customerTable tbody tr:nth-child(even) td[data-column="customer"] {
    background: #f6f8fb;
  }
}

/* Preserve this additive module's header sizing after shared panel rules. */
.panel-head.slow-stock-head {
  min-height: 62px;
  padding: 10px 14px;
}

/* Compact Bitly click-to-sales module at the bottom of the Sales Dashboard. */
.bitly-top-panel {
  overflow: hidden;
  padding: 0;
}

.bitly-top-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: #fafafa;
}

.bitly-top-filter-title {
  flex: 0 0 auto;
  margin: 0 3px 0 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.bitly-top-field {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #475569;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.bitly-top-field select,
.bitly-top-field input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #172033;
  font-size: 10px;
  font-weight: 750;
}

.bitly-top-field input {
  width: 112px;
}

.bitly-top-reset {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  cursor: pointer;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.bitly-top-reset:hover,
.bitly-top-reset:focus-visible {
  background: var(--blue-soft);
}

.bitly-top-source {
  margin-left: auto;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.bitly-top-source strong {
  color: var(--green-text);
}

.bitly-top-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 9px;
}

.bitly-top-grid.single {
  grid-template-columns: minmax(0, 1fr);
}

.bitly-top-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.bitly-top-card[hidden] {
  display: none;
}

.bitly-top-card-head {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 11px;
  border-bottom: 1px solid var(--line);
  background: #fcfcfd;
}

.bitly-top-card-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #172033;
  font-size: 13px;
  font-weight: 850;
}

.bitly-top-card-title::before {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
  content: "";
}

.bitly-top-card.pg .bitly-top-card-title::before {
  background: #5856d6;
  box-shadow: 0 0 0 4px rgba(88, 86, 214, 0.12);
}

.bitly-top-card-note {
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
}

.bitly-top-table-wrap {
  overflow-x: auto;
}

.bitly-top-table {
  width: 100%;
  min-width: 570px;
  border-collapse: collapse;
}

.bitly-top-table th {
  height: 29px;
  padding: 0 7px;
  border-bottom: 1px solid rgba(60, 60, 67, 0.28);
  background: #f8fafc;
  color: #6b7280;
  text-align: left;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.bitly-top-table th.num,
.bitly-top-table td.num {
  text-align: right;
}

.bitly-top-sort {
  width: 100%;
  height: 29px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.bitly-top-sort:hover,
.bitly-top-sort:focus-visible,
.bitly-top-sort.active {
  color: var(--blue);
}

.bitly-top-card.pg .bitly-top-sort.active {
  color: #5856d6;
}

.bitly-top-table td {
  height: 42px;
  padding: 4px 7px;
  border-bottom: 1px solid rgba(60, 60, 67, 0.15);
  color: var(--text);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.bitly-top-table tbody tr:last-child td {
  border-bottom: 0;
}

.bitly-top-table tbody tr:hover {
  background: rgba(0, 122, 255, 0.035);
}

.bitly-top-rank {
  width: 30px;
  color: var(--muted) !important;
  font-weight: 800;
}

.bitly-top-product {
  min-width: 118px;
}

.bitly-top-item {
  display: block;
  color: #172033;
  font-size: 11px;
  font-weight: 850;
}

.bitly-top-link {
  display: block;
  max-width: 145px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bitly-top-current {
  background: rgba(0, 122, 255, 0.025) !important;
}

.bitly-top-conversion {
  background: rgba(52, 199, 89, 0.045) !important;
}

.bitly-top-rate {
  font-size: 12px;
  font-weight: 900;
}

.bitly-top-rate.good {
  color: var(--green-text);
}

.bitly-top-rate.watch {
  color: #b25e00;
}

.bitly-top-rate.risk {
  color: #d62f28;
}

.bitly-top-signal {
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 850;
  white-space: nowrap;
}

.bitly-top-signal.follow {
  background: var(--blue-soft);
  color: var(--blue);
}

.bitly-top-signal.strong {
  background: var(--green-soft);
  color: var(--green-text);
}

.bitly-top-signal.watch {
  background: #fff0df;
  color: #b25e00;
}

.bitly-top-empty td {
  height: 160px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.bitly-top-foot {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px;
}

.bitly-top-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
  white-space: nowrap;
}

.bitly-top-legend strong {
  font-size: 9px;
  font-weight: 800;
}

.bitly-top-legend .good {
  color: var(--green-text);
}

.bitly-top-legend .watch {
  color: #b25e00;
}

.bitly-top-legend .risk {
  color: #d62f28;
}

.bitly-top-panel[data-months="1"] .bitly-top-month-2,
.bitly-top-panel[data-months="1"] .bitly-top-month-3,
.bitly-top-panel[data-months="2"] .bitly-top-month-3 {
  display: none;
}

@media (max-width: 1100px) {
  .bitly-top-month-3 {
    display: none;
  }
}

@media (max-width: 900px) {
  .bitly-top-filter-bar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .bitly-top-source {
    width: 100%;
    margin-left: 0;
  }

  .bitly-top-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .bitly-top-month-2 {
    display: none;
  }
}

@media (max-width: 620px) {
  .bitly-top-field {
    flex: 1 1 calc(50% - 6px);
  }

  .bitly-top-field input {
    width: 100%;
  }

  .bitly-top-foot {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* KPI cards: remove decorative icons on desktop and mobile. */
.scorecard,
.scorecard:last-child {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.score-icon {
  display: none;
}

/* Keep the ALL / PG / KL dashboard scope available when the phone status details are collapsed. */
@media (max-width: 820px) {
  .statusbar {
    min-height: 42px;
    display: flex;
    justify-content: center;
    padding: 6px 12px;
  }

  .statusbar .status-left,
  .statusbar .status-right {
    display: none;
  }

  .statusbar .dashboard-scope-filter {
    width: 100%;
    justify-content: center;
  }

  .statusbar .dashboard-scope-filter select {
    width: min(220px, 70vw);
    min-width: 150px;
    height: 32px;
  }

  /* Override saved desktop column widths so the phone customer-name column stays compact. */
  #customerTable [data-column="customer"] {
    width: 145px !important;
    min-width: 145px !important;
    max-width: 145px !important;
  }

  /* iPhone Safari: keep every Popular Products heading cell fixed as one row. */
  .summary-grid .top-scroll #topItemsTable thead th {
    position: -webkit-sticky;
    position: sticky !important;
    top: 0 !important;
    z-index: 6;
    background: #ffffff;
  }

  .summary-grid .top-scroll #topItemsTable thead th[data-column="rank"],
  .summary-grid .top-scroll #topItemsTable thead th[data-column="group"] {
    z-index: 9;
  }
}

/* Phone density: use the limited viewport for data instead of column whitespace. */
@media (max-width: 560px) {
  /* Keep order and monthly history on desktop, but omit them on phones. */
  .customer-detail .detail-grid {
    display: none !important;
  }

  .content {
    padding: 4px 4px max(14px, env(safe-area-inset-bottom));
    gap: 6px;
  }

  .grid,
  .mid-grid,
  .summary-grid,
  .bottom-grid,
  .detail-grid,
  .detail-brand-grid,
  .code-trend-grid {
    gap: 6px;
  }

  .summary-grid .top-panel .panel-head,
  .summary-grid .customer-panel .panel-head {
    padding: 7px 6px 6px;
  }

  .summary-grid .panel-tools {
    min-height: 28px;
    gap: 4px;
  }

  .summary-grid .mini-select,
  .summary-grid .metric-toggle {
    min-height: 28px;
    height: 28px;
  }

  .summary-grid .metric-toggle button {
    height: 24px;
    padding: 0 8px;
  }

  .summary-grid .table th,
  .summary-grid .table td {
    height: 28px;
    padding-right: 3px;
    padding-left: 3px;
  }

  #topItemsTable {
    width: 560px !important;
    min-width: 560px !important;
  }

  #topItemsTable [data-column="rank"],
  #customerTable [data-column="rank"] {
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
  }

  #topItemsTable [data-column="group"] {
    width: 116px !important;
    min-width: 116px !important;
    max-width: 116px !important;
    padding-right: 4px;
    padding-left: 4px;
  }

  #topItemsTable [data-column="qty"] {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
  }

  #topItemsTable [data-column="clicks"] {
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
  }

  #topItemsTable [data-column="previousQty"],
  #topItemsTable [data-column="averageQty"],
  #topItemsTable [data-column="customerCount"] {
    width: 54px !important;
    min-width: 54px !important;
    max-width: 54px !important;
  }

  #topItemsTable [data-column="latest"] {
    width: 90px !important;
    min-width: 90px !important;
    max-width: 90px !important;
  }

  #topItemsTable [data-column="share"] {
    width: 64px !important;
    min-width: 64px !important;
    max-width: 64px !important;
  }

  #customerTable {
    width: 430px !important;
    min-width: 430px !important;
  }

  body[data-kl-sales-amounts="true"] #customerTable {
    width: 500px !important;
    min-width: 500px !important;
  }

  #customerTable [data-column="customer"] {
    width: 132px !important;
    min-width: 132px !important;
    max-width: 132px !important;
    padding-right: 4px;
    padding-left: 4px;
  }

  #customerTable [data-column="sales"] {
    width: 70px !important;
    min-width: 70px !important;
    max-width: 70px !important;
  }

  #customerTable [data-column="previousQty"] {
    width: 54px !important;
    min-width: 54px !important;
    max-width: 54px !important;
  }

  #customerTable [data-column="value"] {
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
  }

  #customerTable [data-column="colourCount"] {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
  }

  #customerTable [data-column="share"],
  #customerTable [data-column="cumulative"] {
    width: 58px !important;
    min-width: 58px !important;
    max-width: 58px !important;
  }

  #topItemsTable th[data-column="group"],
  #topItemsTable td[data-column="group"],
  #customerTable th[data-column="customer"],
  #customerTable td[data-column="customer"] {
    left: 30px;
  }
}
