/* Daily Sales v2 — page-specific styles (ds- prefix)
   Aligned to ai_reference/design_system/design-system.md, with one documented
   exception: the 42px Revenue hero on the headline card. */

.ds-page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px 24px;
  background: var(--bg);
}

/* ============================================================
   HEADER ROW
   ============================================================ */
.ds-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.ds-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
  letter-spacing: -0.2px;
}

.ds-date-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ds-date-form { display: inline-flex; align-items: center; }

.ds-date-input {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ds-date-input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(26, 26, 26, 0.08);
}

.ds-date-display {
  font-size: 13px;
  color: var(--muted);
}

/* Gross/Net Toggle */
.ds-toggle {
  display: inline-flex;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 3px;
}

.ds-toggle-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 16px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  min-height: 30px;
}
.ds-toggle-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(26, 26, 26, 0.12);
}
.ds-toggle-btn--active {
  background: var(--ink);
  color: #ffffff;
}

/* ============================================================
   CARD BASE
   ============================================================ */
.ds-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 14px;
}

/* ============================================================
   HEADLINE CARD (Revenue hero + 3-col mini-KPIs)
   ============================================================ */
.ds-headline {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  align-items: stretch;
}

.ds-hero-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Documented exception: 42px hero metric — design bundle README override of
   design-system.md's 32px cap. Scoped to this one page only. */
.ds-hero-value {
  font-family: 'DM Sans', sans-serif;
  font-size: 42px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 12px;
}

.ds-hero-benchmarks {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}
.ds-hero-benchmarks .ds-bm-row { display: inline-flex; gap: 6px; align-items: baseline; }

.ds-kpi-group {
  padding-left: 28px;
  border-left: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.ds-kpi {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ds-kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ds-kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
  margin-bottom: 10px;
}

.ds-kpi-benchmarks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
}

.ds-bm-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}
.ds-bm-label { color: var(--muted); }
.ds-delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.ds-delta--pos { color: var(--green); }
.ds-delta--neg { color: var(--red); }
.ds-delta--new { color: var(--blue); }
.ds-delta--neutral { color: var(--muted); }

/* Discount info tooltip (focus + hover) */
.ds-info {
  display: inline-flex;
  align-items: center;
  color: #b0aead;
  position: relative;
  cursor: help;
  outline: none;
}
.ds-info:focus-visible { color: var(--muted); }
.ds-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  max-width: 260px;
  padding: 8px 10px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.ds-info:hover .ds-tooltip,
.ds-info:focus .ds-tooltip,
.ds-info:focus-visible .ds-tooltip {
  opacity: 1;
}

/* ============================================================
   BREAKDOWN CARD (ranked stacked bar + 4-col legend)
   ============================================================ */
.ds-breakdown-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.ds-breakdown-title { font-size: 13px; font-weight: 700; color: var(--ink); }
.ds-breakdown-summary {
  font-size: 11px;
  color: var(--muted);
}
.ds-breakdown-summary .ds-mono {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--ink);
}

.ds-stacked-bar {
  display: flex;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.ds-bar-segment {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.4);
  transition: width 0.25s;
}
.ds-bar-segment:last-child { border-right: 0; }

/* Ranked warm palette — CHART-SCOPED EXCEPTION (dataviz ordinal, not status).
   design-system §2 says --accent is "NOT for status", which still holds;
   this is revenue-rank coloring on a stacked bar. Do NOT globalize these. */
.ds-bar-segment--rank-1 { background: #e54d2e; color: #ffffff; }
.ds-bar-segment--rank-2 { background: #f59e0b; color: #1a1a1a; }
.ds-bar-segment--rank-3 { background: #fcd7a0; color: #5a3a1a; }
.ds-bar-segment--rank-4 { background: #f3e7d3; color: #8a6a3a; }
.ds-bar-segment--rank-5 { background: #ece9e1; color: #8a6a3a; }

.ds-bar-pct {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.ds-legend {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  row-gap: 10px;
  column-gap: 20px;
  margin-top: 16px;
}

.ds-legend-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.ds-legend-swatch {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-top: 3px;
}
.ds-legend-swatch--bordered { border: 1px solid #d4d2cd; }

.ds-legend-text { min-width: 0; flex: 1; }
.ds-legend-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-legend-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.ds-empty-row {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 18px 0;
}

/* ============================================================
   MOVEMENT TABLES ROW (Top / Biggest Drops)
   ============================================================ */
.ds-movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.ds-movers-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.ds-movers-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.ds-movers-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}
.ds-movers-arrow--up { color: var(--green); display: inline-flex; }
.ds-movers-arrow--down { color: var(--red); display: inline-flex; }

.ds-movers-table { display: block; }

.ds-movers-thead,
.ds-movers-row {
  display: grid;
  grid-template-columns: 1fr 70px 50px 70px;
  align-items: center;
}

.ds-movers-thead {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--light);
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.ds-movers-thead > span:not(:first-child) { text-align: right; }

.ds-movers-row {
  font-size: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #f5f4f2;
  color: var(--ink);
}
.ds-movers-row:last-child { border-bottom: 0; }
.ds-movers-row:hover { background: #fafaf8; }

.ds-movers-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}
.ds-movers-rev,
.ds-movers-units,
.ds-movers-change {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}
.ds-movers-units { color: var(--muted); }
.ds-movers-change { font-weight: 600; }

/* ============================================================
   PRODUCT TABLE (standard design-system §10)
   ============================================================ */
.ds-product-card { padding: 0; overflow: hidden; }

.ds-product-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.ds-product-title { font-size: 13px; font-weight: 700; color: var(--ink); }
.ds-product-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
.ds-product-icon { color: var(--muted); display: inline-flex; }

.ds-product-scroll { overflow-x: auto; }

.ds-product-thead,
.ds-product-row,
.ds-product-footer {
  display: grid;
  grid-template-columns: 1fr 100px 140px;
  align-items: center;
}

.ds-product-thead {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--light);
  background: #fafaf8;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-light);
}
.ds-product-thead > span:not(:first-child) { text-align: right; }

.ds-product-row {
  font-size: 12px;
  padding: 9px 18px;
  border-bottom: 1px solid #f5f4f2;
  color: var(--ink);
  text-decoration: none;
  transition: background-color 0.1s;
}
.ds-product-row:hover { background: #fafaf8; }
.ds-product-row:last-of-type { border-bottom: 0; }

.ds-product-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 12px;
  color: var(--ink);
}
.ds-product-units,
.ds-product-revenue {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}
.ds-product-units { color: var(--muted); }
.ds-product-revenue { font-weight: 600; }

.ds-product-footer {
  font-size: 12px;
  font-weight: 700;
  background: #fafaf8;
  padding: 10px 18px;
  color: var(--ink);
}
.ds-product-footer > span:not(:first-child) {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

.ds-product-empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ============================================================
   RESPONSIVE (< 768px)
   ============================================================ */
@media (max-width: 767px) {
  .ds-page {
    padding: 20px 12px;
  }

  .ds-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .ds-toggle-btn {
    padding: 8px 18px;
    min-height: 44px;
  }

  .ds-headline {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .ds-kpi-group {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--border);
    padding-top: 18px;
    gap: 14px;
  }

  .ds-hero-value { font-size: 36px; }

  .ds-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
  }

  .ds-movers-grid {
    grid-template-columns: 1fr;
  }

  .ds-movers-thead,
  .ds-movers-row {
    grid-template-columns: 1fr 64px 44px 64px;
  }
}
