.plan-profit-analytics { min-width: 0; color: var(--ink); margin-top: 24px; }
.plan-profit-analytics > section { min-width: 0; max-width: 100%; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
/* Within the analysis workspace, the parent already owns the card surface. */
.sales-analysis .plan-profit-analytics > section { padding: 0; border: 0; border-radius: 0; }
.plan-profit-analytics.profit-embedded { margin: 12px 0 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.profit-embedded .profit-heading { margin-bottom: 12px; }
.profit-embedded .profit-heading h3 { margin: 0; color: var(--ink); font-size: var(--workspace-section-heading-size, 18px); font-weight: var(--workspace-heading-weight, 700); line-height: var(--workspace-section-heading-leading, 1.5); }
.profit-embedded [data-profit-summary][hidden] { display: none; }
.profit-embedded :is(.profit-period-details,.profit-chart-basis) { margin-top: 12px; border-top: 1px solid var(--line); }
.profit-embedded :is(.profit-period-details,.profit-chart-basis) > summary { min-height: 44px; padding: 10px 0; cursor: pointer; color: var(--brand-dark); font-size: 14px; }
.profit-embedded :is(.profit-period-details,.profit-chart-basis) > summary:hover { text-decoration: underline; }
.profit-embedded :is(.profit-period-details,.profit-chart-basis) > summary:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.profit-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.profit-heading h2 { margin: 0; color: var(--ink); font-size: var(--workspace-section-heading-size); font-weight: var(--workspace-heading-weight); line-height: var(--workspace-section-heading-leading); }
.profit-heading .feature-beta-badge { flex: 0 0 auto; margin-top: 5px; }
.profit-note { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.profit-summary { margin: 18px 0 20px; padding: 16px 0; border-block: 1px solid var(--line); }
.profit-summary dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; }
.profit-summary dt { font-size: 16px; font-weight: 600; }
.profit-summary dd { margin: 4px 0 0; font-size: 24px; font-weight: 700; line-height: 1.4; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.profit-controls { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 14px; }
.profit-control-fields { display: flex; flex-wrap: wrap; gap: 12px; min-width: 0; max-width: 100%; }
.profit-metric-buttons { display: flex; gap: 8px; }
.profit-metric-buttons button { min-width: 88px; min-height: 44px; margin: 0; font-size: 14px; white-space: nowrap; }
.profit-metric-buttons button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--panel); }
.profit-metric-buttons button[aria-pressed="true"]:hover { background: var(--brand-dark); }
.profit-metric-buttons button:active { transform: translateY(1px); }
.profit-mode-field { display: grid; gap: 4px; margin: 0; font-size: 14px; color: var(--muted); }
.profit-mode-field select { width: 100%; min-width: 190px; min-height: 44px; padding: 8px 12px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 16px; }
.profit-mode-field select:disabled { color: var(--muted); background: var(--panel-strong); cursor: default; opacity: 1; }
.profit-chart-type-field select { min-width: 150px; }
.profit-cost-note { margin-top: 16px; min-height: 24px; }
.profit-chart-unit { color: var(--muted); font-size: 14px; margin-top: 12px; margin-left: 4px; }
.profit-chart-shell { min-width: 0; display: grid; grid-template-columns: 66px minmax(0, 1fr); }
.profit-chart-axis { position: relative; height: 314px; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.profit-chart-axis span { position: absolute; right: 10px; transform: translateY(-50%); white-space: nowrap; }
.profit-chart-scroll { min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-gutter: auto; }
.profit-chart-canvas { position: relative; height: 314px; width: 100%; }
.profit-chart-canvas svg { display: block; position: absolute; inset: 0; width: 100%; height: 280px; overflow: visible; }
.profit-grid-line { stroke: var(--line); stroke-width: 1; }
.profit-zero-axis { stroke: var(--muted); stroke-width: 1.5; }
.profit-bar { fill: var(--brand); }
.profit-bar-negative { fill: url(#profitNegativePattern); stroke: var(--loss); stroke-width: 1.5; }
.profit-negative-pattern { stroke: var(--loss); stroke-width: 2; }
.profit-candle-body { fill: var(--brand); }
.profit-candle-wick { stroke: var(--brand); stroke-width: 2; }
.profit-candle-negative { fill: url(#profitNegativePattern); stroke: var(--loss); stroke-width: 1.5; }
.profit-candle-negative-wick { stroke: var(--loss); }
.profit-candlestick-help { padding: 12px 14px; background: var(--panel-strong); border-radius: 6px; }
.profit-margin-line { fill: none; stroke: var(--brand); stroke-width: 2.5; }
.profit-margin-point { fill: var(--panel); stroke: var(--brand); stroke-width: 2.5; }
.profit-margin-point-negative { fill: var(--loss); stroke: var(--loss); }
.profit-loss-label { display: inline-block; margin-left: 8px; font-size: 14px; font-weight: 600; line-height: 1.4; vertical-align: middle; white-space: nowrap; }
.profit-chart-number { fill: var(--ink); font-size: 14px; font-weight: 600; text-anchor: middle; font-variant-numeric: tabular-nums; }
.profit-period-buttons { position: absolute; inset: 0; display: flex; }
.profit-period-button { position: relative; flex: 1 1 0; min-width: 0; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--ink); font-size: 14px; padding: 0; }
.profit-period-button span { position: absolute; left: 0; right: 0; text-align: center; white-space: nowrap; }
.profit-period-button .profit-period-label { bottom: 8px; }
.profit-period-value { font-size: 14px; font-weight: 600; transform: translateY(-50%); font-variant-numeric: tabular-nums; }
.profit-period-button[aria-pressed="true"] { border-color: var(--line); }
.profit-period-button[aria-pressed="true"] .profit-period-label { color: var(--brand-dark); font-weight: 700; }
.profit-period-button:hover { background: color-mix(in srgb, var(--brand) 5%, transparent); }
.plan-profit-analytics button:focus-visible, .plan-profit-analytics select:focus-visible, .profit-chart-scroll:focus-visible, .profit-table-scroll:focus-visible, .profit-data-details summary:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.profit-period-button:focus-visible { outline-offset: -3px !important; }
.profit-period-detail { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 18px; }
.profit-period-detail h3 { margin: 0 0 12px; font-size: 18px; }
.profit-period-values { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 0 0 16px; }
.profit-period-values dt { color: var(--muted); font-size: 14px; }
.profit-period-values dd { margin: 2px 0 0; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.profit-table-scroll { max-width: 100%; overflow-x: auto; scrollbar-gutter: auto; }
.profit-table { border-collapse: collapse; width: 100%; min-width: 600px; font-size: 14px; }
.profit-table th, .profit-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; white-space: nowrap; font-variant-numeric: tabular-nums; }
.profit-table th:first-child { text-align: left; min-width: 180px; white-space: normal; overflow-wrap: anywhere; }
.profit-table thead th { background: var(--panel-strong); font-weight: 600; }
.profit-table tbody th { font-size: 16px; font-weight: 600; }
.profit-table caption { text-align: left; color: var(--muted); font-size: 14px; line-height: 1.6; padding: 12px 0; }
.profit-record-date { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; font-weight: 400; }
.profit-table-scroll-hint { display: none; }
.profit-open-record { min-height: 44px; padding: 8px 0; text-align: left; font-size: 14px; color: var(--brand-dark); margin-top: 4px; }
.profit-open-record:hover { text-decoration: underline; }
.profit-status { margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; min-height: 0; }
.profit-status:empty { display: none; }
.profit-data-details { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 6px; }
.profit-data-details summary { min-height: 44px; padding: 10px 0; font-size: 16px; color: var(--brand-dark); cursor: pointer; }
.profit-data-details summary:hover { text-decoration: underline; }
.profit-empty { min-height: 210px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 24px 0; }
.profit-empty h3 { margin: 0; font-size: 18px; }
.profit-empty p { margin: 8px 0 0; color: var(--muted); }
.profit-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 1100px) {
  .profit-summary dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profit-summary dl > div:last-child { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .plan-profit-analytics > section { padding: 16px; }
  .profit-heading { display: block; }
  .profit-heading .feature-beta-badge { margin-top: 10px; }
  .profit-summary dl { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
  .profit-summary dl > div:last-child { grid-column: 1 / -1; }
  .profit-summary dd { font-size: 22px; }
  .profit-summary dt { font-size: 14px; }
  .profit-period-values { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .profit-control-fields { width: 100%; }
  .profit-control-fields .profit-mode-field { flex: 1 1 160px; min-width: 0; }
  .profit-mode-field select { min-width: 0; }
  .profit-table-scroll-hint { display: block; }
}
@media (max-width: 400px) {
  .profit-summary dl { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .profit-summary dl > div { display:grid; grid-template-columns:minmax(0, 1fr) minmax(0, 1.5fr); align-items:baseline; gap:12px; }
  .profit-summary dl > div + div { border-top:1px solid var(--line); padding-top:12px; }
  .profit-summary dl > div:last-child { grid-column: auto; }
  .profit-summary dd { margin:0; text-align:right; font-size:20px; }
  .profit-controls { align-items: stretch; }
  .profit-mode-field { flex: 1 1 100%; }
}
@media (forced-colors: active) {
  .profit-bar, .profit-candle-body { fill: Highlight; }
  .profit-bar-negative, .profit-candle-negative { fill: url(#profitNegativePattern); stroke: CanvasText; }
  .profit-candle-wick, .profit-candle-negative-wick { stroke: CanvasText; }
  .profit-margin-line, .profit-margin-point, .profit-zero-axis { stroke: CanvasText; }
  .profit-chart-number { fill: CanvasText; }
  .profit-negative-pattern { stroke: CanvasText; }
  .profit-margin-point-negative { fill: CanvasText; stroke: CanvasText; }
  .profit-period-button[aria-pressed="true"] { border-color: Highlight; }
}
