.profit-page {
    display: grid;
    gap: 1.25rem;
}

.profit-hero,
.profit-card {
    padding: 1.25rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
    box-shadow: var(--ds-soft-shadow);
}

.profit-hero {
    display: grid;
    gap: 1.25rem;
}

.profit-inline-form {
    padding: 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface-alt);
}

.profit-inline-form-header {
    margin-bottom: 0.9rem;
}

.profit-inline-form-header strong {
    display: block;
    color: var(--ds-text);
}

.profit-inline-form-header small {
    color: var(--ds-muted);
}

.profit-inline-form-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.profit-hero-actions,
.profit-hero-action-group,
.profit-hero-body,
.profit-meta-line,
.profit-card-header {
    display: flex;
    gap: 0.75rem;
}

.profit-hero-actions,
.profit-card-header {
    align-items: center;
    justify-content: space-between;
}

.profit-hero-action-group,
.profit-meta-line {
    flex-wrap: wrap;
}

.profit-hero-body {
    align-items: center;
}

.profit-avatar {
    display: grid;
    place-items: center;
    width: 5rem;
    height: 5rem;
    border-radius: 1rem;
    color: var(--ds-primary);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(15, 118, 110, 0.1));
    font-size: 1.75rem;
    font-weight: 800;
}

.profit-identity {
    display: grid;
    gap: 0.4rem;
}

.profit-identity h1,
.profit-card h2 {
    margin: 0;
    color: var(--ds-text);
    font-weight: 800;
}

.profit-identity p {
    margin: 0;
    color: var(--ds-muted);
}

.profit-chip {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0 0.75rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.profit-chip.is-male {
    color: #1d4ed8;
    background: #dbeafe;
}

.profit-chip.is-female {
    color: #be185d;
    background: #fce7f3;
}

.profit-chip.is-born {
    color: #166534;
    background: #dcfce7;
}

.profit-chip.is-purchased {
    color: #9a6500;
    background: #fff4da;
}

.profit-chip.is-age {
    color: var(--ds-text);
    background: var(--ds-surface-alt);
}

.profit-kpi-grid,
.profit-grid,
.cost-legend,
.cost-summary-strip {
    display: grid;
    gap: 1rem;
}

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

.profit-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
}

.profit-kpi-card {
    display: grid;
    gap: 0.35rem;
    padding: 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: linear-gradient(180deg, #fffdfa, #ffffff);
}

.profit-kpi-card span,
.profit-kpi-card small,
.profit-eyebrow {
    color: var(--ds-muted);
}

.profit-kpi-card strong {
    color: var(--ds-text);
    font-size: 1.8rem;
    line-height: 1.05;
}

.profit-kpi-card.positive strong,
.positive-text {
    color: var(--ds-success);
}

.profit-kpi-card.negative strong,
.negative-text {
    color: var(--ds-danger);
}

.profit-summary-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--ds-border);
}

.profit-summary-item {
    display: grid;
    gap: 0.2rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-alt);
}

.profit-summary-item span {
    color: var(--ds-muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.profit-summary-item strong {
    color: var(--ds-text);
    font-size: 0.98rem;
    font-weight: 800;
}

.profit-eyebrow {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.cost-stack {
    display: flex;
    height: 1.25rem;
    overflow: hidden;
    border-radius: 999px;
    background: #eef2f6;
}

.cost-segment {
    display: block;
    min-width: 0;
    height: 100%;
}

.segment-purchase {
    background: #2563eb;
}

.segment-feed {
    background: #65a30d;
}

.segment-health {
    background: #a16207;
}

.segment-labor {
    background: #6b7280;
}

.segment-other {
    background: #c7c2b8;
}

.segment-shared {
    background: #475569;
}

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

.cost-legend.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem 1rem;
}

.cost-legend-item {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
}

.cost-legend-item strong {
    display: block;
    color: var(--ds-text);
}

.cost-legend-item small {
    color: var(--ds-muted);
}

.cost-dot {
    width: 0.7rem;
    height: 0.7rem;
    margin-top: 0.35rem;
    border-radius: 50%;
}

.cost-summary-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding-top: 0.35rem;
    border-top: 1px solid var(--ds-border);
}

.cost-summary-strip div {
    display: grid;
    gap: 0.2rem;
}

.cost-summary-strip span {
    color: var(--ds-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.cost-summary-strip strong {
    color: var(--ds-text);
}

.profit-cost-visuals {
    display: grid;
    grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr);
    gap: 1rem;
    align-items: start;
}

.profit-timeline-panel {
    display: grid;
    gap: 0.85rem;
    padding: 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface-alt);
}

.profit-timeline-header {
    display: grid;
    gap: 0.2rem;
}

.profit-timeline-header strong {
    color: var(--ds-text);
}

.profit-timeline-header small,
.profit-timeline-panel p,
.profit-timeline-empty {
    margin: 0;
    color: var(--ds-muted);
}

.profit-timeline-chart {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.75rem;
    align-items: end;
    min-height: 12rem;
}

.profit-timeline-column {
    position: relative;
    display: grid;
    gap: 0.45rem;
    text-align: center;
}

.profit-timeline-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.75rem);
    z-index: 5;
    display: grid;
    gap: 0.35rem;
    min-width: 15rem;
    padding: 0.8rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: #fff;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.14);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(0.35rem);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    text-align: left;
    pointer-events: none;
}

.profit-timeline-column:hover .profit-timeline-tooltip,
.profit-timeline-column:focus-within .profit-timeline-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.profit-timeline-tooltip > strong {
    color: var(--ds-text);
    font-size: 0.9rem;
}

.profit-timeline-tooltip > span {
    color: var(--ds-muted);
    font-size: 0.82rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--ds-border);
}

.profit-timeline-tooltip-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--ds-muted);
    font-size: 0.82rem;
}

.profit-timeline-tooltip-row strong {
    color: var(--ds-text);
    font-size: 0.82rem;
}

.profit-timeline-track {
    position: relative;
    display: flex;
    align-items: end;
    justify-content: center;
    min-height: 8.5rem;
    padding: 0.35rem;
    border-radius: 1rem;
    background: #eef2f6;
}

.profit-timeline-fill {
    width: 100%;
    border-radius: 0.8rem;
    background: linear-gradient(180deg, #2563eb 0%, #0f766e 100%);
}

.profit-timeline-column strong {
    color: var(--ds-text);
    font-size: 0.9rem;
}

.profit-timeline-column small {
    color: var(--ds-muted);
    font-size: 0.78rem;
}

.profit-timeline-purchase-flag {
    position: absolute;
    top: -1.35rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.profitability-curve-panel {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface-alt);
}

.profitability-curve-header {
    display: grid;
    gap: 0.2rem;
}

.profitability-curve-header strong {
    color: var(--ds-text);
}

.profitability-curve-header small,
.profitability-curve-hint {
    margin: 0;
    color: var(--ds-muted);
    font-size: 0.82rem;
}

.profitability-curve-svg {
    width: 100%;
    height: auto;
}

.profitability-axis {
    stroke: #cbd5e1;
    stroke-width: 1;
}

.profitability-grid {
    stroke: #e2e8f0;
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.profitability-guide {
    stroke: rgba(148, 163, 184, 0.35);
    stroke-width: 1;
    stroke-dasharray: 3 5;
}

.profitability-line {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.profitability-line.is-cost {
    stroke: #2563eb;
}

.profitability-line.is-value {
    stroke: #059669;
}

.profitability-line.is-margin {
    stroke: #ea580c;
    stroke-dasharray: 6 4;
}

.profitability-point {
    stroke: #fff;
    stroke-width: 2;
}

.profitability-point.is-cost {
    fill: #2563eb;
}

.profitability-point.is-value {
    fill: #059669;
}

.profitability-point.is-margin {
    fill: #ea580c;
}

.profitability-label {
    fill: var(--ds-muted);
    font-size: 9px;
    text-anchor: middle;
}

.profitability-label-y {
    text-anchor: start;
    font-size: 10px;
    font-weight: 600;
}

.profitability-curve-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    color: var(--ds-muted);
    font-size: 0.82rem;
}

.profitability-curve-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.profitability-month-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.profitability-month-card {
    display: grid;
    gap: 0.55rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: #fff;
}

.profitability-month-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
    flex-wrap: wrap;
}

.profitability-month-head strong {
    color: var(--ds-text);
    font-size: 0.92rem;
}

.profitability-month-head small {
    color: var(--ds-muted);
}

.profitability-month-metrics {
    display: grid;
    gap: 0.4rem;
}

.profitability-month-metrics span {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--ds-muted-strong);
    font-size: 0.85rem;
}

.profitability-month-metrics strong {
    color: var(--ds-text);
}

.farm-charge-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.farm-charge-card {
    display: grid;
    gap: 0.35rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: #fff;
}

.farm-charge-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
}

.farm-charge-head strong {
    color: var(--ds-text);
    font-size: 0.92rem;
}

.farm-charge-head span,
.farm-charge-card small {
    color: var(--ds-muted-strong);
}

.farm-charge-note {
    color: var(--ds-muted);
}

.legend-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    display: inline-block;
}

.legend-dot.is-cost {
    background: #2563eb;
}

.legend-dot.is-value {
    background: #059669;
}

.legend-dot.is-margin {
    background: #ea580c;
}

@media (max-width: 1100px) {
    .profitability-month-grid,
    .farm-charge-grid {
        grid-template-columns: 1fr;
    }
}

.profit-cost-breakdown {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.profit-cost-detail-card {
    display: grid;
    gap: 0.35rem;
    padding: 0.9rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface-alt);
}

.profit-cost-detail-topline {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.5rem;
    align-items: center;
}

.profit-cost-detail-topline strong,
.profit-cost-detail-amount {
    color: var(--ds-text);
}

.profit-cost-detail-topline span:last-child,
.profit-cost-detail-card small {
    color: var(--ds-muted);
}

.profit-cost-detail-amount {
    font-size: 1.05rem;
    font-weight: 800;
}

.profit-feed-section {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ds-border);
}

.profit-feed-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
}

.profit-feed-header-metric {
    display: grid;
    gap: 0.1rem;
    text-align: right;
}

.profit-feed-header-metric span {
    color: var(--ds-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.profit-feed-header h3 {
    margin: 0.15rem 0 0;
    color: var(--ds-text);
    font-size: 1.15rem;
}

.profit-feed-header strong,
.profit-feed-card-topline strong,
.profit-feed-card-topline span {
    color: var(--ds-text);
}

.profit-feed-empty {
    margin: 0;
    color: var(--ds-muted);
}

.profit-feed-explainer {
    margin: -0.4rem 0 0;
    color: var(--ds-muted);
    font-size: 0.9rem;
}

.profit-feed-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.profit-feed-card {
    display: grid;
    gap: 0.55rem;
    padding: 0.9rem;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface-alt);
}

.profit-feed-card-topline,
.profit-feed-card-metrics {
    display: grid;
    gap: 0.35rem;
}

.profit-feed-card-topline {
    grid-template-columns: 1fr auto;
    align-items: center;
}

.profit-feed-card-metrics span {
    color: var(--ds-muted);
    font-size: 0.9rem;
}

.profit-metrics {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.profit-metric-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--ds-border);
}

.profit-metric-row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.profit-metric-row span {
    color: var(--ds-muted-strong, var(--ds-muted));
    font-weight: 700;
}

.profit-metric-row strong {
    font-size: 1.05rem;
}

.profit-message {
    padding: 1rem;
    border-radius: var(--ds-radius-lg);
}

.profit-message strong {
    display: block;
    margin-bottom: 0.35rem;
}

.profit-message p {
    margin: 0;
}

.profit-message.is-good {
    color: #3f6212;
    background: #edf7dd;
}

.profit-message.is-risk {
    color: #8a3b12;
    background: #fff3e8;
}

.comparison-chart {
    display: grid;
    gap: 0.8rem;
    margin-top: 1rem;
}

.comparison-chart-row {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
}

.comparison-chart-row span {
    color: var(--ds-muted-strong, var(--ds-muted));
    font-weight: 700;
}

.comparison-track {
    height: 0.7rem;
    overflow: hidden;
    border-radius: 999px;
    background: #e8edf3;
}

.comparison-fill {
    height: 100%;
    border-radius: 999px;
}

.comparison-fill.is-cost {
    background: #2563eb;
}

.comparison-fill.is-value {
    background: #15803d;
}

.comparison-fill.is-margin {
    background: #0f766e;
}

.comparison-fill.is-risk {
    background: #b42318;
}

.profit-feed-context-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.confidence-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
}

.confidence-badge.is-high {
    color: #166534;
    background: #dcfce7;
}

.confidence-badge.is-medium {
    color: #9a6700;
    background: #fef3c7;
}

.confidence-badge.is-low {
    color: #9f1239;
    background: #ffe4e6;
}

@media (max-width: 960px) {
    .profit-kpi-grid,
    .profit-grid,
    .cost-legend,
    .cost-summary-strip,
    .profit-summary-bar {
        grid-template-columns: 1fr 1fr;
    }

    .profit-cost-visuals,
    .profit-cost-breakdown,
    .profit-feed-context-grid,
    .profit-feed-grid,
    .profit-timeline-chart {
        grid-template-columns: 1fr;
    }

    .profit-timeline-tooltip {
        left: 0;
        right: 0;
        min-width: 0;
        transform: translateX(0) translateY(0.35rem);
    }

    .profit-timeline-column:hover .profit-timeline-tooltip,
    .profit-timeline-column:focus-within .profit-timeline-tooltip {
        transform: translateX(0) translateY(0);
    }
}

@media (max-width: 720px) {
    .profit-hero-actions,
    .profit-hero-body,
    .profit-card-header,
    .profit-feed-header {
        flex-direction: column;
        align-items: stretch;
    }

    .profit-feed-header-metric {
        text-align: left;
    }

    .profit-kpi-grid,
    .profit-grid,
    .cost-legend,
    .cost-summary-strip,
    .profit-summary-bar {
        grid-template-columns: 1fr;
    }

    .comparison-chart-row {
        grid-template-columns: 1fr;
    }

    .profit-hero-action-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}
