/* =========================================================
   page-daily-sales.css
   當日業績看板（v3 暖色系）
   依賴：ewoooc-tokens.css → ewoooc-tokens-v2-alias.css → ewoooc-shell.css
   ========================================================= */

.daily-sales-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--momo-text-primary);
  font-family: var(--momo-font-family);
  font-size: var(--momo-text-body);
  line-height: var(--momo-line-height-base);
}

/* ---------- Hero ---------- */
.daily-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--momo-border-strong);
  border-radius: 8px;
  background: var(--momo-bg-elevated);
}

.daily-hero__title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--momo-font-family);
  font-size: 26px;
  font-weight: 800;
  color: var(--momo-page-ink, var(--momo-text-primary));
  line-height: var(--momo-line-height-tight);
  letter-spacing: 0;
}

.daily-hero__title i {
  color: var(--momo-page-accent);
}

.daily-hero__subtitle {
  margin: 4px 0 0;
  color: var(--momo-text-secondary);
  font-size: var(--momo-text-body);
}

.daily-hero__subtitle code {
  padding: 2px 6px;
  background: var(--momo-page-accent-soft);
  border-radius: 4px;
  color: var(--momo-page-accent-dark);
  font-size: var(--momo-text-meta);
}

.daily-hero__controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
  min-width: 180px;
}

.daily-hero__label {
  font-size: var(--momo-text-label);
  color: var(--momo-text-secondary);
  font-weight: 600;
  letter-spacing: 0;
}

.daily-hero__controls .form-select {
  border: 1px solid var(--momo-border-strong);
  background: var(--momo-bg-surface);
  color: var(--momo-text-primary);
  font-weight: 600;
}

.daily-hero__controls .form-select:focus {
  border-color: var(--momo-page-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--momo-page-accent) 20%, transparent);
}

@media (max-width: 768px) {
  .daily-hero {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .daily-hero__controls {
    align-items: stretch;
  }
}

/* ---------- Empty / Error ---------- */
.empty-state {
  background: var(--momo-warning-bg);
  border: 1px solid var(--momo-warning-border);
  border-radius: 8px;
  padding: 2.4rem 2rem;
  text-align: center;
}

.empty-state__icon {
  font-size: 2.4rem;
  color: var(--momo-warning-text);
  margin-bottom: 0.8rem;
}

.empty-state__title {
  color: var(--momo-text-primary);
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.empty-state__hint {
  color: var(--momo-text-secondary);
  margin: 0;
}

.empty-state a {
  color: var(--momo-danger-text);
  font-weight: 700;
}

/* ---------- Calendar ---------- */
.daily-calendar {
  background: var(--momo-bg-elevated);
  border: 1px solid var(--momo-border-strong);
  border-radius: 8px;
  padding: 12px;
  overflow: hidden;
}

.daily-calendar__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--momo-border-light);
}

.daily-calendar__title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--momo-font-family);
  font-size: var(--momo-text-title);
  font-weight: 700;
  color: var(--momo-page-ink, var(--momo-text-primary));
  cursor: pointer;
  transition: color 180ms ease;
}

.daily-calendar__title:hover {
  color: var(--momo-page-accent);
}

.daily-calendar__title i {
  color: var(--momo-page-accent);
}

.daily-calendar__nav {
  display: flex;
  gap: 6px;
}

.btn-month {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--momo-bg-surface);
  color: var(--momo-text-primary);
  border: 1px solid var(--momo-border-strong);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.btn-month:hover {
  background: var(--momo-page-accent-soft);
  border-color: var(--momo-page-accent);
  color: var(--momo-page-accent-dark);
}

.daily-calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  border-top: 1px solid var(--momo-border-light);
  border-left: 1px solid var(--momo-border-light);
}

.daily-calendar__weekday {
  text-align: center;
  font-size: var(--momo-text-label);
  font-weight: 700;
  color: var(--momo-text-secondary);
  padding: 8px 6px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: var(--momo-bg-surface);
  border-right: 1px solid var(--momo-border-light);
  border-bottom: 1px solid var(--momo-border-light);
}

/* ---- 行事曆方格 ---- */
.cal-day {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 5px;
  background: var(--momo-bg-surface);
  border: 0;
  border-right: 1px solid var(--momo-border-light);
  border-bottom: 1px solid var(--momo-border-light);
  border-radius: 0;
  padding: 10px;
  min-height: 124px;
  cursor: default;
  transition: background 160ms ease, box-shadow 160ms ease;
}

.cal-day.has-data {
  cursor: pointer;
  background: var(--momo-bg-elevated);
}

.cal-day.has-data:hover {
  background: color-mix(in srgb, var(--momo-page-accent) 7%, var(--momo-bg-elevated));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--momo-page-accent) 45%, transparent);
}

.cal-day.is-other-month {
  opacity: 0.32;
  cursor: not-allowed;
}

.cal-day.is-weekend:not(.has-data) {
  background: color-mix(in srgb, var(--momo-text-primary) 4%, var(--momo-bg-surface));
}

.cal-day.is-holiday {
  border-color: var(--momo-tag-rust-border);
  background: var(--momo-tag-rust-bg);
}

.cal-day.is-holiday .cal-day__num {
  color: var(--momo-tag-rust-text);
}

.cal-day.is-selected {
  border-color: var(--momo-border-light) !important;
  background: color-mix(in srgb, var(--momo-page-accent) 12%, var(--momo-bg-surface)) !important;
  box-shadow: inset 0 0 0 2px var(--momo-page-accent) !important;
}

.cal-day.is-selected::before {
  content: '✓';
  position: absolute;
  top: 7px;
  right: 7px;
  width: 20px;
  height: 20px;
  background: var(--momo-page-accent);
  border: 1px solid var(--momo-bg-surface);
  border-radius: 6px;
  color: var(--momo-bg-surface);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 800;
  z-index: 4;
}

.cal-day__head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  min-height: 24px;
  margin-bottom: 0;
  padding-right: 48px;
}

.cal-day__num {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--momo-text-primary);
  font-family: var(--momo-font-mono, ui-monospace, monospace);
}

.cal-day__holiday {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--momo-tag-rust-text);
  background: var(--momo-tag-rust-bg);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

/* DoD badge：上漲暖紅 / 下跌暖綠橄欖 */
.cal-day__badge {
  position: absolute;
  top: 9px;
  right: 9px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--momo-font-mono, monospace);
}

.cal-day.dod-up .cal-day__badge {
  background: var(--momo-tag-rust-bg);
  color: var(--momo-tag-rust-text);
  border: 1px solid var(--momo-tag-rust-border);
}

.cal-day.dod-down .cal-day__badge {
  background: var(--momo-tag-olive-bg);
  color: var(--momo-tag-olive-text);
  border: 1px solid var(--momo-tag-olive-border);
}

.cal-day.dod-flat .cal-day__badge {
  background: var(--momo-tag-muted-bg);
  color: var(--momo-tag-muted-text);
  border: 1px solid var(--momo-tag-muted-border);
}

.cal-day__metric {
  display: grid;
  gap: 1px;
  align-self: end;
  min-width: 0;
}

.cal-day__metric-label {
  color: var(--momo-text-secondary);
  font-size: var(--momo-text-label);
  font-weight: 700;
}

.cal-day__metric strong {
  color: var(--momo-text-primary);
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  font-size: var(--momo-text-body-sm);
  font-weight: 800;
  line-height: 1.15;
}

.cal-day__metric--sub {
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 5px;
  padding-top: 4px;
  border-top: 1px dashed var(--momo-border-light);
}

.cal-day__metric--sub strong,
.cal-day__metric--sub span:last-child {
  font-size: 0.72rem;
}

.cal-day__metric--sub span:last-child {
  color: var(--momo-text-secondary);
  font-family: var(--momo-font-mono, ui-monospace, monospace);
}

.cal-day__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.cal-day__chips span {
  max-width: 100%;
  padding: 2px 5px;
  overflow: hidden;
  color: var(--momo-text-secondary);
  background: var(--momo-bg-paper);
  border: 1px solid var(--momo-border-light);
  border-radius: 4px;
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  font-size: 0.64rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-calendar-mobile-list {
  display: none;
}

.daily-mobile-day,
.daily-mobile-empty {
  color: var(--momo-text-primary);
  background: var(--momo-bg-surface);
  border: 1px solid var(--momo-border-light);
  border-radius: 8px;
}

.daily-mobile-day {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  text-decoration: none;
}

.daily-mobile-day:hover {
  color: var(--momo-text-primary);
  border-color: var(--momo-page-accent);
  background: color-mix(in srgb, var(--momo-page-accent) 6%, var(--momo-bg-surface));
}

.daily-mobile-day.is-selected {
  border-color: var(--momo-page-accent);
  box-shadow: inset 0 0 0 1px var(--momo-page-accent);
}

.daily-mobile-day__date {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.daily-mobile-day__date strong {
  color: var(--momo-text-primary);
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
}

.daily-mobile-day__date span {
  overflow: hidden;
  color: var(--momo-text-secondary);
  font-size: 0.76rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-mobile-day__trend {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 6px;
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  font-size: 0.72rem;
  font-weight: 800;
}

.daily-mobile-day__trend.dod-up {
  color: var(--momo-tag-rust-text);
  background: var(--momo-tag-rust-bg);
  border: 1px solid var(--momo-tag-rust-border);
}

.daily-mobile-day__trend.dod-down {
  color: var(--momo-tag-olive-text);
  background: var(--momo-tag-olive-bg);
  border: 1px solid var(--momo-tag-olive-border);
}

.daily-mobile-day__trend.dod-flat {
  color: var(--momo-tag-muted-text);
  background: var(--momo-tag-muted-bg);
  border: 1px solid var(--momo-tag-muted-border);
}

.daily-mobile-day__metric {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding-top: 2px;
}

.daily-mobile-day__metric span,
.daily-mobile-day__metric em {
  color: var(--momo-text-secondary);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 700;
}

.daily-mobile-day__metric strong {
  overflow: hidden;
  color: var(--momo-text-primary);
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  font-size: 0.95rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-mobile-day__chips {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  gap: 5px;
}

.daily-mobile-day__chips span {
  max-width: 100%;
  padding: 3px 6px;
  overflow: hidden;
  color: var(--momo-text-secondary);
  background: var(--momo-bg-paper);
  border: 1px solid var(--momo-border-light);
  border-radius: 4px;
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  font-size: 0.66rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-mobile-empty {
  padding: 14px;
  color: var(--momo-text-secondary);
  font-size: var(--momo-text-body-sm);
  text-align: center;
}

@media (max-width: 1024px) {
  .cal-day { min-height: 124px; padding: 8px; }
  .cal-day__num { font-size: 1rem; }
  .cal-day__metric strong { font-size: 0.82rem; }
}

@media (max-width: 900px) {
  .daily-calendar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px;
  }
  .daily-calendar__header {
    align-items: stretch;
    flex-direction: column;
  }
  .daily-calendar__nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .daily-calendar__grid { min-width: 820px; }
  .cal-day { min-height: 118px; padding: 8px; }
  .cal-day__chips span { font-size: 0.6rem; }
  .daily-calendar::after {
    content: '左右滑動查看完整行事曆';
    display: block;
    text-align: center;
    margin-top: 0.4rem;
    padding: 0.4rem;
    font-size: 0.7rem;
    color: var(--momo-text-secondary);
    background: color-mix(in srgb, var(--momo-text-primary) 5%, var(--momo-bg-surface));
    border-radius: 4px;
  }
}

@media (max-width: 767px) {
  .daily-calendar {
    overflow-x: hidden;
  }

  .daily-calendar__grid {
    display: none;
  }

  .daily-calendar-mobile-list {
    display: grid;
    gap: 8px;
  }

  .daily-calendar::after {
    content: none;
    display: none;
  }
}

/* ---------- Mode Banner ---------- */
.daily-mode-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0;
}

.badge-mode {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-size: var(--momo-text-body-sm);
  font-weight: 700;
  letter-spacing: 0;
}

.badge-mode--month {
  background: var(--momo-page-accent);
  color: var(--momo-page-inverse);
}

.badge-mode--single {
  background: var(--momo-warning-bg);
  color: var(--momo-warning-text);
  border: 1px solid var(--momo-warning-border);
}

.badge-mode--ghost {
  background: var(--momo-bg-paper);
  color: var(--momo-text-primary);
  border: 1px solid var(--momo-border-strong);
}

.daily-mode-banner__hint {
  color: var(--momo-text-secondary);
  font-size: var(--momo-text-body-sm);
}

.daily-mode-banner__link {
  color: var(--momo-page-accent-dark);
  font-weight: 700;
  font-size: var(--momo-text-body-sm);
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
}

.daily-mode-banner__link:hover {
  color: var(--momo-page-accent);
}

/* ---------- KPI Summary ---------- */
.daily-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.daily-kpi-slot {
  min-width: 0;
}

/* ---------- KPI Cards (semantic variants) ---------- */
.kpi-card {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--momo-bg-surface);
  border: 1px solid var(--momo-border-strong);
  box-shadow: var(--momo-shadow-md);
  transition: background 160ms ease, border-color 160ms ease;
  height: 100%;
  /* 左側 4px accent 條 */
  border-left-width: 4px;
}

.kpi-card:hover {
  border-color: var(--momo-page-accent-line);
  background: var(--momo-bg-elevated);
}

.kpi-card__body {
  position: relative;
  padding: 0.9rem 1rem;
  z-index: 1;
}

.kpi-card__label {
  font-size: var(--momo-text-label);
  font-weight: 700;
  letter-spacing: 0;
  color: var(--momo-text-secondary);
  margin-bottom: 0.4rem;
}

.kpi-card__value {
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  font-size: var(--momo-text-headline);
  font-weight: 800;
  letter-spacing: 0;
  color: var(--momo-page-ink, var(--momo-text-primary));
  line-height: 1.1;
  margin-bottom: 0.6rem;
}

.kpi-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.kpi-card__icon-bg {
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-size: 3.8rem;
  color: currentColor;
  opacity: 0.06;
  transform: rotate(-12deg);
  pointer-events: none;
}

/* variants：每張卡片用對應 token 著色，左 border + label + icon 同色 */
.kpi--revenue { border-left-color: var(--momo-page-accent); color: var(--momo-page-accent); }
.kpi--cost    { border-left-color: var(--momo-tag-honey);   color: var(--momo-tag-honey); }
.kpi--profit  { border-left-color: var(--momo-tag-olive-text);   color: var(--momo-tag-olive-text); }
.kpi--sku     { border-left-color: var(--momo-tag-muted-text);   color: var(--momo-tag-muted-text); }
.kpi--aov     { border-left-color: var(--momo-danger-text);      color: var(--momo-danger-text); }
.kpi--qty     { border-left-color: var(--momo-tag-clay-text);    color: var(--momo-tag-clay-text); }

.kpi-card .kpi-card__label,
.kpi-card .kpi-card__value {
  color: inherit;
}
.kpi-card__label { color: var(--momo-text-secondary); }
.kpi-card__value { color: var(--momo-page-ink, var(--momo-text-primary)); }

/* DoD/WoW pill */
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  font-size: var(--momo-text-meta);
  font-weight: 700;
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  background: var(--momo-bg-paper);
  border: 1px solid var(--momo-border-light);
}

.kpi-delta__label {
  font-family: var(--momo-font-display);
  font-size: var(--momo-text-label-tiny);
  letter-spacing: 0;
  color: var(--momo-text-secondary);
  text-transform: uppercase;
}

.kpi-delta.is-up {
  color: var(--momo-tag-rust-text);
  border-color: var(--momo-tag-rust-border);
  background: var(--momo-tag-rust-bg);
}

.kpi-delta.is-down {
  color: var(--momo-tag-olive-text);
  border-color: var(--momo-tag-olive-border);
  background: var(--momo-tag-olive-bg);
}

.kpi-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
  font-size: var(--momo-text-meta);
  font-weight: 700;
  background: var(--momo-bg-paper);
  color: var(--momo-text-primary);
  border: 1px solid var(--momo-border-light);
}

.kpi-tag--ghost {
  background: transparent;
  color: var(--momo-text-secondary);
}

/* ---------- Chart cards ---------- */
.chart-card {
  border-radius: 8px;
  border: 1px solid var(--momo-border-strong);
  background: var(--momo-bg-surface);
  box-shadow: var(--momo-shadow-md);
  height: 100%;
}

.chart-card .card-header {
  background: color-mix(in srgb, var(--momo-page-accent) 6%, var(--momo-bg-surface));
  border-bottom: 1px solid var(--momo-border-light);
  font-weight: 700;
  color: var(--momo-text-primary);
  padding: 0.85rem 1.2rem;
  font-size: 0.98rem;
  border-radius: 8px 8px 0 0;
}

.chart-card .card-header i {
  color: var(--momo-page-accent);
  margin-right: 0.4rem;
}

.daily-competitor-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.daily-competitor-summary > div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--momo-border-light);
  border-radius: 6px;
  background: var(--momo-bg-surface);
}

.daily-competitor-summary span,
.daily-competitor-risk-list span {
  display: block;
  color: var(--momo-text-secondary);
  font-size: 0.72rem;
}

.daily-competitor-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--momo-text-primary);
  font-size: clamp(1rem, 1.2vw, 1.35rem);
  overflow-wrap: anywhere;
}

.daily-competitor-risk-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 1.1rem;
}

.daily-competitor-risk-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--momo-border-light);
}

.daily-competitor-risk-list li:last-child {
  border-bottom: 0;
}

.daily-competitor-risk-list strong {
  color: var(--momo-danger-text);
}

.daily-competitor-risk-list--review {
  padding-left: 0;
  list-style: none;
}

.daily-competitor-risk-list--review strong {
  color: var(--momo-page-accent-dark);
  font-size: 0.78rem;
}

.daily-competitor-risk-list--review em {
  display: block;
  margin-top: 3px;
  color: var(--momo-text-muted);
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  font-size: 0.72rem;
  font-style: normal;
}

.card-header--split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.daily-table-count {
  display: inline-flex;
  margin-left: 0.5rem;
  color: var(--momo-text-tertiary);
  font-size: 0.76rem;
  font-weight: 700;
}

.daily-table-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-table-toggle {
  background: var(--momo-bg-surface);
  color: var(--momo-text-secondary);
  border: 1px solid var(--momo-border-light);
  border-radius: 6px;
  padding: 0.35rem 0.85rem;
  font-weight: 700;
  font-size: 0.82rem;
}

.btn-table-toggle:hover {
  background: var(--momo-bg-paper);
  color: var(--momo-text-primary);
  border-color: var(--momo-page-accent-line);
}

.btn-export {
  background: var(--momo-success-bg);
  color: var(--momo-success-text);
  border: 1px solid var(--momo-success-border);
  border-radius: 6px;
  padding: 0.35rem 0.85rem;
  font-weight: 600;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-export:hover {
  background: color-mix(in srgb, var(--momo-success) 14%, var(--momo-bg-surface));
  color: var(--momo-success-text);
}

.chart-container {
  position: relative;
  height: 320px;
}

.chart-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.chart-container.chart-fallback-active canvas {
  display: none !important;
}

.chart-container.chart-empty-active canvas {
  display: none !important;
}

.chart-empty-state {
  position: absolute;
  inset: var(--momo-space-4, 16px);
  border: 1px dashed var(--momo-page-accent-line);
  border-radius: var(--momo-radius-md, 6px);
  background: color-mix(in srgb, var(--momo-bg-paper) 86%, white);
  color: var(--momo-text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--momo-space-2, 8px);
  text-align: center;
  padding: var(--momo-space-4, 16px);
}

.chart-empty-state strong {
  color: var(--momo-text-primary);
  font-size: var(--momo-text-body, 16px);
  letter-spacing: 0;
}

.chart-empty-state span {
  max-width: 34rem;
  font-size: var(--momo-text-caption, 12px);
  line-height: 1.6;
  letter-spacing: 0;
}

.chart-fallback-bars {
  position: absolute;
  inset: 0;
  padding: 1rem;
  color: var(--momo-text-primary);
}

.chart-fallback-bars.is-vertical {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.chart-fallback-bars.is-horizontal {
  display: grid;
  gap: 0.55rem;
  align-content: center;
}

.chart-fallback-bar {
  min-width: 0;
  color: var(--momo-text-secondary);
}

.chart-fallback-bars.is-vertical .chart-fallback-bar {
  position: relative;
  flex: 1 1 0;
  height: var(--bar-h);
  border-radius: 6px 6px 2px 2px;
  background: color-mix(in srgb, var(--momo-page-accent) 72%, white);
  border: 1px solid var(--momo-page-accent-line);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.35rem 0.25rem;
}

.chart-fallback-bars.is-horizontal .chart-fallback-bar {
  display: grid;
  grid-template-columns: minmax(88px, 0.42fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
}

.chart-fallback-bars.is-horizontal .chart-fallback-bar::before {
  content: "";
  height: 16px;
  width: var(--bar-w);
  min-width: 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--momo-page-accent) 72%, white);
  border: 1px solid var(--momo-page-accent-line);
}

.chart-fallback-bar.is-negative {
  background: color-mix(in srgb, var(--momo-danger-bg) 84%, white);
}

.chart-fallback-bar.is-negative::before {
  background: color-mix(in srgb, var(--momo-danger-bg) 84%, white);
}

.chart-fallback-label,
.chart-fallback-value {
  font-family: var(--momo-font-mono);
  font-size: var(--momo-text-caption, 12px);
  letter-spacing: 0;
}

.chart-fallback-value {
  color: var(--momo-text-primary);
}

.chart-fallback-list {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--momo-space-2, 8px);
  align-content: center;
  padding: var(--momo-space-3, 12px);
}

.chart-fallback-item {
  min-width: 0;
  border: 1px solid var(--momo-page-accent-line);
  border-radius: var(--momo-radius-md, 6px);
  background: color-mix(in srgb, var(--momo-page-accent-soft) 72%, white);
  padding: var(--momo-space-2, 8px);
  display: flex;
  justify-content: space-between;
  gap: var(--momo-space-2, 8px);
}

.chart-fallback-item b,
.chart-fallback-item strong {
  min-width: 0;
  font-family: var(--momo-font-mono);
  font-size: var(--momo-text-caption, 12px);
  letter-spacing: 0;
}

.chart-fallback-item b {
  color: var(--momo-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-fallback-item strong {
  color: var(--momo-text-primary);
  white-space: nowrap;
}

.chart-container--md { height: 350px; }

.chart-container:not(.chart-fallback-active) .chart-fallback-bars,
.chart-container:not(.chart-fallback-active) .chart-fallback-list {
  display: none !important;
}

.chart-container:not(.chart-empty-active) .chart-empty-state {
  display: none !important;
}

.chart-container.chart-fallback-active .chart-fallback-list {
  display: grid;
}

.chart-container.chart-fallback-active .chart-fallback-bars.is-vertical {
  display: flex;
}

.chart-container.chart-fallback-active .chart-fallback-bars.is-horizontal {
  display: grid;
}

.chart-responsive {
  min-width: 0;
  overflow: hidden;
}

#top10ChartContainer {
  min-width: 0;
  width: 100%;
}

.chart-mobile-hint {
  background: var(--momo-page-accent-soft);
  border: 1px solid var(--momo-page-accent-line);
  color: var(--momo-page-accent-dark);
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  font-size: 0.8rem;
  margin-bottom: 0.8rem;
}

.chart-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--momo-text-secondary);
}

.chart-empty i {
  font-size: 1.8rem;
  margin-bottom: 0.6rem;
  display: block;
  color: color-mix(in srgb, var(--momo-text-secondary) 60%, transparent);
}

.marketing-subhead {
  font-weight: 700;
  color: var(--momo-text-primary);
  margin-bottom: 0.8rem;
  font-size: 0.95rem;
}

.marketing-subhead i {
  color: var(--momo-page-accent);
  margin-right: 0.35rem;
}

/* ---------- Category Table ---------- */
#categoryTable {
  border-radius: 8px;
  overflow: hidden;
}

#categoryTable thead {
  background: color-mix(in srgb, var(--momo-page-accent) 10%, var(--momo-bg-surface));
}

#categoryTable thead th {
  border: none;
  padding: 0.85rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--momo-text-primary);
  border-bottom: 2px solid var(--momo-page-accent);
}

#categoryTable tbody tr {
  transition: background 180ms ease;
}

#categoryTable tbody tr:hover {
  background: color-mix(in srgb, var(--momo-page-accent) 6%, var(--momo-bg-surface));
}

#categoryTable tbody td {
  padding: 0.7rem 0.9rem;
  vertical-align: middle;
  color: var(--momo-text-primary);
  border-bottom: 1px solid var(--momo-border-light);
}

#categoryTable td.num {
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

@media (max-width: 767px) {
  .daily-sales-page .table-responsive {
    max-width: 100%;
    overflow: hidden;
  }

  .daily-sales-page .table-responsive * {
    min-width: 0;
    max-width: 100%;
  }

  #categoryTable_wrapper > .row {
    --bs-gutter-x: 0;
    margin-right: 0;
    margin-left: 0;
    gap: 8px;
  }

  #categoryTable_wrapper [class*="col-"] {
    padding-right: 0;
    padding-left: 0;
  }

  #categoryTable_wrapper .dataTables_length,
  #categoryTable_wrapper .dataTables_filter,
  #categoryTable_wrapper .dataTables_info,
  #categoryTable_wrapper .dataTables_paginate {
    width: 100%;
    text-align: left;
  }

  #categoryTable_wrapper .dataTables_length label,
  #categoryTable_wrapper .dataTables_filter label {
    display: grid;
    width: 100%;
    gap: 4px;
  }

  #categoryTable_wrapper .dataTables_length select,
  #categoryTable_wrapper .dataTables_filter input {
    width: 100%;
    margin-left: 0;
  }

  #categoryTable,
  #categoryTable thead,
  #categoryTable tbody,
  #categoryTable tr,
  #categoryTable td {
    display: block;
    width: 100%;
  }

  #categoryTable thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  #categoryTable tbody {
    display: grid;
    gap: 10px;
    padding: 10px 0;
    background: var(--momo-bg-paper);
  }

  #categoryTable tbody tr {
    background: var(--momo-bg-surface);
    border: 1px solid var(--momo-border-light);
    border-radius: 8px;
    overflow: hidden;
  }

  #categoryTable tbody td {
    display: grid;
    grid-template-columns: minmax(82px, 0.36fr) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    min-height: 38px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--momo-border-light);
    font-size: 0.78rem;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  #categoryTable tbody td:last-child {
    border-bottom: 0;
  }

  #categoryTable tbody td::before {
    content: attr(data-label);
    color: var(--momo-text-tertiary);
    font-family: var(--momo-font-mono, ui-monospace, monospace);
    font-size: 0.66rem;
    font-weight: 800;
  }

  #categoryTable td.num {
    text-align: left;
  }
}

/* ---------- Mobile KPI compaction ---------- */
@media (max-width: 1200px) {
  .daily-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  .daily-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card__value { font-size: 1.2rem; }
  .kpi-card__label { font-size: 0.7rem; }
  .kpi-card__icon-bg {
    right: 8px;
    bottom: 8px;
    font-size: 2.8rem;
  }
  .chart-container { height: 250px; }
}

@media (max-width: 340px) {
  .daily-kpi-grid { grid-template-columns: 1fr; }
}

@media (max-width: 575px) {
  .chart-container { height: 220px; }
  #top10ChartContainer { min-width: 0; }
}
