/* Patterns (S-04): profit calendar, Check this week, margin heatmap, sales against margin. */
.only-phone { display: none; }

/* ---- profit calendar */
.card--cal { flex: 1.5 1 560px; }
.cal-scroll { overflow-x: auto; }
.cal { width: 100%; min-width: 560px; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.cal th { padding: var(--space-1) 6px; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-muted); text-align: left; }
.cal .cal-week { width: 104px; }
.cal td { padding: 0; }
.cal td.cal-week { padding: var(--space-2); border-left: 2px solid var(--line); vertical-align: middle; }
.cal-week__total { display: block; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; line-height: 18px; font-weight: 600; }
.cal-week__note { display: block; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.cal-day {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-1);
  width: 100%;
  min-height: 64px;
  margin: 0;
  padding: 6px var(--space-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: left;
  cursor: default;
}
.cal-day--0 { background: color-mix(in srgb, var(--insights) 8%, var(--surface-raised)); color: var(--ink); }
.cal-day--1 { background: color-mix(in srgb, var(--insights) 20%, var(--surface-raised)); color: var(--ink); }
.cal-day--2 { background: color-mix(in srgb, var(--insights) 36%, var(--surface-raised)); color: var(--ink); }
.cal-day--3 { background: var(--insights); color: var(--on-insights); }
.cal-day__top { display: flex; justify-content: space-between; align-items: center; width: 100%; font-size: 12px; line-height: 16px; font-weight: 600; }
.cal-day__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; line-height: 18px; font-weight: 600; }
.cal-day:focus-visible, .hm-cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; box-shadow: none; }
@media (hover: hover) and (pointer: fine) {
  .cal-day:hover, .hm-cell:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
}
.sale-mark { display: inline-block; width: 8px; height: 8px; border-radius: 2px; border: 1.5px solid currentColor; }
.legend .sale-mark { border-color: var(--ink); }
.legend__title { font-weight: 600; color: var(--ink); }
.swatch--cal { border: 1px solid var(--line); }

/* ---- check this week */
.card--alerts { flex: 1 1 380px; gap: var(--space-1); }
.card--alerts .card-sub { padding-bottom: var(--space-2); }
.alerts { list-style: none; margin: 0; padding: 0; }
.alert { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4) 0; border-top: 1px solid var(--line); }
.alert:last-child { padding-bottom: 0; }
.alert__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 13px; line-height: 18px; font-weight: 600; }
.pill--danger { background: var(--danger-soft); color: var(--danger); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--ok { background: var(--ok-soft); color: var(--ok); }
.alert__stake { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; line-height: 18px; font-weight: 600; }
.alert__stake--danger { color: var(--danger); }
.alert__stake--warn { color: var(--warn); }
.alert__title { font-size: 15px; line-height: 22px; font-weight: 600; }
.alert__body { font-size: 14px; line-height: 21px; color: var(--ink-muted); }
.btn-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--insights);
  border-radius: var(--radius-md);
  color: var(--insights);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
@media (hover: hover) and (pointer: fine) {
  .btn-link:hover { background: var(--insights-soft); }
}

/* ---- margin heatmap */
.card--hm { flex: 1 1 520px; }
.hm-scroll { overflow-x: auto; }
.hm { width: 100%; min-width: 480px; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.hm th { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-muted); }
.hm .hm__product { text-align: left; vertical-align: bottom; }
.hm .hm__mp { width: 92px; text-align: center; padding-bottom: var(--space-1); border-bottom: 2px solid transparent; }
.hm .hm__mp.is-selected { color: var(--insights); border-bottom-color: var(--insights); }
.hm td { padding: 0; }
.hm .hm__name { text-align: left; font-size: 13px; line-height: 18px; color: var(--ink); }
.hm__name .num-badge { margin-right: var(--space-2); vertical-align: middle; }
.num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-sunken);
  color: var(--ink);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 600;
}
.num-badge--blank { visibility: hidden; }
.hm-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 6px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  cursor: default;
}
.hm-cell--loss { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.hm-cell--thin { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); }
.hm-cell--b1 { background: color-mix(in srgb, var(--insights) 14%, var(--surface-raised)); color: var(--ink); border: 1px solid var(--line); }
.hm-cell--b2 { background: color-mix(in srgb, var(--insights) 34%, var(--surface-raised)); color: var(--ink); border: 1px solid var(--line); }
.hm-cell--b3 { background: var(--insights); color: var(--on-insights); border: 1px solid var(--insights); }

/* ---- sales against margin */
.card--qd { flex: 1 1 480px; }
.qd { display: flex; gap: var(--space-2); }
.qd__y { flex: 0 0 36px; position: relative; height: 300px; }
.qd__ytick { position: absolute; right: 0; transform: translateY(50%); font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.qd__plot { flex: 1 1 auto; min-width: 0; position: relative; height: 300px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper); overflow: hidden; }
.qd__grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); opacity: 0.6; }
.qd__zero { position: absolute; left: 0; right: 0; border-top: 1px solid var(--ink); }
.qd__zero-label { position: absolute; left: var(--space-2); font-size: 11px; line-height: 14px; color: var(--ink-muted); }
.bubble {
  position: absolute;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 600;
  cursor: default;
  background: color-mix(in srgb, var(--insights) 45%, var(--surface-raised));
  border: 2px solid var(--insights);
  color: var(--ink);
  transition: left 300ms cubic-bezier(0.77, 0, 0.175, 1), bottom 300ms cubic-bezier(0.77, 0, 0.175, 1),
    width 300ms cubic-bezier(0.77, 0, 0.175, 1), height 300ms cubic-bezier(0.77, 0, 0.175, 1);
}
/* A 44px hit area around small circles. */
.bubble::before { content: ''; position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; transform: translate(-50%, -50%); border-radius: 999px; }
.bubble--loss { background: var(--danger-soft); border: 2px dashed var(--danger); color: var(--danger); }
.bubble:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; box-shadow: none; z-index: 1; }
@media (hover: hover) and (pointer: fine) {
  .bubble:hover { outline: 2px solid var(--ink); outline-offset: 1px; z-index: 1; }
}
.qd__x { display: flex; justify-content: space-between; padding-left: 44px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.qd__axes { padding-left: 44px; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.qd__key { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: 13px; line-height: 18px; }
.qd__key li { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.qd__key .num-badge { width: 20px; height: 20px; flex-basis: 20px; font-size: 11px; }

@media (max-width: 599px) {
  .only-wide { display: none; }
  .only-phone { display: inline; }
  .cal-day .only-phone { display: block; }
  .card--cal { order: 8; }
  .card--alerts { order: 9; }
  .card--hm { order: 10; }
  .card--qd { display: none; }
  .cal { min-width: 0; border-spacing: 2px; }
  .cal th { padding: 2px 0; text-align: center; font-size: 11px; line-height: 14px; }
  .cal .cal-week { display: none; }
  .cal-day { min-height: 52px; padding: var(--space-1) 5px; }
  .cal-day__top { font-size: 10px; line-height: 12px; }
  .cal-day__value { font-size: 12px; line-height: 16px; }
  .sale-mark { width: 6px; height: 6px; }
  .alert { gap: 6px; padding: 14px 0; }
  .alert__title { font-size: 15px; line-height: 21px; }
  .hm { min-width: 0; }
  .hm .hm__mp { width: 64px; font-size: 11px; }
  .hm .hm__name { font-size: 12px; line-height: 16px; }
  .hm__name .num-badge { width: 20px; height: 20px; font-size: 11px; margin-right: 6px; }
  .hm-cell { padding: 0 2px; font-size: 12px; }
}

/* Under 400px the calendar card runs to the screen edges so seven day cells stay at least 44px wide. */
@media (max-width: 399px) {
  figure.card--cal { margin: 0 calc(-1 * var(--space-4)); border-left: 0; border-right: 0; border-radius: 0; }
}
