/* Sales analysis workspace · 2026-10-01
 * Scope: hierarchy, controls, responsive layout, and interaction states.
 */

.revenue-page {
  --revenue-surface-muted: #f8fafc;
  --revenue-surface-selected: #eaf2ff;
  --revenue-ink-strong: #0f172a;
  --revenue-control-height: 38px;
}

.revenue-subnav {
  margin-bottom: 16px;
}

.revenue-subnav a,
.revenue-kpi,
.revenue-day-average-card {
  box-shadow: none;
}

.revenue-subnav a {
  min-height: 66px;
  justify-content: center;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.revenue-subnav a.active {
  background: var(--revenue-surface-selected);
  border-color: rgba(20, 110, 245, .4);
  box-shadow: inset 3px 0 0 var(--brand);
}

.revenue-subnav a.active strong {
  color: var(--brand);
}

.revenue-subnav a.active span {
  color: #52677f;
}

.revenue-hero-toolbar {
  display: grid;
  grid-template-columns: minmax(230px, .7fr) minmax(0, 2.3fr);
  align-items: center;
  gap: 16px 24px;
  padding: 18px 20px;
  border-top: 3px solid var(--brand);
  box-shadow: none;
}

.revenue-hero-title {
  min-width: 0;
}

.revenue-hero-title h2 {
  font-size: 18px;
}

.revenue-hero-title p {
  flex-wrap: wrap;
  line-height: 1.45;
}

.revenue-baseline {
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  white-space: nowrap;
}

#revenueRange {
  display: inline-block;
  white-space: nowrap;
}

.revenue-ctrl-group {
  display: grid;
  grid-template-columns: max-content max-content minmax(170px, 1fr) minmax(142px, max-content) max-content;
  align-items: center;
  justify-content: end;
  gap: 8px;
  min-width: 0;
}

.revenue-overview-controls {
  grid-template-columns: minmax(0, 1fr);
  justify-items: stretch;
}

.revenue-overview-controls .revenue-mode-buttons {
  justify-self: start;
}

.revenue-overview-date-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.revenue-overview-date-row > label {
  min-width: 0;
  flex: 1 1 auto;
}

.revenue-overview-date-row .revenue-btn-primary {
  flex: 0 0 auto;
  margin-left: auto;
}

.revenue-ctrl-group label {
  min-width: 0;
}

.revenue-merchant-control,
.revenue-merchant-control input,
.revenue-merchant-control select {
  width: 100%;
  min-width: 0;
}

.revenue-merchant-control {
  position: relative;
}

.revenue-merchant-suggestions {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(24, 32, 47, .14);
}

.revenue-merchant-suggestions button {
  display: flex;
  width: 100%;
  min-height: 44px;
  padding: 7px 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
}

.revenue-merchant-suggestions button:hover,
.revenue-merchant-suggestions button:focus-visible {
  background: #f2f5f7;
}

.revenue-merchant-suggestions strong {
  font-size: 13px;
}

.revenue-merchant-suggestions small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.revenue-ctrl-group select,
.revenue-ctrl-group input[type="text"],
.revenue-ctrl-group input[type="date"],
.revenue-btn-primary {
  height: var(--revenue-control-height);
}

.revenue-ctrl-group select,
.revenue-ctrl-group input[type="text"],
.revenue-ctrl-group input[type="date"] {
  outline: 2px solid transparent;
  outline-offset: 1px;
}

.revenue-ctrl-group select:focus,
.revenue-ctrl-group input:focus,
.revenue-ctrl-group select:focus-visible,
.revenue-ctrl-group input:focus-visible {
  border-color: var(--brand);
  outline-color: rgba(20, 110, 245, .32);
  box-shadow: none;
}

.revenue-btn-primary {
  min-width: 76px;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease;
}

.revenue-btn-primary:hover {
  background: #0d5dd3;
  border-color: #0d5dd3;
}

.revenue-btn-primary:active {
  background: #094fb5;
  border-color: #094fb5;
}

.revenue-btn-primary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.revenue-btn-primary:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.revenue-kpi-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.revenue-kpi {
  min-height: 112px;
  border-top: 2px solid #cbd5e1;
  transition: border-color .15s ease, background-color .15s ease;
}

.revenue-kpi:hover {
  border-color: #94a3b8;
  box-shadow: none;
}

.revenue-kpi:nth-child(1) {
  order: 1;
  grid-column: span 2;
  background: var(--revenue-surface-selected);
  border-color: var(--brand);
}

.revenue-kpi:nth-child(6) {
  order: 2;
  grid-column: span 2;
  background: #eefaf5;
  border-color: var(--green);
}

.revenue-kpi:nth-child(2) {
  order: 3;
  grid-column: span 1;
}

.revenue-kpi:nth-child(3) {
  order: 4;
  grid-column: span 1;
}

.revenue-kpi:nth-child(4) {
  order: 5;
  grid-column: span 3;
  min-height: 92px;
}

.revenue-kpi:nth-child(5) {
  order: 6;
  grid-column: span 3;
  min-height: 92px;
}

.revenue-kpi:nth-child(1) strong {
  color: var(--brand);
  font-size: clamp(26px, 2.2vw, 32px);
}

.revenue-kpi:nth-child(6) strong {
  color: #08734d;
  font-size: clamp(26px, 2.2vw, 32px);
}

.revenue-kpi-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

#revenueAreaNote span {
  display: inline-block;
  white-space: nowrap;
}

#revenueAreaNote i {
  font-style: normal;
}

.revenue-shop-type-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.revenue-shop-type-group {
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-top: 2px solid #64748b;
  border-radius: 8px;
  background: #fff;
}

.revenue-shop-type-group.duojing {
  border-top-color: var(--green);
  background: #f7fcf9;
}

.revenue-shop-type-group h3 {
  margin: 0 0 12px;
  color: var(--revenue-ink-strong);
  font-size: 15px;
  line-height: 1.2;
}

.revenue-shop-type-group dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
}

.revenue-shop-type-group dl > div {
  min-width: 0;
  padding: 0 14px;
  border-left: 1px solid #e2e8f0;
}

.revenue-shop-type-group dl > div:first-child {
  padding-left: 0;
  border-left: 0;
}

.revenue-shop-type-group dt {
  color: var(--muted);
  font-size: 12px;
}

.revenue-shop-type-group dd {
  overflow: hidden;
  margin: 6px 0 0;
  color: var(--revenue-ink-strong);
  font-size: clamp(17px, 1.5vw, 22px);
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.revenue-shop-type-group.duojing dd {
  color: #08734d;
}

.revenue-day-average-card {
  transition: border-color .15s ease, background-color .15s ease;
}

.revenue-day-average-card:hover {
  border-color: #cbd5e1;
  box-shadow: none;
}

.revenue-analysis-row {
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, .85fr);
}

.revenue-diagnosis-panel {
  border-top: 3px solid var(--orange);
}

.revenue-section-head {
  align-items: center;
}

.revenue-section-head .eyebrow {
  display: block;
  margin-bottom: 4px;
}

.revenue-table-scroll {
  scrollbar-gutter: stable;
}

.revenue-structure-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.revenue-structure-trigger {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.revenue-structure-trigger:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.revenue-structure-chevron {
  display: inline-flex;
  width: 20px;
  height: 20px;
  margin-right: 6px;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  font-size: 20px;
  font-style: normal;
  transition: transform .15s ease;
}

.revenue-structure-group.is-expanded > .revenue-structure-trigger {
  background: var(--revenue-surface-selected);
}

.revenue-structure-group.is-expanded .revenue-structure-chevron {
  transform: rotate(90deg);
}

.revenue-structure-detail {
  padding: 12px 14px 16px 40px;
  border-bottom: 1px solid #dbe6f3;
  background: #f8fbff;
}

.revenue-structure-detail-head {
  display: flex;
  margin-bottom: 10px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.revenue-structure-detail-head strong { font-size: 13px; }
.revenue-structure-detail-head span { color: var(--muted); font-size: 11px; }

.revenue-structure-detail-columns,
.revenue-structure-detail-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(150px, 1.2fr) repeat(5, minmax(90px, 1fr));
  min-height: 38px;
  padding: 0 10px;
  align-items: center;
  gap: 12px;
}

.revenue-structure-detail-columns {
  background: #edf4fc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.revenue-structure-detail-row {
  border-bottom: 1px solid #e7eef6;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.revenue-structure-detail-row:last-child { border-bottom: 0; }
.revenue-structure-detail-row > span:not(:first-child),
.revenue-structure-detail-columns > span:not(:first-child) { text-align: right; }
.revenue-structure-detail-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.revenue-structure-detail-row strong i { margin-right: 8px; color: var(--muted); font-size: 10px; font-style: normal; }


.revenue-export-actions {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}

#revenueDeepExportBtn {
  background: #1e3a8a;
  color: #ffffff;
  border-color: #1e3a8a;
}

#revenueDeepExportBtn:hover {
  background: #172554;
  border-color: #172554;
  color: #ffffff;
}

@media (max-width: 1180px) {
  .revenue-hero-toolbar {
    grid-template-columns: 1fr;
  }

  .revenue-ctrl-group {
    justify-content: stretch;
    grid-template-columns: max-content max-content minmax(180px, 1fr) minmax(150px, 1fr) max-content;
  }
}

@media (max-width: 900px) {
  .revenue-subnav {
    grid-template-columns: 1fr 1fr;
  }

  .revenue-ctrl-group {
    grid-template-columns: 1fr 1fr;
  }

  .revenue-mode-buttons,
  #revenueMerchantTypeField {
    width: 100%;
  }

  .revenue-mode-buttons {
    grid-column: 1 / -1;
  }

  .revenue-mode-buttons button,
  .revenue-type-toggle button {
    flex: 1 1 auto;
    white-space: nowrap;
  }

  .revenue-merchant-control {
    grid-column: 2;
  }

  .revenue-btn-primary {
    width: 100%;
  }

  .revenue-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .revenue-kpi:nth-child(n) {
    grid-column: span 1;
  }

  .revenue-kpi:nth-child(1),
  .revenue-kpi:nth-child(6) {
    grid-column: span 1;
  }

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

@media (max-width: 620px) {
  .revenue-page {
    --revenue-control-height: 44px;
  }

  .revenue-shop-type-row {
    grid-template-columns: 1fr;
  }

  .revenue-shop-type-group {
    padding: 14px;
  }

  .revenue-shop-type-group dl > div {
    padding-inline: 10px;
  }

  .revenue-shop-type-group dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 12px;
  }

  .revenue-shop-type-group dl > div:first-child {
    grid-column: 1 / -1;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
  }

  .revenue-shop-type-group dl > div:nth-child(2) {
    padding-left: 0;
    border-left: 0;
  }

  .revenue-shop-type-group dd {
    font-size: 16px;
    overflow: visible;
    text-overflow: clip;
  }

  .revenue-baseline {
    display: block;
    margin-left: 0;
    margin-top: 2px;
  }

  .revenue-subnav {
    grid-template-columns: 1fr;
  }

  .revenue-subnav a {
    min-height: 58px;
  }

  .revenue-hero-toolbar {
    padding: 16px;
  }

  .revenue-ctrl-group {
    grid-template-columns: 1fr;
  }

  .revenue-mode-buttons,
  #revenueMerchantTypeField,
  .revenue-merchant-control,
  .revenue-ctrl-group > label,
  .revenue-btn-primary {
    grid-column: 1;
    width: 100%;
  }

  .revenue-ctrl-group select,
  .revenue-ctrl-group input[type="text"],
  .revenue-ctrl-group input[type="date"] {
    width: 100%;
  }

  .revenue-mode-buttons button,
  .revenue-type-toggle button {
    min-width: 0;
    min-height: 44px;
    padding-inline: 8px;
  }

  .revenue-kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .revenue-kpi:nth-child(1),
  .revenue-kpi:nth-child(6) {
    grid-column: 1 / -1;
  }

  .revenue-kpi:nth-child(4),
  .revenue-kpi:nth-child(5) {
    min-height: 104px;
  }

  .revenue-day-average-card dl {
    grid-template-columns: 1fr;
  }

  .revenue-day-average-card dl > div + div {
    border-left: 0;
    border-top: 1px solid #f1f5f9;
  }

  .revenue-structure-detail {
    padding: 10px;
  }

  .revenue-structure-detail-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .revenue-export-actions {
    width: 100%;
    justify-content: stretch;
  }

  .revenue-export-actions .revenue-btn-excel {
    flex: 1;
    justify-content: center;
  }

  .revenue-merchant-panel .revenue-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .revenue-merchant-table {
    min-width: 880px;
  }

  .revenue-merchant-table .revenue-table-head,
  .revenue-merchant-table .revenue-table-row {
    grid-template-columns: minmax(160px, 1.3fr) minmax(130px, 1fr) minmax(96px, 1fr) minmax(85px, 1fr) minmax(85px, 1fr) minmax(75px, 1fr) minmax(85px, 1fr);
    gap: 10px;
  }

  .revenue-merchant-table .revenue-table-head > :nth-child(n + 3),
  .revenue-merchant-table .revenue-table-row > :nth-child(n + 3) {
    display: block;
  }

  .revenue-merchant-table .revenue-table-head > :nth-child(2),
  .revenue-merchant-table .revenue-table-row > :nth-child(2) {
    text-align: right;
    white-space: normal;
  }

  .revenue-pagination {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .revenue-subnav a,
  .revenue-kpi,
  .revenue-day-average-card,
  .revenue-btn-primary {
    transition: none;
  }
}
