:root {
    --cost-green: #17653D;
    --cost-green-dark: #102f20;
    --cost-green-soft: #eaf4ee;
    --cost-gold: #b28a2e;
    --cost-red: #c43c3c;
    --cost-text: #172019;
    --cost-muted: #737d75;
    --cost-border: #e2e7e2;
    --cost-surface: #F8F8F8;
}

[hidden] {
    display: none !important;
}

.cost-page {
    background: var(--background, #f4f6f8) !important;
}

.dashboard-topbar.cost-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding: 10px 0;
    background: var(--background, #f4f6f8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: none;
    border: none;
}

.cost-topbar-primary {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1 1 auto;
}

.cost-add-button {
    margin-left: auto;
}

.cost-page-heading {
    min-width: 0;
}

.cost-page-heading h1 {
    margin: 0;
    color: var(--cost-text);
    font-size: clamp(24px, 3vw, 34px);
    font-weight: 700;
    line-height: 1.15;
}

.cost-eyebrow,
.cost-panel-eyebrow {
    margin: 0 0 5px;
    color: #21734f;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
}

.cost-page-description {
    margin: 4px 0 0;
    color: var(--cost-muted);
    font-size: 14px;
}

.cost-mobile-menu {
    display: none;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    color: var(--cost-text);
    background: #fff;
    border: 1px solid var(--cost-border);
    border-radius: 50%;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
    cursor: pointer;
}

.cost-add-button,
.cost-empty-state button {
    min-height: 46px;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 0 0 auto;
    color: #ffffff;
    background:  #17653D;
    border: 1px solid rgba(254, 254, 254, 0.92);
    border-radius: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.cost-add-button:hover,
.cost-empty-state button:hover {
    background: #102f20;
    border: 1px solid rgba(254, 254, 254, 0.92);
    transform: translateY(-1px);
}

.cost-add-button:focus-visible,
.cost-page button:focus-visible,
.cost-page input:focus-visible,
.cost-page select:focus-visible,
.cost-modal button:focus-visible,
.cost-modal input:focus-visible,
.cost-modal select:focus-visible,
.cost-modal textarea:focus-visible,
.cost-image-lightbox button:focus-visible {
    outline: 3px solid rgba(24, 63, 44, .2);
    outline-offset: 2px;
}

.cost-account-actions .user-profile {
    color: var(--cost-text);
    text-decoration: none;
}

.cost-market-link {
    padding-bottom: 12px;
}

.cost-sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(3, 10, 6, .52);
    border: 0;
}

/* Cost view navigation and summary */
.cost-overview-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.cost-view-menu {
    min-width: 0;
    width: 100%;
    display: grid;
    grid-column: span 3;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.cost-view-card {
    position: relative;
    min-width: 0;
    min-height: 56px;
    height: 64px;
    padding: 8px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: #ffffff;
    color: #172019;
    border: 1px solid #e3e8e4;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(22, 35, 27, 0.04);
    font: inherit;
    font-size: clamp(0.78rem, 0.95vw, 0.92rem);
    font-weight: 550;
    line-height: 1.2;
    letter-spacing: -0.01em;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.cost-view-card::after {
    display: none !important;
}

.cost-view-card span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: inherit;
    font-weight: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cost-view-card:not(.active):hover {
    transform: translateY(-1px);
    background: #f8faf8;
    border-color: #d1d9d3;
    color: #102f20;
    box-shadow: 0 4px 12px rgba(22, 35, 27, 0.07);
}

.cost-view-card.active,
.cost-view-card[aria-selected="true"] {
    background: var(--cost-green, #174d34) !important;
    color: #ffffff !important;
    border-color: var(--cost-green, #174d34) !important;
    box-shadow: 0 8px 20px rgba(23, 77, 52, 0.16) !important;
    font-weight: 600;
}

.cost-view-card.active span,
.cost-view-card[aria-selected="true"] span {
    color: #ffffff !important;
    font-weight: 600;
}

.cost-view-card.active:hover,
.cost-view-card[aria-selected="true"]:hover {
    transform: translateY(-1px);
    background: #13422c !important;
    border-color: #13422c !important;
    box-shadow: 0 8px 22px rgba(23, 77, 52, 0.22) !important;
}

.cost-view-card:focus-visible {
    outline: 2px solid #174d34;
    outline-offset: 2px;
}

.cost-view-card.active:focus-visible {
    outline: 2px solid #174d34;
    outline-offset: 3px;
}

.cost-view-card:active {
    transform: translateY(0);
}

.cost-summary-card {
    min-width: 0;
    min-height: 180px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 14px;
    color: var(--cost-text);
    background: var(--cost-surface);
    border: 1px solid rgba(254, 254, 254, 0.92);
    border-radius: 22px;
    box-shadow: 0 5px 32px rgba(22, 35, 27, 0.1);
}

.cost-summary-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.cost-summary-title {
    color: #657067;
    font-size: .94rem;
    font-weight: 600;
    line-height: 1.45;
}

.cost-summary-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    color: var(--cost-green);
    background: var(--cost-green-soft);
    border-radius: 14px;
    font-size: 20px;
}

.cost-summary-card[data-tone="income"] .cost-summary-icon,
.cost-summary-card[data-tone="profit"] .cost-summary-icon {
    color: #0f7b4d;
    background: #e8f8ef;
}

.cost-summary-card[data-tone="average"] .cost-summary-icon {
    color: #8a6210;
    background: #fff5dc;
}

.cost-summary-value {
    display: block;
    overflow-wrap: normal;
    color: var(--cost-text);
    font-size: clamp(1.55rem, 2.25vw, 2.15rem);
    font-weight: 750;
    letter-spacing: -.03em;
    line-height: 1.1;
}

.cost-summary-main {
    margin-bottom: auto;
}

.cost-summary-value.is-positive {
    color: #138653;
}

.cost-summary-value.is-negative {
    color: var(--cost-red);
}

.cost-summary-card[data-tone="profit"] {
    gap: 12px;
}

.cost-summary-card[data-tone="profit"] .cost-summary-value {
    font-size: clamp(1.3rem, 1.75vw, 1.72rem);
}

.cost-profit-main {
    min-width: 0;
}

.cost-summary-caption {
    margin-top: 7px;
    display: block;
    color: #8a918c;
    font-size: .78rem;
}

.cost-summary-latest {
    padding-top: 12px;
    display: grid;
    gap: 5px;
    border-top: 1px solid #e8ece8;
}

.cost-summary-latest > span {
    color: #8a918c;
    font-size: .69rem;
    font-weight: 650;
}

.cost-summary-latest > strong {
    overflow: hidden;
    color: #344039;
    font-size: .79rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cost-summary-latest > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.cost-summary-latest b {
    color: var(--cost-text);
    font-size: .78rem;
}

.cost-summary-latest time {
    color: #8a918c;
    font-size: .7rem;
    white-space: nowrap;
}

.cost-profit-breakdown {
    margin-top: auto;
    display: grid;
    gap: 10px;
}

.cost-profit-bar {
    width: 100%;
    height: 13px;
    display: flex;
    overflow: hidden;
    background: #edf1ee;
    border: 1px solid rgba(218, 225, 219, .9);
    border-radius: 999px;
    box-shadow: inset 0 1px 2px rgba(20, 32, 24, .06);
}

.cost-profit-segment {
    min-width: 0;
    flex-basis: 0;
    flex-grow: 0;
    background-color: var(--segment-color);
    background-image: repeating-linear-gradient(
        135deg,
        rgba(255, 255, 255, .34) 0,
        rgba(255, 255, 255, .34) 2px,
        transparent 2px,
        transparent 7px
    );
    transition: flex-grow .28s ease;
}

.cost-profit-segment:not(:last-child):not(.is-empty) {
    border-right: 3px solid #fff;
}

.cost-profit-segment.is-empty {
    display: none;
}

.cost-profit-segment.is-income,
.cost-profit-legend-row i.is-income {
    --segment-color: #168ef3;
}

.cost-profit-segment.is-expense,
.cost-profit-legend-row i.is-expense {
    --segment-color: #3bc5de;
}

.cost-profit-legend {
    display: grid;
    gap: 5px;
}

.cost-profit-legend-row {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #59645c;
    font-size: .72rem;
    line-height: 1.35;
}

.cost-profit-legend-row > span {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
}

.cost-profit-legend-row i {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    background: var(--segment-color);
    border-radius: 50%;
}

.cost-profit-legend-row strong {
    color: #28342c;
    font-size: .73rem;
    font-weight: 700;
    white-space: nowrap;
}

/* Panels and charts */
.cost-insight-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.75fr) minmax(300px, .8fr);
    gap: 18px;
    margin-bottom: 22px;
}

.cost-panel {
    min-width: 0;
    color: var(--cost-text);
    background: var(--cost-surface);
    border: 1px solid rgba(254, 254, 254, 0.92);
    border-radius: 28px;
    box-shadow: 0 5px 32px rgba(22, 35, 27, 0.1);
}

.cost-trend-panel,
.cost-category-panel {
    padding: 24px;
}

.cost-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.cost-panel-header h2,
.cost-records-header h2 {
    margin: 0;
    color: var(--cost-text);
    font-size: 1.2rem;
}

.cost-trend-heading {
    min-width: 0;
    display: grid;
    gap: 9px;
}

.cost-trend-total {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
}

.cost-trend-total strong {
    color: var(--cost-text);
    font-size: clamp(1.42rem, 2.1vw, 1.85rem);
    font-weight: 750;
    letter-spacing: -.035em;
}

.cost-trend-total span {
    color: #8a918c;
    font-size: .72rem;
}

.cost-trend-periods {
    padding: 4px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #F2F2F2;
    border: 1px solid #e5eae6;
    border-radius: 12px;
}

.cost-trend-periods button {
    min-width: 52px;
    padding: 7px 10px;
    color: #758078;
    background: transparent;
    border: 0;
    border-radius: 8px;
    font: inherit;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    transition: color .18s ease, background .18s ease, box-shadow .18s ease;
}

.cost-trend-periods button:hover {
    color: #176ea8;
}

.cost-trend-periods button.active,
.cost-trend-periods button[aria-pressed="true"] {
    color: #1679ba;
    background: #fff;
    box-shadow: 0 3px 10px rgba(29, 88, 126, .12);
}

.cost-trend-periods button:focus-visible {
    outline: 3px solid rgba(36, 145, 232, .22);
    outline-offset: 2px;
}

.cost-line-chart {
    min-height: 270px;
    margin-top: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: #cbd8d0 transparent;
}

.cost-line-chart svg {
    min-width: 100%;
    height: 260px;
    display: block;
    overflow: visible;
}

.cost-line-grid {
    stroke: #e8edf0;
    stroke-width: 1;
}

.cost-line-average {
    stroke: #8d9aa2;
    stroke-width: 1.2;
    stroke-dasharray: 4 5;
}

.cost-line-average-label {
    fill: #69767e;
    font-family: "Noto Sans Thai", "Prompt", sans-serif;
    font-size: 11px;
    font-weight: 600;
}

.cost-line-area {
    fill: url(#cost-trend-area-gradient);
}

.cost-line-path {
    fill: none;
    stroke: #2491e8;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cost-line-point {
    fill: #2491e8;
    stroke: #fff;
    stroke-width: 2;
    cursor: help;
    transition: r .16s ease;
}

.cost-line-point:hover,
.cost-line-point:focus {
    r: 5.5px;
    outline: none;
}

.cost-line-label {
    fill: #7f8a82;
    font-family: "Noto Sans Thai", "Prompt", sans-serif;
    font-size: 11px;
    text-anchor: middle;
}

.cost-line-empty {
    fill: #8a948d;
    font-family: "Noto Sans Thai", "Prompt", sans-serif;
    font-size: 13px;
    text-anchor: middle;
}

.cost-category-list {
    margin-top: 22px;
    display: grid;
    gap: 15px;
}

.cost-category-row {
    display: grid;
    gap: 7px;
}

.cost-category-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #58635a;
    font-size: .8rem;
}

.cost-category-meta strong {
    color: var(--cost-text);
    font-size: .78rem;
}

.cost-category-track {
    height: 8px;
    overflow: hidden;
    background: #eef2ee;
    border-radius: 999px;
}

.cost-category-fill {
    height: 100%;
    background: linear-gradient(90deg, #2d7653, #73a987);
    border-radius: inherit;
}

.cost-category-empty {
    padding: 36px 10px;
    color: var(--cost-muted);
    text-align: center;
    font-size: .85rem;
}

/* Records */
.cost-records-panel {
    overflow: hidden;
}

.cost-records-header {
    padding: 24px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.cost-records-header > div:first-child > p:last-child {
    margin: 7px 0 0;
    color: var(--cost-muted);
    font-size: .82rem;
}

.cost-record-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: clamp(18px, 2.2vw, 30px);
}

.cost-search-group {
    width: min(390px, 38vw);
    height: 36px;
    padding: 3px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: center;
    gap: 6px;
    background: #e4e5e8;
    border-radius: 999px;
    transition: box-shadow .2s ease;
}

.cost-search-group:focus-within {
    box-shadow: 0 0 0 4px rgba(35, 131, 41, .12);
}

.cost-search-box {
    min-width: 0;
    height: 100%;
    display: block;
}

.cost-search-box input {
    min-width: 0;
    width: 100%;
    height: 100%;
    padding: 0 16px;
    color: var(--cost-text);
    background: transparent;
    border: 0;
    border-radius: 999px;
    outline: 0;
    box-shadow: none;
}

.cost-search-box input:focus,
.cost-search-box input:focus-visible {
    outline: 0;
    background: transparent;
    box-shadow: none;
}

.cost-search-button {
    width: 38px;
    height: 38px;
    padding: 0;
    display: grid;
    place-items: center;
    color: #fff;
    background: #238329;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color .2s ease, transform .2s ease;
}

.cost-search-button:hover {
    background: #175f1b;
    transform: scale(1.04);
}

.cost-category-filter-field {
    position: relative;
    display: block;
}

.cost-category-filter-field select {
    width: auto;
    min-width: 150px;
    min-height: 44px;
    padding: 7px 30px 7px 0;
    color: #374151;
    background-color: transparent;
    border: 0;
    border-radius: 0;
    outline: 0;
    box-shadow: none;
    font-weight: 600;
    cursor: pointer;
}

.cost-category-filter-field select:hover,
.cost-category-filter-field select:focus-visible {
    color: #08752a;
    outline: 2px solid rgba(35, 131, 41, .18);
    outline-offset: 3px;
    box-shadow: none;
}

.cost-table-wrap {
    overflow-x: auto;
}

.cost-table {
    width: 100%;
    min-width: 780px;
    border-collapse: collapse;
}

.cost-table th,
.cost-table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid #eef1ee;
}

.cost-table th {
    color: #778079;
    background: #fafbfa;
    font-size: .75rem;
    font-weight: 650;
}

.cost-table td {
    color: #525e55;
    font-size: .82rem;
}

.cost-table tbody tr:last-child td {
    border-bottom: 0;
}

.cost-table tbody tr:hover td {
    background: #fbfcfb;
}

.cost-item-cell {
    display: grid;
    gap: 3px;
}

.cost-item-cell strong {
    color: var(--cost-text);
    font-size: .86rem;
}

.cost-item-cell small {
    color: #8a938c;
    font-size: .72rem;
}

.cost-category-badge {
    padding: 6px 10px;
    display: inline-flex;

    color: #ffffff;
    background: #1F8A4D;

    border-radius: 999px;
    font-weight: 300;
}

.cost-amount-column {
    text-align: right !important;
}

.cost-table td.cost-amount-column {
    color: var(--cost-text);
    font-weight: 700;
}

.cost-table-actions {
    min-width: 210px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    
}

.cost-table-action {
    min-height: 32px;
    padding: 0 10px;
    color: #0d0d0d;
    background: #edf5f0;
    border: 1px solid #ffffff;
    border-radius: 999px;
    font: inherit;
    font-size: 1rem;
    font-weight: 300;
    cursor: pointer;
}

.cost-table-action:hover {
    color: #fff;
    background: var(--cost-green);
    border-color: var(--cost-green);
}

.cost-table-action.is-danger {
    color: #0d0d0d;
    background: #fff3f3;
    border-color: #f1d4d4;
}

.cost-table-action.is-danger:hover {
    color: #fff;
    background: #b74747;
    border-color: #b74747;
}

.cost-table-action:disabled {
    opacity: .55;
    cursor: wait;
}

.cost-records-heading {
    min-width: 0;
}

.cost-back-button {
    margin: 0 0 10px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #276444;
    background: transparent;
    border: 0;
    font: inherit;
    font-size: .78rem;
    font-weight: 650;
    cursor: pointer;
}

.cost-back-button:hover {
    color: var(--cost-green-dark);
}

.cost-chicken-summary {
    display: grid;
    gap: 4px;
}

.cost-chicken-summary strong {
    color: var(--cost-text);
    font-size: .9rem;
}

.cost-chicken-summary small {
    color: #8a938c;
    font-size: .72rem;
}

.cost-empty-state {
    min-height: 280px;
    padding: 42px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
}

.cost-empty-state > span {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    color: #397a59;
    background: #eaf4ee;
    border-radius: 20px;
    font-size: 28px;
}

.cost-empty-state h3 {
    margin: 15px 0 5px;
    color: var(--cost-text);
}

.cost-empty-state p {
    margin: 0 0 18px;
    color: var(--cost-muted);
    font-size: .85rem;
}

/* Modal and form */
.cost-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    padding: 24px;
    display: grid;
    place-items: center;
}

.cost-modal-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    background: rgba(7, 17, 11, .58);
    border: 0;
    backdrop-filter: blur(3px);
}

.cost-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(760px, 100%);
    max-height: calc(100vh - 48px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .85);
    border-radius: 26px;
    box-shadow: 0 30px 80px rgba(6, 20, 12, .3);
}

.cost-modal-header {
    padding: 24px 26px 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.cost-modal-header h2 {
    margin: 0;
    color: var(--cost-text);
    font-size: 1.45rem;
}

.cost-modal-header p {
    margin: 5px 0 0;
    color: var(--cost-muted);
    font-size: .9rem;
}

.cost-modal-close {
    width: 40px;
    height: 40px;
    padding: 0;
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    color: #566058;
    background: #f2f5f2;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
}

.cost-form {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.cost-form-body {
    min-height: 0;
    padding: 24px 26px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.cost-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.cost-field {
    min-width: 0;
    display: grid;
    gap: 8px;
}

.cost-field-full {
    grid-column: 1 / -1;
}

.is-farm-cost-form .cost-field:not([hidden]),
.is-farm-cost-form .cost-optional-quantity:not([hidden]) {
    animation: cost-field-reveal .18s ease both;
}

@keyframes cost-field-reveal {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.cost-field label,
.cost-field-label,
.cost-form-section legend {
    color: #29342c;
    font-size: .88rem;
    font-weight: 650;
}

.cost-required,
.cost-field-error {
    color: var(--cost-red);
}

.cost-optional-label {
    color: #7b847d;
    font-size: .78rem;
    font-weight: 500;
}

.cost-optional-quantity {
    margin-top: -8px;
}

.cost-optional-quantity button {
    width: fit-content;
    min-height: 38px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--cost-green);
    background: #f2f7f3;
    border: 1px dashed #9fb5a5;
    border-radius: 999px;
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
}

.cost-optional-quantity button:hover {
    background: #eaf4ed;
    border-color: #71947c;
}

.cost-note-meta {
    margin-top: -2px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #89918b;
    font-size: .72rem;
}

.cost-field input,
.cost-field select,
.cost-field textarea {
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    color: var(--cost-text);
    background: #f8faf8;
    border: 1px solid #dfe5df;
    border-radius: 13px;
    font: inherit;
    outline: 0;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

.cost-field textarea {
    min-height: 92px;
    padding-top: 12px;
    padding-bottom: 12px;
    resize: vertical;
}

.cost-field input:hover,
.cost-field select:hover,
.cost-field textarea:hover,
.cost-field input:focus,
.cost-field select:focus,
.cost-field textarea:focus {
    background: #fff;
    border-color: #8bab96;
    box-shadow: 0 0 0 4px rgba(24, 63, 44, .08);
}

.cost-field input[aria-invalid="true"],
.cost-field select[aria-invalid="true"] {
    border-color: #d65b5b;
    box-shadow: 0 0 0 4px rgba(214, 91, 91, .09);
}

.cost-money-input {
    position: relative;
}

.cost-money-input input {
    padding-right: 48px;
}

.cost-money-input span {
    position: absolute;
    top: 50%;
    right: 14px;
    color: #687169;
    transform: translateY(-50%);
    font-weight: 600;
}

.cost-field-error {
    min-height: 18px;
    margin: 0;
    font-size: .76rem;
}

.cost-form-section {
    min-width: 0;
    margin: 2px 0 0;
    padding: 18px;
    grid-column: 1 / -1;
    border: 1px solid var(--cost-border);
    border-radius: 16px;
}

.cost-form-section legend {
    padding: 0 6px;
}

.cost-radio-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.cost-radio-option {
    min-height: 48px;
    padding: 11px 13px;
    display: flex;
    align-items: center;
    gap: 9px;
    color: #445047;
    background: #f8faf8;
    border: 1px solid #e1e6e1;
    border-radius: 13px;
    cursor: pointer;
}

.cost-radio-option:has(input:checked) {
    color: var(--cost-green);
    background: #edf7f0;
    border-color: #8db79b;
}

.cost-radio-option input {
    width: 17px;
    height: 17px;
    accent-color: var(--cost-green);
}

.cost-specific-chicken {
    margin-top: 14px;
}

.cost-upload-box {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #f8faf8;
    border: 1px dashed #aebcaf;
    border-radius: 15px;
}

.cost-upload-box p {
    margin: 0;
    color: #6f7971;
    font-size: .8rem;
}

.cost-upload-button {
    min-height: 40px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
    color: var(--cost-green);
    background: var(--cost-green-soft);
    border: 0;
    border-radius: 11px;
    font-weight: 650;
    cursor: pointer;
}

.cost-receipt-preview {
    margin-top: 12px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f5f8f5;
    border-radius: 14px;
}

.cost-receipt-thumbnail {
    position: relative;
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
}

.cost-receipt-preview img {
    width: 58px;
    height: 58px;
    object-fit: cover;
    border-radius: 10px;
    cursor: zoom-in;
}

.cost-receipt-zoom {
    position: absolute;
    right: -5px;
    bottom: -5px;
    width: 28px;
    height: 28px;
    padding: 0;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--cost-green);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 5px 12px rgba(14, 52, 31, .24);
    cursor: zoom-in;
}

.cost-receipt-zoom:hover {
    background: #24583b;
    transform: scale(1.06);
}

.cost-receipt-preview span {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    color: #4d574f;
    font-size: .82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cost-receipt-link {
    width: fit-content;
    margin-top: 9px;
    color: var(--cost-green);
    font-size: .78rem;
    font-weight: 650;
    text-decoration: none;
}

.cost-receipt-link:hover {
    text-decoration: underline;
}

.cost-image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2400;
    padding: 24px;
    display: grid;
    place-items: center;
}

.cost-image-lightbox-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    background: rgba(3, 9, 5, .86);
    border: 0;
    backdrop-filter: blur(5px);
}

.cost-image-lightbox-dialog {
    position: relative;
    z-index: 1;
    width: min(1050px, 100%);
    max-height: calc(100dvh - 48px);
    padding: 16px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 12px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .42);
}

.cost-image-lightbox-dialog header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.cost-image-lightbox-dialog h2 {
    margin: 0;
    color: var(--cost-text);
    font-size: 1rem;
}

.cost-image-lightbox-close {
    width: 40px;
    height: 40px;
    padding: 0;
    display: grid;
    place-items: center;
    color: #4c5750;
    background: #edf1ee;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
}

.cost-image-lightbox-canvas {
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: auto;
    background: #101612;
    border-radius: 14px;
}

.cost-image-lightbox-canvas img {
    display: block;
    max-width: 100%;
    max-height: calc(100dvh - 170px);
    object-fit: contain;
}

.cost-image-lightbox-dialog > p {
    margin: 0;
    overflow: hidden;
    color: #687169;
    font-size: .8rem;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cost-remove-receipt {
    width: 36px;
    height: 36px;
    padding: 0;
    display: grid;
    place-items: center;
    flex: 0 0 36px;
    color: #b23b3b;
    background: #fff;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.cost-form-actions {
    padding: 18px 26px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    background: #fff;
    border-top: 1px solid #edf0ed;
}

.cost-form-message {
    min-width: 0;
    margin: 0 auto 0 0;
    color: var(--cost-red);
    font-size: .78rem;
}

.cost-cancel-button,
.cost-save-button {
    min-height: 44px;
    padding: 0 18px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
}

.cost-cancel-button {
    color: #59625b;
    background: #f0f3f0;
    border: 1px solid #e1e5e1;
}

.cost-save-button {
    color: #fff;
    background: var(--cost-green);
    border: 1px solid var(--cost-green);
    box-shadow: 0 8px 18px rgba(24, 63, 44, .18);
}

.cost-save-button:disabled {
    opacity: .62;
    cursor: wait;
}

.cost-form input:disabled,
.cost-form select:disabled {
    color: #465149;
    background: #f1f4f1;
    border-color: #e1e6e1;
    opacity: 1;
}

.cost-metric-grid {
    margin-bottom: 22px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.cost-metric-card {
    min-width: 0;
    padding: 18px;
    display: grid;
    gap: 8px;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .95);
    border-radius: 20px;
    box-shadow: 0 5px 24px rgba(22, 35, 27, .07);
}

.cost-metric-card span {
    color: var(--cost-muted);
    font-size: .78rem;
}

.cost-metric-card strong {
    color: var(--cost-text);
    font-size: clamp(1.05rem, 1.55vw, 1.45rem);
}

.cost-custom-range {
    padding: 0 22px 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.cost-custom-range label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--cost-muted);
    font-size: .75rem;
}

.cost-custom-range input,
.cost-chicken-filters input,
.cost-chicken-filters select {
    min-height: 38px;
    padding: 7px 10px;
    color: var(--cost-text);
    background: #fff;
    border: 1px solid var(--cost-border);
    border-radius: 12px;
    font: inherit;
    font-size: .75rem;
}

.cost-chart-legend {
    padding: 0 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    color: var(--cost-muted);
    font-size: .74rem;
}

.cost-chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.cost-chart-legend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.cost-chart-legend .is-farm,
.cost-bar.is-farm {
    fill: #238329;
    background: #238329;
}

.cost-chart-legend .is-chicken,
.cost-bar.is-chicken {
    fill: #e0a12d;
    background: #e0a12d;
}

.cost-bar {
    transition: opacity .2s ease;
}

.cost-bar:hover {
    opacity: .78;
}

.cost-chicken-filters {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(110px, 1fr));
    gap: 8px;
}

.cost-record-tools:has(.cost-chicken-filters:not([hidden])) {
    max-width: 760px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.cost-inventory-panel {
    margin-top: 22px;
    padding-bottom: 22px;
}

.cost-inventory-grid {
    padding: 0 22px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.cost-inventory-card {
    padding: 16px;
    display: grid;
    gap: 7px;
    background: #fff;
    border: 1px solid var(--cost-border);
    border-radius: 18px;
}

.cost-inventory-card header,
.cost-inventory-card footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.cost-inventory-card span,
.cost-inventory-card small {
    color: var(--cost-muted);
    font-size: .72rem;
}

.cost-inventory-card strong {
    color: var(--cost-text);
}

.cost-inventory-empty {
    grid-column: 1 / -1;
    padding: 28px;
    color: var(--cost-muted);
    text-align: center;
}

.cost-inventory-calculation {
    margin: 8px 0 0;
    color: #276444;
    font-size: .8rem;
    font-weight: 650;
}

.cost-chicken-detail-dialog {
    width: min(1080px, 100%);
}

.cost-chicken-detail-body {
    display: grid;
    gap: 20px;
    padding: 22px 26px 28px;
    overflow: auto;
    background: #ffffff;
}

.cost-detail-chart-card,
.cost-detail-history {
    min-width: 0;
    padding: 20px;
    border: 1px solid #e9eeeb;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(28, 55, 40, .055);
}

.cost-detail-chart-card > h3,
.cost-detail-history-heading h3 {
    margin: 0;
    color: var(--cost-text);
    font-size: 1.05rem;
}

.cost-detail-summary-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
    align-items: stretch;
    margin-top: 18px;
}

.cost-detail-chicken-profile {
    min-width: 0;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    padding: 12px;
    background: #fff;
}

.cost-detail-chicken-profile img {
    width: 240px;
    height: 240px;
    flex: 0 0 240px;
    border-radius: 28px;
    object-fit: cover;
    background: #ffffff;
    box-shadow: 0 8px 22px rgba(25, 52, 38, .1);
}

.cost-detail-chicken-profile > div {
    min-width: 0;
}

.cost-detail-chicken-profile strong {
    display: block;
    overflow: hidden;
    color: var(--cost-text);
    font-size: clamp(1.45rem, 2.3vw, 2rem);
    line-height: 1.15;
    letter-spacing: -.035em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cost-detail-chicken-profile p {
    max-width: 250px;
    margin: 8px 0 0;
    color: var(--cost-muted);
    font-size: .82rem;
    line-height: 1.65;
}

.cost-detail-breakdown {
    min-width: 0;
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    padding: 12px 0;
}

.cost-detail-donut {
    position: relative;
    width: 160px;
    height: 160px;
    margin: auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #edf1ee;
    transition: background .25s ease;
}

.cost-detail-donut::before {
    content: "";
    position: absolute;
    inset: 28px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(31, 65, 48, .035);
}

.cost-detail-donut-center {
    position: relative;
    z-index: 1;
    width: 112px;
    display: grid;
    justify-items: center;
    gap: 3px;
    text-align: center;
}

.cost-detail-donut-center span {
    color: var(--cost-muted);
    font-size: .7rem;
}

.cost-detail-donut-center strong {
    max-width: 112px;
    overflow: hidden;
    color: var(--cost-text);
    font-size: clamp(.92rem, 1.8vw, 1.22rem);
    line-height: 1.1;
    letter-spacing: -.035em;
    text-overflow: clip;
    white-space: nowrap;
}

.cost-detail-legend {
    display: grid;
    gap: 6px;
}

.cost-detail-legend-wrap {
    min-width:0;
    display:grid;
    gap:10px;
}

.cost-detail-lifetime-total {
    min-width:0;
    padding:10px 12px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    background:#f4f8f5;
    border:1px solid #e0e9e3;
    border-radius:13px;
}

.cost-detail-lifetime-total span {
    color:#68746d;
    font-size:.74rem;
}

.cost-detail-lifetime-total strong {
    color:#174d34;
    font-size:.92rem;
    white-space:nowrap;
}

.cost-detail-legend-row {
    min-width: 0;
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
    padding: 7px 8px;
    border-radius: 12px;
    transition: background-color .18s ease;
}

.cost-detail-legend-row:hover {
    background: #f7f9f7;
}

.cost-detail-legend-row i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.cost-detail-legend-row span {
    min-width: 0;
    overflow: hidden;
    color: #536159;
    font-size: .8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cost-detail-legend-row strong {
    color: var(--cost-text);
    font-size: .82rem;
    white-space: nowrap;
}

.cost-detail-history-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.cost-detail-history-heading p {
    margin: 4px 0 0;
    color: var(--cost-muted);
    font-size: .74rem;
}

.cost-detail-filters {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(150px, auto) minmax(125px, auto);
    gap: 8px;
    margin-bottom: 14px;
}

.cost-detail-filters label {
    min-width: 0;
}

.cost-detail-filters input,
.cost-detail-filters select {
    width: 100%;
    height: 46px;
    padding: 0 16px;
    border: 1px solid #e5eae7;
    border-radius: 999px;
    outline: 0;
    background: #f7f9f7;
    color: var(--cost-text);
    font: inherit;
    font-size: .8rem;
    transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
}

.cost-detail-filters input:focus,
.cost-detail-filters select:focus {
    border-color: #90b4a0;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(39, 117, 88, .09);
}

.cost-detail-search {
    position: relative;
    display: block;
}

.cost-detail-search i {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 16px;
    color: #77847d;
    transform: translateY(-50%);
    pointer-events: none;
}

.cost-detail-search input {
    padding-left: 42px;
}

.cost-detail-history-table {
    min-width: 760px;
}

.cost-detail-history-table th,
.cost-detail-history-table td {
    padding-top: 13px;
    padding-bottom: 13px;
}

.cost-detail-history-empty td {
    padding: 34px 16px;
    color: var(--cost-muted);
    text-align: center;
}

.cost-detail-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 14px;
}

.cost-detail-pagination[hidden] {
    display: none;
}

.cost-detail-pagination p {
    margin: 0;
    color: var(--cost-muted);
    font-size: .74rem;
}

.cost-detail-pagination nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 5px;
}

.cost-detail-pagination button {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid #e3e9e5;
    border-radius: 999px;
    background: #fff;
    color: #526159;
    font: inherit;
    font-size: .74rem;
    cursor: pointer;
}

.cost-detail-pagination button:hover:not(:disabled),
.cost-detail-pagination button.active {
    border-color: #1f684b;
    background: #1f684b;
    color: #fff;
}

.cost-detail-pagination button:disabled {
    opacity: .42;
    cursor: default;
}

@media (max-width: 900px) {
    .cost-detail-summary-layout {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .cost-detail-chicken-profile {
        min-height: 180px;
    }
}

/* Responsive */
@media (max-width: 1180px) {
    .cost-overview-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .cost-view-menu {
        grid-column: span 6;
    }

    .cost-overview-grid > .cost-summary-card {
        grid-column: span 3;
    }

    .cost-insight-grid {
        grid-template-columns: 1fr;
    }

    .cost-category-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cost-metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .cost-inventory-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .cost-mobile-menu {
        display: grid;
    }

    .cost-sidebar-overlay {
        display: block;
    }

    .cost-topbar-primary {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .cost-topbar {
        padding: 18px;
        gap: 18px;
        background: #fff;
        border-radius: 20px;
        box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
    }

    .cost-topbar-primary {
        width: 100%;
        flex-wrap: wrap;
    }

    .cost-add-button {
        margin-left: auto;
    }

    .cost-account-actions {
        justify-content: flex-end;
    }

    .cost-records-header {
        align-items: stretch;
        flex-direction: column;
    }

    .cost-record-tools {
        width: 100%;
    }

    .cost-chicken-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cost-search-group {
        width: auto;
        flex: 1;
    }

    .cost-category-list {
        grid-template-columns: 1fr;
    }

    .cost-modal {
        padding: 12px;
    }

    .cost-modal-dialog {
        max-height: calc(100dvh - 24px);
        border-radius: 20px;
    }

    .cost-modal-header,
    .cost-form-body,
    .cost-form-actions {
        padding-right: 18px;
        padding-left: 18px;
    }

    .cost-form-grid,
    .cost-radio-group {
        grid-template-columns: 1fr;
    }

    .cost-field-full,
    .cost-form-section {
        grid-column: auto;
    }
}

@media (max-width: 640px) {
    .cost-overview-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .cost-view-menu {
        grid-column: auto;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .cost-overview-grid > .cost-summary-card {
        grid-column: auto;
    }

    .cost-view-card {
        min-height: 52px;
        height: 56px;
        border-radius: 14px;
        font-size: 0.88rem;
        padding: 8px 10px;
    }

    .cost-metric-grid,
    .cost-inventory-grid,
    .cost-detail-breakdown {
        grid-template-columns: 1fr;
    }

    .cost-custom-range,
    .cost-chart-legend {
        align-items: stretch;
        flex-direction: column;
    }

    .cost-chicken-filters {
        grid-template-columns: 1fr;
    }

    .cost-summary-card {
        min-height: 180px;
        padding: 19px;
        border-radius: 20px;
    }

    .cost-topbar-primary {
        align-items: flex-start;
    }

    .cost-page-heading {
        flex: 1;
    }

    .cost-add-button {
        width: 100%;
        margin-left: 0;
    }

    .cost-record-tools {
        align-items: stretch;
        flex-direction: column;
    }

    .cost-search-group,
    .cost-category-filter-field,
    .cost-category-filter-field select {
        width: 100%;
    }

    .cost-category-filter-field select {
        padding-right: 6px;
    }

    .cost-trend-panel .cost-panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .cost-trend-periods {
        width: 100%;
    }

    .cost-trend-periods button {
        min-width: 0;
        flex: 1;
    }

    .cost-line-chart {
        min-height: 250px;
        margin-right: -4px;
        padding-bottom: 4px;
    }

    .cost-line-chart svg {
        height: 240px;
    }

    .cost-upload-box {
        align-items: stretch;
        flex-direction: column;
    }

    .cost-upload-button {
        justify-content: center;
    }

    .cost-image-lightbox {
        padding: 10px;
    }

    .cost-image-lightbox-dialog {
        max-height: calc(100dvh - 20px);
        padding: 12px;
        border-radius: 16px;
    }

    .cost-image-lightbox-canvas img {
        max-height: calc(100dvh - 145px);
    }

    .cost-form-actions {
        display: grid;
        grid-template-columns: 1fr 1.25fr;
    }

    .cost-form-message {
        grid-column: 1 / -1;
    }
}


@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}


/* Inventory filter revision: only search expands; other controls stay visible. */
.cost-inventory-filterbar .inventory-search-slot {
    position: relative;
    z-index: 8;
    flex: 0 0 48px;
    width: 48px;
    min-width: 48px;
    height: 48px;
    transition: width .3s ease, flex-basis .3s ease;
}

.cost-inventory-filterbar .inventory-search-slot:hover,
.cost-inventory-filterbar .inventory-search-slot:focus-within {
    flex-basis: 240px;
    width: 240px;
}

.cost-inventory-filterbar .inventory-search-slot .is-search {
    position: absolute;
    inset: 0 auto auto 0;
}

.cost-inventory-filterbar .inventory-static-pill {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    color: #242424;
    background: #f5f5f5;
    border: 1px solid #eeeeee;
    border-radius: 999px;
    box-shadow: 0 5px 14px rgba(17, 17, 17, .05);
    overflow: hidden;
    transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.cost-inventory-filterbar .inventory-static-pill:hover,
.cost-inventory-filterbar .inventory-static-pill:focus-within {
    color: #151515;
    background: #eeeeee;
    border-color: #e4e4e4;
    box-shadow: 0 7px 18px rgba(17, 17, 17, .08);
}

.cost-inventory-filterbar .inventory-static-pill.is-category {
    width: 112px;
}

.cost-inventory-filterbar .inventory-static-pill.is-status {
    width: 108px;
}

.cost-inventory-filterbar .inventory-static-pill.is-sort {
    width: 94px;
}

.cost-inventory-filterbar .inventory-static-pill select,
.cost-inventory-filterbar .inventory-static-pill select:hover,
.cost-inventory-filterbar .inventory-static-pill select:focus-visible,
.cost-inventory-filterbar .inventory-static-pill select.is-active-filter {
    width: 100%;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0 28px 0 14px;
    color: #242424;
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23444444' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.6' d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    border: 0;
    border-radius: 999px;
    box-shadow: none;
    outline: 0;
    appearance: none;
    font: inherit;
    font-size: .76rem;
    font-weight: 650;
    cursor: pointer;
}

.cost-inventory-filterbar .inventory-static-pill select option {
    color: #111;
    background: #fff;
}

.cost-inventory-filterbar .inventory-static-pill:has(select.is-active-filter) {
    background: #ececec;
    border-color: #dddddd;
}

.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill,
.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill:hover,
.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill:focus-visible,
.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill[aria-expanded="true"] {
    width: 108px;
    min-width: 108px;
    min-height: 44px;
    padding: 0 14px;
    justify-content: center;
    gap: 7px;
    color: #242424;
    background: #f5f5f5;
    border-color: #eeeeee;
    border-radius: 999px;
    box-shadow: 0 5px 14px rgba(17, 17, 17, .05);
    transform: none;
}

.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill:hover,
.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill:focus-visible {
    background: #eeeeee;
    border-color: #e4e4e4;
    box-shadow: 0 7px 18px rgba(17, 17, 17, .08);
}

.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill[aria-expanded="true"] {
    background: #e9e9e9;
    border-color: #d8d8d8;
}

.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill > i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    color: currentColor;
    font-size: .9rem;
}

.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill > span {
    opacity: 1;
    pointer-events: auto;
    transform: none;
    white-space: nowrap;
    font-size: .76rem;
    font-weight: 700;
}

@media (max-width: 700px) {
    .cost-inventory-filterbar .inventory-search-slot {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
    }

    .cost-inventory-filterbar .inventory-search-slot:hover,
    .cost-inventory-filterbar .inventory-search-slot:focus-within {
        width: 100%;
    }

    .cost-inventory-filterbar .inventory-search-slot .is-search,
    .cost-inventory-filterbar .inventory-search-slot .is-search:hover,
    .cost-inventory-filterbar .inventory-search-slot .is-search:focus-within,
    .cost-inventory-filterbar .inventory-static-pill,
    .cost-inventory-filterbar .inventory-static-pill.is-category,
    .cost-inventory-filterbar .inventory-static-pill.is-status,
    .cost-inventory-filterbar .inventory-static-pill.is-sort,
    .cost-inventory-filterbar #inventory-filter-button.inventory-static-pill,
    .cost-inventory-filterbar #inventory-filter-button.inventory-static-pill:hover,
    .cost-inventory-filterbar #inventory-filter-button.inventory-static-pill:focus-visible,
    .cost-inventory-filterbar #inventory-filter-button.inventory-static-pill[aria-expanded="true"] {
        width: 100%;
        min-width: 0;
    }

    .cost-inventory-filterbar .inventory-search-slot .is-search {
        position: relative;
    }
}

/* Keep the inventory content anchored directly below its menu row. */
@media (min-width: 981px) {
    body.inventory-view .cost-overview-grid {
        grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
        gap: 14px 16px;
        align-items: start;
    }

    body.inventory-view .cost-view-menu {
        grid-column: 1;
        grid-row: 1;
        align-self: start;
    }

    body.inventory-view #inventory-right-rail {
        grid-column: 2;
        grid-row: 1;
        align-self: start;
    }

    body.inventory-view #cost-inventory-panel,
    body.inventory-view #cost-inventory-history-panel {
        grid-column: 1 / -1;
        grid-row: auto;
        width: 100%;
        margin-top: 18px;
    }
}

body.inventory-view .cost-page {
    min-width: 0;
    overflow-x: clip;
}

@media (max-width: 980px) {
    body.inventory-view .cost-view-menu {
        grid-column: 1;
        grid-row: 1;
    }

    body.inventory-view #cost-inventory-panel {
        grid-column: 1;
        grid-row: 2;
    }

    body.inventory-view #inventory-right-rail {
        grid-column: 1;
        grid-row: 3;
    }
}
.cost-inventory-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.cost-secondary-button {
    min-height: 42px;
    padding: 0 18px;
    border: 1px solid #d8dee8;
    border-radius: 999px;
    background: #fff;
    color: #26323f;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.cost-secondary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(24, 35, 49, .08);
}

.cost-inventory-grid > .cost-table-wrap { width: 100%; grid-column:1 / -1; }
.cost-inventory-table { width:100%; min-width:780px; }

.cost-inventory-layout { display:grid; grid-template-columns:1fr; gap:18px; align-items:start; }
.cost-inventory-main { min-width:0; }
.cost-inventory-filterbar { display:flex; flex-wrap:wrap; gap:10px; margin-bottom:12px; }
.cost-inventory-filterbar input { flex:1 1 190px; }
.cost-inventory-filterbar select {
    min-height: 44px;    /* เดิม 52px */
    min-width: 100px;    /* เดิม 112px */
    padding: 0 27px 0 12px;
    font-size: .76rem;
}
.cost-inventory-filterbar #inventory-sort { flex-basis:175px; }
.cost-inventory-filterbar input,.cost-inventory-filterbar select { min-width:0; min-height:42px; border:1px solid #e1e8e3; border-radius:12px; padding:0 13px; background:#fff; color:#26352d; font:inherit; }
.cost-inventory-filterbar #inventory-filter-button {
    min-height: 40px;    /* เดิม 44px */
    padding: 0 12px;
    font-size: .76rem;
}
.cost-inventory-advanced-filters { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin:0 0 16px; padding:16px; border:1px solid #e8ede9; border-radius:16px; background:#f8faf8; }
.cost-inventory-advanced-filters label { display:grid; gap:6px; min-width:0; }
.cost-inventory-advanced-filters label > span { color:#66736c; font-size:.7rem; font-weight:700; }
.cost-inventory-advanced-filters input,.cost-inventory-advanced-filters select { width:100%; min-width:0; min-height:40px; padding:0 11px; border:1px solid #dfe6e1; border-radius:11px; background:#fff; color:#26352d; font:inherit; font-size:.78rem; }
.cost-inventory-custom-dates:not([hidden]) { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.cost-inventory-clear-filter { align-self:end; min-height:40px; border:0; border-radius:999px; background:#eef3ef; color:#466052; font:inherit; font-size:.76rem; font-weight:700; cursor:pointer; }
.cost-inventory-clear-filter:hover { background:#e3ebe5; }
.cost-inventory-side { display:grid; grid-template-columns:minmax(260px,3fr) minmax(0,7fr); gap:16px; align-items:stretch; }
.cost-inventory-recent-card { grid-column:1; grid-row:1; }
.cost-inventory-chart-card { grid-column:2; grid-row:1; }
.cost-inventory-right-rail { min-width:0; }
.cost-inventory-right-rail:not([hidden]) { display:grid; gap:14px; align-content:start; }
.cost-inventory-summary-card { background:#fff; border:1px solid #e9eeeb; border-radius:24px; padding:24px; box-shadow:0 12px 34px rgba(28,55,40,.07); }
.cost-inventory-summary-card h3 { margin:0; font-size:1.08rem; color:#1d2a23; }
.cost-inventory-chart-header { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:20px; }
.cost-inventory-chart-header span { display:block; margin-bottom:3px; color:#87918b; font-size:.7rem; font-weight:700; letter-spacing:.04em; }
.cost-inventory-chart-header > i { display:grid; width:38px; height:38px; flex:0 0 38px; place-items:center; border-radius:13px; background:#f2f7f4; color:#38745a; font-size:1.05rem; }
.cost-inventory-chart-body { display:grid; grid-template-columns:160px minmax(0,1fr); gap:18px; align-items:center; }
.cost-inventory-donut { position:relative; width:160px; height:160px; margin:auto; border-radius:50%; display:grid; place-items:center; background:#edf1ee; transition:background .25s ease; }
.cost-inventory-donut::before { content:""; position:absolute; inset:27px; border-radius:50%; background:#fff; box-shadow:0 0 0 1px rgba(31,65,48,.025); }
.cost-inventory-donut-center { position:relative; z-index:1; max-width:96px; display:grid; justify-items:center; text-align:center; }
.cost-inventory-donut-center span { color:#7b8780; font-size:.63rem; line-height:1.2; }
.cost-inventory-donut-center strong { margin:2px 0 0; color:#17231d; font-size:2rem; line-height:1; letter-spacing:-.04em; }
.cost-inventory-donut-center small { color:#8b958f; font-size:.68rem; }
.cost-inventory-legend-wrap { min-width:0; }
.cost-inventory-legend { display:grid; gap:10px; font-size:.77rem; }
.cost-inventory-legend div { display:grid; grid-template-columns:8px minmax(0,1fr) auto; gap:8px; align-items:center; min-width:0; }
.cost-inventory-legend i { width:7px; height:7px; border-radius:50%; }
.cost-inventory-legend span { min-width:0; color:#536159; line-height:1.25; }
.cost-inventory-legend strong { color:#25352c; font-size:.74rem; font-weight:700; white-space:nowrap; }
.cost-inventory-out-count { margin:13px 0 0; padding-top:11px; border-top:1px solid #eef1ef; color:#8a6f47; font-size:.73rem; font-weight:700; }
.cost-inventory-kpis { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; margin-top:20px; }
.cost-inventory-kpis article {
    position: relative;
    min-width: 0;
    padding: 14px;
    border-radius: 17px;
    background: #ffffff;
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.cost-inventory-kpis article:hover { transform:translateY(-2px); border-color:#dfe8e2; box-shadow:0 8px 18px rgba(28,55,40,.055); }
.cost-inventory-kpis article > i { position:absolute; top:13px; right:13px; color:#759082; font-size:.92rem; }
.cost-inventory-kpis article.is-low > i { color:#c28a43; }
/* หัวข้อ เช่น รายการทั้งหมด / ใกล้หมด / มูลค่าคงเหลือ */
.cost-inventory-kpis span {
    font-size: .78rem;   /* เดิม .66rem */
    font-weight: 700;
}

/* ตัวเลข 7 / 0 / ฿3,271.50 */
.cost-inventory-kpis strong {
    font-size: 1.5rem;  /* เดิม 1.05rem */
    font-weight: 750;
}

/* ข้อความเล็กด้านล่าง */
.cost-inventory-kpis small {
    font-size: .70rem;   /* เดิม .61rem */
}
.cost-inventory-chart-empty { min-height:210px; display:grid; justify-items:center; align-content:center; padding:12px 0 4px; text-align:center; }
.cost-inventory-chart-empty[hidden] { display:none; }
.cost-inventory-chart-empty > i { display:grid; width:58px; height:58px; place-items:center; border-radius:19px; background:#f2f6f3; color:#000000; font-size:1.55rem; }
.cost-inventory-chart-empty h4 { margin:14px 0 3px; color:#000000; font-size:1rem; }
.cost-inventory-chart-empty p { margin:0 0 15px; color:#87918b; font-size:.78rem; }
.cost-inventory-chart-empty .cost-add-button { min-height:40px; margin:0; padding:0 17px; border-color:#194d39; border-radius:999px; background:#194d39; color:#fff; font-size:.78rem; }
.cost-inventory-chart-empty .cost-add-button:hover { border-color:#123d2d; background:#123d2d; }
.cost-context-chart {
    min-height: 0;
    height: auto;
    width: 100%;
    overflow: hidden;
}

/* ให้ขนาดกราฟวงกลมเท่ากับแผนภูมิคลังสินค้า */
.cost-context-donut {
    width: 160px;
    height: 160px;
}

.cost-context-donut::before {
    inset: 27px;
}
.cost-context-chart.is-switching { animation:cost-context-chart-in .22s ease both; }
.cost-context-description { margin:-12px 0 16px; color:#7f8a84; font-size:.72rem; line-height:1.45; }
.cost-context-periods { display:flex; flex-wrap:wrap; gap:5px; margin-bottom:15px; }
.cost-context-periods button { min-height:29px; padding:0 9px; border:1px solid #e6ebe8; border-radius:999px; background:#f8faf8; color:#68756e; font:inherit; font-size:.62rem; cursor:pointer; }
.cost-context-periods button:hover,.cost-context-periods button.active { border-color:#8fb4a0; background:#edf5f0; color:#225f43; }
.cost-context-custom-range { grid-template-columns:1fr 1fr; gap:8px; margin:-5px 0 15px; }
.cost-context-custom-range:not([hidden]) { display:grid; }
.cost-context-custom-range label { display:grid; gap:4px; color:#7b8780; font-size:.62rem; }
.cost-context-custom-range input { min-width:0; width:100%; height:34px; padding:0 8px; border:1px solid #e0e7e2; border-radius:9px; background:#fff; color:#34443b; font:inherit; font-size:.68rem; }
.cost-context-overview-total { margin-bottom:8px; text-align:center; }
.cost-context-overview-total span { display:block; color:#7c8881; font-size:.68rem; }
.cost-context-overview-total strong { display:block; margin-top:2px; color:#17231d; font-size:1.55rem; letter-spacing:-.03em; }
.cost-context-overview-legend { display:flex; justify-content:center; gap:14px; margin:0 0 5px; color:#758179; font-size:.64rem; }
.cost-context-overview-legend[hidden] { display:none; }
.cost-context-overview-legend span { min-width:0; display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:3px 7px; text-align:left; }
.cost-context-overview-legend b { min-width:0; color:#758179; font-size:.68rem; font-weight:650; white-space:nowrap; }
.cost-context-overview-legend strong { grid-column:2; color:#1d2a23; font-size:.92rem; font-weight:750; white-space:nowrap; }
.cost-context-overview-legend i { width:7px; height:7px; border-radius:2px; background:#34795b; }
.cost-context-overview-legend i.is-chicken { background:#d6a13c; }
.cost-context-timeline { width:100%; overflow-x:auto; overflow-y:hidden; scrollbar-width:thin; }
.cost-context-timeline svg { display:block; min-width:100%; height:155px; }
.cost-context-timeline .context-grid { stroke:#edf1ee; stroke-width:1; }
.cost-context-timeline .context-bar-farm { fill:#34795b; }
.cost-context-timeline .context-bar-chicken { fill:#d6a13c; }
.cost-context-timeline .context-label { fill:#8a958f; font-size:9px; text-anchor:middle; }
.cost-context-timeline .context-empty-label { fill:#8a958f; font-size:11px; text-anchor:middle; }
.cost-context-donut-layout { 
    grid-template-columns: 190px minmax(0,1fr); 
    gap: 20px; 
}

.cost-context-donut { 
    width: 190px; 
    height: 190px; 
}

.cost-context-donut::before { 
    inset: 32px; 
}

.cost-context-donut .cost-inventory-donut-center strong {
    max-width: 120px;
    font-size: 1.25rem;
    line-height: 1.1;
}
.cost-context-legend { align-content:center; }
.cost-context-legend div { grid-template-columns:8px minmax(0,1fr); }
.cost-context-legend strong { grid-column:2; margin-top:-5px; color:#2c3b33; }
.cost-context-kpis { margin-top:18px; }
.cost-context-kpis article { min-height:93px; }
.cost-context-chicken {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr); /* เดิม 46px */
    gap: 12px;
    align-items: center;
    margin: -3px 0 14px;
    padding: 12px 14px;
    border: none;               /* ลบขอบ */
    border-radius: 15px;
    background: #ffffff;        /* เปลี่ยนเป็นขาว */
}

.cost-context-chicken img {
    width: 84px;                /* เดิม 46px */
    height: 84px;               /* เดิม 46px */
    border-radius: 12px;
    object-fit: cover;
    background: #ffffff;        /* เปลี่ยนเป็นขาว */
}
.cost-context-chicken span { min-width:0; display:grid; gap:1px; }
.cost-context-chicken strong { overflow:hidden; color:#25342c; font-size:.82rem; text-overflow:ellipsis; white-space:nowrap; }
.cost-context-chicken small { color:#89948e; font-size:.67rem; }
.cost-context-empty { min-height:300px; }
@keyframes cost-context-chart-in { from { opacity:.55; transform:scale(.985); } to { opacity:1; transform:scale(1); } }
.cost-inventory-recent-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:10px; }
.cost-inventory-recent-heading button { border:0; background:none; color:#18734f; font:inherit; font-size:.76rem; font-weight:700; cursor:pointer; }
.cost-inventory-recent-list { display:grid; }
.cost-inventory-recent-item { width:100%; display:grid; grid-template-columns:30px minmax(0,1fr) 14px; gap:9px; align-items:center; padding:10px 4px; border:0; border-bottom:1px solid #edf1ee; background:transparent; color:#26352d; font:inherit; text-align:left; cursor:pointer; transition:background-color .18s ease; }
.cost-inventory-recent-item:last-child { border-bottom:0; }
.cost-inventory-recent-item:hover { background:#f8faf8; }
.cost-inventory-recent-item > i:first-child { display:grid; width:28px; height:28px; place-items:center; border-radius:9px; background:#eef6f1; color:#277558; font-size:.8rem; }
.cost-inventory-recent-item.is-use > i:first-child { background:#fbf4ea; color:#a66e2f; }
.cost-inventory-recent-item > i:last-child { color:#a2aba6; font-size:.68rem; }
.cost-inventory-recent-copy { min-width:0; display:grid; gap:2px; }
.cost-inventory-recent-title { min-width:0; overflow:hidden; color:#26352d; font-size:.76rem; font-weight:700; text-overflow:ellipsis; white-space:nowrap; }
.cost-inventory-recent-title em { margin-right:4px; color:#277558; font-style:normal; }
.cost-inventory-recent-item.is-use .cost-inventory-recent-title em { color:#9b682e; }
.cost-inventory-recent-meta,.cost-inventory-recent-date { color:#89938d; font-size:.68rem; line-height:1.25; }
.cost-inventory-recent-empty { margin:0; padding:18px 4px; color:#89938d; font-size:.75rem; text-align:center; }
.cost-inventory-status { font-weight:600; }.cost-inventory-status.is-ready{color:#198754}.cost-inventory-status.is-low{color:#c47a18}.cost-inventory-status.is-empty{color:#cf4e4e}
.cost-inventory-remaining { display:grid; justify-items:end; gap:3px; }
.cost-inventory-remaining small { font-size:.62rem; font-weight:700; }
.cost-inventory-item-name { display:grid; gap:2px; min-width:120px; }
.cost-inventory-item-name strong { color:#26352d; font-size:.78rem; }
.cost-inventory-item-name small { color:#8a958f; font-size:.64rem; font-weight:500; }
.cost-inventory-table-empty { display:grid; justify-items:center; padding:42px 20px; text-align:center; }
.cost-inventory-table-empty > i { display:grid; width:48px; height:48px; place-items:center; border-radius:15px; background:#f1f5f2; color:#789083; font-size:1.2rem; }
.cost-inventory-table-empty h3 { margin:12px 0 3px; color:#2b3931; font-size:.95rem; }
.cost-inventory-table-empty p { margin:0 0 13px; color:#8a958f; font-size:.75rem; }
.cost-inventory-table-empty button { min-height:36px; padding:0 14px; border:1px solid #dbe5de; border-radius:999px; background:#fff; color:#315c46; font:inherit; font-size:.72rem; font-weight:700; cursor:pointer; }
.cost-inventory-pagination { display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:12px; align-items:center; margin-top:14px; padding-top:13px; border-top:1px solid #edf1ee; }
.cost-inventory-pagination p,.cost-inventory-history-pagination p { margin:0; color:#78847d; font-size:.72rem; }
.cost-inventory-pagination nav,.cost-inventory-history-pagination nav { display:flex; flex-wrap:wrap; justify-content:center; gap:5px; }
.cost-inventory-pagination nav button,.cost-inventory-history-pagination nav button { min-width:32px; height:32px; padding:0 8px; border:1px solid #e0e7e2; border-radius:9px; background:#fff; color:#536159; font:inherit; font-size:.72rem; cursor:pointer; }
.cost-inventory-pagination nav button:hover,.cost-inventory-history-pagination nav button:hover { border-color:#9fbbaa; background:#f4f8f5; }
.cost-inventory-pagination nav button.is-active,.cost-inventory-history-pagination nav button.is-active { border-color:#28664a; background:#28664a; color:#fff; }
.cost-inventory-pagination nav button:disabled,.cost-inventory-history-pagination nav button:disabled { opacity:.4; cursor:not-allowed; }
.cost-inventory-pagination select { min-height:34px; padding:0 28px 0 10px; border:1px solid #e0e7e2; border-radius:10px; background:#fff; color:#536159; font:inherit; font-size:.72rem; }
.cost-inventory-history-dialog { width:min(960px,100%); max-height:min(88vh,820px); }
.cost-inventory-history-filters { display:grid; grid-template-columns:minmax(170px,1.3fr) repeat(4,minmax(120px,1fr)); gap:10px; padding:18px 24px 14px; border-bottom:1px solid #edf1ee; }
.cost-inventory-history-filters input,.cost-inventory-history-filters select { min-width:0; min-height:40px; padding:0 11px; border:1px solid #e0e7e2; border-radius:11px; background:#fff; color:#2b3931; font:inherit; font-size:.76rem; }
.cost-inventory-history-list { min-height:220px; padding:0 24px; overflow:auto; }
.cost-inventory-history-list .cost-inventory-recent-item { grid-template-columns:34px minmax(0,1fr) auto; padding:13px 4px; cursor:default; }
.cost-inventory-history-list .cost-inventory-recent-item > i:last-child { display:none; }
.cost-inventory-history-list .cost-inventory-recent-title { font-size:.8rem; }
.cost-inventory-history-list .cost-inventory-recent-meta { white-space:normal; }
.cost-inventory-history-pagination { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:12px; align-items:center; padding:14px 24px 20px; border-top:1px solid #edf1ee; }
.inventory-view .cost-overview-grid { grid-template-columns:minmax(0,1fr) minmax(340px,420px); gap:14px 16px; margin-bottom:14px; align-items:start; }
.inventory-view .cost-view-menu { grid-column:1; grid-row:1; align-self:start; }
.inventory-view .cost-inventory-right-rail { grid-column:2; grid-row:1; }
.inventory-view .cost-inventory-panel,
.inventory-view #cost-inventory-panel,
.inventory-view #cost-inventory-history-panel { grid-column:1 / -1 !important; grid-row:auto !important; margin-top:18px !important; width:100% !important; }
.cost-inventory-right-rail > .cost-context-chart,
.cost-inventory-right-rail > .cost-inventory-top-chart,
.cost-inventory-right-rail > .cost-inventory-top-recent { grid-column:1; grid-row:auto; width:100%; }
.inventory-view .cost-inventory-grid { display:block; width:100%; }
.inventory-view .cost-inventory-main,
.inventory-view .cost-inventory-layout,
.inventory-view .cost-inventory-top-chart,
.inventory-view .cost-inventory-top-recent { align-self:start; }

body:not(.inventory-view) .cost-overview-grid { grid-template-columns:repeat(2,minmax(0,0.75fr)) minmax(340px,1fr); gap:12px 16px; align-items:start; }
body:not(.inventory-view) .cost-view-menu { grid-column:1 / 3; grid-row:1; align-self:start; }
body:not(.inventory-view) .cost-inventory-right-rail { grid-column:3; grid-row:1 / span 2; }
body:not(.inventory-view) .cost-summary-card[data-tone="expense"] { grid-column:1; grid-row:2; }
body:not(.inventory-view) .cost-summary-card[data-tone="average"] { grid-column:2; grid-row:2; }
body:not(.inventory-view) .cost-summary-card { min-height:0; border-radius:18px; padding:14px 16px; background:#fff; border:1px solid #edf1ee; box-shadow:0 8px 26px rgba(28,55,40,.06); }
body:not(.inventory-view) .cost-summary-value { font-size:clamp(1.25rem,2vw,1.75rem); }
body:not(.inventory-view) .cost-summary-latest { margin-top:8px; padding-top:8px; }
.cost-metric-grid { gap:10px; margin-bottom:14px; }
.cost-metric-card { border:1px solid #edf1ee; border-radius:16px; background:#fff; box-shadow:0 7px 22px rgba(28,55,40,.05); }
.cost-panel { border:1px solid #edf1ee; border-radius:20px; background:#fff; box-shadow:0 8px 28px rgba(28,55,40,.06); }
.cost-record-tools input,.cost-record-tools select { border-color:#e1e8e3; border-radius:12px; background:#fbfcfb; }
.cost-table thead th {
    background: #ffffff;
    color: #000000;
    font-weight: 600;
}
.cost-table tbody tr { transition:background .18s ease; }
.cost-table tbody tr:hover { background:#f8fbf9; }
@media (max-width:980px) { body:not(.inventory-view) .cost-overview-grid { grid-template-columns:1fr 1fr; } body:not(.inventory-view) .cost-view-menu { grid-column:1 / -1; grid-row:1; } body:not(.inventory-view) .cost-inventory-right-rail { grid-column:1 / -1; grid-row:2; } body:not(.inventory-view) .cost-summary-card[data-tone="expense"] { grid-column:1; grid-row:3; } body:not(.inventory-view) .cost-summary-card[data-tone="average"] { grid-column:2; grid-row:3; } }
@media (max-width: 1180px) { .cost-inventory-side { grid-template-columns:minmax(230px,3fr) minmax(0,7fr); } }
@media (max-width: 820px) {
    .cost-inventory-side { grid-template-columns:1fr; }
    .cost-inventory-recent-card,.cost-inventory-chart-card { grid-column:1; grid-row:auto; }
    .cost-inventory-chart-card { order:1; }
    .cost-inventory-recent-card { order:2; }
    .cost-inventory-chart-body { grid-template-columns:1fr; }
    .cost-inventory-kpis { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .cost-inventory-kpis article:last-child { grid-column:1 / -1; }
    .cost-inventory-advanced-filters { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .cost-inventory-history-filters { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width: 980px) {
    .inventory-view .cost-overview-grid { grid-template-columns:1fr; }
    .inventory-view .cost-view-menu { grid-column:1; grid-row:1; }
    .inventory-view .cost-inventory-right-rail { grid-column:1; grid-row:2; }
    .inventory-view .cost-inventory-panel { grid-column:1; grid-row:3; }
}
@media (max-width: 680px) {
    body:not(.inventory-view) .cost-overview-grid { grid-template-columns:1fr; }
    body:not(.inventory-view) .cost-view-menu { grid-column:1; grid-row:1; }
    body:not(.inventory-view) .cost-inventory-right-rail { grid-column:1; grid-row:2; }
    body:not(.inventory-view) .cost-summary-card[data-tone="expense"] { grid-column:1; grid-row:3; }
    body:not(.inventory-view) .cost-summary-card[data-tone="average"] { grid-column:1; grid-row:4; }
    .cost-context-donut-layout { grid-template-columns:1fr; }
    .cost-context-custom-range:not([hidden]) { grid-template-columns:1fr; }
    .cost-inventory-filterbar > * { flex:1 1 100%; width:100%; }
    .cost-inventory-advanced-filters,.cost-inventory-history-filters { grid-template-columns:1fr; }
    .cost-inventory-custom-dates:not([hidden]) { grid-template-columns:1fr; }
    .cost-inventory-pagination,.cost-inventory-history-pagination { grid-template-columns:1fr; justify-items:center; text-align:center; }
    .cost-inventory-pagination label { width:100%; }
    .cost-inventory-pagination select { width:100%; }
    .cost-inventory-kpis { grid-template-columns:1fr; }
    .cost-inventory-kpis article:last-child { grid-column:auto; }
    .cost-view-menu { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
    .cost-inventory-summary-card { padding:20px; border-radius:22px; }
}

.cost-chicken-summary {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cost-chicken-summary > img {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 14px;
    object-fit: cover;
    background: #edf0f4;
}

.cost-chicken-summary > span { display: grid; gap: 2px; }

@media (max-width: 720px) {
    .cost-inventory-actions,
    .cost-inventory-actions > button { width: 100%; }
}
.inventory-feed-summary {
    padding: 18px;
    background: #f7faf8;
    border: 1px solid #dfe7e1;
    border-radius: 18px;
}

.inventory-feed-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.inventory-feed-summary-header strong {
    color: var(--cost-text);
    font-size: 15px;
}

.inventory-feed-summary-header span {
    padding: 5px 10px;
    color: var(--cost-green);
    background: var(--cost-green-soft);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.inventory-feed-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.inventory-feed-summary-grid > div {
    padding: 12px;
    background: #fff;
    border: 1px solid #e5ebe6;
    border-radius: 14px;
}

.inventory-feed-summary-grid span {
    display: block;
    margin-bottom: 4px;
    color: #7a847c;
    font-size: 12px;
}

.inventory-feed-summary-grid strong {
    color: var(--cost-text);
    font-size: 15px;
}

#inventory-feed-chickens {
    max-height: 190px;
    overflow-y: auto;
    border-top: 1px solid #e2e8e3;
}

.inventory-feed-chicken-row {
    padding: 10px 2px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid #edf1ee;
    font-size: 13px;
}

.inventory-feed-chicken-row > span {
    display: flex;
    gap: 8px;
}

@media (max-width: 720px) {
    .inventory-feed-summary-grid {
        grid-template-columns: 1fr;
    }
}

#cost-chicken-filters .is-active-filter {
    color: #1f6a45 !important;
    background-color: #edf6ef !important;
    box-shadow: inset 0 0 0 1px rgba(40, 103, 68, .18) !important;
}

/* Unified filter bar — matches the marketplace capsule controls. */
.cost-records-header {
    align-items: stretch;
    flex-direction: column;
    gap: 20px;
}

.cost-record-tools {
    width: 100%;
    display: flex;
    align-items: center;
    gap: clamp(10px, 1.4vw, 22px);
}

.cost-record-tools .cost-search-group {
    width: auto;
    min-width: 300px;
    flex: 1 1 50%;
}

.cost-record-tools .cost-chicken-filters:not([hidden]) {
    display: flex;
    align-items: center;
    gap: clamp(8px, 1vw, 16px);
}

.cost-filter-stage {
    position: relative;
    z-index: 12;
    margin-bottom: 18px;
    container-type: inline-size;
}

.cost-inventory-filterbar {
    margin: 0;
    display: grid;
    grid-template-columns: minmax(300px, 1fr) max-content max-content max-content max-content;
    align-items: center;
    gap: clamp(8px, 1.2vw, 18px);
}

.cost-inventory-search {
    width: 100%;
    min-width: 0;
}

.cost-inventory-filterbar .cost-inventory-search input {
    min-height: 0;
    padding: 0 16px;
    background: transparent;
    border: 0;
    border-radius: 999px;
    box-shadow: none;
}

.cost-record-tools select:not(.thai-datetime-select),
.cost-record-tools .cost-chicken-filters input,
.cost-inventory-filterbar select:not(.thai-datetime-select) {
    width: auto;
    min-width: 112px;
    min-height: 52px;
    padding: 0 32px 0 16px;
    color: #26342c;
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%235b685f' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    border: 0;
    border-radius: 16px;
    box-shadow: none;
    appearance: none;
    font: inherit;
    font-size: .82rem;
    font-weight: 650;
    cursor: pointer;
    transition: color .18s ease, background-color .18s ease, box-shadow .18s ease;
}

.cost-record-tools .cost-chicken-filters input {
    max-width: 140px;
    padding-right: 13px;
    background-image: none;
    background-color: #f6f7f6;
    font-weight: 550;
    cursor: text;
}

.cost-record-tools select:not(.thai-datetime-select):hover,
.cost-record-tools select:not(.thai-datetime-select):focus-visible,
.cost-record-tools .cost-chicken-filters input:hover,
.cost-record-tools .cost-chicken-filters input:focus-visible,
.cost-inventory-filterbar select:not(.thai-datetime-select):hover,
.cost-inventory-filterbar select:not(.thai-datetime-select):focus-visible,
.cost-record-tools .is-active-filter,
.cost-inventory-filterbar .is-active-filter {
    color: var(--cost-green);
    background-color: #eff6f1;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(32, 91, 64, .07);
}

.cost-inventory-filterbar #inventory-sort {
    min-width: 105px;
}

.cost-inventory-filterbar #inventory-filter-button {
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid #dce4de;
    border-radius: 999px;
    background: #fff;
    box-shadow: none;
    white-space: nowrap;
}

.cost-inventory-filterbar #inventory-filter-button:hover,
.cost-inventory-filterbar #inventory-filter-button[aria-expanded="true"] {
    color: var(--cost-green);
    background: #eef6f0;
    border-color: #9fbaa8;
    transform: none;
}

.cost-inventory-advanced-filters {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 60;
    width: min(680px, 100%);
    margin: 0;
    padding: 20px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    background: #fff;
    border: 1px solid #e3e9e5;
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(23, 49, 34, .14);
    animation: cost-filter-panel-in .18s ease both;
}

.cost-filter-panel-title {
    grid-column: 1 / -1;
    color: #233129;
    font-size: .92rem;
}

@keyframes cost-filter-panel-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

@container (max-width: 760px) {
    .cost-inventory-filterbar {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
    }

    .cost-inventory-filterbar .cost-inventory-search {
        grid-column: 1 / -1;
    }

    .cost-inventory-filterbar select,
    .cost-inventory-filterbar #inventory-sort,
    .cost-inventory-filterbar #inventory-filter-button {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 1120px) {
    .cost-inventory-filterbar {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .cost-inventory-filterbar .cost-inventory-search {
        min-width: 0;
        grid-column: 1 / -1;
    }

    .cost-inventory-filterbar select {
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 640px) {
    .cost-records-header {
        padding: 20px 16px;
    }

    .cost-inventory-filterbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .cost-inventory-filterbar .cost-inventory-search {
        grid-column: 1 / -1;
    }

    .cost-inventory-filterbar #inventory-filter-button {
        width: 100%;
    }

    .cost-inventory-filterbar select {
        min-height: 46px;
        padding-left: 12px;
        font-size: .76rem;
    }

    .cost-inventory-advanced-filters {
        left: 0;
        right: auto;
        width: 100%;
        grid-template-columns: 1fr;
        max-height: min(520px, 70vh);
        overflow-y: auto;
    }
}


/* Inventory search and all four controls share one row when desktop space is available. */
.cost-inventory-filterbar {
    grid-template-columns: minmax(160px, 1fr) 88px 78px 88px 88px;
    gap: 5px;
}

.cost-inventory-filterbar .cost-inventory-search {
    grid-column: auto;
}

.cost-inventory-filterbar select,
.cost-inventory-filterbar #inventory-sort,
.cost-inventory-filterbar #inventory-filter-button {
    width: 100%;
    min-width: 0;
}

.cost-inventory-filterbar select {
    padding-right: 26px;
    padding-left: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cost-inventory-filterbar #inventory-filter-button {
    padding: 0 10px;
    justify-content: center;
}

@media (max-width: 700px) {
    .cost-inventory-filterbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .cost-inventory-filterbar .cost-inventory-search {
        grid-column: 1 / -1;
    }
}

/* Chicken view: count, total cost and average cost appear in that order. */
body.chicken-view .cost-overview-grid > .cost-summary-card {
    min-height: 210px;
    height: 264px;
    padding: 24px 26px;
    gap: 18px;
    justify-content: center;
    background: #fff;
    border: 1px solid #e9eeeb;
    border-radius: 24px;
    box-shadow: 0 12px 34px rgba(28, 55, 40, .08);
}

body.chicken-view .cost-summary-title {
    color: #536159;
    font-size: 1rem;
    font-weight: 700;
}

/* Keep chicken summary figures prominent and on one line. JavaScript reduces
   the inline font size only when a rendered value is wider than its card. */
body.chicken-view .cost-overview-grid > .cost-summary-card .cost-summary-main {
    min-width: 0;
    width: 100%;
    margin: 0;
    gap: 12px;
}

body.chicken-view .cost-overview-grid > .cost-summary-card .cost-summary-value {
    display: block;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    overflow-wrap: normal;
    word-break: keep-all;
    font-size: clamp(2rem, 2.7vw, 3.1rem);
    line-height: 1;
    letter-spacing: -0.04em;
}

body.chicken-view .cost-overview-grid > .cost-summary-card[data-tone="average"] .cost-summary-value {
    font-size: clamp(1.7rem, 2.3vw, 2.6rem);
}



body.chicken-view .cost-summary-caption {
    margin-top: 10px;
    font-size: .84rem;
}

body.chicken-view .cost-summary-latest {
    margin-top: auto;
    padding-top: 14px;
    gap: 7px;
}

body.chicken-view .cost-summary-latest > strong,
body.chicken-view .cost-summary-latest b {
    font-size: .86rem;
}

body.chicken-view .cost-chicken-count-card {
    justify-content: center;
}

body.chicken-view .cost-chicken-count-card .cost-summary-main {
    margin-top: 0;
}

@media (min-width: 981px) {
    body.chicken-view .cost-overview-grid {
        grid-template-columns:
            repeat(3, minmax(0, 0.5fr))
            minmax(340px, 1fr);
        gap: 12px 16px;
        align-items: start;
    }

    body.chicken-view .cost-view-menu {
        grid-column: 1 / 4;
        grid-row: 1;
    }

    body.chicken-view .cost-inventory-right-rail {
        grid-column: 4;
        grid-row: 1 / span 2;
    }

    body.chicken-view .cost-summary-card[data-tone="count"] {
        grid-column: 1;
        grid-row: 2;
    }

    body.chicken-view .cost-summary-card[data-tone="expense"] {
        grid-column: 2;
        grid-row: 2;
    }

    body.chicken-view .cost-summary-card[data-tone="average"] {
        grid-column: 3;
        grid-row: 2;
    }
}

@media (min-width: 681px) and (max-width: 980px) {
    body.chicken-view .cost-summary-card[data-tone="count"] {
        grid-column: 1;
        grid-row: 3;
    }

    body.chicken-view .cost-summary-card[data-tone="expense"] {
        grid-column: 2;
        grid-row: 3;
    }

    body.chicken-view .cost-summary-card[data-tone="average"] {
        grid-column: 1 / -1;
        grid-row: 4;
    }
}

@media (max-width: 680px) {
    body.chicken-view .cost-overview-grid > .cost-summary-card {
        height: auto;
        min-height: 190px;
        padding: 21px;
    }

    body.chicken-view .cost-summary-card[data-tone="count"] {
        grid-column: 1;
        grid-row: 3;
    }

    body.chicken-view .cost-summary-card[data-tone="expense"] {
        grid-column: 1;
        grid-row: 4;
    }

    body.chicken-view .cost-summary-card[data-tone="average"] {
        grid-column: 1;
        grid-row: 5;
    }

    .cost-chicken-detail-body {
        gap: 14px;
        padding: 16px;
    }

    .cost-detail-chart-card,
    .cost-detail-history {
    background: #ffffff;
    border: none;
    box-shadow: none;
    }

    .cost-detail-breakdown {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .cost-detail-chicken-profile {
        min-height: 0;
        justify-content: flex-start;
        gap: 18px;
        padding: 8px 0 14px;
    }

    .cost-detail-chicken-profile img {
        width: 112px;
        height: 112px;
        flex-basis: 112px;
        border-radius: 24px;
    }

    .cost-detail-donut {
        width: 166px;
        height: 166px;
    }

    .cost-detail-donut::before {
        inset: 29px;
    }

    .cost-detail-filters {
        grid-template-columns: 1fr 1fr;
    }

    .cost-detail-search {
        grid-column: 1 / -1;
    }

    .cost-detail-pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .cost-detail-pagination nav {
        justify-content: flex-start;
    }
}
.cost-search-group {
    height: 46px;
    padding: 4px;
    grid-template-columns: minmax(0, 1fr) 38px;
}

.cost-search-button {
    width: 38px;
    height: 38px;
}

.cost-filter-stage {
    position: relative;
    z-index: 12;

    width: 100%;
    margin: 0 0 18px;
    padding: 0 20px;
    box-sizing: border-box;

    container-type: inline-size;
}

.cost-inventory-filterbar {
    width: 100%;
    min-width: 0;

    grid-template-columns:
        minmax(0, 1fr)
        max-content
        max-content
        max-content
        max-content;

    gap: 8px;
}

.cost-inventory-filterbar select {
    min-width: 95px;
    min-height: 44px;
    padding: 0 26px 0 10px;
    font-size: .76rem;
}

.cost-inventory-filterbar #inventory-sort {
    min-width: 90px;
}

.cost-inventory-filterbar #inventory-filter-button {
    min-height: 40px;
    padding: 0 11px;
    font-size: .76rem;
}

/* Inventory filters: premium icon pills that expand without changing filter logic. */
.cost-filter-stage .cost-inventory-filterbar {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    min-height: 52px;
    overflow: visible;
}

.cost-inventory-filterbar .inventory-hover-pill {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: #fff;
    background: #151515;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
    cursor: pointer;
    isolation: isolate;
    will-change: width;
    transition: width .3s ease, background-color .3s ease, box-shadow .3s ease, border-color .3s ease;
}

.cost-inventory-filterbar .inventory-hover-pill:hover,
.cost-inventory-filterbar .inventory-hover-pill:focus-within {
    background: #1d1d1d;
    border-color: rgba(255, 255, 255, .14);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .16);
}

.cost-inventory-filterbar .inventory-hover-pill.is-search:hover,
.cost-inventory-filterbar .inventory-hover-pill.is-search:focus-within {
    width: 240px;
}

.cost-inventory-filterbar .inventory-hover-pill.is-category:hover,
.cost-inventory-filterbar .inventory-hover-pill.is-category:focus-within {
    width: 156px;
}

.cost-inventory-filterbar .inventory-hover-pill.is-status:hover,
.cost-inventory-filterbar .inventory-hover-pill.is-status:focus-within {
    width: 150px;
}

.cost-inventory-filterbar .inventory-hover-pill.is-sort:hover,
.cost-inventory-filterbar .inventory-hover-pill.is-sort:focus-within {
    width: 146px;
}

.cost-inventory-filterbar .inventory-hover-pill.is-advanced:hover,
.cost-inventory-filterbar .inventory-hover-pill.is-advanced:focus-visible {
    width: 132px;
}

.cost-inventory-filterbar .inventory-hover-pill > i,
.cost-inventory-filterbar .inventory-hover-pill .inventory-pill-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 46px;
    width: 46px;
    min-width: 46px;
    height: 46px;
    margin: 0;
    padding: 0;
    color: #fff;
    background: transparent;
    border: 0;
    border-radius: 999px;
    box-shadow: none;
    font-size: 1rem;
    line-height: 1;
    transform: none;
}

.cost-inventory-filterbar .inventory-hover-pill .inventory-pill-icon:hover,
.cost-inventory-filterbar .inventory-hover-pill .inventory-pill-icon:focus-visible {
    color: #fff;
    background: transparent;
    box-shadow: none;
    outline: 0;
    transform: none;
}

.cost-inventory-filterbar .inventory-hover-pill .cost-search-box,
.cost-inventory-filterbar .inventory-hover-pill select,
.cost-inventory-filterbar .inventory-hover-pill > span {
    min-width: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateX(8px);
    transition: opacity .2s ease .05s, transform .3s ease;
}

.cost-inventory-filterbar .inventory-hover-pill:hover .cost-search-box,
.cost-inventory-filterbar .inventory-hover-pill:focus-within .cost-search-box,
.cost-inventory-filterbar .inventory-hover-pill:hover select,
.cost-inventory-filterbar .inventory-hover-pill:focus-within select,
.cost-inventory-filterbar .inventory-hover-pill:hover > span,
.cost-inventory-filterbar .inventory-hover-pill:focus-visible > span {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.cost-inventory-filterbar .inventory-hover-pill .cost-search-box {
    display: flex;
    flex: 1 1 auto;
    width: 188px;
    height: 100%;
    margin: 0;
    padding: 0 14px 0 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.cost-inventory-filterbar .inventory-hover-pill #inventory-search {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    color: #fff;
    caret-color: #fff;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    outline: 0;
    font: inherit;
    font-size: .8rem;
}

.cost-inventory-filterbar .inventory-hover-pill #inventory-search::placeholder {
    color: rgba(255, 255, 255, .65);
}

.cost-inventory-filterbar .inventory-hover-pill select,
.cost-inventory-filterbar .inventory-hover-pill select:hover,
.cost-inventory-filterbar .inventory-hover-pill select:focus-visible,
.cost-inventory-filterbar .inventory-hover-pill select.is-active-filter {
    flex: 1 1 auto;
    width: calc(100% - 46px);
    min-width: 0;
    height: 46px;
    min-height: 46px;
    margin: 0;
    padding: 0 26px 0 0;
    color: #fff;
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.6' d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    outline: 0;
    appearance: none;
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
}

.cost-inventory-filterbar .inventory-hover-pill select option {
    color: #111;
    background: #fff;
}

.cost-inventory-filterbar .inventory-hover-pill:has(select.is-active-filter) {
    background: #1d1d1d;
    border-color: rgba(255, 255, 255, .2);
}

.cost-inventory-filterbar #inventory-filter-button.inventory-hover-pill,
.cost-inventory-filterbar #inventory-filter-button.inventory-hover-pill:hover,
.cost-inventory-filterbar #inventory-filter-button.inventory-hover-pill[aria-expanded="true"] {
    width: 48px;
    min-width: 48px;
    min-height: 48px;
    padding: 0;
    justify-content: flex-start;
    color: #fff;
    background: #151515;
    border-color: rgba(255, 255, 255, .08);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
    transform: none;
}

.cost-inventory-filterbar #inventory-filter-button.inventory-hover-pill:hover,
.cost-inventory-filterbar #inventory-filter-button.inventory-hover-pill:focus-visible {
    width: 132px;
    color: #fff;
    background: #1d1d1d;
    border-color: rgba(255, 255, 255, .14);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .16);
}

.cost-inventory-filterbar #inventory-filter-button.inventory-hover-pill[aria-expanded="true"] {
    border-color: rgba(255, 255, 255, .32);
}

.cost-inventory-filterbar #inventory-filter-button.inventory-hover-pill > span {
    flex: 0 0 auto;
    padding-right: 18px;
    white-space: nowrap;
    font-size: .8rem;
    font-weight: 700;
}

@media (max-width: 700px) {
    .cost-filter-stage .cost-inventory-filterbar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .cost-inventory-filterbar .inventory-hover-pill,
    .cost-inventory-filterbar .inventory-hover-pill:hover,
    .cost-inventory-filterbar .inventory-hover-pill:focus-within,
    .cost-inventory-filterbar #inventory-filter-button.inventory-hover-pill,
    .cost-inventory-filterbar #inventory-filter-button.inventory-hover-pill:hover,
    .cost-inventory-filterbar #inventory-filter-button.inventory-hover-pill:focus-visible,
    .cost-inventory-filterbar #inventory-filter-button.inventory-hover-pill[aria-expanded="true"] {
        width: 100%;
        min-width: 0;
    }

    .cost-inventory-filterbar .inventory-hover-pill.is-search {
        grid-column: 1 / -1;
    }

    .cost-inventory-filterbar .inventory-hover-pill .cost-search-box,
    .cost-inventory-filterbar .inventory-hover-pill select,
    .cost-inventory-filterbar .inventory-hover-pill > span {
        opacity: 1;
        pointer-events: auto;
        transform: translateX(0);
    }

    .cost-inventory-filterbar .inventory-hover-pill .cost-search-box {
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cost-inventory-filterbar .inventory-hover-pill,
    .cost-inventory-filterbar .inventory-hover-pill .cost-search-box,
    .cost-inventory-filterbar .inventory-hover-pill select,
    .cost-inventory-filterbar .inventory-hover-pill > span {
        transition-duration: .01ms;
    }
}

/* Farm and chicken filters: the single authoritative layout.
   Farm date filtering is a three-control group, so the toolbar may wrap.
   The nested filter groups become transparent to layout via display: contents. */
.cost-record-tools:has(#cost-farm-filters:not([hidden])),
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) {
    width: 100%;
    max-width: none;
    display: flex;
    grid-template-columns: none;
    align-items: center;
    flex-flow: row wrap;
    justify-content: flex-start;
    gap: 10px;
    padding: 8px 0;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.cost-record-tools:has(#cost-farm-filters:not([hidden])) .dashboard-filter-search-slot,
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) .dashboard-filter-search-slot {
    flex: 0 0 48px;
    width: 48px;
    min-width: 48px;
}

.cost-record-tools:has(#cost-farm-filters:not([hidden])) .dashboard-filter-search-slot:hover,
.cost-record-tools:has(#cost-farm-filters:not([hidden])) .dashboard-filter-search-slot:focus-within,
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) .dashboard-filter-search-slot:hover,
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) .dashboard-filter-search-slot:focus-within {
    flex-basis: 220px;
    width: 220px;
}

.cost-record-tools:has(#cost-farm-filters:not([hidden])) .dashboard-filter-search-slot:hover .cost-search-group,
.cost-record-tools:has(#cost-farm-filters:not([hidden])) .dashboard-filter-search-slot:focus-within .cost-search-group,
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) .dashboard-filter-search-slot:hover .cost-search-group,
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) .dashboard-filter-search-slot:focus-within .cost-search-group {
    width: 220px;
}

.cost-record-tools:has(#cost-farm-filters:not([hidden])) #cost-farm-filters,
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) #cost-chicken-filters {
    display: contents;
}

.cost-record-tools:has(#cost-farm-filters:not([hidden])) .cost-category-filter-field {
    flex: 0 0 128px;
    width: 128px;
    min-width: 128px;
}

.cost-record-tools:has(#cost-farm-filters:not([hidden])) .cost-category-filter-field,
.cost-record-tools:has(#cost-farm-filters:not([hidden])) #cost-farm-filters > label,
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) #cost-chicken-filters > select,
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) #cost-chicken-filters > label {
    height: 48px;
    min-height: 48px;
    box-sizing: border-box;
}

.cost-record-tools:has(#cost-farm-filters:not([hidden])) .cost-category-filter-field select,
.cost-record-tools:has(#cost-farm-filters:not([hidden])) #cost-farm-filters label,
.cost-record-tools:has(#cost-farm-filters:not([hidden])) #cost-farm-filters input,
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) #cost-chicken-filters > select,
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) #cost-chicken-filters > label,
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) #cost-chicken-filters input {
    width: 100%;
    min-width: 0;
    max-width: none;
    margin: 0;
}

.cost-record-tools:has(#cost-farm-filters:not([hidden])) .cost-category-filter-field select,
.cost-record-tools:has(#cost-farm-filters:not([hidden])) #cost-farm-filters input,
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) #cost-chicken-filters input {
    height: 46px;
    min-height: 46px;
    box-sizing: border-box;
}

.cost-record-tools:has(#cost-farm-filters:not([hidden])) .cost-date-range-picker-wrap {
    flex: 0 0 auto;
}

.cost-record-tools:has(#cost-farm-filters:not([hidden])) #cost-farm-filters > label {
    flex: 0 0 112px;
}

.cost-record-tools:has(#cost-chicken-filters:not([hidden])) #cost-gender-filter {
    flex: 0 0 110px;
}

.cost-record-tools:has(#cost-chicken-filters:not([hidden])) #cost-breed-filter {
    flex: 0 0 138px;
}

.cost-record-tools:has(#cost-chicken-filters:not([hidden])) #cost-chicken-filters > label {
    flex: 0 0 112px;
}

@media (max-width: 900px) {
    .cost-record-tools:has(#cost-farm-filters:not([hidden])),
    .cost-record-tools:has(#cost-chicken-filters:not([hidden])) {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .cost-record-tools:has(#cost-farm-filters:not([hidden])) .dashboard-filter-search-slot,
    .cost-record-tools:has(#cost-chicken-filters:not([hidden])) .dashboard-filter-search-slot {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
    }

    .cost-record-tools:has(#cost-farm-filters:not([hidden])) .dashboard-filter-search,
    .cost-record-tools:has(#cost-chicken-filters:not([hidden])) .dashboard-filter-search {
        position: relative;
        width: 100%;
    }

    .cost-record-tools:has(#cost-farm-filters:not([hidden])) .dashboard-filter-search input,
    .cost-record-tools:has(#cost-chicken-filters:not([hidden])) .dashboard-filter-search input,
    .cost-record-tools:has(#cost-farm-filters:not([hidden])) .dashboard-filter-search label,
    .cost-record-tools:has(#cost-chicken-filters:not([hidden])) .dashboard-filter-search label {
        opacity: 1;
        pointer-events: auto;
        transform: none;
    }

    .cost-record-tools:has(#cost-farm-filters:not([hidden])) .cost-category-filter-field,
    .cost-record-tools:has(#cost-farm-filters:not([hidden])) #cost-farm-filters > label,
    .cost-record-tools:has(#cost-chicken-filters:not([hidden])) #cost-chicken-filters > select,
    .cost-record-tools:has(#cost-chicken-filters:not([hidden])) #cost-chicken-filters > label {
        width: 100%;
        min-width: 0;
        max-width: none;
        flex-basis: auto;
    }

    .cost-record-tools:has(#cost-farm-filters:not([hidden])) #cost-farm-filters > label:first-child {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
        max-width: none;
    }
}
/* หน้า ต้นทุนฟาร์ม: ให้ 2 กล่องสูงเท่ากัน */
body.farm-view .cost-summary-card[data-tone="expense"],
body.farm-view .cost-summary-card[data-tone="average"] {
    align-self: stretch;
    height: 100%;
    box-sizing: border-box;
}
/* เฉพาะหน้า ต้นทุนฟาร์ม: จัดกล่องจำนวนรายการให้อยู่กลาง */
body.farm-view .cost-summary-card[data-tone="average"] {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* จัดเนื้อหาภายในให้อยู่กลาง */
body.farm-view .cost-summary-card[data-tone="average"] .cost-summary-card-top,
body.farm-view .cost-summary-card[data-tone="average"] .cost-summary-main {
    width: 100%;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* หัวข้อ */
body.farm-view .cost-summary-card[data-tone="average"] .cost-summary-title {
    text-align: center;
}

/* ตัวเลข 4 รายการ */
body.farm-view .cost-summary-card[data-tone="average"] .cost-summary-value {
    text-align: center;
}

/* ล่าสุด 24 ส.ค. 2569 */
body.farm-view .cost-summary-card[data-tone="average"] .cost-summary-caption {
    text-align: center;
}
body.farm-view .cost-summary-card[data-tone="average"] {
    gap: 10px;
}

body.farm-view .cost-summary-card[data-tone="average"] .cost-summary-main {
    margin: 0;
    gap: 6px;
}
/* รายละเอียด */
.cost-table-action[data-action="view"] {
    color: #ffffff;
    background: #6B7280;
    border-color: #6B7280;
}

/* แก้ไข */
.cost-table-action[data-action="edit"] {
    color: #ffffff;
    background: #EAB308;
    border-color: #EAB308;
}

/* ลบ */
.cost-table-action[data-action="delete"] {
    color: #ffffff;
    background: #DC2626;
    border-color: #DC2626;
}

/* Overview dashboard: scoped so farm, chicken and inventory keep their existing UI. */
body.overview-view .cost-overview-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(340px, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 14px 16px;
    align-items: stretch;
    margin-bottom: 18px;
}

body.overview-view .cost-year-toolbar {
    grid-column:1;
    grid-row:2;
    min-width:0;
    padding:14px 18px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
    background:#fff;
    border:1px solid #e9eeeb;
    border-radius:18px;
    box-shadow:0 7px 22px rgba(28,55,40,.05);
}

body.overview-view .cost-year-toolbar h2 {
    margin:0;
    color:#172019;
    font-size:1.05rem;
}

body.overview-view .cost-year-toolbar p {
    margin:4px 0 0;
    color:#617068;
    font-size:.76rem;
}

body.overview-view .cost-year-toolbar p[data-status="closed"] {
    color:#8a641e;
}

body.overview-view .cost-year-select-field {
    min-width:190px;
    display:flex;
    align-items:center;
    gap:10px;
    color:#68746d;
    font-size:.76rem;
    font-weight:650;
}

body.overview-view .cost-year-select-field select {
    min-width: 116px;
    height: 42px;
    padding: 0 34px 0 14px;
    color: #000000;
    background: #ffffff;   /* เปลี่ยนเป็นขาว */
    border: none;          /* ลบขอบ */
    border-radius: 13px;
    font: inherit;
    font-size: .86rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: none;      /* กันเงาถ้ามี */
}

/* ========================================================================== 
   Premium Ledger Modal System
   One scoped visual contract for every cost dialog and popup state.
   ========================================================================== */
@layer cost-modal-legacy {
.cost-modal,
.cost-image-lightbox {
    --cost-modal-radius: 16px;
    --cost-modal-control-radius: 12px;
    --cost-modal-divider: #e1e7e3;
    --cost-modal-field: #ffffff;
    --cost-modal-canvas: #f7f9f7;
    --cost-modal-focus: rgba(24, 63, 44, .09);
    font-family: "Prompt", "Noto Sans Thai", sans-serif;
}

.cost-modal {
    padding: clamp(16px, 3vw, 30px);
}

.cost-modal-backdrop {
    background: rgba(7, 16, 10, .42);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: cost-modal-backdrop-in 180ms ease-out both;
}

.cost-modal-dialog {
    width: min(744px, 100%);
    max-height: min(92dvh, 880px);
    background: var(--cost-modal-canvas);
    border: 1px solid rgba(224, 231, 226, .92);
    border-radius: var(--cost-modal-radius);
    box-shadow: 0 2px 8px rgba(7, 22, 13, .08), 0 28px 70px rgba(7, 22, 13, .2);
    animation: cost-modal-dialog-in 220ms cubic-bezier(.22, 1, .36, 1) both;
}

#inventory-modal .cost-modal-dialog {
    width: min(704px, 100%);
}

#inventory-use-modal .cost-modal-dialog {
    width: min(824px, 100%);
}

.cost-chicken-detail-dialog {
    width: min(1080px, 100%);
}

.cost-inventory-history-dialog {
    width: min(960px, 100%);
    max-height: min(92dvh, 840px);
}

.cost-modal-header {
    position: relative;
    z-index: 3;
    flex: 0 0 auto;
    padding: 20px 22px;
    align-items: center;
    gap: 16px;
    background: #fff;
    border-bottom: 0;
    box-shadow: inset 0 -1px 0 rgba(225, 231, 227, .8);
}

.cost-modal-heading,
.cost-modal-heading-copy {
    min-width: 0;
}

.cost-modal-heading {
    display: flex;
    align-items: center;
    gap: 13px;
}

.cost-modal-context-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    color: #285b40;
    background: #edf4ef;
    border: 1px solid #dae7de;
    border-radius: 12px;
    font-size: 1rem;
}

.cost-modal-header h2 {
    margin: 0;
    color: var(--cost-text);
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -.015em;
}

.cost-modal-header p {
    max-width: 68ch;
    margin: 3px 0 0;
    color: #66736c;
    font-size: .8rem;
    line-height: 1.55;
}

.cost-modal-close,
.cost-image-lightbox-close {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    color: #5f6b64;
    background: #f7f9f7;
    border: 1px solid #edf1ee;
    border-radius: var(--cost-modal-control-radius);
    transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.cost-modal-close:hover,
.cost-image-lightbox-close:hover {
    color: var(--cost-green);
    background: #edf4ef;
    border-color: #d5e2d9;
}

.cost-modal-close:active,
.cost-image-lightbox-close:active {
    transform: scale(.96);
}

.cost-form {
    min-height: 0;
    overflow: hidden;
}

.cost-form-body {
    padding: 20px 22px 22px;
    overflow-x: hidden;
    background: var(--cost-modal-canvas);
    scrollbar-width: thin;
    scrollbar-color: #b7c4bb transparent;
}

.cost-form-body::-webkit-scrollbar,
.cost-chicken-detail-body::-webkit-scrollbar,
.cost-inventory-history-list::-webkit-scrollbar,
.inventory-chicken-picker::-webkit-scrollbar,
.cost-table-wrap::-webkit-scrollbar,
.cost-image-lightbox-canvas::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.cost-form-body::-webkit-scrollbar-thumb,
.cost-chicken-detail-body::-webkit-scrollbar-thumb,
.cost-inventory-history-list::-webkit-scrollbar-thumb,
.inventory-chicken-picker::-webkit-scrollbar-thumb,
.cost-table-wrap::-webkit-scrollbar-thumb,
.cost-image-lightbox-canvas::-webkit-scrollbar-thumb {
    background: #b7c4bb;
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

.cost-form-stack {
    display: grid;
}

.cost-form-group {
    min-width: 0;
    padding-bottom: 20px;
}

.cost-form-group + .cost-form-group,
.cost-form-group + .cost-form-section,
.cost-form-section + .cost-form-group {
    padding-top: 20px;
    border-top: 1px solid var(--cost-modal-divider);
}

.cost-form-group:last-child {
    padding-bottom: 0;
}

.cost-form-group-dynamic:not(:has(.cost-field:not([hidden]), .inventory-feed-summary:not([hidden]))) {
    display: none;
}

.cost-form-group-heading {
    margin: 0 0 12px;
}

.cost-form-group-heading h3 {
    margin: 0;
    color: #334139;
    font-size: .875rem;
    font-weight: 700;
    line-height: 1.45;
}

.cost-form-group-grid,
.cost-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 14px;
    row-gap: 14px;
}

.cost-form-group-grid-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cost-form-group-grid-value {
    grid-template-columns: minmax(0, 1.35fr) repeat(2, minmax(0, .82fr));
}

#auto-feeding-panel {
    padding: 15px;
    background: #fff;
    border: 1px solid var(--cost-modal-divider);
    border-radius: 12px;
}

.cost-form-group .cost-inventory-calculation:not(#inventory-calculation) {
    margin: 0;
    color: #69776f;
    font-size: .8rem;
    font-weight: 500;
    line-height: 1.45;
}

.cost-field {
    gap: 6px;
}

.cost-field label,
.cost-field-label,
.cost-form-section legend {
    color: #2e3c34;
    font-size: .8rem;
    font-weight: 600;
    line-height: 1.45;
}

.cost-optional-label {
    color: #66736c;
    font-size: .8rem;
}

.cost-required {
    color: #a94a4a;
    font-size: .72em;
}

.cost-modal .cost-field input:not([type="checkbox"]):not([type="radio"]),
.cost-modal .cost-field select,
.cost-modal .cost-field textarea,
.cost-inventory-history-filters input,
.cost-inventory-history-filters select,
.cost-detail-filters input,
.cost-detail-filters select {
    min-width: 0;
    min-height: 46px;
    padding-right: 14px;
    padding-left: 14px;
    color: var(--cost-text);
    background: var(--cost-modal-field);
    border: 1px solid #d9e1dc;
    border-radius: var(--cost-modal-control-radius);
    box-shadow: none;
    font: inherit;
    font-size: .875rem;
    transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.cost-modal .cost-field textarea {
    min-height: 88px;
    padding-top: 11px;
    padding-bottom: 11px;
    line-height: 1.55;
}

.cost-modal .cost-field input:not([type="checkbox"]):not([type="radio"]):hover,
.cost-modal .cost-field select:hover,
.cost-modal .cost-field textarea:hover,
.cost-inventory-history-filters input:hover,
.cost-inventory-history-filters select:hover,
.cost-detail-filters input:hover,
.cost-detail-filters select:hover {
    background: #fff;
    border-color: #bdc9c1;
}

.cost-modal .cost-field input:not([type="checkbox"]):not([type="radio"]):focus,
.cost-modal .cost-field select:focus,
.cost-modal .cost-field textarea:focus,
.cost-inventory-history-filters input:focus,
.cost-inventory-history-filters select:focus,
.cost-detail-filters input:focus,
.cost-detail-filters select:focus {
    background: #fff;
    border-color: #628672;
    box-shadow: 0 0 0 3px var(--cost-modal-focus);
    outline: 0;
}

.cost-modal input[type="checkbox"],
.cost-modal input[type="radio"] {
    width: 18px;
    min-width: 18px;
    height: 18px;
    min-height: 18px;
    padding: 0;
    accent-color: var(--cost-green);
}

.cost-modal .cost-field input:disabled,
.cost-modal .cost-field select:disabled,
.cost-modal .cost-field textarea:disabled,
.cost-modal .cost-field input[readonly] {
    color: #68746d;
    background: #f1f4f2;
    border-color: #e1e7e3;
    box-shadow: none;
    cursor: not-allowed;
}

.cost-modal .cost-field input[aria-invalid="true"],
.cost-modal .cost-field select[aria-invalid="true"],
.cost-modal .cost-field textarea[aria-invalid="true"] {
    background: #fffafa;
    border-color: #c96767;
    box-shadow: 0 0 0 3px rgba(185, 63, 63, .1);
}

.cost-modal input::placeholder,
.cost-modal textarea::placeholder,
.cost-inventory-history-filters input::placeholder,
.cost-detail-filters input::placeholder {
    color: #66736c;
    opacity: 1;
}

.cost-modal input,
.cost-modal textarea,
.cost-inventory-history-filters input,
.cost-detail-filters input {
    caret-color: var(--cost-green);
}

.cost-modal ::selection,
.cost-image-lightbox ::selection {
    color: #fff;
    background: #315d47;
}

.cost-field-emphasis input:not([type="checkbox"]):not([type="radio"]) {
    color: #173d2b;
    background: #fff;
    border-color: #b8cabe;
    font-size: 1.2rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.cost-field-error {
    min-height: 0;
    margin: 0;
    color: #a93636;
    font-size: .8rem;
    line-height: 1.45;
}

.cost-field-error:empty {
    display: none;
}

.cost-note-meta {
    margin-top: 0;
    color: #66736c;
    font-size: .8rem;
}

.cost-money-input span {
    color: #65716a;
    font-size: .8rem;
    font-weight: 650;
}

.cost-calculation-card {
    min-width: 0;
    min-height: 76px;
    padding: 13px 14px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    background: #edf5f0;
    border: 1px solid #d6e5db;
    border-radius: 12px;
}

.cost-calculation-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: #22583a;
    background: #fff;
    border: 1px solid #d9e6dd;
    border-radius: 12px;
    font-size: 1.2rem;
}

.cost-calculation-label {
    display: block;
    margin-bottom: 2px;
    color: #607168;
    font-size: .8rem;
    font-weight: 600;
}

.cost-calculation-card .cost-inventory-calculation {
    margin: 0;
    color: #153f2b;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
}

.cost-calculation-formula {
    color: #66766d;
    font-size: .8rem;
    white-space: nowrap;
}

.cost-form-section {
    margin: 0;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--cost-modal-divider);
    border-radius: 16px;
}

.cost-radio-group {
    gap: 8px;
}

.cost-radio-option {
    min-height: 44px;
    padding: 9px 11px;
    color: #526058;
    background: #fafbfa;
    border-color: #dfe6e1;
    border-radius: var(--cost-modal-control-radius);
    font-size: .8rem;
    transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.cost-radio-option:hover {
    border-color: #b9c8be;
}

.cost-radio-option:has(input:checked) {
    color: var(--cost-green);
    background: var(--cost-green-soft);
    border-color: #9ebba8;
}

.cost-optional-quantity {
    margin-top: -3px;
}

.cost-optional-quantity button,
.cost-modal .cost-secondary-button {
    min-height: 40px;
    padding: 0 14px;
    color: #345343;
    background: #fff;
    border: 1px solid #d8e2db;
    border-radius: var(--cost-modal-control-radius);
    box-shadow: none;
    font: inherit;
    font-size: .8rem;
    font-weight: 650;
    transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.cost-optional-quantity button:hover,
.cost-modal .cost-secondary-button:hover {
    color: var(--cost-green);
    background: #f2f7f4;
    border-color: #b8cbbf;
}

.cost-upload-box {
    padding: 14px 15px;
    background: #fff;
    border-color: #b8c7bd;
    border-radius: 12px;
    transition: background-color 160ms ease, border-color 160ms ease;
}

.cost-upload-box:focus-within,
.cost-upload-box:hover {
    background: #f5f9f6;
    border-color: #779884;
}

.cost-upload-box p {
    color: #69756e;
    font-size: .8rem;
    line-height: 1.5;
}

.cost-upload-button {
    min-height: 40px;
    padding: 0 14px;
    color: var(--cost-green);
    background: var(--cost-green-soft);
    border: 1px solid #d1e1d7;
    border-radius: var(--cost-modal-control-radius);
    font-size: .8rem;
    transition: background-color 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.cost-upload-button:hover {
    background: #dfeee5;
    border-color: #b8cebf;
}

.cost-upload-button:active,
.cost-optional-quantity button:active,
.cost-modal .cost-secondary-button:active {
    transform: translateY(1px);
}

.cost-receipt-preview {
    margin-top: 10px;
    padding: 10px;
    background: #fbfcfb;
    border: 1px solid var(--cost-modal-divider);
    border-radius: 12px;
}

.cost-receipt-preview img {
    border-radius: 12px;
}

.cost-receipt-zoom {
    background: var(--cost-green);
    box-shadow: 0 4px 10px rgba(16, 47, 32, .18);
}

.cost-remove-receipt {
    color: #a93636;
    background: #fff;
    border: 1px solid #ecd2d2;
    border-radius: 12px;
    transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.cost-remove-receipt:hover {
    color: #8f3030;
    background: #fbeeee;
    border-color: #dfb8b8;
}

.cost-remove-receipt:active {
    transform: scale(.96);
}

.cost-form-actions {
    position: relative;
    z-index: 3;
    flex: 0 0 auto;
    min-height: 64px;
    padding: 10px 22px;
    gap: 9px;
    background: #fff;
    border-top: 0;
    box-shadow: 0 -8px 24px rgba(19, 43, 29, .045), inset 0 1px 0 rgba(225, 231, 227, .82);
}

.cost-form-message {
    margin-right: auto;
    color: #a93636;
    font-size: .8rem;
    line-height: 1.45;
}

.cost-form-message:not(:empty) {
    padding: 7px 10px;
    background: #fff6f6;
    border-radius: 12px;
}

.cost-form:has(.cost-save-button:disabled) .cost-form-message:not(:empty) {
    color: #315d47;
    background: #f0f6f2;
}

.cost-cancel-button,
.cost-save-button {
    position: relative;
    min-width: 104px;
    min-height: 42px;
    padding: 0 17px;
    border-radius: var(--cost-modal-control-radius);
    box-shadow: none;
    font: inherit;
    font-size: .8rem;
    font-weight: 700;
    transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 120ms ease;
}

.cost-cancel-button {
    color: #526159;
    background: #fff;
    border-color: #d9e1dc;
}

.cost-cancel-button:hover {
    color: var(--cost-green);
    background: #f5f8f6;
    border-color: #b9c9bf;
}

.cost-save-button {
    min-width: 126px;
    color: #fff;
    background: var(--cost-green);
    border-color: var(--cost-green);
}

.cost-save-button:hover:not(:disabled) {
    background: var(--cost-green-dark);
    border-color: var(--cost-green-dark);
    box-shadow: 0 8px 18px rgba(16, 47, 32, .16);
    transform: translateY(-1px);
}

.cost-cancel-button:active,
.cost-save-button:active:not(:disabled) {
    transform: translateY(1px);
}

.cost-save-button:disabled {
    color: transparent;
    background: #6f8d7b;
    border-color: #6f8d7b;
    box-shadow: none;
    opacity: 1;
    cursor: wait;
}

.cost-save-button:disabled::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .42);
    border-top-color: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: cost-modal-spin 700ms linear infinite;
}

.cost-inline-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.cost-inline-actions label {
    min-height: 40px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #fff;
    border: 1px solid #dfe6e1;
    border-radius: var(--cost-modal-control-radius);
    cursor: pointer;
}

.cost-inline-actions > strong,
.cost-inline-actions > span {
    margin-left: auto;
    color: #617068;
    font-size: .8rem;
    font-weight: 650;
}

.inventory-chicken-picker {
    max-height: 220px;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--cost-modal-divider);
    border-radius: 12px;
    scrollbar-width: thin;
    scrollbar-color: #b7c4bb transparent;
}

.inventory-chicken-picker-row {
    min-height: 44px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #46544c;
    border-bottom: 1px solid #edf1ee;
    font-size: .8rem;
    line-height: 1.45;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.inventory-chicken-picker-row:last-child {
    border-bottom: 0;
}

.inventory-chicken-picker-row:hover,
.inventory-chicken-picker-row:has(input:checked) {
    background: #f1f7f3;
}

.inventory-feed-summary {
    padding: 15px;
    background: #f7faf8;
    border-color: #dfe7e1;
    border-radius: 16px;
}

.inventory-feed-summary-grid {
    gap: 8px;
    margin-bottom: 12px;
}

.inventory-feed-summary-grid > div {
    padding: 10px;
    border-radius: 12px;
}

.inventory-feed-warning {
    margin-bottom: 10px;
    padding: 9px 11px;
    color: #8b5f1d;
    background: #fbf7ed;
    border: 1px solid #eadcb8;
    border-radius: 12px;
    font-size: .8rem;
    line-height: 1.5;
}

.cost-chicken-detail-body {
    gap: 16px;
    padding: 18px 22px 22px;
    overflow-x: hidden;
    background: #f7f9f7;
    scrollbar-width: thin;
    scrollbar-color: #b7c4bb transparent;
}

.cost-detail-chart-card,
.cost-detail-history {
    padding: 20px;
    background: #fff;
    border: 1px solid var(--cost-modal-divider);
    border-radius: 16px;
    box-shadow: none;
}

.cost-detail-chart-card > h3,
.cost-detail-history-heading h3 {
    font-size: 1rem;
}

.cost-detail-summary-layout {
    gap: 24px;
    margin-top: 16px;
}

.cost-detail-chicken-profile {
    min-height: 178px;
    gap: 17px;
    padding: 14px;
    justify-content: flex-start;
    background: #f7f9f7;
    border-radius: 12px;
}

.cost-detail-chicken-profile img {
    width: 156px;
    height: 156px;
    flex-basis: 156px;
    border: 1px solid #e3e9e5;
    border-radius: 12px;
    box-shadow: none;
}

.cost-detail-chicken-profile strong {
    font-size: 1.2rem;
}

.cost-detail-breakdown {
    gap: 16px;
    padding: 14px 4px;
}

.cost-detail-lifetime-total,
.cost-detail-legend-row {
    border-radius: 12px;
}

.cost-detail-filters {
    grid-template-columns: minmax(210px, 1fr) minmax(145px, .44fr) minmax(120px, .35fr);
    gap: 8px;
    padding: 8px;
    background: #f7f9f7;
    border: 1px solid #e7ece8;
    border-radius: 12px;
}

.cost-detail-filters input,
.cost-detail-filters select {
    height: 42px;
    min-height: 42px;
    border-radius: var(--cost-modal-control-radius);
}

.cost-detail-search input {
    padding-left: 40px;
}

.cost-detail-history .cost-table-wrap {
    max-width: 100%;
    max-height: min(38dvh, 340px);
    overflow: auto;
    border: 1px solid #e5ebe7;
    border-radius: 12px;
    scrollbar-width: thin;
    scrollbar-color: #b7c4bb transparent;
}

.cost-detail-history-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f7f9f7;
}

.cost-detail-pagination button,
.cost-inventory-history-pagination nav button {
    border-radius: 12px;
}

.cost-inventory-history-filters {
    flex: 0 0 auto;
    grid-template-columns: minmax(180px, 1.35fr) repeat(4, minmax(118px, 1fr));
    gap: 8px;
    padding: 14px 20px;
    background: #f7f9f7;
    border-bottom: 1px solid var(--cost-modal-divider);
}

.cost-inventory-history-filters input,
.cost-inventory-history-filters select {
    min-height: 42px;
}

.cost-inventory-history-search {
    position: relative;
    min-width: 0;
}

.cost-inventory-history-search i {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 13px;
    color: #76827b;
    transform: translateY(-50%);
    pointer-events: none;
}

.cost-inventory-history-search input {
    width: 100%;
    padding-left: 38px;
}

.cost-inventory-history-list {
    min-height: 180px;
    padding: 0 20px;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #b7c4bb transparent;
}

.cost-inventory-history-list .cost-inventory-recent-item {
    min-width: 0;
    padding: 12px 2px;
}

.cost-inventory-history-list .cost-inventory-recent-empty {
    padding: 40px 12px;
    color: #738078;
    text-align: center;
}

.cost-inventory-history-pagination {
    flex: 0 0 auto;
    padding: 12px 20px 16px;
    background: #fff;
    border-top-color: var(--cost-modal-divider);
}

.cost-image-lightbox {
    padding: clamp(12px, 2.5vw, 24px);
}

.cost-image-lightbox-backdrop {
    background: rgba(5, 13, 8, .74);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: cost-modal-backdrop-in 180ms ease-out both;
}

.cost-image-lightbox-dialog {
    width: min(980px, 100%);
    max-height: calc(100dvh - clamp(24px, 5vw, 48px));
    padding: 14px;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--cost-modal-divider);
    border-radius: var(--cost-modal-radius);
    box-shadow: 0 18px 54px rgba(0, 0, 0, .24);
    animation: cost-modal-dialog-in 220ms cubic-bezier(.22, 1, .36, 1) both;
}

.cost-image-lightbox-dialog header {
    min-height: 42px;
}

.cost-image-lightbox-heading {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cost-image-lightbox-heading > span {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: #285b40;
    background: #edf4ef;
    border-radius: 12px;
}

.cost-image-lightbox-dialog h2 {
    font-size: .875rem;
}

.cost-image-lightbox-canvas {
    border-radius: 12px;
    scrollbar-width: thin;
    scrollbar-color: #8fa096 transparent;
}

.cost-image-lightbox-dialog > p {
    color: #66736c;
    font-size: .8rem;
}

@keyframes cost-modal-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cost-modal-dialog-in {
    from {
        opacity: .72;
        transform: translateY(8px) scale(.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes cost-modal-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@media (max-width: 900px) {
    .cost-chicken-detail-dialog,
    .cost-inventory-history-dialog {
        width: min(760px, 100%);
    }

    .cost-detail-summary-layout {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .cost-form-group-grid-three,
    .cost-form-group-grid-value {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cost-form-group-grid-value .cost-field-emphasis {
        grid-column: 1 / -1;
    }

    .cost-detail-chicken-profile {
        min-height: 150px;
        justify-content: flex-start;
    }

    .cost-detail-chicken-profile img {
        width: 150px;
        height: 150px;
        flex-basis: 150px;
    }

    .cost-inventory-history-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cost-inventory-history-filters > :first-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    .cost-modal {
        padding: 12px;
        place-items: center;
    }

    .cost-modal-dialog,
    .cost-inventory-history-dialog {
        width: 100%;
        max-height: calc(100dvh - 24px);
        border-radius: 16px;
    }

    .cost-modal-header {
        padding: 15px 16px;
        align-items: flex-start;
    }

    .cost-modal-heading {
        align-items: flex-start;
        gap: 10px;
    }

    .cost-modal-context-icon {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
        border-radius: 12px;
    }

    .cost-modal-header h2 {
        padding-top: 1px;
        font-size: 1.2rem;
    }

    .cost-modal-header p {
        font-size: .8rem;
        line-height: 1.45;
    }

    .cost-modal-close {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }

    .cost-form-body,
    .cost-chicken-detail-body {
        padding: 16px;
    }

    .cost-form-grid,
    .cost-form-group-grid,
    .cost-form-group-grid-three,
    .cost-form-group-grid-value,
    .cost-radio-group,
    .cost-detail-filters,
    .cost-detail-breakdown,
    .inventory-feed-summary-grid,
    .cost-inventory-history-filters {
        grid-template-columns: 1fr;
    }

    .cost-form-group-grid-value .cost-field-emphasis {
        grid-column: auto;
    }

    .cost-form-group {
        padding-bottom: 16px;
    }

    .cost-form-group + .cost-form-group,
    .cost-form-group + .cost-form-section,
    .cost-form-section + .cost-form-group {
        padding-top: 16px;
    }

    .cost-form-group-heading {
        margin-bottom: 10px;
    }

    .cost-inventory-history-filters > :first-child {
        grid-column: auto;
    }

    .cost-form-section {
        padding: 13px;
    }

    .cost-upload-box {
        align-items: stretch;
        flex-direction: column;
        gap: 11px;
    }

    .cost-upload-button {
        width: 100%;
        justify-content: center;
    }

    .cost-form-actions {
        min-height: 0;
        padding: 12px 16px 14px;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
        gap: 8px;
    }

    .cost-calculation-card {
        grid-template-columns: 36px minmax(0, 1fr);
        gap: 10px;
    }

    .cost-calculation-formula {
        grid-column: 1 / -1;
        padding-left: 46px;
    }

    .cost-form-message {
        width: 100%;
        margin: 0;
        grid-column: 1 / -1;
    }

    .cost-cancel-button,
    .cost-save-button {
        width: 100%;
        min-width: 0;
        min-height: 46px;
        padding: 0 12px;
    }

    .cost-inline-actions > strong,
    .cost-inline-actions > span {
        width: 100%;
        margin-left: 0;
    }

    .inventory-chicken-picker {
        max-height: 180px;
    }

    .inventory-feed-summary {
        padding: 12px;
    }

    .cost-detail-chart-card,
    .cost-detail-history {
        padding: 14px;
        border-radius: 12px;
    }

    .cost-detail-chicken-profile {
        min-height: 0;
        align-items: flex-start;
        gap: 13px;
        padding: 0;
    }

    .cost-detail-chicken-profile img {
        width: 96px;
        height: 96px;
        flex-basis: 96px;
        border-radius: 12px;
    }

    .cost-detail-chicken-profile strong {
        font-size: 1.2rem;
        white-space: normal;
    }

    .cost-detail-history-heading,
    .cost-detail-pagination,
    .cost-inventory-history-pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .cost-detail-history-table {
        min-width: 700px;
    }

    .cost-inventory-history-filters {
        padding: 12px 16px;
    }

    .cost-inventory-history-list {
        padding: 0 16px;
    }

    .cost-inventory-history-pagination {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }

    .cost-image-lightbox {
        padding: 10px;
    }

    .cost-image-lightbox-dialog {
        max-height: calc(100dvh - 20px);
        padding: 10px;
        border-radius: 16px;
    }

    .cost-image-lightbox-canvas img {
        max-height: calc(100dvh - 140px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .cost-modal-backdrop,
    .cost-modal-dialog,
    .cost-image-lightbox-backdrop,
    .cost-image-lightbox-dialog,
    .cost-save-button:disabled::after {
        animation: none;
    }
}
}

/* ========================================================================== 
   Farm cost entry dialog — approved master modal
   Its dimensions, controls, spacing, and actions define the shared modal system.
   ========================================================================== */
.cost-entry-modal {
    padding: 16px;
}

.cost-entry-modal .cost-modal-backdrop {
    background: rgba(9, 15, 11, .52);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.farm-cost-dialog {
    position: relative;
    z-index: 1;
    width: min(552px, calc(100vw - 32px));
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #172019;
    background: #fff;
    border: 1px solid #dfe5e1;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .1);
    font-family: "Prompt", "Noto Sans Thai", sans-serif;
    animation: farm-cost-dialog-in 180ms cubic-bezier(.22, 1, .36, 1) both;
}

.farm-cost-dialog__header {
    position: relative;
    flex: 0 0 auto;
    padding: 24px 60px 18px 24px;
}

.farm-cost-dialog__heading h2 {
    margin: 0;
    color: #172019;
    font-size: 1.3rem;
    font-weight: 650;
    line-height: 1.35;
    letter-spacing: -.018em;
}

.farm-cost-dialog__heading p {
    max-width: 65ch;
    margin: 4px 0 0;
    color: #66736c;
    font-size: .82rem;
    font-weight: 400;
    line-height: 1.55;
}

.farm-cost-dialog__close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 32px;
    height: 32px;
    padding: 0;
    display: grid;
    place-items: center;
    color: #66736c;
    background: transparent;
    border: 0;
    border-radius: 8px;
    font: inherit;
    font-size: .94rem;
    cursor: pointer;
    transition: color 140ms ease, background-color 140ms ease, transform 100ms ease;
}

.farm-cost-dialog__close:hover {
    color: #172019;
    background: #f1f3f2;
}

.farm-cost-dialog__close:active {
    transform: scale(.95);
}

.farm-cost-dialog__close:focus-visible,
.farm-cost-upload__button:focus-visible,
.farm-cost-receipt__zoom:focus-visible,
.farm-cost-receipt__remove:focus-visible,
.farm-cost-button:focus-visible,
.farm-cost-optional-quantity button:focus-visible {
    outline: 3px solid rgba(24, 63, 44, .16);
    outline-offset: 2px;
}

.farm-cost-form {
    min-height: 0;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
}

.farm-cost-dialog__body {
    min-height: 0;
    padding: 2px 24px 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #b5c0b9 transparent;
}

.farm-cost-dialog__body::-webkit-scrollbar {
    width: 8px;
}

.farm-cost-dialog__body::-webkit-scrollbar-thumb {
    background: #b5c0b9;
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

.farm-cost-form__fields {
    display: grid;
    gap: 17px;
}

.farm-cost-form__row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.farm-cost-form__row--date-amount,
.farm-cost-form__row:has(#cost-date) {
    grid-template-columns: minmax(0, 1fr);
}

.farm-cost-form__optional-row:not(:has(.farm-cost-field:not([hidden]))) {
    display: none;
}

.farm-cost-field {
    min-width: 0;
    display: grid;
    gap: 7px;
}

.farm-cost-field--full {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
}

.farm-cost-field > label,
.farm-cost-field__label,
.farm-cost-scope legend {
    color: #29332d;
    font-size: .82rem;
    font-weight: 550;
    line-height: 1.45;
}

.farm-cost-required {
    color: #b93f3f;
    font-size: .88em;
}

.farm-cost-optional {
    color: #66736c;
    font-weight: 400;
}

.farm-cost-field input:not([type="checkbox"]):not([type="radio"]),
.farm-cost-field select,
.farm-cost-field textarea {
    width: 100%;
    min-width: 0;
    color: #172019;
    background: #fff;
    border: 1px solid #d5dcd7;
    border-radius: 8px;
    box-shadow: none;
    font: inherit;
    font-size: .875rem;
    font-weight: 400;
    caret-color: #183f2c;
    transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.farm-cost-field input:not([type="checkbox"]):not([type="radio"]),
.farm-cost-field select {
    height: 42px;
    padding: 0 12px;
}

.farm-cost-field select {
    cursor: pointer;
}

.farm-cost-field textarea {
    min-height: 96px;
    padding: 10px 12px;
    line-height: 1.55;
    resize: vertical;
}

.farm-cost-field input::placeholder,
.farm-cost-field textarea::placeholder {
    color: #6f7872;
    opacity: 1;
}

.farm-cost-field input:not([type="checkbox"]):not([type="radio"]):hover,
.farm-cost-field select:hover,
.farm-cost-field textarea:hover {
    border-color: #aeb8b1;
}

.farm-cost-field input:not([type="checkbox"]):not([type="radio"]):focus,
.farm-cost-field select:focus,
.farm-cost-field textarea:focus {
    border-color: #496d58;
    box-shadow: 0 0 0 3px rgba(24, 63, 44, .1);
    outline: 0;
}

.farm-cost-field input:disabled,
.farm-cost-field select:disabled,
.farm-cost-field textarea:disabled,
.farm-cost-field input[readonly] {
    color: #78817b;
    background: #f1f3f2;
    border-color: #e0e5e2;
    box-shadow: none;
    cursor: not-allowed;
}

.farm-cost-field input[aria-invalid="true"],
.farm-cost-field select[aria-invalid="true"],
.farm-cost-field textarea[aria-invalid="true"] {
    background: #fffafa;
    border-color: #b93f3f;
    box-shadow: 0 0 0 3px rgba(185, 63, 63, .08);
}

.farm-cost-field__error {
    min-height: 0;
    margin: 0;
    color: #a93636;
    font-size: .76rem;
    font-weight: 400;
    line-height: 1.45;
}

.farm-cost-field__error:empty {
    display: none;
}

.farm-cost-money {
    position: relative;
}

.farm-cost-money input {
    padding-right: 34px !important;
    font-variant-numeric: tabular-nums;
}

.farm-cost-money > span {
    position: absolute;
    top: 50%;
    right: 12px;
    color: #66736c;
    font-size: .8rem;
    font-weight: 550;
    transform: translateY(-50%);
    pointer-events: none;
}

/* Dynamic Farm Cost Calculation Fields */
.farm-cost-dynamic-section {
    display: grid;
    gap: 14px;
    margin-bottom: 4px;
}

.farm-cost-dynamic-section:empty {
    display: none;
}

.farm-cost-dynamic-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
}

.farm-cost-dynamic-grid--3 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 14px 16px;
}

.farm-cost-dynamic-grid--full {
    grid-column: 1 / -1;
}

.farm-cost-input-wrapper {
    position: relative;
    width: 100%;
}

.farm-cost-input-wrapper input {
    width: 100%;
    padding-right: 48px !important;
    font-variant-numeric: tabular-nums;
}

.farm-cost-input-wrapper .farm-cost-suffix {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    color: #66736c;
    font-size: 0.8rem;
    font-weight: 550;
    pointer-events: none;
}

.farm-cost-summary-box {
    min-height: 52px;
    padding: 12px 16px;
    margin-bottom: 14px;
    background: #f0f7f3;
    border: 1px solid #c8ded1;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: all 0.2s ease;
}

.farm-cost-summary-box__header {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.farm-cost-summary-box__label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #17653D;
    letter-spacing: 0.01em;
}

.farm-cost-summary-box__formula {
    font-size: 0.74rem;
    color: #526e5e;
    font-variant-numeric: tabular-nums;
}

.farm-cost-summary-box__amount {
    font-size: 1.25rem;
    font-weight: 700;
    color: #102f20;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

@media (max-width: 640px) {
    .farm-cost-dynamic-grid,
    .farm-cost-dynamic-grid--3 {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.farm-cost-note-meta {
    margin-top: -1px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #66736c;
    font-size: .74rem;
    line-height: 1.45;
}

.farm-cost-note-meta span:last-child {
    font-variant-numeric: tabular-nums;
}

.farm-cost-optional-quantity button {
    min-height: 38px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #314239;
    background: #fff;
    border: 1px solid #d5dcd7;
    border-radius: 8px;
    font: inherit;
    font-size: .8rem;
    font-weight: 550;
    cursor: pointer;
}

.farm-cost-optional-quantity button:hover {
    color: #183f2c;
    background: #f5f7f5;
    border-color: #aebcb2;
}

.farm-cost-scope {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.farm-cost-scope.is-chicken-direct legend,
.farm-cost-scope.is-chicken-direct .farm-cost-scope__options {
    display: none !important;
}

.farm-cost-scope.is-chicken-direct .farm-cost-scope__chicken {
    margin-top: 0 !important;
}

.farm-cost-scope__options {
    margin-top: 7px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.farm-cost-scope__option {
    min-height: 42px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4c5851;
    background: #fff;
    border: 1px solid #d5dcd7;
    border-radius: 8px;
    font-size: .78rem;
    cursor: pointer;
}

.farm-cost-scope__option:hover {
    border-color: #aeb8b1;
}

.farm-cost-scope__option:has(input:checked) {
    color: #183f2c;
    background: #f0f5f2;
    border-color: #92aa9a;
}

.farm-cost-scope__option input {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    accent-color: #183f2c;
}

.farm-cost-scope__chicken {
    margin-top: 14px;
}

.farm-cost-upload {
    min-height: 108px;
    padding: 14px 16px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    background: #fff;
    border: 1px dashed #b8c1bb;
    border-radius: 8px;
    transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.farm-cost-upload:hover,
.farm-cost-upload:focus-within,
.farm-cost-upload.is-dragging {
    background: #f5f8f6;
    border-color: #668272;
}

.farm-cost-upload__icon {
    color: #66736c;
    font-size: 1.45rem;
    transition: color 140ms ease;
}

.farm-cost-upload:hover .farm-cost-upload__icon,
.farm-cost-upload:focus-within .farm-cost-upload__icon,
.farm-cost-upload.is-dragging .farm-cost-upload__icon {
    color: #183f2c;
}

.farm-cost-upload__copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.farm-cost-upload__copy strong {
    color: #29332d;
    font-size: .8rem;
    font-weight: 550;
    line-height: 1.45;
}

.farm-cost-upload__copy span {
    color: #66736c;
    font-size: .72rem;
    line-height: 1.45;
}

.farm-cost-upload__button {
    min-height: 36px;
    padding: 0 12px;
    color: #183f2c;
    background: #fff;
    border: 1px solid #cfd8d2;
    border-radius: 8px;
    font: inherit;
    font-size: .78rem;
    font-weight: 550;
    white-space: nowrap;
    cursor: pointer;
}

.farm-cost-upload__button:hover {
    background: #eef4f0;
    border-color: #a9b9ae;
}

.farm-cost-receipt {
    min-height: 64px;
    padding: 8px;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 36px;
    gap: 10px;
    align-items: center;
    background: #fafbfa;
    border: 1px solid #dfe5e1;
    border-radius: 8px;
}

.farm-cost-receipt__thumbnail {
    position: relative;
    width: 48px;
    height: 48px;
    overflow: hidden;
    background: #eef1ef;
    border-radius: 6px;
}

.farm-cost-receipt__thumbnail img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.farm-cost-receipt__zoom {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    color: transparent;
    background: transparent;
    border: 0;
    cursor: zoom-in;
}

.farm-cost-receipt__zoom:hover {
    color: #fff;
    background: rgba(16, 47, 32, .62);
}

.farm-cost-receipt__info {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.farm-cost-receipt__info strong,
.farm-cost-receipt__info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.farm-cost-receipt__info strong {
    color: #29332d;
    font-size: .78rem;
    font-weight: 550;
}

.farm-cost-receipt__info span {
    color: #66736c;
    font-size: .7rem;
}

.farm-cost-receipt__remove {
    width: 36px;
    height: 36px;
    padding: 0;
    display: grid;
    place-items: center;
    color: #a93636;
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.farm-cost-receipt__remove:hover {
    background: #fbeeee;
}

.farm-cost-receipt__link {
    width: fit-content;
    color: #315d47;
    font-size: .74rem;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.farm-cost-dialog__actions {
    flex: 0 0 auto;
    padding: 20px 24px 24px;
    display: grid;
    gap: 10px;
    background: #fff;
}

.farm-cost-form__message {
    margin: 0;
    color: #a93636;
    font-size: .76rem;
    line-height: 1.45;
}

.farm-cost-form__message:empty {
    display: none;
}

.farm-cost-form__message:not(:empty) {
    padding: 8px 10px;
    background: #fff7f7;
    border-radius: 8px;
}

.farm-cost-form__message[data-state="success"],
.farm-cost-form__message.is-success {
    color: #22633f;
    background: #f0f7f3;
}

.farm-cost-dialog__buttons {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
}

.farm-cost-button {
    min-height: 40px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 8px;
    font: inherit;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 100ms ease;
}

.farm-cost-button--secondary {
    color: #29332d;
    background: #fff;
    border: 1px solid #d5dcd7;
}

.farm-cost-button--secondary:hover {
    background: #f2f4f3;
    border-color: #bcc5bf;
}

.farm-cost-button--primary {
    min-width: 126px;
    color: #fff;
    background: #183f2c;
    border: 1px solid #183f2c;
}

.farm-cost-button--primary:hover:not(:disabled) {
    background: #102f20;
    border-color: #102f20;
}

.farm-cost-button:active:not(:disabled) {
    transform: translateY(1px);
}

.farm-cost-button:disabled {
    color: rgba(255, 255, 255, .92);
    background: #6f8577;
    border-color: #6f8577;
    box-shadow: none;
    cursor: wait;
}

.farm-cost-button[aria-busy="true"]::before {
    width: 14px;
    height: 14px;
    content: "";
    display: inline-block;
    flex: 0 0 14px;
    border: 2px solid rgba(255, 255, 255, .42);
    border-top-color: #fff;
    border-radius: 50%;
    animation: farm-cost-spin .72s linear infinite;
}

.farm-cost-dialog ::selection {
    color: #fff;
    background: #315d47;
}

@keyframes farm-cost-dialog-in {
    from {
        opacity: .78;
        transform: translateY(8px) scale(.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes farm-cost-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 620px) {
    .cost-entry-modal {
        padding: 12px;
    }

    .farm-cost-dialog {
        width: calc(100vw - 24px);
        max-height: calc(100dvh - 24px);
    }

    .farm-cost-dialog__header {
        padding: 20px 54px 16px 18px;
    }

    .farm-cost-dialog__close {
        top: 14px;
        right: 14px;
        width: 36px;
        height: 36px;
    }

    .farm-cost-dialog__body {
        padding-right: 18px;
        padding-left: 18px;
    }

    .farm-cost-form__row,
    .farm-cost-scope__options {
        grid-template-columns: 1fr;
    }

    .farm-cost-field input:not([type="checkbox"]):not([type="radio"]),
    .farm-cost-field select {
        height: 44px;
    }

    .farm-cost-upload {
        min-height: 112px;
        grid-template-columns: 32px minmax(0, 1fr);
    }

    .farm-cost-upload__button {
        width: 100%;
        grid-column: 1 / -1;
    }

    .farm-cost-dialog__actions {
        padding: 18px;
    }

    .farm-cost-dialog__buttons {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    }

    .farm-cost-button {
        width: 100%;
        min-width: 0;
        min-height: 44px;
    }
}

@media (max-width: 360px) {
    .farm-cost-dialog__buttons {
        grid-template-columns: 1fr;
    }

    .farm-cost-button--primary {
        order: -1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .farm-cost-dialog,
    .farm-cost-button[aria-busy="true"]::before {
        animation: none;
    }
}

/* ========================================================================== 
   Cost modal system — derived from the approved Farm Cost master dialog
   Generic dialogs keep the master's shell and controls; modifiers only set
   content-appropriate width and internal composition.
   ========================================================================== */
.cost-modal:not(.cost-entry-modal),
.cost-image-lightbox {
    padding: 16px;
}

.cost-modal:not(.cost-entry-modal) .cost-modal-backdrop,
.cost-image-lightbox-backdrop {
    background: rgba(9, 15, 11, .52);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.cost-system-dialog {
    width: min(552px, calc(100vw - 32px));
}

.cost-system-dialog--form {
    width: min(640px, calc(100vw - 32px));
}

.cost-system-dialog--form-wide {
    width: min(760px, calc(100vw - 32px));
}

.cost-system-dialog--wide {
    width: min(980px, calc(100vw - 32px));
    max-height: min(90dvh, 840px);
}

.cost-system-dialog--history {
    width: min(900px, calc(100vw - 32px));
    max-height: min(90dvh, 780px);
}

.cost-system-dialog .cost-form-body {
    padding: 2px 24px 0;
    background: #fff;
}

.cost-system-dialog .cost-form-stack {
    display: grid;
}

.cost-system-dialog .cost-form-group {
    min-width: 0;
    padding: 0 0 19px;
}

.cost-system-dialog .cost-form-group + .cost-form-group {
    padding-top: 19px;
    border-top: 1px solid #edf0ee;
}

.cost-system-dialog .cost-form-group:last-child {
    padding-bottom: 0;
}

.cost-system-dialog .cost-form-group-dynamic:not(:has(.cost-field:not([hidden]), .inventory-feed-summary:not([hidden]))) {
    display: none;
}

.cost-system-dialog .cost-form-group-heading {
    margin: 0 0 13px;
}

.cost-system-dialog .cost-form-group-heading h3,
.cost-system-dialog .cost-detail-chart-card > h3,
.cost-system-dialog .cost-detail-history-heading h3 {
    margin: 0;
    color: #29332d;
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.45;
}

.cost-system-dialog .cost-form-group-grid,
.cost-system-dialog .cost-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.cost-system-dialog .cost-form-group-grid-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cost-system-dialog .inventory-receive-grid,
.cost-system-dialog .cost-form-group-grid:has(#inventory-date) {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 16px !important;
}

.cost-system-dialog .inventory-receive-date-field,
.cost-system-dialog .cost-field:has(#inventory-date) {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
}

.cost-system-dialog .cost-field {
    min-width: 0;
    display: grid;
    gap: 7px;
}

.cost-system-dialog .cost-field > label,
.cost-system-dialog .cost-field-label {
    color: #29332d;
    font-size: .82rem;
    font-weight: 550;
    line-height: 1.45;
}

.cost-system-dialog .cost-required {
    color: #b93f3f;
    font-size: .88em;
}

.cost-system-dialog .cost-field input:not([type="checkbox"]):not([type="radio"]),
.cost-system-dialog .cost-field select,
.cost-system-dialog .cost-field textarea,
.cost-system-dialog .cost-inventory-history-filters input,
.cost-system-dialog .cost-inventory-history-filters select,
.cost-system-dialog .cost-detail-filters input,
.cost-system-dialog .cost-detail-filters select {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 0 12px;
    color: #172019;
    background: #fff;
    border: 1px solid #d5dcd7;
    border-radius: 8px;
    box-shadow: none;
    font: inherit;
    font-size: .875rem;
    font-weight: 400;
    caret-color: #183f2c;
    transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.cost-system-dialog .cost-field textarea {
    min-height: 96px;
    padding-top: 10px;
    padding-bottom: 10px;
    line-height: 1.55;
    resize: vertical;
}

.cost-system-dialog .cost-field input::placeholder,
.cost-system-dialog .cost-field textarea::placeholder,
.cost-system-dialog .cost-inventory-history-filters input::placeholder,
.cost-system-dialog .cost-detail-filters input::placeholder {
    color: #6f7872;
    opacity: 1;
}

.cost-system-dialog .cost-field input:not([type="checkbox"]):not([type="radio"]):hover,
.cost-system-dialog .cost-field select:hover,
.cost-system-dialog .cost-field textarea:hover,
.cost-system-dialog .cost-inventory-history-filters input:hover,
.cost-system-dialog .cost-inventory-history-filters select:hover,
.cost-system-dialog .cost-detail-filters input:hover,
.cost-system-dialog .cost-detail-filters select:hover {
    border-color: #aeb8b1;
}

.cost-system-dialog .cost-field input:not([type="checkbox"]):not([type="radio"]):focus,
.cost-system-dialog .cost-field select:focus,
.cost-system-dialog .cost-field textarea:focus,
.cost-system-dialog .cost-inventory-history-filters input:focus,
.cost-system-dialog .cost-inventory-history-filters select:focus,
.cost-system-dialog .cost-detail-filters input:focus,
.cost-system-dialog .cost-detail-filters select:focus {
    border-color: #496d58;
    box-shadow: 0 0 0 3px rgba(24, 63, 44, .1);
    outline: 0;
}

.cost-system-dialog .cost-field input:disabled,
.cost-system-dialog .cost-field select:disabled,
.cost-system-dialog .cost-field textarea:disabled,
.cost-system-dialog .cost-field input[readonly] {
    color: #78817b;
    background: #f1f3f2;
    border-color: #e0e5e2;
    box-shadow: none;
    cursor: not-allowed;
}

.cost-system-dialog .cost-field input[aria-invalid="true"],
.cost-system-dialog .cost-field select[aria-invalid="true"],
.cost-system-dialog .cost-field textarea[aria-invalid="true"] {
    background: #fffafa;
    border-color: #b93f3f;
    box-shadow: 0 0 0 3px rgba(185, 63, 63, .08);
}

.cost-system-dialog .cost-field-error,
.cost-system-dialog .cost-form-message {
    min-height: 0;
    margin: 0;
    color: #a93636;
    font-size: .76rem;
    font-weight: 400;
    line-height: 1.45;
}

.cost-system-dialog .cost-field-error:empty,
.cost-system-dialog .cost-form-message:empty {
    display: none;
}

.cost-system-dialog .cost-form-message:not(:empty) {
    padding: 8px 10px;
    background: #fff7f7;
    border-radius: 8px;
}

.cost-system-dialog .cost-money-input {
    position: relative;
}

.cost-system-dialog .cost-money-input input {
    padding-right: 48px !important;
    font-variant-numeric: tabular-nums;
}

.cost-system-dialog .cost-money-input span {
    position: absolute;
    top: 50%;
    right: 12px;
    color: #66736c;
    font-size: .8rem;
    font-weight: 550;
    transform: translateY(-50%);
    pointer-events: none;
}

.cost-system-dialog .cost-calculation-card {
    min-width: 0;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 16px;
    align-items: center;
    background: #f5f7f5;
    border: 1px solid #dfe5e1;
    border-radius: 8px;
}

.cost-system-dialog .cost-calculation-icon {
    display: none;
}

.cost-system-dialog .cost-calculation-label,
.cost-system-dialog .cost-calculation-formula,
.cost-system-dialog .cost-inventory-calculation {
    color: #66736c;
    font-size: .74rem;
    line-height: 1.45;
}

.cost-system-dialog .cost-calculation-card .cost-inventory-calculation {
    margin: 2px 0 0;
    color: #183f2c;
    font-size: .875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.cost-system-dialog #auto-feeding-panel,
.cost-system-dialog .inventory-feed-summary {
    padding: 14px;
    background: #f7f9f7;
    border: 1px solid #dfe5e1;
    border-radius: 8px;
}

.cost-system-dialog .cost-inline-actions {
    gap: 8px;
}

.cost-system-dialog .cost-secondary-button {
    min-height: 38px;
    padding: 0 12px;
    color: #314239;
    background: #fff;
    border: 1px solid #d5dcd7;
    border-radius: 8px;
    box-shadow: none;
    font: inherit;
    font-size: .8rem;
    font-weight: 550;
}

.cost-system-dialog .cost-secondary-button:hover {
    color: #183f2c;
    background: #f5f7f5;
    border-color: #aebcb2;
}

.cost-system-dialog .inventory-chicken-picker {
    max-height: 220px;
    overflow: auto;
    background: #fff;
    border: 1px solid #dfe5e1;
    border-radius: 8px;
}

.cost-system-dialog .inventory-chicken-picker-row {
    min-height: 42px;
    padding: 8px 10px;
    border-bottom: 1px solid #edf0ee;
    font-size: .8rem;
}

.cost-system-dialog .inventory-chicken-picker-row:last-child {
    border-bottom: 0;
}

.cost-system-dialog .inventory-chicken-picker-row:hover,
.cost-system-dialog .inventory-chicken-picker-row:has(input:checked) {
    background: #f5f7f5;
}

.cost-system-dialog .cost-form-actions {
    padding: 20px 24px 24px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    background: #fff;
    border: 0;
    box-shadow: none;
}

.cost-system-dialog .cost-form-actions > .farm-cost-dialog__buttons {
    grid-column: 1 / -1;
}

.cost-system-dialog .farm-cost-button:focus-visible,
.cost-confirm-dialog .farm-cost-button:focus-visible,
.cost-confirm-dialog .farm-cost-dialog__close:focus-visible,
.cost-system-lightbox-dialog .farm-cost-dialog__close:focus-visible,
.farm-cost-detail__receipt:focus-visible {
    outline: 3px solid rgba(24, 63, 44, .16);
    outline-offset: 2px;
}

.farm-cost-detail {
    min-height: 0;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
}

.farm-cost-detail__body {
    min-height: 0;
    padding: 2px 24px 0;
    display: grid;
    gap: 20px;
    overflow-x: hidden;
    overflow-y: auto;
}

.farm-cost-detail__section + .farm-cost-detail__section {
    padding-top: 19px;
    border-top: 1px solid #edf0ee;
}

.farm-cost-detail__section h3 {
    margin: 0 0 13px;
    color: #29332d;
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.45;
}

.farm-cost-detail__grid {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 24px;
}

.farm-cost-detail__grid > div {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.farm-cost-detail__grid dt {
    color: #66736c;
    font-size: .76rem;
    line-height: 1.45;
}

.farm-cost-detail__grid dd {
    min-width: 0;
    margin: 0;
    color: #172019;
    font-size: .875rem;
    font-weight: 500;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.farm-cost-detail__grid .farm-cost-detail__amount dd {
    color: #183f2c;
    font-size: 1rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.farm-cost-detail__full {
    grid-column: 1 / -1;
}

.farm-cost-detail__note {
    margin: 0;
    color: #36423b;
    font-size: .875rem;
    line-height: 1.65;
    white-space: pre-wrap;
}

.farm-cost-detail__receipt {
    min-height: 38px;
    margin-top: 12px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #183f2c;
    background: #fff;
    border: 1px solid #d5dcd7;
    border-radius: 8px;
    font: inherit;
    font-size: .8rem;
    font-weight: 550;
    cursor: pointer;
}

.farm-cost-detail__receipt:hover {
    background: #f5f7f5;
    border-color: #aebcb2;
}

.cost-chicken-detail-body {
    padding: 2px 24px 24px;
    display: grid;
    gap: 20px;
    background: #fff;
}

.cost-system-dialog .cost-detail-chart-card,
.cost-system-dialog .cost-detail-history {
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.cost-system-dialog .cost-detail-history {
    padding-top: 19px;
    border-top: 1px solid #edf0ee;
}

.cost-system-dialog .cost-detail-summary-layout {
    gap: 20px;
    margin-top: 13px;
}

.cost-system-dialog .cost-detail-chicken-profile {
    min-height: 150px;
    padding: 12px;
    background: #f7f9f7;
    border: 1px solid #dfe5e1;
    border-radius: 8px;
}

.cost-system-dialog .cost-detail-chicken-profile img {
    width: 132px;
    height: 132px;
    flex-basis: 132px;
    border: 0;
    border-radius: 8px;
    box-shadow: none;
}

.cost-system-dialog .cost-detail-chicken-profile strong {
    font-size: 1.2rem;
}

.cost-system-dialog .cost-detail-filters {
    grid-template-columns: minmax(210px, 1fr) minmax(140px, .45fr) minmax(120px, .38fr);
    gap: 8px;
    padding: 0;
    background: transparent;
    border: 0;
}

.cost-system-dialog .cost-detail-search input {
    padding-left: 38px;
}

.cost-system-dialog .cost-detail-history .cost-table-wrap {
    max-width: 100%;
    max-height: min(36dvh, 320px);
    overflow: auto;
    border: 1px solid #dfe5e1;
    border-radius: 8px;
}

.cost-system-dialog .cost-detail-history-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f7f9f7;
}

.cost-inventory-history-filters {
    flex: 0 0 auto;
    grid-template-columns: minmax(180px, 1.35fr) repeat(4, minmax(118px, 1fr));
    gap: 8px;
    padding: 2px 24px 16px;
    background: #fff;
    border-bottom: 1px solid #edf0ee;
}

.cost-inventory-history-search {
    position: relative;
    min-width: 0;
}

.cost-inventory-history-search i {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 12px;
    color: #66736c;
    transform: translateY(-50%);
    pointer-events: none;
}

.cost-system-dialog .cost-inventory-history-search input {
    padding-left: 38px;
}

.cost-inventory-history-list {
    min-height: 200px;
    padding: 0 24px;
    flex: 1 1 auto;
    overflow: auto;
}

.cost-inventory-history-list .cost-inventory-recent-item {
    min-width: 0;
    padding: 12px 2px;
}

.cost-inventory-history-list .cost-inventory-recent-empty,
.cost-inventory-history-list .cost-inventory-table-empty {
    padding: 40px 12px;
    color: #66736c;
    text-align: center;
}

.cost-inventory-history-pagination {
    flex: 0 0 auto;
    padding: 14px 24px 20px;
    background: #fff;
    border-top: 1px solid #edf0ee;
}

.cost-inventory-history-pagination nav button,
.cost-detail-pagination button {
    border-radius: 8px;
}

.farm-cost-button--danger {
    color: #fff;
    background: #a83d3d;
    border-color: #a83d3d;
}

.farm-cost-button--danger:hover:not(:disabled) {
    background: #8f3030;
    border-color: #8f3030;
}

.cost-system-lightbox-dialog {
    width: min(900px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
}

.cost-system-lightbox-dialog .farm-cost-dialog__header {
    padding-bottom: 16px;
}

.cost-system-lightbox-dialog .cost-image-lightbox-canvas {
    min-height: 0;
    margin: 0 24px;
    flex: 1 1 auto;
    overflow: auto;
    background: #f7f9f7;
    border: 1px solid #dfe5e1;
    border-radius: 8px;
}

.cost-system-lightbox-dialog .cost-image-lightbox-canvas img {
    max-width: 100%;
    max-height: calc(100dvh - 190px);
}

.cost-system-lightbox-dialog > p {
    margin: 0;
    padding: 12px 24px 20px;
    color: #66736c;
    font-size: .76rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

@media (max-width: 900px) {
    .cost-system-dialog--wide,
    .cost-system-dialog--history {
        width: min(760px, calc(100vw - 32px));
    }

    .cost-system-dialog .cost-form-group-grid-three {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cost-system-dialog .cost-field-emphasis,
    .cost-system-dialog .cost-calculation-card {
        grid-column: 1 / -1;
    }

    .cost-system-dialog .cost-detail-summary-layout {
        grid-template-columns: 1fr;
    }

    .cost-inventory-history-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cost-inventory-history-filters > :first-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 620px) {
    .cost-modal:not(.cost-entry-modal),
    .cost-image-lightbox {
        padding: 12px;
    }

    .cost-system-dialog,
    .cost-system-dialog--form,
    .cost-system-dialog--form-wide,
    .cost-system-dialog--wide,
    .cost-system-dialog--history,
    .cost-system-lightbox-dialog {
        width: calc(100vw - 24px);
        max-height: calc(100dvh - 24px);
    }

    .cost-system-dialog .cost-form-body,
    .farm-cost-detail__body,
    .cost-chicken-detail-body {
        padding-right: 18px;
        padding-left: 18px;
    }

    .cost-system-dialog .cost-form-group-grid,
    .cost-system-dialog .cost-form-grid,
    .cost-system-dialog .cost-form-group-grid-three,
    .cost-system-dialog .cost-detail-filters,
    .cost-inventory-history-filters,
    .farm-cost-detail__grid {
        grid-template-columns: 1fr;
    }

    .cost-system-dialog .cost-field-emphasis,
    .cost-system-dialog .cost-calculation-card,
    .cost-inventory-history-filters > :first-child,
    .farm-cost-detail__full {
        grid-column: auto;
    }

    .cost-system-dialog .cost-calculation-card {
        grid-template-columns: 1fr;
    }

    .cost-system-dialog .cost-calculation-formula {
        white-space: normal;
    }

    .cost-system-dialog .cost-form-actions {
        padding: 18px;
    }

    .cost-system-dialog .farm-cost-dialog__buttons {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    }

    .cost-system-dialog .farm-cost-button {
        width: 100%;
        min-width: 0;
        min-height: 44px;
    }

    .cost-system-dialog .cost-detail-chicken-profile {
        min-height: 0;
        align-items: flex-start;
    }

    .cost-system-dialog .cost-detail-chicken-profile img {
        width: 96px;
        height: 96px;
        flex-basis: 96px;
    }

    .cost-inventory-history-filters {
        padding: 2px 18px 14px;
    }

    .cost-inventory-history-list {
        padding: 0 18px;
    }

    .cost-inventory-history-pagination {
        padding: 14px 18px 18px;
    }

    .cost-system-lightbox-dialog .cost-image-lightbox-canvas {
        margin: 0 18px;
    }

    .cost-system-lightbox-dialog > p {
        padding: 12px 18px 18px;
    }
}

@media (max-width: 360px) {
    .cost-system-dialog .farm-cost-dialog__buttons {
        grid-template-columns: 1fr;
    }

    .cost-system-dialog .farm-cost-button--primary {
        order: -1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cost-system-dialog,
    .cost-system-lightbox-dialog {
        animation: none;
    }
}

body.overview-view .cost-view-menu {
    grid-column: 1;
    grid-row: 1;
}

body.overview-view .cost-metric-grid {
    grid-column: 1;
    grid-row: 3;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
}

body.overview-view .cost-metric-card {
    grid-column: span 2;
    min-height: 138px;
    padding: 22px;
    align-content: center;
    gap: 12px;
    border: 1px solid #e9eeeb;
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(22, 35, 27, .065);
}

body.overview-view .cost-metric-card:nth-child(-n+2) {
    grid-column: span 3;
}

body.overview-view .cost-metric-card span {
    color: #68746d;
    font-size: .82rem;
    font-weight: 650;
}

body.overview-view .cost-metric-card strong {
    display: block;
    width: 100%;
    min-width: 0;
    color: #142019;
    font-size: clamp(2rem, 3.1vw, 2.9rem);
    line-height: 1;
    letter-spacing: -.045em;
    white-space: nowrap;
    overflow: hidden;
    overflow-wrap: normal;
    word-break: keep-all;
}

body.overview-view .cost-insight-grid {
    grid-template-columns: minmax(0, 1fr);
    margin-bottom: 18px;
}

body.overview-view .cost-category-panel {
    grid-column: 2;
    grid-row: 1 / span 3;
    min-height: 100%;
    padding: 24px;
}

body.overview-view .cost-trend-panel {
    grid-column:1;
    grid-row:1;
}

body.overview-view .cost-trend-panel,
body.overview-view .cost-category-panel,
body.overview-view .cost-records-panel {
    border-radius:22px;
}

/* Automatic feeding: local extension of the chicken-cost operating surface */
.feeding-operations-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 0 0 16px;
}

.feeding-operation-panel {
    min-width: 0;
    min-height: 300px;
    padding: 18px 20px;
    color: var(--cost-text);
    background: #fff;
    border: 1px solid var(--cost-border);
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(22, 35, 27, .055);
}

.feeding-operation-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

.feeding-operation-header h2,
.feeding-round-editor h3 {
    margin: 0;
    color: var(--cost-text);
    font-size: 19px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -.015em;
}

.feeding-operation-header p,
.feeding-round-editor header p {
    margin: 3px 0 0;
    color: var(--cost-muted);
    font-size: 12px;
    line-height: 1.55;
}

.feeding-outline-button {
    min-height: 36px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 0 0 auto;
    color: var(--cost-green);
    background: #fff;
    border: 1px solid rgba(23, 101, 61, .42);
    border-radius: 10px;
    font: inherit;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
    transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.feeding-outline-button:hover {
    color: var(--cost-green-dark);
    background: var(--cost-green-soft);
    border-color: var(--cost-green);
    transform: translateY(-1px);
}

.feeding-configuration-list,
.feeding-task-list {
    max-height: 330px;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd6cf transparent;
}

.feeding-configuration-item {
    padding: 12px 0 0;
    border-top: 1px solid #e7ece8;
}

.feeding-configuration-item:first-child {
    padding-top: 4px;
    border-top: 0;
}

.feeding-configuration-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 5px;
}

.feeding-configuration-summary strong {
    min-width: 0;
    overflow: hidden;
    color: var(--cost-text);
    font-size: 13px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feeding-setting-row,
.feeding-task-row {
    min-width: 0;
    min-height: 42px;
    display: grid;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #edf0ed;
}

.feeding-setting-row {
    grid-template-columns: 30px minmax(80px, .75fr) minmax(0, 1.1fr) auto;
}

.feeding-setting-icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    color: var(--cost-green);
    background: var(--cost-green-soft);
    border-radius: 9px;
    font-size: 13px;
}

.feeding-setting-label {
    color: #344139;
    font-size: 12px;
    font-weight: 650;
}

.feeding-setting-value {
    min-width: 0;
    overflow: hidden;
    color: var(--cost-text);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feeding-status-badge {
    min-height: 24px;
    padding: 3px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.feeding-status-badge.is-active,
.feeding-status-badge.is-completed {
    color: #19633b;
    background: #e7f5eb;
}

.feeding-status-badge.is-pending {
    color: #9a5d08;
    background: #fff2d8;
}

.feeding-status-badge.is-overdue {
    color: #a83c25;
    background: #fde9e4;
}

.feeding-status-badge.is-skipped,
.feeding-status-badge.is-inactive {
    color: #5e6862;
    background: #eef1ef;
}

.feeding-configuration-actions {
    padding: 10px 0 12px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.feeding-configuration-actions button {
    min-height: 34px;
    padding: 0 8px;
    color: #314239;
    background: #fff;
    border: 1px solid #d9e0db;
    border-radius: 9px;
    font: inherit;
    font-size: 11px;
    font-weight: 650;
    cursor: pointer;
}

.feeding-configuration-actions button:hover {
    color: var(--cost-green);
    background: #f6faf7;
    border-color: #adc4b5;
}

.feeding-configuration-actions button.is-disable {
    color: #b43a35;
    border-color: #efc7c5;
}

.feeding-task-row {
    width: 100%;
    grid-template-columns: 62px minmax(0, 1fr) auto 20px;
    padding: 0 3px;
    color: inherit;
    background: transparent;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.feeding-task-row:hover {
    background: #f8faf8;
}

.feeding-task-row time {
    color: #344139;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.feeding-task-row strong {
    min-width: 0;
    overflow: hidden;
    font-size: 12px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feeding-task-row > i {
    color: #78837c;
    font-size: 12px;
}

.feeding-empty-state {
    min-height: 190px;
    padding: 28px 18px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    color: var(--cost-muted);
    text-align: center;
}

.feeding-empty-state i {
    color: #8ea899;
    font-size: 24px;
}

.feeding-empty-state strong {
    color: #344139;
    font-size: 13px;
}

.feeding-empty-state p {
    max-width: 36ch;
    margin: 0;
    font-size: 12px;
    line-height: 1.55;
}

.feeding-loading-row {
    min-height: 190px;
    display: grid;
    place-items: center;
    color: var(--cost-muted);
    font-size: 12px;
}

.cost-notification-popover {
    position: fixed;
    top: 76px;
    right: 28px;
    z-index: 85;
    width: min(390px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 96px));
    overflow: hidden;
    color: var(--cost-text);
    background: #fff;
    border: 1px solid var(--cost-border);
    border-radius: 16px;
    box-shadow: 0 18px 44px rgba(14, 28, 19, .16);
}

.cost-notification-popover > header {
    padding: 14px 16px 11px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--cost-border);
}

.cost-notification-popover h2 { margin: 0; font-size: 16px; }
.cost-notification-popover p { margin: 2px 0 0; color: var(--cost-muted); font-size: 11px; }
.cost-notification-popover > header button { width: 32px; height: 32px; display: grid; place-items: center; color: #4f5b54; background: transparent; border: 0; border-radius: 9px; cursor: pointer; }
.cost-notification-popover > header button:hover { background: #f1f5f2; }
.cost-notification-list { max-height: 420px; overflow: auto; }
.cost-notification-item { width: 100%; padding: 13px 16px; display: grid; grid-template-columns: 9px minmax(0,1fr) auto; gap: 10px; color: inherit; background: #fff; border: 0; border-bottom: 1px solid #edf0ed; font: inherit; text-align: left; cursor: pointer; }
.cost-notification-item:hover { background: #f7faf8; }
.cost-notification-item > i { width: 8px; height: 8px; margin-top: 6px; background: var(--cost-green); border-radius: 50%; }
.cost-notification-item.is-read > i { background: #c8d0cb; }
.cost-notification-item strong { display: block; font-size: 12px; }
.cost-notification-item span { display: block; margin-top: 2px; color: var(--cost-muted); font-size: 11px; line-height: 1.45; }
.cost-notification-item > time { color: #738078; font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.feeding-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.feeding-form-grid .cost-field > span:first-child,
.feeding-chicken-picker > span:first-child {
    margin-bottom: 7px;
    display: block;
    color: #314239;
    font-size: 12px;
    font-weight: 650;
}

.feeding-form-grid small { margin-top: 5px; display: block; color: var(--cost-muted); font-size: 11px; }
.feeding-chicken-picker { padding-top: 2px; }
.feeding-chicken-picker > div { max-height: 190px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; overflow: auto; }
.feeding-chicken-option { min-height: 40px; padding: 8px 10px; display: flex; align-items: center; gap: 8px; border: 1px solid #e2e7e2; border-radius: 10px; font-size: 12px; cursor: pointer; }
.feeding-chicken-option:has(input:checked) { color: var(--cost-green-dark); background: var(--cost-green-soft); border-color: #a8c6b3; }

.feeding-round-editor {
    padding-top: 16px;
    border-top: 1px solid var(--cost-border);
}

.feeding-round-editor > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.feeding-round-editor h3 { font-size: 15px; }
.feeding-round-row { min-height: 52px; padding: 8px 0; display: grid; grid-template-columns: minmax(0,1fr) 130px auto 34px; gap: 8px; align-items: center; border-top: 1px solid #edf0ed; }
.feeding-round-row:first-child { border-top: 0; }
.feeding-round-row input[type="text"], .feeding-round-row input[type="time"] { min-width: 0; height: 40px; padding: 0 11px; border: 1px solid var(--cost-border); border-radius: 10px; font: inherit; font-size: 12px; }
.feeding-round-row label { display: inline-flex; align-items: center; gap: 6px; color: #415047; font-size: 11px; white-space: nowrap; }
.feeding-round-remove { width: 34px; height: 34px; display: grid; place-items: center; color: #b43a35; background: #fff; border: 1px solid #efcfcd; border-radius: 9px; cursor: pointer; }

.feeding-detail-body { display: grid; gap: 16px; }
.feeding-detail-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.feeding-detail-summary strong { font-size: 18px; }
.feeding-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 22px; border-top: 1px solid var(--cost-border); }
.feeding-detail-grid div { padding: 12px 0; border-bottom: 1px solid #edf0ed; }
.feeding-detail-grid span { display: block; color: var(--cost-muted); font-size: 11px; }
.feeding-detail-grid strong { display: block; margin-top: 3px; color: var(--cost-text); font-size: 13px; }
.feeding-detail-rounds { display: grid; gap: 0; }

.feeding-task-preview { display: grid; gap: 18px; }
.feeding-task-context { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.feeding-task-context h3 { margin: 0; font-size: 18px; }
.feeding-task-context p { margin: 3px 0 0; color: var(--cost-muted); font-size: 12px; }
.feeding-preview-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 8px; }
.feeding-preview-grid div { min-width: 0; padding: 12px; background: #f6f8f6; border-radius: 12px; }
.feeding-preview-grid span { display: block; color: var(--cost-muted); font-size: 10px; }
.feeding-preview-grid strong { display: block; margin-top: 4px; overflow: hidden; color: var(--cost-text); font-size: 14px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.feeding-preview-grid .is-warning strong { color: #a83c25; }
.feeding-preview-chickens { border-top: 1px solid var(--cost-border); }
.feeding-preview-chicken { min-height: 48px; display: grid; grid-template-columns: minmax(0,1.2fr) .8fr .8fr .8fr; gap: 10px; align-items: center; border-bottom: 1px solid #edf0ed; font-size: 12px; }
.feeding-preview-chicken strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feeding-preview-chicken span { color: #536058; font-variant-numeric: tabular-nums; text-align: right; }
.feeding-skip-button { color: #5f6862 !important; }

.feeding-all-task-list { max-height: min(620px, 72vh); padding: 4px 20px 20px; overflow: auto; }
.feeding-all-task-list .feeding-task-row { min-height: 50px; grid-template-columns: 94px 66px minmax(0,1fr) auto 20px; }
.feeding-all-task-list .feeding-task-date { color: var(--cost-muted); font-size: 11px; }

.dashboard-confirm-body { padding: 20px 24px; }
.dashboard-confirm-body p { margin: 0; color: #39483f; font-size: 14px; line-height: 1.65; }

@media (max-width: 1100px) {
    .feeding-preview-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 980px) {
    .feeding-operations-grid { grid-template-columns: 1fr; }
    .feeding-operation-panel { min-height: 0; }
    .feeding-configuration-list, .feeding-task-list { max-height: none; }
}

@media (max-width: 700px) {
    .feeding-operation-panel { padding: 16px; border-radius: 16px; }
    .feeding-operation-header { align-items: stretch; flex-direction: column; }
    .feeding-operation-header .feeding-outline-button { width: 100%; }
    .feeding-setting-row { grid-template-columns: 30px minmax(76px,.8fr) minmax(0,1fr); }
    .feeding-setting-row .feeding-status-badge { grid-column: 2 / -1; justify-self: start; margin-bottom: 8px; }
    .feeding-configuration-actions { grid-template-columns: 1fr; }
    .feeding-form-grid, .feeding-detail-grid { grid-template-columns: 1fr; }
    .feeding-chicken-picker > div { grid-template-columns: 1fr; }
    .feeding-round-row { grid-template-columns: minmax(0,1fr) 112px 34px; }
    .feeding-round-row label { grid-column: 1 / 3; }
    .feeding-round-remove { grid-column: 3; grid-row: 1; }
    .feeding-preview-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .feeding-preview-chicken { grid-template-columns: minmax(0,1fr) auto; padding: 9px 0; }
    .feeding-preview-chicken span { text-align: right; }
    .feeding-task-row { grid-template-columns: 52px minmax(0,1fr) auto 16px; }
    .feeding-all-task-list .feeding-task-row { grid-template-columns: 76px 50px minmax(0,1fr) 16px; }
    .feeding-all-task-list .feeding-status-badge { grid-column: 2 / 4; justify-self: start; }
    .cost-notification-popover { top: 70px; right: 16px; }
}

@media (max-width: 460px) {
    .feeding-preview-grid { grid-template-columns: 1fr; }
    .feeding-task-context { align-items: flex-start; flex-direction: column; }
}

body.overview-view .cost-panel-description {
    margin:6px 0 0;
    color:#7a857e;
    font-size:.78rem;
}

body.overview-view .cost-category-list {
    grid-template-columns:minmax(0,1fr);
    gap:18px;
}

body.overview-view .cost-category-row {
    min-width:0;
}

body.overview-view .cost-category-meta span {
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

body.overview-view .cost-category-meta strong {
    flex:0 0 auto;
    white-space:nowrap;
}

body.overview-view .cost-category-fill {
    background:linear-gradient(90deg,#1f6a47,#59a775);
}

body.overview-view .cost-record-tools {
    flex-wrap:nowrap;
}

body.overview-view .cost-category-filter-field {
    flex:0 1 230px;
    min-width:170px;
}

body.overview-view .cost-category-badge.is-farm {
    color:#236243;
    background:#e9f4ed;
}

body.overview-view .cost-category-badge.is-chicken {
    color:#875c13;
    background:#fff3d9;
}

@media (max-width:980px) {
    body.overview-view .cost-overview-grid { grid-template-columns:1fr; grid-template-rows:auto; }
    body.overview-view .cost-view-menu { grid-column:1; grid-row:1; }
    body.overview-view .cost-year-toolbar { grid-column:1; grid-row:2; }
    body.overview-view .cost-metric-grid { grid-column:1; grid-row:3; }
    body.overview-view .cost-category-panel { grid-column:1; grid-row:4; min-height:0; }
    body.overview-view .cost-insight-grid { grid-template-columns:1fr; }
    body.overview-view .cost-trend-panel { grid-column:1; grid-row:1; }
}

@media (max-width:760px) {
    body.overview-view .cost-metric-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
    body.overview-view .cost-metric-card,
    body.overview-view .cost-metric-card:nth-child(-n+2) { grid-column:span 1; min-height:124px; }
    body.overview-view .cost-metric-card:last-child { grid-column:1 / -1; }
    body.overview-view .cost-category-list { grid-template-columns:1fr; }
    body.overview-view .cost-record-tools { flex-wrap:wrap; }
}

@media (max-width:520px) {
    body.overview-view .cost-year-toolbar { align-items:stretch; flex-direction:column; }
    body.overview-view .cost-year-select-field { width:100%; justify-content:space-between; }
    body.overview-view .cost-year-select-field select { flex:1; max-width:190px; }
    body.overview-view .cost-metric-grid { grid-template-columns:1fr; }
    body.overview-view .cost-metric-card,
    body.overview-view .cost-metric-card:nth-child(-n+2),
    body.overview-view .cost-metric-card:last-child { grid-column:1; }
}

/* =====================================================
   COST TREND CHART INTERACTIVE BAR & DETAIL PANEL (SHADCN MINIMAL)
   ===================================================== */

.cost-bar-column {
    cursor: pointer;
    outline: none;
    transition: opacity 180ms ease;
}

.cost-bar-active-track {
    fill: rgba(23, 101, 61, 0.05);
    stroke: transparent;
    stroke-width: 1.5;
    opacity: 0;
    transition: opacity 160ms ease, fill 160ms ease, stroke 160ms ease;
    pointer-events: none;
}

.cost-bar-column:hover .cost-bar-active-track,
.cost-bar-column:focus-visible .cost-bar-active-track {
    opacity: 0.8;
    fill: rgba(23, 101, 61, 0.08);
    stroke: rgba(23, 101, 61, 0.2);
}

.cost-bar-column.is-selected .cost-bar-active-track {
    opacity: 1 !important;
    fill: rgba(23, 101, 61, 0.1) !important;
    stroke: #17653d !important;
    stroke-dasharray: none;
}

.cost-bar {
    cursor: pointer;
    transition: opacity 180ms ease, transform 180ms cubic-bezier(0.16, 1, 0.3, 1), filter 180ms ease;
}

.cost-bar.is-farm {
    fill: #1b6b3e !important;
}

.cost-bar.is-chicken {
    fill: #d97706 !important;
}

.cost-bar-column:hover .cost-bar {
    filter: brightness(1.1);
}

.cost-line-chart.has-selection .cost-bar-column:not(.is-selected) .cost-bar {
    opacity: 0.32 !important;
}

.cost-bar-column.is-selected .cost-bar {
    opacity: 1 !important;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.2));
}

.cost-line-label {
    fill: #7f8a82;
    font-family: "Prompt", "Noto Sans Thai", sans-serif;
    font-size: 11px;
    font-weight: 500;
    text-anchor: middle;
    transition: fill 160ms ease, font-weight 160ms ease;
}

.cost-line-label.is-selected {
    fill: #0f172a !important;
    font-weight: 750 !important;
}

/* Detail Panel Container */
.cost-chart-detail-panel {
    margin-top: 14px;
    padding: 0 4px;
}

.cost-chart-detail-empty {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 500;
    transition: all 180ms ease;
}

.cost-chart-detail-empty i {
    color: #17653d;
    font-size: 0.85rem;
}

.cost-chart-detail-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 14px rgba(15, 23, 42, 0.03);
    animation: cost-detail-panel-in 180ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes cost-detail-panel-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cost-chart-detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cost-chart-detail-date-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 8px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.cost-chart-detail-date-badge i {
    color: #17653d;
    font-size: 0.85rem;
}

.cost-chart-detail-metrics {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.cost-chart-detail-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cost-chart-detail-item .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cost-chart-detail-item .dot.is-farm { background: #1b6b3e; }
.cost-chart-detail-item .dot.is-chicken { background: #d97706; }

.cost-chart-detail-item .cost-chart-detail-label {
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 500;
}

.cost-chart-detail-item .cost-chart-detail-val {
    color: #0f172a;
    font-size: 0.95rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cost-chart-detail-item .cost-chart-detail-pct {
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 500;
}

.cost-chart-detail-item.is-total {
    padding-left: 14px;
    border-left: 1px solid #e2e8f0;
}

.cost-chart-detail-item.is-total .cost-chart-detail-label {
    color: #334155;
    font-weight: 600;
}

.cost-chart-detail-item.is-total .cost-chart-detail-total {
    color: #17653d;
    font-size: 1.05rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.cost-chart-detail-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cost-chart-drilldown-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #1e293b;
    font: inherit;
    font-size: 0.76rem;
    font-weight: 650;
    cursor: pointer;
    transition: all 140ms ease;
}

.cost-chart-drilldown-btn:hover {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(22, 101, 52, 0.08);
}

.cost-chart-drilldown-btn:active {
    transform: translateY(0) scale(0.98);
}

.cost-chart-detail-close-btn {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: all 140ms ease;
}

.cost-chart-detail-close-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

@media (max-width: 768px) {
    .cost-chart-detail-card {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 14px;
        box-sizing: border-box;
        width: 100%;
        overflow: hidden;
    }

    .cost-chart-detail-header {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .cost-chart-detail-metrics {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px 10px;
        box-sizing: border-box;
    }

    .cost-chart-detail-item {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        align-items: center;
        gap: 2px 5px;
        min-width: 0;
        padding: 8px 10px;
        background: #f8fafc;
        border-radius: 8px;
        border: 1px solid #f1f5f9;
        box-sizing: border-box;
    }

    .cost-chart-detail-item .dot {
        grid-column: 1;
        grid-row: 1;
    }

    .cost-chart-detail-item .cost-chart-detail-label {
        grid-column: 2;
        grid-row: 1;
        font-size: 0.76rem;
        color: #64748b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cost-chart-detail-item .cost-chart-detail-pct {
        grid-column: 3;
        grid-row: 1;
        font-size: 0.70rem;
        color: #94a3b8;
        font-weight: 600;
        white-space: nowrap;
        justify-self: end;
    }

    .cost-chart-detail-item .cost-chart-detail-val {
        grid-column: 1 / -1;
        grid-row: 2;
        font-size: 0.88rem;
        font-weight: 700;
        color: #0f172a;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding-top: 2px;
    }

    .cost-chart-detail-item.is-total {
        grid-column: 1 / -1;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 10px 12px;
        background: #f0fdf4;
        border: 1px solid #dcfce7;
        border-radius: 8px;
        margin-top: 2px;
    }

    .cost-chart-detail-item.is-total .cost-chart-detail-label {
        color: #166534;
        font-size: 0.82rem;
        font-weight: 600;
    }

    .cost-chart-detail-item.is-total .cost-chart-detail-total {
        color: #15803d;
        font-size: 1.02rem;
        font-weight: 800;
        font-variant-numeric: tabular-nums;
    }

    .cost-chart-detail-actions,
    .cost-chart-drilldown-btn {
        width: 100%;
        justify-content: center;
    }
}



/* =======================================================
   FARM COST DATE RANGE FILTER & POPOVER
   ======================================================= */
.cost-date-range-picker-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.cost-date-range-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 46px;
    min-height: 46px;
    padding: 0 14px;
    background: #ffffff;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    color: #26342c;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 550;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    box-sizing: border-box;
}

.cost-date-range-trigger:hover {
    border-color: #17653d;
    background-color: #f6f9f7;
    color: #17653d;
}

.cost-date-range-trigger:focus-visible {
    outline: 0;
    border-color: #17653d;
    box-shadow: 0 0 0 3px rgba(23, 101, 61, 0.15);
}

.cost-date-range-trigger.is-active-filter {
    border-color: #17653d;
    background-color: #edf5f0;
    color: #17653d;
    font-weight: 650;
    box-shadow: 0 0 0 2px rgba(23, 101, 61, 0.12);
}

.cost-date-range-trigger i {
    font-size: 0.95rem;
    color: #4a5c52;
    transition: color 0.18s ease;
}

.cost-date-range-trigger.is-active-filter i {
    color: #17653d;
}

.cost-date-range-clear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(23, 101, 61, 0.14);
    color: #17653d;
    font-size: 14px;
    line-height: 1;
    margin-left: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.cost-date-range-clear-btn:hover {
    background: rgba(23, 101, 61, 0.28);
}

/* Reset / Clear All Filters button */
.cost-filter-reset-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 46px;
    min-height: 46px;
    padding: 0 13px;
    background: #f4f6f5;
    border: 1px solid #d8e0dc;
    border-radius: 12px;
    color: #4f5f56;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 550;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    box-sizing: border-box;
}

.cost-filter-reset-btn:hover {
    background: #e9efe9;
    color: #17653d;
    border-color: #17653d;
}

.cost-filter-reset-btn:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(23, 101, 61, 0.15);
}

/* Backdrop */
.cost-date-range-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(18, 38, 28, 0.25);
    backdrop-filter: blur(1px);
    animation: cost-backdrop-fade 0.15s ease-out;
}

@keyframes cost-backdrop-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Date Range Picker Popover - Fixed Outside Clipped Parent */
.cost-date-range-picker-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.cost-date-range-trigger {
    cursor: pointer;
    min-width: 104px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    background: #ffffff;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    color: #344054;
    font-size: 0.86rem;
    font-weight: 550;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    white-space: nowrap;
}

.cost-date-range-trigger:hover {
    border-color: #17653d;
    color: #17653d;
    background: #f8faf9;
}

.cost-date-range-trigger.is-active-filter {
    background: #edf5f0;
    border-color: #17653d;
    color: #17653d;
    font-weight: 600;
}

.cost-date-range-clear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    font-size: 1.15rem;
    line-height: 1;
    color: #667085;
    cursor: pointer;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    transition: all 0.15s ease;
}

.cost-date-range-clear-btn:hover {
    background: rgba(23, 101, 61, 0.15);
    color: #17653d;
}

.cost-filter-reset-btn {
    cursor: pointer;
    height: 46px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    background: #ffffff;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    color: #475467;
    font-size: 0.86rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.cost-filter-reset-btn:hover {
    border-color: #0f4a2b;
    color: #0f4a2b;
    background: #f4f7f5;
}

.cost-date-range-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99998;
    background: rgba(15, 28, 20, 0.35);
    display: none;
}

/* Cost overview trend — production line/area chart */
body.overview-view .cost-trend-panel {
    padding: 22px 24px 20px;
    overflow: hidden;
    border: 1px solid #e3e9e5;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 12px 34px rgba(19, 46, 31, .07);
}

body.overview-view .cost-trend-panel .cost-panel-header {
    align-items: flex-start;
    gap: 20px;
}

body.overview-view .cost-trend-header-actions {
    display: grid;
    justify-items: end;
    gap: 8px;
    min-width: 0;
}

body.overview-view .cost-trend-heading {
    gap: 7px;
}

body.overview-view .cost-trend-heading h2 {
    color: #202722;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -.015em;
}

body.overview-view .cost-trend-total {
    display: grid;
    gap: 3px;
}

body.overview-view .cost-trend-total strong {
    color: #17653d;
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 750;
    letter-spacing: -.035em;
    line-height: 1.08;
    font-variant-numeric: tabular-nums;
}

body.overview-view .cost-trend-total span {
    color: #68746d;
    font-size: .75rem;
}

body.overview-view .cost-trend-periods {
    display: flex;
    max-width: 100%;
    padding: 3px;
    gap: 2px;
    overflow-x: auto;
    border: 1px solid #e2e7e4;
    border-radius: 10px;
    background: #f7f9f8;
    box-shadow: none;
    scrollbar-width: none;
}

body.overview-view .cost-trend-periods::-webkit-scrollbar {
    display: none;
}

body.overview-view .cost-trend-periods button {
    min-width: auto;
    min-height: 34px;
    flex: 0 0 auto;
    padding: 0 11px;
    border: 0;
    border-radius: 7px;
    color: #647169;
    background: transparent;
    box-shadow: none;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

body.overview-view .cost-trend-periods button:hover {
    color: #174b31;
    background: #eef3f0;
}

body.overview-view .cost-trend-periods button.active,
body.overview-view .cost-trend-periods button[aria-pressed="true"] {
    color: #fff;
    background: #17653d;
    box-shadow: 0 3px 9px rgba(23, 101, 61, .17);
}

body.overview-view .cost-trend-periods button:focus-visible,
body.overview-view .cost-chart-legend button:focus-visible {
    outline: 3px solid rgba(23, 101, 61, .2);
    outline-offset: 2px;
}

body.overview-view .cost-custom-range {
    display: grid;
    align-items: end;
    justify-content: stretch;
    margin: 14px 0 0;
    padding: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    border: 1px solid #e5eae7;
    border-radius: 12px;
    background: #fafcfb;
}

body.overview-view .cost-custom-range label {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 6px;
    min-width: 0;
}

body.overview-view .cost-line-chart {
    position: relative;
    min-height: 320px;
    margin: 12px -4px 0;
    padding: 0 4px 4px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: #bdc8c1 transparent;
}

body.overview-view .cost-line-chart::-webkit-scrollbar {
    height: 6px;
}

body.overview-view .cost-line-chart::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #bdc8c1;
}

body.overview-view .cost-line-chart svg {
    display: block;
    width: 100%;
    min-width: 720px;
    height: 300px;
    overflow: visible;
}

body.overview-view .cost-line-grid {
    stroke: #e7ece9;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

body.overview-view .cost-trend-axis-label,
body.overview-view .cost-line-label {
    fill: #68746d;
    font-family: "Prompt", "Noto Sans Thai", sans-serif;
    font-size: 10.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

body.overview-view .cost-trend-axis-label {
    text-anchor: end;
}

body.overview-view .cost-line-label {
    text-anchor: middle;
}

body.overview-view .cost-line-label.is-selected {
    fill: #183c2a;
    font-weight: 700;
}

body.overview-view .cost-line-empty {
    fill: #68746d;
    font-family: "Prompt", "Noto Sans Thai", sans-serif;
    font-size: 12px;
    text-anchor: middle;
}

body.overview-view .cost-trend-line {
    fill: none;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

body.overview-view .cost-trend-line.is-farm {
    stroke: #17653d;
}

body.overview-view .cost-trend-line.is-chicken {
    stroke: #d88727;
}

body.overview-view .cost-trend-area {
    pointer-events: none;
}

body.overview-view .cost-trend-point-column {
    cursor: crosshair;
    outline: none;
}

body.overview-view .cost-trend-hitbox {
    cursor: crosshair;
}

body.overview-view .cost-trend-crosshair {
    stroke: #9ca8a0;
    stroke-width: 1;
    stroke-dasharray: 3 4;
    opacity: 0;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
    transition: opacity 150ms ease;
}

body.overview-view .cost-trend-point {
    stroke: #fff;
    stroke-width: 2.5;
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
    transition: opacity 150ms ease, transform 180ms cubic-bezier(.16, 1, .3, 1);
    pointer-events: none;
}

body.overview-view .cost-trend-point.is-farm {
    fill: #17653d;
}

body.overview-view .cost-trend-point.is-chicken {
    fill: #d88727;
}

body.overview-view .cost-trend-point-column:hover .cost-trend-crosshair,
body.overview-view .cost-trend-point-column:focus-visible .cost-trend-crosshair,
body.overview-view .cost-trend-point-column.is-selected .cost-trend-crosshair,
body.overview-view .cost-trend-point-column:hover .cost-trend-point,
body.overview-view .cost-trend-point-column:focus-visible .cost-trend-point,
body.overview-view .cost-trend-point-column.is-selected .cost-trend-point {
    opacity: 1;
}

body.overview-view .cost-trend-point-column:hover .cost-trend-point,
body.overview-view .cost-trend-point-column:focus-visible .cost-trend-point {
    transform: scale(1.22);
}

body.overview-view .cost-line-chart.has-selection .cost-trend-point-column:not(.is-selected) .cost-trend-point {
    opacity: .25;
}

body.overview-view .cost-trend-tooltip {
    position: fixed;
    z-index: 1200;
    display: grid;
    min-width: 190px;
    gap: 8px;
    padding: 12px 13px;
    border: 1px solid rgba(18, 45, 30, .12);
    border-radius: 11px;
    background: #fff;
    color: #26322b;
    box-shadow: 0 12px 30px rgba(16, 37, 25, .16);
    pointer-events: none;
}

body.overview-view .cost-trend-tooltip[hidden] {
    display: none;
}

body.overview-view .cost-trend-tooltip > b {
    color: #1d2a22;
    font-size: .78rem;
    font-weight: 700;
}

body.overview-view .cost-trend-tooltip > span {
    display: grid;
    grid-template-columns: 8px minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
    color: #637068;
    font-size: .72rem;
}

body.overview-view .cost-trend-tooltip i,
body.overview-view .cost-chart-legend i {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
}

body.overview-view .cost-trend-tooltip i.is-farm,
body.overview-view .cost-chart-legend i.is-farm {
    background: #17653d;
}

body.overview-view .cost-trend-tooltip i.is-chicken,
body.overview-view .cost-chart-legend i.is-chicken {
    background: #d88727;
}

body.overview-view .cost-trend-tooltip strong {
    color: #26322b;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

body.overview-view .cost-trend-tooltip em {
    padding-top: 7px;
    border-top: 1px solid #e6ebe8;
    color: #17653d;
    font-size: .73rem;
    font-style: normal;
    font-weight: 700;
}

body.overview-view .cost-chart-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    padding: 0;
}

body.overview-view .cost-chart-legend button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    min-height: 28px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #607068;
    cursor: pointer;
    font: inherit;
    font-size: .69rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    transition: border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

body.overview-view .cost-chart-legend button:hover,
body.overview-view .cost-chart-legend button.is-active:hover {
    border-color: #dce4df;
    background: #f8faf9;
}

body.overview-view .cost-chart-legend button[aria-pressed="false"] {
    opacity: .46;
}

body.overview-view .cost-chart-legend button > i {
    margin: 0;
}

body.overview-view .cost-chart-detail-panel {
    margin-top: 12px;
    padding: 0;
}

body.overview-view .cost-chart-detail-empty {
    padding: 7px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #68746d;
}

body.overview-view .cost-trend-countup {
    font-variant-numeric: tabular-nums;
}

.cost-summary-value,
.cost-metric-card strong {
    font-variant-numeric: tabular-nums;
}

body.overview-view .cost-trend-panel.is-chart-revealing .cost-trend-reveal-mask {
    transform-box: fill-box;
    transform-origin: left center;
    animation: cost-trend-mask-in 780ms cubic-bezier(.16, 1, .3, 1) both;
}

body.overview-view .cost-trend-panel.is-chart-revealing .cost-trend-line {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: cost-trend-line-in 780ms cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes cost-trend-mask-in {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

@keyframes cost-trend-line-in {
    to { stroke-dashoffset: 0; }
}

@media (max-width: 900px) {
    body.overview-view .cost-trend-panel .cost-panel-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    body.overview-view .cost-trend-header-actions {
        justify-items: start;
        width: 100%;
    }

    body.overview-view .cost-trend-periods {
        width: max-content;
    }
}

@media (max-width: 620px) {
    body.overview-view .cost-trend-panel {
        padding: 18px 16px 16px;
        border-radius: 14px;
    }

    body.overview-view .cost-trend-periods {
        width: 100%;
    }

    body.overview-view .cost-custom-range {
        grid-template-columns: minmax(0, 1fr);
    }

    body.overview-view .cost-line-chart {
        min-height: 300px;
        margin-inline: 0;
        padding-inline: 0;
    }

    body.overview-view .cost-line-chart svg {
        min-width: 680px;
        height: 286px;
    }

    body.overview-view .cost-chart-legend {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.overview-view .cost-chart-legend button {
        min-width: 0;
    }

    body.overview-view .cost-trend-tooltip {
        min-width: 178px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.overview-view .cost-trend-panel.is-chart-revealing .cost-trend-reveal-mask,
    body.overview-view .cost-trend-panel.is-chart-revealing .cost-trend-line {
        animation: none;
    }

    body.overview-view .cost-trend-crosshair,
    body.overview-view .cost-trend-point,
    body.overview-view .cost-chart-legend button {
        transition-duration: .01ms;
    }
}

.cost-date-range-popover {
    position: fixed;
    z-index: 99999;
    width: 430px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #dfe7e2;
    border-radius: 16px;
    box-shadow: 0 18px 46px rgba(22, 46, 31, 0.18);
    padding: 14px;
    box-sizing: border-box;
}

@media (max-width: 640px) {
    .cost-date-range-backdrop:not([hidden]) {
        display: block;
    }
}

.cost-date-range-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px solid #edf2ef;
}

.cost-date-range-popover-header h4 {
    margin: 0;
    font-size: 0.94rem;
    font-weight: 650;
    color: #173c2b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cost-date-range-popover-header h4 i {
    color: #17653d;
}

.cost-date-range-close-btn {
    background: transparent;
    border: none;
    color: #667085;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 4px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.cost-date-range-close-btn:hover {
    background: #f2f4f7;
    color: #1d2939;
}

.cost-date-range-quick-presets {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 10px;
}

.cost-preset-btn {
    min-height: 38px;
    padding: 7px 10px;
    background: #f6f8f7;
    color: #425248;
    border: 1px solid #e2e8e4;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 550;
    text-align: center;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.cost-preset-btn:hover,
.cost-preset-btn.is-active {
    background: #e9f4ed;
    color: #214b34;
    border-color: #88aa95;
    font-weight: 600;
}

.cost-preset-btn[data-preset="range"] {
    grid-column: 1 / -1;
}

.cost-date-custom-section,
.cost-date-range-custom-section {
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid #e7ece9;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cost-date-custom-section label,
.cost-date-range-field label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #284435;
    margin-bottom: 3px;
    display: block;
}

.cost-date-range-inputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cost-date-range-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cost-date-range-field .thai-datetime-control,
.cost-date-custom-section .thai-datetime-control {
    display: grid !important;
    grid-template-columns: 1fr 1.6fr 1.3fr !important;
    gap: 6px !important;
    width: 100% !important;
}

.cost-date-range-field .thai-datetime-control .thai-datetime-date-group,
.cost-date-custom-section .thai-datetime-control .thai-datetime-date-group {
    display: contents !important;
}

.cost-date-range-field select,
.cost-date-custom-section select {
    height: 38px !important;
    font-size: 0.82rem !important;
    padding: 0 6px !important;
    border: 1px solid #d0d5dd !important;
    border-radius: 8px !important;
    background: #ffffff !important;
    color: #344054 !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.cost-date-range-error {
    margin: 8px 0 0;
    color: #d92d20;
    font-size: 0.78rem;
    font-weight: 600;
}

.cost-date-range-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid #edf2ef;
}

.cost-date-range-actions-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cost-date-range-btn-cancel {
    padding: 7px 14px;
    background: #ffffff;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    color: #344054;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 550;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cost-date-range-btn-cancel:hover {
    background: #f2f4f7;
    color: #1d2939;
}

.cost-date-range-btn-apply {
    padding: 7px 16px;
    background: #17653d;
    border: 1px solid #17653d;
    border-radius: 8px;
    color: #ffffff;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cost-date-range-btn-apply:hover {
    background: #0f4a2b;
    border-color: #0f4a2b;
}