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

.farm-profitability-panel {
    border: 1px solid #dfe8e2;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 12px 40px rgba(21, 32, 27, 0.06);
    overflow: hidden;
}

.farm-profitability-panel .section-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e8efeb;
    background: linear-gradient(180deg, #fbfdfb 0%, #f4f8f5 100%);
}

.finance-inline-loading {
    margin: 1rem 1.5rem 0;
    padding: 0.65rem 0.9rem;
    border: 1px solid #dce8e0;
    border-radius: 10px;
    background: #f8fcf9;
    color: #496155;
    font-size: 0.86rem;
    font-weight: 700;
}

.finance-hero {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1.35rem 1.5rem;
    margin: 0 1.5rem 1.25rem;
    border-radius: 14px;
    border: 1px solid #dce8e0;
    background: linear-gradient(135deg, #f8fcf9 0%, #eef6f0 100%);
}

.finance-hero.is-profit {
    border-color: #b8dfc8;
    background: linear-gradient(135deg, #f3fbf6 0%, #e6f5ec 100%);
}

.finance-hero.is-loss {
    border-color: #f0c4c4;
    background: linear-gradient(135deg, #fff8f8 0%, #fdeeee 100%);
}

.finance-hero.is-neutral {
    border-color: #dfe5e1;
}

.finance-hero-copy h2 {
    margin: 0.15rem 0 0.35rem;
    font-size: clamp(1.75rem, 3vw, 2.35rem);
    font-weight: 800;
    color: #17251f;
    line-height: 1.1;
}

.finance-hero-copy p {
    margin: 0;
    color: #5f7167;
    font-size: 0.92rem;
}

.finance-hero-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: flex-end;
}

.finance-metric-chip {
    display: grid;
    gap: 0.1rem;
    min-width: 7.5rem;
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    border: 1px solid #dfe8e2;
    background: rgba(255, 255, 255, 0.88);
}

.finance-metric-chip span {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6a7b71;
}

.finance-metric-chip strong {
    font-size: 1.05rem;
    color: #17251f;
}

.finance-metric-chip.tone-success strong { color: #1f7a45; }
.finance-metric-chip.tone-danger strong { color: #b33a3a; }
.finance-metric-chip.tone-info strong { color: #2563eb; }

.finance-filters {
    padding: 1rem 1.5rem 0.25rem;
    border-bottom: 1px solid #eef2ef;
}

.finance-filters .form-label {
    color: #5f7167;
    font-weight: 600;
}

.finance-tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.85rem 1.5rem 0;
}

.finance-tab {
    border: 1px solid #d8e3dc;
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    background: #fff;
    color: #3f5248;
    font-size: 0.86rem;
    font-weight: 700;
    transition: all 0.15s ease;
}

.finance-tab:hover {
    border-color: #2f6f4e;
    color: #2f6f4e;
}

.finance-tab.is-active {
    border-color: #2f6f4e;
    background: linear-gradient(135deg, #2f6f4e, #3d8b5f);
    color: #fff;
    box-shadow: 0 8px 20px rgba(47, 111, 78, 0.22);
}

.finance-panel-body {
    padding: 1.25rem 1.5rem 1.5rem;
}

.finance-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.finance-section-title h6 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: #17251f;
}

.finance-kpi-block {
    margin-bottom: 1.25rem;
}

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

.finance-chart-card {
    height: 100%;
    padding: 1rem 1.1rem 0.75rem;
    border: 1px solid #e5ece7;
    border-radius: 14px;
    background: #fcfdfc;
}

.finance-chart-card .chart-wrapper {
    min-height: 280px;
}

.finance-donut-legend {
    display: grid;
    gap: 0.45rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e5ece7;
}

.finance-donut-legend-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.65rem;
    align-items: center;
    font-size: 0.84rem;
}

.finance-donut-legend-label {
    color: #4b5c52;
}

.finance-donut-legend-item strong {
    color: #17251f;
    white-space: nowrap;
}

.finance-donut-legend-item small {
    color: #6a7b71;
    min-width: 2.5rem;
    text-align: right;
}

.finance-breakdown-card {
    height: 100%;
    padding: 1rem 1.1rem;
    border: 1px solid #e5ece7;
    border-radius: 14px;
    background: #fff;
}

.finance-breakdown-list {
    display: grid;
    gap: 0.7rem;
}

.finance-breakdown-row {
    display: grid;
    grid-template-columns: minmax(90px, 130px) 1fr auto;
    gap: 0.75rem;
    align-items: center;
}

.finance-breakdown-row span {
    color: #4b5c52;
    font-size: 0.88rem;
}

.finance-breakdown-row strong {
    color: #17251f;
    font-size: 0.92rem;
}

.finance-bar {
    height: 10px;
    border-radius: 999px;
    background: #eef2f6;
    overflow: hidden;
}

.finance-bar > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #60a5fa);
}

.finance-bar.is-revenue > span {
    background: linear-gradient(90deg, #0f766e, #2dd4bf);
}

.finance-bar.is-cost > span {
    background: linear-gradient(90deg, #dc2626, #f87171);
}

.finance-bar.is-potential > span {
    background: linear-gradient(90deg, #7c3aed, #a78bfa);
}

.finance-ranking-list {
    display: grid;
    gap: 0.55rem;
}

.finance-ranking-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.55rem 0.65rem;
    border-radius: 10px;
    background: #f8faf9;
}

.finance-ranking-item.positive strong { color: #1f7a45; }
.finance-ranking-item.negative strong { color: #b33a3a; }

.finance-hint-box {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px dashed #d5e3da;
    background: #f7fbf8;
    color: #5f7167;
    font-size: 0.88rem;
}

.finance-hint-box p {
    margin: 0 0 0.35rem;
}

.finance-hint-box p:last-child {
    margin-bottom: 0;
}

.finance-result-banner {
    padding: 1rem 1.15rem;
    border-radius: 12px;
    border: 1px solid transparent;
    font-size: 0.95rem;
}

.finance-result-banner.is-profit {
    border-color: #b8dfc8;
    background: #edf8f1;
    color: #1f5c38;
}

.finance-result-banner.is-loss {
    border-color: #f0c4c4;
    background: #fef2f2;
    color: #8b2e2e;
}

.finance-table-shell {
    border: 1px solid #e5ece7;
    border-radius: 12px;
    overflow: hidden;
}

.finance-table-shell .table {
    margin-bottom: 0;
}

.finance-table-shell thead {
    background: #f4f8f5;
}

.finance-table-shell thead th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #5f7167;
    border-bottom-color: #dfe8e2;
}

.finance-table-shell thead th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.finance-table-shell thead th.sortable::after {
    content: "↕";
    margin-left: 0.35rem;
    font-size: 0.62rem;
    opacity: 0.45;
    vertical-align: middle;
}

.finance-table-shell thead th.sortable:hover {
    color: #1f7a45;
    background: #eaf4ee;
}

.finance-table-shell thead th.sortable.is-sorted {
    color: #173628;
    background: #e3efe8;
}

.finance-table-shell thead th.sortable.is-sorted::after {
    content: none;
}

.finance-ranking-table tbody tr.positive td:last-child strong {
    color: #1f7a45;
}

.finance-ranking-table tbody tr.negative td:last-child strong {
    color: #b33a3a;
}

.finance-badge-paid {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: #e6f5ec;
    color: #1f7a45;
    font-size: 0.78rem;
    font-weight: 700;
}

.finance-badge-pending {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: #fff4e5;
    color: #b45309;
    font-size: 0.78rem;
    font-weight: 700;
}

.finance-expense-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 1rem;
    border: 1px solid #e5ece7;
    border-radius: 12px;
    background: #f8fbf9;
}

.finance-expense-toolbar-copy strong {
    display: block;
    margin-bottom: 0.25rem;
    color: #17251f;
}

.finance-expense-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.finance-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    font-size: 0.88rem;
    color: #3f5248;
    font-weight: 600;
}

.finance-expense-group-row {
    background: #f4f8f5;
}

.finance-expense-detail-row {
    background: #fbfcfb;
}

.finance-expense-detail-row td {
    border-top: 1px dashed #e5ece7;
}

.finance-expense-expand {
    width: 1.6rem;
    height: 1.6rem;
    border: 1px solid #cfd9d2;
    border-radius: 8px;
    background: #fff;
    color: #2f6f4e;
    font-weight: 800;
    line-height: 1;
}

.finance-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.finance-type-badge.is-feed {
    background: #e6f5ec;
    color: #1f7a45;
}

.finance-type-badge.is-purchase {
    background: #eff6ff;
    color: #1d4ed8;
}

.finance-type-badge.is-fixed {
    background: #f5f3ff;
    color: #6d28d9;
}

.finance-type-badge.is-other {
    background: #f3f4f6;
    color: #4b5563;
}

.finance-ref-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 0.76rem;
    font-weight: 700;
}

@media (max-width: 992px) {
    .finance-kpi-block .kpi-grid,
    .finance-hero {
        grid-template-columns: 1fr;
    }

    .finance-hero-metrics {
        justify-content: flex-start;
    }

    .finance-breakdown-row {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }
}

@media (max-width: 768px) {
    .finance-kpi-block .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .finance-tab-nav {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.35rem;
    }

    .finance-panel-body,
    .finance-filters,
    .finance-hero {
        margin-left: 0;
        margin-right: 0;
        padding-left: 1rem;
        padding-right: 1rem;
    }
}
