.client-dashboard .rail-bottom strong {
  color: var(--teal);
  font-weight: 600;
}

.client-header {
  align-items: flex-end;
}

.client-date {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid var(--rule);
  background: var(--white);
  color: var(--muted);
  font-size: 12px;
}

.client-overview {
  padding-top: 24px;
}

.overview-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.overview-bar h2 {
  margin: 0;
}

.store-periods {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 4px;
  background: #e8e8e1;
}

.store-periods button {
  padding: 7px 17px;
  border-color: transparent;
  background: transparent;
}

.store-periods button[aria-pressed="true"] {
  border-color: var(--rule);
  background: var(--white);
  font-weight: 600;
}

.period-control {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.custom-period {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.custom-period[hidden] { display: none; }
.custom-period label { display: grid; gap: 3px; color: var(--muted); font-size: 11px; }
.custom-period input { min-height: 34px; padding: 5px 8px; border: 1px solid var(--rule); background: var(--white); color: var(--ink); font: inherit; }
.custom-period button { min-height: 34px; padding: 6px 15px; background: var(--teal); color: var(--white); border-color: var(--teal); }
.custom-period button:disabled { opacity: .55; cursor: wait; }
.custom-status { min-height: 17px; margin: 0; color: var(--muted); font-size: 11px; }

.client-dashboard .metric .value {
  display: block;
  margin: 6px 0 4px;
  font-size: clamp(23px, 2.2vw, 31px);
  font-weight: 600;
  letter-spacing: -.025em;
  white-space: nowrap;
}

.metric-scope {
  color: var(--muted);
  font-size: 11px;
}

.client-dashboard .secondary > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
  font-size: 12px;
}

.client-dashboard .secondary strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
}

.focus-stores {
  margin-top: 42px;
  padding-top: 18px;
  border-top: 1px solid var(--ink);
}

.store-count {
  color: var(--teal);
  font-size: 12px;
  font-weight: 600;
}

.store-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.store-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--rule);
  border-top: 3px solid var(--teal);
  background: var(--white);
}

.store-card-unavailable {
  border-top-color: var(--red);
}

.store-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}

.store-card h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.02em;
}

.store-card-head p {
  max-width: 47ch;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.store-state {
  flex: 0 0 auto;
  padding: 3px 7px;
  color: var(--red);
  background: #f4e8e1;
  font-size: 11px;
}

.store-money {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}

.store-money.live-money {
  grid-template-columns: 2fr 1fr 1fr;
}

.store-live { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.store-live h4 { margin: 0 0 8px; font-size: 13px; }
.store-live p { margin: 0; color: var(--muted); font-size: 12px; }
.store-live ul { margin: 0; padding: 0; list-style: none; }
.store-live li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 6px 0; font-size: 12px; }
.store-live li span { min-width: 0; overflow-wrap: anywhere; }
.store-live li strong { white-space: nowrap; font-variant-numeric: tabular-nums; }

.store-money > div {
  min-width: 0;
  padding: 0 11px;
}

.store-money > div:first-child {
  padding-left: 0;
}

.store-money > div + div {
  border-left: 1px solid var(--rule);
}

.store-money span,
.store-counts > span,
.store-channels > span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.store-money strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  font-size: clamp(15px, 1.25vw, 19px);
  font-weight: 600;
  text-overflow: ellipsis;
}

.store-counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 13px 0 7px;
}

.store-counts strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.store-channels {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 12px;
  min-height: 27px;
  padding: 6px 0 10px;
}

.store-channels > span {
  margin-right: auto;
}

.store-channels b {
  font-size: 11px;
  font-weight: 500;
}

.store-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
}

.store-copy,
.store-open {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 0;
  background: transparent;
  color: var(--teal);
}

.store-copy {
  border-color: var(--rule);
}

.store-copy.copied {
  border-color: var(--teal);
  background: #e6eee8;
  font-weight: 600;
}

.store-copy:hover,
.store-open:hover {
  background: #eeeee7;
  color: var(--ink);
}

.store-reason {
  min-height: 92px;
  margin: 0;
  padding: 18px 0;
  color: var(--red);
}

.customer-analysis {
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
}

.ranking-rows {
  padding-top: 11px;
}

.rank-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
}

.rank-index {
  color: var(--muted);
  font-size: 12px;
}

.rank-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
  font-size: 12px;
}

.rank-label strong {
  font-weight: 600;
}

.rank-label span {
  color: var(--muted);
}

.rank-bar,
.channel-track {
  height: 5px;
  background: #e4e4dc;
}

.rank-bar i,
.channel-track i {
  display: block;
  height: 100%;
  background: var(--teal);
}

.channels-section {
  margin-top: 38px;
  padding-top: 18px;
  border-top: 1px solid var(--ink);
}

.customer-channels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px 30px;
}

.customer-channel {
  padding: 10px 0;
}

.channel-label {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
  font-size: 12px;
}

.channel-label strong {
  font-weight: 600;
}

.channel-label span {
  color: var(--muted);
}

.detail-name {
  margin: 18px 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.detail-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 20px 0 28px;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
}

.detail-metrics > div {
  padding: 13px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.detail-metrics span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.detail-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
  font-weight: 600;
}

.detail-channels > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 12px;
}

.detail-channels strong {
  font-weight: 600;
}

@media (min-width: 1500px) {
  .store-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .store-money {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .store-money > div {
    padding: 10px 12px;
  }

  .store-money > div:nth-child(odd) {
    padding-left: 0;
    border-left: 0;
  }

  .store-money > div:nth-child(n+3) {
    border-top: 1px solid var(--rule);
  }

  .store-money.live-money {
    grid-template-columns: 1.6fr 1fr 1fr;
  }

  .store-money.live-money > div,
  .store-money.live-money > div:nth-child(n+3) {
    padding: 10px 8px;
    border-top: 0;
  }

  .store-money.live-money > div:first-child {
    padding-left: 0;
  }

  .store-money.live-money > div:nth-child(3) {
    border-left: 1px solid var(--rule);
  }
}

@media (max-width: 800px) {
  html {
    scroll-padding-top: 105px;
  }

  .rail {
    position: sticky;
    top: 0;
    z-index: 8;
    display: block;
    width: auto;
    padding: max(10px, env(safe-area-inset-top)) 14px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .rail .brand {
    margin-bottom: 7px;
  }

  .rail .region,
  .rail-bottom {
    display: none;
  }

  .rail nav {
    display: flex;
    flex-direction: row;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .rail nav::-webkit-scrollbar {
    display: none;
  }

  .rail nav a,
  .rail nav a:nth-child(2),
  .rail nav a:nth-child(3) {
    display: block;
    flex: 1 0 auto;
    min-height: 44px;
    padding: 11px 12px;
    border: 1px solid var(--rule);
    background: var(--paper);
  }

  main {
    margin: 0;
    padding: 22px max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  .client-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .client-header p {
    max-width: none;
  }

  .client-date {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .overview-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .store-periods {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
  }

  .period-control { width: 100%; justify-items: stretch; }
  .custom-period { justify-content: flex-start; }
  .custom-period label { flex: 1 1 125px; }
  .custom-period input { width: 100%; min-height: 44px; }
  .custom-period button { min-height: 44px; }
  .custom-status { text-align: left; }

  .store-periods button {
    min-width: 0;
    min-height: 44px;
    padding-inline: 8px;
  }

  .store-cards,
  .customer-channels {
    grid-template-columns: 1fr;
  }

  .store-card {
    padding: 16px;
  }

  .store-money strong {
    font-size: 18px;
  }

  .store-copy,
  .store-open,
  select,
  .trace button {
    min-height: 44px;
  }

  .customer-analysis {
    grid-template-columns: 1fr;
  }

  .trace {
    width: 100%;
    padding-right: max(18px, env(safe-area-inset-right));
    padding-left: max(18px, env(safe-area-inset-left));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 25px;
  }

  .client-dashboard .ledger {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .client-dashboard .metric {
    padding: 15px 12px 15px 0;
  }

  .client-dashboard .metric + .metric {
    padding-left: 12px;
  }

  .client-dashboard .metric:nth-child(3) {
    padding-left: 0;
    border-top: 1px solid var(--rule);
    border-left: 0;
  }

  .client-dashboard .metric:nth-child(4) {
    border-top: 1px solid var(--rule);
  }

  .client-dashboard .metric .value {
    font-size: 22px;
  }

  .client-dashboard .secondary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .store-card-head {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

@media print {
  .store-periods,
  .store-copy,
  .store-open,
  .trace {
    display: none;
  }

  .store-cards,
  .customer-channels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .store-card {
    break-inside: avoid;
  }
}
