/*
 * Cost page refinement layer
 * Presentation-only overrides that preserve the existing DOM and behavior.
 */

body {
    --cost-polish-surface: #ffffff;
    --cost-polish-surface-soft: #f7f9f7;
    --cost-polish-text: #172019;
    --cost-polish-muted: #66736c;
    --cost-polish-border: #e3e9e5;
    --cost-polish-green: #183f2c;
    --cost-polish-green-hover: #102f20;
    --cost-polish-green-soft: #eaf4ee;
    --cost-polish-gold: #b28a2e;
    --cost-polish-danger: #b93f3f;
    --cost-polish-radius: 16px;
    --cost-polish-control-radius: 12px;
    --cost-polish-shadow: 0 10px 30px rgba(22, 35, 27, .07);
    accent-color: var(--cost-polish-green);
    caret-color: var(--cost-polish-green);
}

body ::selection {
    color: #ffffff;
    background: var(--cost-polish-green);
}

.cost-page,
.cost-modal,
.cost-image-lightbox {
    color: var(--cost-polish-text);
}

.cost-page {
    line-height: 1.55;
}

.cost-page :where(strong, .cost-amount-column, .cost-summary-value, .cost-metric-card strong),
.cost-modal :where(input[type="number"], input[type="date"]) {
    font-variant-numeric: tabular-nums;
}

/* Header */
.dashboard-topbar.cost-topbar {
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
}

.cost-topbar-primary {
    min-height: 52px;
    gap: 14px;
}

.cost-page-heading {
    display: grid;
    gap: 4px;
}

.cost-page-heading h1 {
    font-size: clamp(2rem, 3vw, 2.35rem);
    font-weight: 700;
    letter-spacing: -.025em;
}

.cost-page-description {
    max-width: 62ch;
    margin: 0;
    color: var(--cost-polish-muted);
    font-size: .875rem;
    line-height: 1.6;
}

.cost-account-actions {
    flex: 0 0 auto;
    gap: 10px;
}

.cost-account-actions .icon-btn,
.cost-account-actions .user-profile {
    box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
}

.cost-account-actions .icon-btn {
    transition: color .2s ease, background-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.cost-account-actions .icon-btn:hover {
    background: var(--cost-polish-green);
    box-shadow: 0 10px 24px rgba(24, 63, 44, .16);
    transform: translateY(-2px);
}

/* Primary and secondary actions */
.cost-add-button,
.cost-empty-state button,
.cost-inventory-chart-empty .cost-add-button {
    min-height: 44px;
    padding: 0 18px;
    color: #ffffff;
    background: var(--cost-polish-green);
    border: 1px solid var(--cost-polish-green);
    border-radius: var(--cost-polish-control-radius);
    box-shadow: 0 7px 18px rgba(24, 63, 44, .14);
    font-size: .875rem;
    font-weight: 700;
    transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.cost-add-button:hover,
.cost-empty-state button:hover,
.cost-inventory-chart-empty .cost-add-button:hover {
    color: #ffffff;
    background: var(--cost-polish-green-hover);
    border-color: var(--cost-polish-green-hover);
    box-shadow: 0 10px 22px rgba(16, 47, 32, .19);
    transform: translateY(-1px);
}

.cost-secondary-button,
.cost-cancel-button {
    min-height: 44px;
    padding: 0 16px;
    color: #314239;
    background: #ffffff;
    border: 1px solid #d8e1db;
    border-radius: var(--cost-polish-control-radius);
    box-shadow: none;
    font-size: .82rem;
    font-weight: 700;
    transition: color .2s ease, background-color .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.cost-secondary-button:hover,
.cost-cancel-button:hover {
    color: var(--cost-polish-green);
    background: var(--cost-polish-green-soft);
    border-color: #c8d9ce;
    box-shadow: 0 7px 18px rgba(24, 63, 44, .07);
    transform: translateY(-1px);
}

.cost-save-button {
    min-height: 44px;
    padding: 0 18px;
    color: #ffffff;
    background: var(--cost-polish-green);
    border: 1px solid var(--cost-polish-green);
    border-radius: var(--cost-polish-control-radius);
    box-shadow: 0 7px 18px rgba(24, 63, 44, .14);
    font-size: .84rem;
    font-weight: 700;
    transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.cost-save-button:hover:not(:disabled) {
    background: var(--cost-polish-green-hover);
    border-color: var(--cost-polish-green-hover);
    box-shadow: 0 10px 22px rgba(16, 47, 32, .18);
    transform: translateY(-1px);
}

.cost-page button:disabled,
.cost-modal button:disabled {
    box-shadow: none;
    opacity: .58;
    transform: none;
}

/* View controls and surface rhythm */
.cost-overview-grid,
body.overview-view .cost-overview-grid {
    gap: 16px;
    margin-bottom: 20px;
}

.cost-view-menu {
    gap: 10px;
}

.cost-view-card,
.inventory-view .cost-view-card {
    min-height: 56px;
    padding: 9px 14px;
    color: #344139;
    background: #e9ecea;
    border: 1px solid transparent;
    border-radius: 14px;
    box-shadow: none;
    font-size: .875rem;
    font-weight: 600;
    transition: color .2s ease, background-color .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.cost-view-card:hover,
.inventory-view .cost-view-card:hover {
    color: var(--cost-polish-green);
    background: #f0f3f1;
    border-color: #dce5df;
    box-shadow: 0 8px 20px rgba(22, 35, 27, .06);
    transform: translateY(-2px);
}

.cost-view-card.active,
.inventory-view .cost-view-card.active {
    color: var(--cost-polish-green);
    background: #ffffff;
    border-color: transparent;
    box-shadow: 0 9px 24px rgba(22, 35, 27, .10);
}

.cost-view-card::after,
.inventory-view .cost-view-card::after {
    right: 24%;
    bottom: 0;
    left: 24%;
    height: 3px;
    background: transparent;
}

.cost-view-card.active::after,
.inventory-view .cost-view-card.active::after {
    background: var(--cost-polish-gold);
}

.cost-summary-card,
body:not(.inventory-view) .cost-summary-card,
body.chicken-view .cost-overview-grid > .cost-summary-card,
.cost-metric-card,
body.overview-view .cost-metric-card,
.cost-panel,
body.overview-view .cost-trend-panel,
body.overview-view .cost-category-panel,
body.overview-view .cost-records-panel,
.cost-inventory-summary-card {
    background: var(--cost-polish-surface);
    border: 0;
    border-radius: var(--cost-polish-radius);
    box-shadow: var(--cost-polish-shadow);
}

.cost-summary-card,
body:not(.inventory-view) .cost-summary-card {
    padding: 18px;
}

body.chicken-view .cost-overview-grid > .cost-summary-card {
    height: 240px;
    min-height: 210px;
    padding: 22px;
}

.cost-summary-title,
.cost-metric-card span {
    color: var(--cost-polish-muted);
    font-size: .8rem;
    font-weight: 650;
    line-height: 1.45;
}

.cost-summary-value,
.cost-metric-card strong {
    color: var(--cost-polish-text);
    font-weight: 750;
    letter-spacing: -.03em;
}

.cost-summary-caption,
.cost-summary-latest,
.cost-panel-description {
    color: var(--cost-polish-muted);
    line-height: 1.55;
}

.cost-metric-grid,
body.overview-view .cost-metric-grid {
    gap: 12px;
}

.cost-metric-card,
body.overview-view .cost-metric-card {
    min-height: 128px;
    padding: 20px;
    align-content: center;
    gap: 10px;
}

body.overview-view .cost-metric-card strong {
    font-size: clamp(1.85rem, 3vw, 2.55rem);
    letter-spacing: -.035em;
}

.cost-panel-header h2,
.cost-records-header h2,
.cost-year-toolbar h2,
.cost-inventory-summary-card h3 {
    color: var(--cost-polish-text);
    font-weight: 700;
    letter-spacing: -.015em;
    line-height: 1.35;
}

.cost-trend-panel,
.cost-category-panel,
body.overview-view .cost-category-panel,
.cost-inventory-summary-card {
    padding: 22px;
}

body.overview-view .cost-year-toolbar {
    padding: 15px 18px;
    background: #ffffff;
    border: 0;
    border-radius: var(--cost-polish-radius);
    box-shadow: var(--cost-polish-shadow);
}

body.overview-view .cost-year-select-field select {
    height: 42px;
    color: #26342c;
    background: var(--cost-polish-surface-soft);
    border: 1px solid var(--cost-polish-border);
    border-radius: var(--cost-polish-control-radius);
}

.cost-trend-periods,
.cost-context-periods {
    gap: 4px;
    padding: 4px;
    background: #f1f3f2;
    border: 0;
    border-radius: var(--cost-polish-control-radius);
}

.cost-trend-periods button,
.cost-context-periods button {
    min-height: 34px;
    color: #68756e;
    border: 0;
    border-radius: 9px;
    font-weight: 650;
}

.cost-trend-periods button:hover,
.cost-context-periods button:hover {
    color: var(--cost-polish-green);
    background: #e7ece9;
}

.cost-trend-periods button.active,
.cost-trend-periods button[aria-pressed="true"],
.cost-context-periods button.active {
    color: var(--cost-polish-green);
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(22, 35, 27, .08);
}

.cost-category-list {
    gap: 16px;
    margin-top: 20px;
}

.cost-category-track {
    height: 7px;
    background: #edf1ee;
}

/* Records, filters, and tables */
/* Records, filters, and tables - Strict Left Alignment */
.cost-records-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 18px;
    padding: 22px;
    text-align: left;
    width: 100%;
}

.cost-records-heading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
    gap: 4px;
    width: 100%;
    margin: 0;
    padding: 0;
}

.cost-records-heading h2,
#cost-records-title {
    text-align: left;
    margin: 0;
    padding: 0;
    color: var(--cost-polish-text, #172019);
    font-weight: 700;
    letter-spacing: -.015em;
}

.cost-records-heading p,
#cost-result-text,
.cost-records-header > div:first-child > p:last-child {
    text-align: left;
    margin: 0;
    padding: 0;
    color: var(--cost-polish-muted, #5f6b64);
    line-height: 1.55;
    font-size: .82rem;
}

/* Inventory panel header: Title left, Actions right */
.cost-inventory-panel .cost-records-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 22px;
    width: 100%;
    text-align: left;
}

.cost-inventory-panel .cost-records-header > div:first-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    margin: 0;
}

.cost-inventory-panel .cost-records-header h2 {
    text-align: left;
    margin: 0;
    padding: 0;
}

.cost-inventory-panel .cost-inventory-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

/* Ensure inventory filter stage and grid align with 22px card padding */
.cost-filter-stage {
    padding-left: 22px !important;
    padding-right: 22px !important;
}

.cost-inventory-grid {
    padding-left: 22px !important;
    padding-right: 22px !important;
}

/* Feeding Operations headers: Title left, Action right */
.feeding-operation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    text-align: left;
}

.feeding-operation-header > div:first-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.feeding-operation-header h2,
.feeding-operation-header p {
    text-align: left;
    margin-left: 0;
    padding-left: 0;
}

.cost-inventory-recent-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.cost-inventory-recent-heading h3 {
    text-align: left;
    margin: 0;
}

.cost-detail-history-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    text-align: left;
}

.cost-detail-history-heading > div:first-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.cost-detail-history-heading h3,
.cost-detail-history-heading p {
    text-align: left;
    margin-left: 0;
    padding-left: 0;
}

.cost-record-tools,
.cost-record-tools:has(#cost-farm-filters:not([hidden])),
.cost-record-tools:has(#cost-chicken-filters:not([hidden])) {
    gap: 8px;
    padding: 0 !important;
}

.dashboard-filter-search-slot,
.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 {
    height: 44px;
    min-height: 44px;
}

.dashboard-filter-search,
.dashboard-filter-search-slot .dashboard-filter-search {
    height: 44px;
    min-height: 44px;
    color: #ffffff;
    background: #15251c !important;
    border: 0;
    box-shadow: 0 7px 18px rgba(21, 37, 28, .13);
}

.dashboard-filter-search-slot:hover .dashboard-filter-search,
.dashboard-filter-search-slot:focus-within .dashboard-filter-search {
    background: var(--cost-polish-green) !important;
    box-shadow: 0 10px 24px rgba(24, 63, 44, .18);
}

.dashboard-filter-search > i,
.dashboard-filter-search .dashboard-filter-search-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
}

.dashboard-filter-capsule,
.cost-record-tools input,
.cost-record-tools select,
.cost-inventory-filterbar .inventory-static-pill,
.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill {
    min-height: 44px;
    color: #344139;
    background: #f5f7f5;
    border: 1px solid var(--cost-polish-border);
    border-radius: var(--cost-polish-control-radius);
    box-shadow: none;
}

.dashboard-filter-capsule:hover,
.dashboard-filter-capsule:focus-within,
.cost-record-tools input:hover,
.cost-record-tools input:focus,
.cost-record-tools select:hover,
.cost-record-tools select:focus,
.cost-inventory-filterbar .inventory-static-pill:hover,
.cost-inventory-filterbar .inventory-static-pill:focus-within,
.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill:hover,
.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill:focus-visible {
    color: var(--cost-polish-green);
    background: #eef3f0;
    border-color: #cfdcd4;
    box-shadow: 0 6px 16px rgba(24, 63, 44, .06);
}

.cost-record-tools .is-active-filter,
.cost-inventory-filterbar .is-active-filter,
.cost-inventory-filterbar .inventory-static-pill:has(select.is-active-filter),
.cost-inventory-filterbar #inventory-filter-button.inventory-static-pill[aria-expanded="true"] {
    color: var(--cost-polish-green);
    background: var(--cost-polish-green-soft);
    border-color: #bfd3c6;
}

.cost-inventory-filterbar {
    gap: 8px;
    margin-bottom: 14px;
}

.cost-inventory-filterbar .inventory-search-slot {
    height: 44px;
}

.cost-inventory-filterbar .cost-inventory-search,
.cost-inventory-filterbar .inventory-search-slot .is-search {
    height: 44px;
    min-height: 44px;
}

.cost-inventory-advanced-filters {
    gap: 12px;
    margin-bottom: 18px;
    padding: 16px;
    background: #f6f8f6;
    border: 1px solid var(--cost-polish-border);
    border-radius: var(--cost-polish-radius);
    box-shadow: none;
}

.cost-inventory-advanced-filters input,
.cost-inventory-advanced-filters select,
.cost-detail-filters input,
.cost-detail-filters select,
.cost-field input,
.cost-field select,
.cost-field textarea {
    border-color: #dce4df;
    border-radius: var(--cost-polish-control-radius);
    box-shadow: none;
}

.cost-inventory-clear-filter {
    min-height: 42px;
    padding: 0 14px;
    color: #48584f;
    background: #e9eeeb;
    border: 0;
    border-radius: var(--cost-polish-control-radius);
}

.cost-inventory-clear-filter:hover {
    color: var(--cost-polish-green);
    background: #dfe8e2;
}

.cost-table-wrap {
    overscroll-behavior-inline: contain;
    scrollbar-color: #b8c5bd transparent;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.cost-table {
    font-variant-numeric: tabular-nums;
}

.cost-table th,
.cost-table td {
    padding: 15px 18px;
    line-height: 1.5;
}

.cost-table th:first-child,
.cost-table td:first-child {
    padding-left: 22px !important;
}

.cost-inventory-grid > .cost-table-wrap {
    margin-left: -22px;
    margin-right: -22px;
    width: calc(100% + 44px) !important;
}

.cost-table thead th {
    color: #5f6b64;
    background: #f7f9f7;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .01em;
}

.cost-table td {
    color: #49574f;
    font-size: .82rem;
}

.cost-table tbody tr {
    transition: background-color .18s ease;
}

.cost-table tbody tr:hover {
    background: #f8faf8;
}

.cost-table tbody tr:hover td {
    background: transparent;
}

.cost-table-actions {
    min-width: 190px;
    gap: 7px;
}

.cost-table-action,
.cost-table-action[data-action="view"],
.cost-table-action[data-action="edit"],
.cost-table-action[data-action="delete"] {
    min-height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: .78rem;
    font-weight: 700;
    transition: color .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.cost-table-action[data-action="view"] {
    color: #ffffff;
    background: #526159;
    border-color: #526159;
}

.cost-table-action[data-action="edit"] {
    color: #3d2d08;
    background: #e8c35c;
    border-color: #e8c35c;
}

.cost-table-action[data-action="delete"],
.cost-table-action.is-danger {
    color: #ffffff;
    background: var(--cost-polish-danger);
    border-color: var(--cost-polish-danger);
}

.cost-table-action:hover:not(:disabled) {
    box-shadow: 0 6px 14px rgba(22, 35, 27, .12);
    filter: brightness(.94);
    transform: translateY(-1px);
}

/* Inventory cards and detail surfaces */
.cost-inventory-kpis {
    gap: 10px;
    margin-top: 18px;
}

.cost-inventory-kpis article {
    min-height: 104px;
    padding: 15px;
    background: var(--cost-polish-surface-soft);
    border: 0;
    border-radius: 14px;
    box-shadow: none;
}

.cost-inventory-kpis article:hover {
    background: #f1f5f2;
    border-color: transparent;
    box-shadow: none;
    transform: translateY(-1px);
}

.cost-inventory-kpis span {
    color: var(--cost-polish-muted);
    font-size: .75rem;
}

.cost-inventory-kpis strong {
    color: var(--cost-polish-text);
    font-size: 1.4rem;
}

.cost-inventory-card,
.inventory-feed-summary,
.inventory-feed-summary-grid > div {
    border-radius: 14px;
}

.cost-inventory-recent-item {
    min-height: 54px;
    padding: 11px 6px;
}

.cost-inventory-recent-heading button,
.cost-receipt-link {
    text-underline-offset: 3px;
}

/* ==========================================================================
   Popup & Modal Unified Design System (6 Modals)
   ========================================================================== */

/* 1. Containers & Backdrops */
.cost-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    padding: 24px;
    display: grid;
    place-items: center;
}

.cost-modal-backdrop,
.cost-image-lightbox-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    background: rgba(7, 17, 11, 0.62);
    border: 0;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    cursor: pointer;
    transition: opacity .2s ease;
}

.cost-image-lightbox-backdrop {
    background: rgba(3, 9, 5, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* 2. Dialog Core Geometry & Semantic Max-Width Hierarchy */
.cost-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(780px, 100%);
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--cost-polish-surface, #ffffff);
    border: 1px solid rgba(227, 233, 229, 0.9);
    border-radius: var(--cost-polish-radius, 16px);
    box-shadow: 0 24px 64px rgba(8, 22, 14, 0.22), 0 4px 16px rgba(8, 22, 14, 0.06);
    color: var(--cost-polish-text, #172019);
    animation: modal-dialog-enter .22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes modal-dialog-enter {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Compact Modal (600px) - Inventory Receive */
#inventory-modal .cost-modal-dialog {
    width: min(600px, 100%);
}

/* Standard Modal (780px) - Add/Edit Cost */
#cost-modal .cost-modal-dialog {
    width: min(780px, 100%);
}

/* Wide Modals (840px - 960px) - History & Analytics */
#inventory-use-modal .cost-modal-dialog {
    width: min(840px, 100%);
}

#chicken-cost-detail-modal .cost-modal-dialog,
.cost-modal-dialog.cost-chicken-detail-dialog,
#inventory-history-modal .cost-modal-dialog,
.cost-modal-dialog.cost-inventory-history-dialog {
    width: min(960px, 100%);
    max-height: min(90vh, 880px);
    max-height: min(90dvh, 880px);
}

/* Media Lightbox Canvas (1050px) */
.cost-image-lightbox-dialog {
    position: relative;
    z-index: 1;
    width: min(1050px, 100%);
    max-height: calc(100dvh - 48px);
    padding: 16px 20px 18px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 12px;
    background: #ffffff;
    border: 1px solid rgba(227, 233, 229, 0.9);
    border-radius: var(--cost-polish-radius, 16px);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
    animation: modal-dialog-enter .22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* 3. Modal Header */
.cost-modal-header,
.cost-image-lightbox-dialog header {
    padding: 22px 26px 18px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    background: #ffffff;
    border-bottom: 1px solid var(--cost-polish-border, #e3e9e5);
    flex-shrink: 0;
}

.cost-modal-header h2,
.cost-image-lightbox-dialog h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--cost-polish-text, #172019);
    letter-spacing: -0.015em;
    line-height: 1.3;
}

.cost-modal-header p {
    margin: 4px 0 0;
    color: var(--cost-polish-muted, #66736c);
    font-size: 0.84rem;
    line-height: 1.5;
    max-width: 65ch;
}

.farm-cost-dialog__close,
.cost-modal-close,
.cost-image-lightbox-close {
    position: absolute !important;
    top: 16px !important;
    right: 16px !important;
    flex: 0 0 46px !important;
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
    aspect-ratio: 1 / 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    color: #374151 !important;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.1) !important;
    font-size: 20px !important;
    cursor: pointer !important;
    z-index: 30 !important;
    transition:
        background-color 140ms ease,
        border-color 140ms ease,
        color 140ms ease,
        transform 160ms cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 140ms ease !important;
}

.farm-cost-dialog__close:hover,
.cost-modal-close:hover,
.cost-image-lightbox-close:hover {
    background: #111827 !important;
    border-color: #111827 !important;
    color: #ffffff !important;
    transform: rotate(90deg) !important;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18) !important;
}

.farm-cost-dialog__close:active,
.cost-modal-close:active,
.cost-image-lightbox-close:active {
    transform: rotate(90deg) scale(0.92) !important;
}

.farm-cost-dialog__close:focus-visible,
.cost-modal-close:focus-visible,
.cost-image-lightbox-close:focus-visible {
    outline: 3px solid rgba(242, 101, 34, 0.24) !important;
    outline-offset: 2px !important;
}

/* 4. Modal Body & Scrolling */
.cost-form-body {
    min-height: 0;
    padding: 22px 26px 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #cbd8d0 transparent;
}

.cost-chicken-detail-body {
    min-height: 0;
    padding: 20px 24px 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: #ffffff;
    scrollbar-width: thin;
    scrollbar-color: #cbd8d0 transparent;
}

/* 5. Form Grids & Form Controls */
.cost-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 14px;
    align-items: start;
}

.cost-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cost-field-full {
    grid-column: 1 / -1;
}

.cost-field label,
.cost-field-label,
.cost-form-section legend {
    color: #26342b;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cost-required {
    color: var(--cost-polish-danger, #b93f3f);
    font-weight: 700;
}

.cost-optional-label {
    color: var(--cost-polish-muted, #66736c);
    font-size: 0.76rem;
    font-weight: 500;
}

.cost-field input,
.cost-field select,
.cost-field textarea {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    color: var(--cost-polish-text, #172019);
    background: #ffffff;
    border: 1px solid var(--cost-polish-border, #e3e9e5);
    border-radius: var(--cost-polish-control-radius, 12px);
    font: inherit;
    font-size: 0.875rem;
    outline: 0;
    box-shadow: none;
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.cost-field textarea {
    min-height: 84px;
    padding-top: 10px;
    padding-bottom: 10px;
    line-height: 1.5;
    resize: vertical;
}

.cost-field input:hover,
.cost-field select:hover,
.cost-field textarea:hover {
    border-color: #9ab4a3;
}

.cost-field input:focus,
.cost-field select:focus,
.cost-field textarea:focus {
    background: #ffffff;
    border-color: var(--cost-polish-green, #183f2c);
    box-shadow: 0 0 0 3px rgba(24, 63, 44, 0.12);
}

.cost-field input[aria-invalid="true"],
.cost-field select[aria-invalid="true"] {
    border-color: var(--cost-polish-danger, #b93f3f);
    box-shadow: 0 0 0 3px rgba(185, 63, 63, 0.12);
}

.cost-field-error {
    min-height: 18px;
    margin: 2px 0 0;
    color: var(--cost-polish-danger, #b93f3f);
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.4;
}

.cost-money-input {
    position: relative;
    width: 100%;
}

.cost-money-input input {
    padding-right: 46px;
}

.cost-money-input span {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    color: var(--cost-polish-muted, #66736c);
    font-size: 0.8125rem;
    font-weight: 600;
    pointer-events: none;
}

/* 6. Form Sections & Custom Radios */
.cost-form-section {
    min-width: 0;
    margin: 2px 0 0;
    padding: 16px;
    grid-column: 1 / -1;
    background: #f8faf8;
    border: 1px solid var(--cost-polish-border, #e3e9e5);
    border-radius: 14px;
}

.cost-form-section legend {
    padding: 0 8px;
}

.cost-radio-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 4px;
}

.cost-radio-option {
    min-height: 46px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #3b4940;
    background: #ffffff;
    border: 1.5px solid #dce4df;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.84rem;
    font-weight: 500;
    transition: all .18s ease;
}

.cost-radio-option:hover {
    background: #f4f8f5;
    border-color: #a0c1ac;
}

.cost-radio-option:has(input:checked) {
    color: var(--cost-polish-green, #183f2c);
    background: #edf7f0;
    border-color: var(--cost-polish-green, #183f2c);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(24, 63, 44, 0.08);
}

.cost-radio-option input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--cost-polish-green, #183f2c);
}

.cost-optional-quantity button {
    min-height: 38px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--cost-polish-green, #183f2c);
    background: #edf6f0;
    border: 1px dashed #8bb397;
    border-radius: 999px;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .18s ease;
}

.cost-optional-quantity button:hover {
    background: #e2f0e6;
    border-color: var(--cost-polish-green, #183f2c);
    transform: translateY(-1px);
}

/* 7. Upload Box & Receipt Preview */
.cost-upload-box {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: #f8faf8;
    border: 1.5px dashed #a8c0af;
    border-radius: 12px;
    transition: all .2s ease;
}

.cost-upload-box:hover {
    border-color: var(--cost-polish-green, #183f2c);
    background: #f2f8f4;
}

.cost-upload-box p {
    margin: 0;
    color: #5f6e65;
    font-size: 0.8125rem;
}

.cost-upload-button {
    min-height: 38px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    color: var(--cost-polish-green, #183f2c);
    background: var(--cost-polish-green-soft, #eaf4ee);
    border: 1px solid #c8e0cf;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all .18s ease;
}

.cost-upload-button:hover {
    background: #dbeef2;
    border-color: #aed1b8;
    transform: translateY(-1px);
}

.cost-receipt-preview {
    margin-top: 10px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f4f8f5;
    border: 1px solid #dfe7e1;
    border-radius: 12px;
}

.cost-receipt-thumbnail {
    position: relative;
    width: 50px;
    height: 50px;
    flex: 0 0 50px;
}

.cost-receipt-preview img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #d4dfd7;
    cursor: zoom-in;
}

.cost-receipt-zoom {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--cost-polish-green, #183f2c);
    color: #ffffff;
    border: 1.5px solid #ffffff;
    display: grid;
    place-items: center;
    font-size: 11px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: transform .16s ease;
}

.cost-receipt-zoom:hover {
    transform: scale(1.12);
}

.cost-receipt-preview span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    color: #2e3d33;
    font-size: 0.8125rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cost-remove-receipt {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    padding: 0;
    display: grid;
    place-items: center;
    color: var(--cost-polish-danger, #b93f3f);
    background: #ffffff;
    border: 1px solid #eadada;
    border-radius: 8px;
    cursor: pointer;
    transition: all .18s ease;
}

.cost-remove-receipt:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    transform: scale(1.05);
}

/* 8. Live Calculation Badges & Compact Calculation Row */
.cost-inventory-calculation:not(#chicken-feed-inventory-hint):not(#inventory-calculation),
#auto-feeding-hint,
#inventory-use-hint {
    margin: 6px 0 0;
    padding: 5px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--cost-polish-green, #183f2c);
    background: var(--cost-polish-green-soft, #eaf4ee);
    border: 1px solid #c9e2d1;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 700;
}

#chicken-feed-inventory-hint {
    margin: 4px 0 0;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
}

#chicken-feed-inventory-hint[hidden] {
    display: none !important;
}

/* Compact Single-Row Calculation Card (No background, compact row) */
.cost-calculation-card,
.cost-system-dialog .cost-calculation-card {
    min-width: 0;
    min-height: auto;
    padding: 4px 2px 2px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: transparent !important;
    border: none !important;
    border-radius: 0;
    box-shadow: none !important;
}

.cost-calculation-card .cost-calculation-icon,
.cost-system-dialog .cost-calculation-icon {
    display: none !important;
}

.cost-calculation-card > div {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.cost-calculation-label,
.cost-system-dialog .cost-calculation-label {
    display: inline;
    margin: 0;
    color: #64748b;
    font-size: 0.8125rem;
    font-weight: 500;
}

.cost-calculation-card #inventory-calculation,
.cost-system-dialog .cost-calculation-card #inventory-calculation {
    display: inline;
    margin: 0;
    padding: 0;
    background: transparent !important;
    border: none !important;
    color: #0f172a;
    font-size: 0.95rem;
    font-weight: 700;
}

.cost-calculation-formula,
.cost-system-dialog .cost-calculation-formula {
    color: #94a3b8;
    font-size: 0.775rem;
    font-weight: 400;
    white-space: nowrap;
    margin: 0;
}

/* 9. Modal Footer & Action Buttons */
.cost-form-actions {
    padding: 16px 26px 18px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    background: #ffffff;
    border-top: 1px solid var(--cost-polish-border, #e3e9e5);
    flex-shrink: 0;
}

.cost-form-message {
    min-width: 0;
    margin: 0 auto 0 0;
    color: var(--cost-polish-danger, #b93f3f);
    font-size: 0.8125rem;
    font-weight: 600;
}

.cost-form-message:not(:empty) {
    padding: 6px 12px;
    background: #fdf2f2;
    border: 1px solid #fbd5d5;
    border-radius: 8px;
}

.cost-cancel-button {
    min-height: 44px;
    padding: 0 18px;
    border-radius: var(--cost-polish-control-radius, 12px);
    font-size: 0.84rem;
    font-weight: 700;
    color: #415147;
    background: #f2f5f3;
    border: 1px solid #dbe3dd;
    cursor: pointer;
    transition: all .18s ease;
}

.cost-cancel-button:hover {
    background: #e5ece7;
    color: var(--cost-polish-green, #183f2c);
    border-color: #c4d4c8;
}

.cost-save-button {
    min-height: 44px;
    padding: 0 20px;
    border-radius: var(--cost-polish-control-radius, 12px);
    font-size: 0.84rem;
    font-weight: 700;
    color: #ffffff;
    background: var(--cost-polish-green, #183f2c);
    border: 1px solid var(--cost-polish-green, #183f2c);
    box-shadow: 0 6px 16px rgba(24, 63, 44, 0.18);
    cursor: pointer;
    transition: all .18s ease;
}

.cost-save-button:hover:not(:disabled) {
    background: var(--cost-polish-green-hover, #102f20);
    border-color: var(--cost-polish-green-hover, #102f20);
    box-shadow: 0 8px 22px rgba(16, 47, 32, 0.24);
    transform: translateY(-1px);
}

.cost-save-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(24, 63, 44, 0.14);
}

/* 10. Specific Polish: #chicken-cost-detail-modal */
.cost-chicken-detail-dialog {
    width: min(940px, calc(100vw - 32px)) !important;
    max-height: min(90vh, 860px) !important;
    background: #ffffff !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 48px rgba(16, 73, 45, 0.12), 0 4px 16px rgba(0, 0, 0, 0.06) !important;
    border: 1px solid #e3e9e5 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.cost-chicken-detail-dialog .farm-cost-dialog__header {
    padding: 18px 24px !important;
    border-bottom: 1px solid #e3e9e5 !important;
    background: #ffffff !important;
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
}

.cost-chicken-detail-dialog .farm-cost-dialog__heading h2 {
    margin: 0 !important;
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    color: #172019 !important;
    letter-spacing: -0.01em !important;
}

.cost-chicken-detail-dialog .farm-cost-dialog__heading p {
    margin: 2px 0 0 !important;
    font-size: 0.8125rem !important;
    color: #66736c !important;
}

.cost-chicken-detail-dialog .farm-cost-dialog__close {
    width: 34px !important;
    height: 34px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    border: 1px solid transparent !important;
    background: #f4f6f8 !important;
    color: #66736c !important;
    font-size: 0.95rem !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
}

.cost-chicken-detail-dialog .farm-cost-dialog__close:hover {
    background: #e9ecef !important;
    color: #172019 !important;
}

.cost-chicken-detail-body {
    padding: 24px 28px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 22px !important;
    background: #ffffff !important;
}

/* --- Section 1: Chicken Hero (No nested card, pure typography & layout) --- */
.cost-chicken-hero {
    display: grid !important;
    grid-template-columns: 200px minmax(0, 1fr) !important;
    gap: 24px !important;
    align-items: center !important;
    padding-bottom: 22px !important;
    border-bottom: 1px solid #e3e9e5 !important;
    background: transparent !important;
}

.cost-chicken-hero__avatar {
    position: relative !important;
    width: 100% !important;
    height: 155px !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    background: #f4f6f8 !important;
    border: 1px solid #e3e9e5 !important;
    box-shadow: 0 2px 8px rgba(23, 32, 25, 0.04) !important;
}

.cost-chicken-hero__avatar img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

.cost-chicken-hero__content {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    gap: 16px !important;
    min-width: 0 !important;
}

.cost-chicken-hero__identity {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    min-width: 0 !important;
}

.cost-chicken-hero__name {
    margin: 0 !important;
    font-size: 1.45rem !important;
    font-weight: 700 !important;
    color: #172019 !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.cost-chicken-hero__meta {
    margin: 0 !important;
    font-size: 0.875rem !important;
    color: #66736c !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
}

.cost-chicken-hero__total {
    display: inline-flex !important;
    flex-direction: column !important;
    gap: 2px !important;
}

.cost-chicken-hero__total-label {
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    color: #66736c !important;
    text-transform: uppercase !important;
    letter-spacing: 0.02em !important;
}

.cost-chicken-hero__total-value {
    font-size: 1.85rem !important;
    font-weight: 800 !important;
    color: #17653d !important;
    line-height: 1.15 !important;
    font-variant-numeric: tabular-nums !important;
}

/* --- Section 2: Cost Breakdown (Clean List, No nested cards) --- */
.cost-chicken-breakdown-section {
    padding-bottom: 22px !important;
    border-bottom: 1px solid #e3e9e5 !important;
}

.cost-section-heading {
    margin-bottom: 12px !important;
}

.cost-section-heading h3 {
    margin: 0 !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    color: #172019 !important;
}

.cost-chicken-breakdown-container {
    width: 100% !important;
}

.cost-chicken-detail-dialog .cost-detail-legend {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
    gap: 8px 24px !important;
    margin-top: 6px !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
}

.cost-chicken-detail-dialog .cost-detail-legend-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 6px 0 !important;
    border-bottom: 1px solid #f0f3f1 !important;
    background: transparent !important;
    border-radius: 0 !important;
    gap: 12px !important;
}

.cost-chicken-detail-dialog .cost-detail-legend-row:hover {
    background: transparent !important;
}

.cost-chicken-detail-dialog .cost-detail-legend-row i {
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    flex: 0 0 8px !important;
    margin-right: 6px !important;
}

.cost-chicken-detail-dialog .cost-detail-legend-row span {
    display: flex !important;
    align-items: center !important;
    font-size: 0.85rem !important;
    color: #4a574f !important;
    flex: 1 1 auto !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.cost-chicken-detail-dialog .cost-detail-legend-row strong {
    font-size: 0.875rem !important;
    font-weight: 700 !important;
    color: #172019 !important;
    font-variant-numeric: tabular-nums !important;
    white-space: nowrap !important;
}

/* --- Section 3: Cost History (Clean Table) --- */
.cost-chicken-history-section {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

.cost-section-heading--split {
    display: flex !important;
    align-items: baseline !important;
    justify-content: space-between !important;
    gap: 12px !important;
    margin-bottom: 2px !important;
}

.cost-section-heading--split h3 {
    display: inline-block !important;
    margin: 0 !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    color: #172019 !important;
}

.cost-section-result {
    display: inline-block !important;
    margin: 0 !important;
    font-size: 0.8125rem !important;
    color: #66736c !important;
    font-weight: 500 !important;
}

.cost-chicken-detail-dialog .cost-detail-filters {
    display: grid !important;
    grid-template-columns: minmax(200px, 1.6fr) minmax(130px, 1fr) minmax(110px, 0.8fr) !important;
    gap: 10px !important;
    margin-bottom: 6px !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
}

.cost-chicken-detail-dialog .cost-detail-filters input,
.cost-chicken-detail-dialog .cost-detail-filters select {
    min-height: 38px !important;
    padding: 0 12px !important;
    border: 1px solid #d5dcd7 !important;
    border-radius: 8px !important;
    font-size: 0.8125rem !important;
    color: #172019 !important;
    background-color: #ffffff !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

.cost-chicken-detail-dialog .cost-detail-filters input:focus,
.cost-chicken-detail-dialog .cost-detail-filters select:focus {
    border-color: #17653d !important;
    box-shadow: 0 0 0 3px rgba(23, 101, 61, 0.12) !important;
    outline: none !important;
}

.cost-chicken-detail-dialog .cost-detail-search {
    position: relative !important;
}

.cost-chicken-detail-dialog .cost-detail-search i {
    position: absolute !important;
    left: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: #8b9990 !important;
    font-size: 0.85rem !important;
    pointer-events: none !important;
}

.cost-chicken-detail-dialog .cost-detail-search input {
    padding-left: 36px !important;
}

.cost-chicken-history-table-wrap {
    border: 1px solid #e3e9e5 !important;
    border-radius: 10px !important;
    overflow: auto !important;
    max-height: 280px !important;
    background: #ffffff !important;
}

.cost-chicken-detail-dialog .cost-detail-history-table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 0.8125rem !important;
}

.cost-chicken-detail-dialog .cost-detail-history-table thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 2 !important;
    background: #f8faf8 !important;
    color: #4a574f !important;
    font-weight: 600 !important;
    padding: 10px 14px !important;
    border-bottom: 1px solid #e3e9e5 !important;
    text-align: left !important;
    white-space: nowrap !important;
}

.cost-chicken-detail-dialog .cost-detail-history-table td {
    padding: 10px 14px !important;
    border-bottom: 1px solid #f0f3f1 !important;
    color: #172019 !important;
    vertical-align: middle !important;
}

.cost-chicken-detail-dialog .cost-detail-history-table tbody tr:hover {
    background-color: #f9fbf9 !important;
}

.cost-chicken-detail-dialog .cost-detail-history-table td.cost-amount-column,
.cost-chicken-detail-dialog .cost-detail-history-table th.cost-amount-column {
    text-align: right !important;
    font-variant-numeric: tabular-nums !important;
}

.cost-chicken-detail-dialog .cost-table-actions {
    min-width: auto !important;
    gap: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    white-space: nowrap !important;
}

.cost-chicken-detail-dialog .cost-table-action {
    min-height: 28px !important;
    padding: 0 10px !important;
    border-radius: 6px !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    border: 1px solid transparent !important;
    box-shadow: none !important;
    transform: none !important;
    transition: all 0.15s ease !important;
}

.cost-chicken-detail-dialog .cost-table-action[data-action="view"] {
    color: #17653d !important;
    background: #eef6f1 !important;
    border-color: #cde4d6 !important;
}

.cost-chicken-detail-dialog .cost-table-action[data-action="view"]:hover {
    background: #17653d !important;
    color: #ffffff !important;
    border-color: #17653d !important;
}

.cost-chicken-detail-dialog .cost-table-action[data-action="edit"] {
    color: #856404 !important;
    background: #fff8e1 !important;
    border-color: #ffe082 !important;
}

.cost-chicken-detail-dialog .cost-table-action[data-action="edit"]:hover {
    background: #ffc107 !important;
    color: #000000 !important;
    border-color: #ffc107 !important;
}

.cost-chicken-detail-dialog .cost-table-action[data-action="delete"],
.cost-chicken-detail-dialog .cost-table-action.is-danger {
    color: #b93f3f !important;
    background: #fdf2f2 !important;
    border-color: #f8d7da !important;
}

.cost-chicken-detail-dialog .cost-table-action[data-action="delete"]:hover,
.cost-chicken-detail-dialog .cost-table-action.is-danger:hover {
    background: #dc3545 !important;
    color: #ffffff !important;
    border-color: #dc3545 !important;
}

.cost-chicken-detail-dialog .cost-detail-pagination {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding-top: 10px !important;
    border-top: 1px solid #f0f3f1 !important;
}

.cost-chicken-detail-dialog .cost-detail-pagination p {
    margin: 0 !important;
    font-size: 0.78rem !important;
    color: #66736c !important;
}

.cost-chicken-detail-dialog .cost-detail-pagination nav {
    display: flex !important;
    gap: 4px !important;
    align-items: center !important;
}

.cost-chicken-detail-dialog .cost-detail-pagination nav button {
    min-width: 28px !important;
    height: 28px !important;
    padding: 0 6px !important;
    font-size: 0.75rem !important;
    border-radius: 6px !important;
    border: 1px solid #d5dcd7 !important;
    background: #ffffff !important;
    color: #172019 !important;
    cursor: pointer !important;
}

.cost-chicken-detail-dialog .cost-detail-pagination nav button.active {
    background: #17653d !important;
    color: #ffffff !important;
    border-color: #17653d !important;
    font-weight: 700 !important;
}

.cost-chicken-detail-dialog .cost-detail-pagination nav button:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

@media (max-width: 640px) {
    .cost-chicken-detail-dialog {
        width: calc(100vw - 20px) !important;
        max-height: 94vh !important;
        border-radius: 12px !important;
    }
    .cost-chicken-detail-body {
        padding: 16px !important;
        gap: 18px !important;
    }
    .cost-chicken-hero {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
        text-align: center !important;
    }
    .cost-chicken-hero__avatar {
        width: 140px !important;
        height: 140px !important;
        margin: 0 auto !important;
    }
    .cost-chicken-hero__content {
        align-items: center !important;
    }
    .cost-chicken-hero__total {
        align-items: center !important;
    }
    .cost-chicken-detail-dialog .cost-detail-filters {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    .cost-chicken-detail-dialog .cost-detail-legend {
        grid-template-columns: 1fr !important;
        gap: 6px !important;
    }
}

/* 11. Specific Polish: #inventory-use-modal & Chicken Feeding Summary */
.inventory-feed-summary {
    margin-top: 14px;
    padding: 16px 18px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.inventory-feed-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.875rem;
    font-weight: 700;
    color: #1e293b;
}

.inventory-feed-summary-header strong {
    color: #1e293b;
    font-size: 0.9rem;
    font-weight: 700;
}

.inventory-feed-summary-header span,
#chicken-feed-preview-count {
    padding: 3px 10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
}

.inventory-feed-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.inventory-feed-summary-grid > div {
    padding: 12px 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    text-align: center;
}

.inventory-feed-summary-grid span {
    display: block;
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 4px;
}

.inventory-feed-summary-grid strong {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}

.inventory-feed-chickens {
    max-height: 180px;
    overflow-y: auto;
    border-top: 1px solid #e2e8f0;
    padding-top: 8px;
}

.inventory-feed-chicken-row {
    padding: 8px 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.825rem;
    color: #334155;
}

.inventory-feed-chicken-row:last-child {
    border-bottom: none;
}

.inventory-feed-chicken-row strong {
    color: #0f172a;
}

.inventory-chicken-picker {
    max-height: 180px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--cost-polish-border, #e3e9e5);
    border-radius: 10px;
    padding: 6px;
    background: #fafcfa;
    display: grid;
    gap: 4px;
}

.inventory-chicken-picker-row {
    min-height: 42px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    border: 1px solid #e6ede8;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s ease;
}

.inventory-chicken-picker-row:hover {
    background: #f0f7f2;
    border-color: #bcd5c4;
}

.inventory-chicken-picker-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--cost-polish-green, #183f2c);
}

/* 12. Specific Polish: #inventory-history-modal */
.cost-inventory-history-filters {
    display: grid;
    grid-template-columns: minmax(180px, 1.4fr) repeat(4, minmax(110px, 1fr));
    gap: 8px;
    padding: 14px 26px;
    background: #f8faf8;
    border-bottom: 1px solid var(--cost-polish-border, #e3e9e5);
}

.cost-inventory-history-filters input,
.cost-inventory-history-filters select {
    min-height: 40px;
    border-radius: 10px;
    font-size: 0.8125rem;
}

.cost-inventory-history-list {
    padding: 16px 26px;
    max-height: 440px;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cost-inventory-recent-item {
    min-height: 52px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: #ffffff;
    border: 1px solid var(--cost-polish-border, #e3e9e5);
    border-radius: 12px;
    text-align: left;
    transition: all .16s ease;
}

.cost-inventory-recent-item:hover {
    border-color: #a3c4af;
    background: #f8fbf9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

.cost-inventory-recent-item.is-receive > i {
    color: #16a34a;
    background: #e8f8ee;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    font-size: 15px;
}

.cost-inventory-recent-item.is-use > i {
    color: #d97706;
    background: #fef3c7;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    font-size: 15px;
}

.cost-inventory-recent-title em {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 6px;
    font-style: normal;
    font-size: 0.72rem;
    font-weight: 700;
    margin-right: 6px;
}

.is-receive .cost-inventory-recent-title em {
    background: #dcfce7;
    color: #15803d;
}

.is-use .cost-inventory-recent-title em {
    background: #fef3c7;
    color: #b45309;
}

.cost-inventory-history-pagination {
    padding: 14px 26px;
    border-top: 1px solid var(--cost-polish-border, #e3e9e5);
    background: #ffffff;
}

/* 13. Specific Polish: #cost-image-lightbox */
.cost-image-lightbox-canvas {
    background: #101612;
    border-radius: 12px;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: auto;
    padding: 14px;
}

.cost-image-lightbox-canvas img {
    max-width: 100%;
    max-height: calc(100dvh - 160px);
    object-fit: contain;
    border-radius: 6px;
}

/* One consistent focus language for every interactive surface. */
.cost-page :where(button, a, input, select, textarea):focus-visible,
.cost-modal :where(button, a, input, select, textarea):focus-visible,
.cost-image-lightbox :where(button, a):focus-visible {
    outline: 3px solid rgba(24, 63, 44, .23);
    outline-offset: 2px;
}

@media (max-width: 1180px) {
    .cost-records-header {
        align-items: stretch;
        flex-direction: column;
    }

    .cost-record-tools {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 900px) {
    .dashboard-topbar.cost-topbar {
        align-items: stretch;
    }

    .cost-modal {
        padding: 14px;
    }

    .cost-inventory-summary-card,
    .cost-trend-panel,
    .cost-category-panel,
    body.overview-view .cost-category-panel {
        padding: 20px;
    }

    .cost-record-tools:has(#cost-farm-filters:not([hidden])),
    .cost-record-tools:has(#cost-chicken-filters:not([hidden])) {
        gap: 8px;
    }

    .cost-detail-summary-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .cost-inventory-history-filters {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 700px) {
    .cost-view-menu,
    .inventory-view .cost-view-menu {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cost-view-card,
    .inventory-view .cost-view-card {
        min-height: 54px;
        padding: 8px 10px;
        font-size: .82rem;
    }

    .cost-records-header {
        padding: 18px 16px !important;
        align-items: stretch !important;
        text-align: left !important;
    }

    .cost-records-heading {
        align-items: flex-start !important;
        text-align: left !important;
    }

    .cost-records-heading h2,
    #cost-records-title,
    .cost-records-heading p,
    #cost-result-text {
        text-align: left !important;
    }

    .cost-inventory-panel .cost-records-header {
        padding: 18px 16px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    .cost-inventory-panel .cost-inventory-actions {
        margin-left: 0 !important;
        width: 100% !important;
        flex-wrap: wrap !important;
    }

    .cost-table th:first-child,
    .cost-table td:first-child {
        padding-left: 16px !important;
    }

    .cost-filter-stage {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .cost-inventory-grid {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .cost-inventory-grid > .cost-table-wrap {
        margin-left: -16px;
        margin-right: -16px;
        width: calc(100% + 32px) !important;
    }

    .cost-record-tools,
    .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));
        align-items: stretch;
        width: 100%;
    }

    .cost-record-tools .dashboard-filter-search-slot,
    .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 .dashboard-filter-search,
    .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%;
        min-width: 0;
    }

    .cost-record-tools .dashboard-filter-search input,
    .cost-record-tools .dashboard-filter-search label {
        opacity: 1;
        pointer-events: auto;
        transform: none;
    }

    .cost-record-tools .dashboard-filter-capsule,
    .cost-record-tools .cost-category-filter-field,
    .cost-record-tools .cost-category-filter-field select,
    .cost-record-tools .cost-chicken-filters,
    .cost-record-tools .cost-chicken-filters > *,
    .cost-record-tools .cost-chicken-filters label,
    .cost-record-tools .cost-chicken-filters input {
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .cost-trend-panel .cost-panel-header {
        gap: 14px;
    }

    .cost-trend-periods {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .cost-table th,
    .cost-table td {
        padding: 14px 16px;
    }

    body.chicken-view .cost-overview-grid > .cost-summary-card {
        height: auto;
        min-height: 176px;
        padding: 20px;
    }
}

@media (max-width: 640px) {
    .cost-modal {
        padding: 8px;
    }

    .cost-modal-dialog,
    .cost-image-lightbox-dialog {
        max-height: calc(100dvh - 16px);
        border-radius: 16px;
    }

    .cost-modal-header,
    .cost-form-body,
    .cost-form-actions,
    .cost-chicken-detail-body,
    .cost-inventory-history-filters,
    .cost-inventory-history-list,
    .cost-inventory-history-pagination {
        padding-right: 16px;
        padding-left: 16px;
    }

    .cost-form-grid,
    .cost-radio-group {
        grid-template-columns: 1fr;
    }

    .cost-form-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .cost-detail-filters {
        grid-template-columns: 1fr;
    }

    .cost-inventory-history-filters {
        grid-template-columns: 1fr;
    }

    .inventory-feed-summary-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}

@media (max-width: 520px) {
    .dashboard-topbar.cost-topbar {
        gap: 14px;
        padding: 16px;
        border-radius: var(--cost-polish-radius);
    }

    .cost-topbar-primary {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: start;
        width: 100%;
    }

    .cost-add-button {
        grid-column: 1 / -1;
        width: 100%;
        margin-left: 0;
    }

    .cost-account-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .cost-account-actions .user-profile {
        margin-left: auto;
    }

    .cost-page-heading h1 {
        font-size: 1.75rem;
    }

    .cost-metric-card,
    body.overview-view .cost-metric-card {
        min-height: 112px;
        padding: 18px;
    }

    .cost-trend-panel,
    .cost-category-panel,
    body.overview-view .cost-category-panel,
    .cost-inventory-summary-card {
        padding: 18px;
    }

    .cost-record-tools,
    .cost-record-tools:has(#cost-farm-filters:not([hidden])),
    .cost-record-tools:has(#cost-chicken-filters:not([hidden])) {
        grid-template-columns: 1fr;
    }

    .cost-record-tools .dashboard-filter-search-slot,
    .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;
    }

    .cost-inventory-filterbar,
    .cost-filter-stage .cost-inventory-filterbar {
        grid-template-columns: 1fr;
    }

    .cost-inventory-filterbar .inventory-search-slot,
    .cost-inventory-filterbar .cost-inventory-search,
    .cost-inventory-filterbar .inventory-static-pill,
    .cost-inventory-filterbar #inventory-filter-button.inventory-static-pill {
        grid-column: 1;
        width: 100%;
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cost-page *,
    .cost-page *::before,
    .cost-page *::after,
    .cost-modal *,
    .cost-image-lightbox * {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Inventory Table Action Buttons */
.cost-actions-header {
    text-align: center !important;
    white-space: nowrap;
    width: 140px;
}

.cost-actions-cell {
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
}

.cost-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.18s ease;
    text-decoration: none;
    line-height: 1.2;
    margin: 0 3px;
}

.cost-action-button i {
    font-size: 0.82rem;
}

.cost-action-edit {
    background: #f0f7f3;
    color: #1b633e;
    border-color: #d1e7dd;
}

.cost-action-edit:hover:not(:disabled):not(.is-disabled) {
    background: #1b633e;
    color: #ffffff;
    border-color: #1b633e;
    box-shadow: 0 2px 6px rgba(27, 99, 62, 0.2);
}

.cost-action-delete {
    background: #fdf2f2;
    color: #d92d20;
    border-color: #fecdca;
}

.cost-action-delete:hover:not(:disabled):not(.is-disabled) {
    background: #d92d20;
    color: #ffffff;
    border-color: #d92d20;
    box-shadow: 0 2px 6px rgba(217, 45, 32, 0.2);
}

.cost-action-button:disabled,
.cost-action-button.is-disabled {
    opacity: 0.45;
    cursor: not-allowed !important;
    pointer-events: auto;
    background: #f3f4f6 !important;
    color: #9ca3af !important;
    border-color: #e5e7eb !important;
    box-shadow: none !important;
    transform: none !important;
}

/* =====================================================
   COST VIEW LABELS (DESKTOP / MOBILE SWITCH) & RESPONSIVE LAYOUT
   ===================================================== */
@media (max-width: 768px) {

    /* 1. Topbar Layout on Mobile */
    .dashboard-topbar.cost-topbar {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 10px 14px !important;
        gap: 10px 8px !important;
        min-height: 56px !important;
    }

    .cost-topbar-primary {
        display: contents !important;
    }

    .cost-mobile-menu {
        display: grid !important;
        order: 1 !important;
    }

    .cost-page-heading {
        margin: 0 !important;
        order: 2 !important;
    }

    .cost-page-heading h1 {
        font-size: 1.3rem !important;
        margin: 0 !important;
        line-height: 1.2 !important;
    }

    .cost-page-description {
        display: none !important;
    }

    .cost-account-actions {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        width: auto !important;
        margin-left: auto !important;
        order: 3 !important;
    }

    .cost-account-actions .user-profile .user-info {
        display: none !important;
    }

    .cost-account-actions .user-profile {
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
    }

    .cost-topbar-primary .cost-add-button,
    .cost-add-button {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        min-height: 44px !important;
        height: 44px !important;
        padding: 0 16px !important;
        border-radius: 12px !important;
        font-size: 0.95rem !important;
        font-weight: 600 !important;
        background: var(--cost-polish-green, #17653D) !important;
        color: #ffffff !important;
        border: 1px solid var(--cost-polish-green, #17653D) !important;
        box-shadow: 0 4px 14px rgba(23, 101, 61, 0.22) !important;
        margin: 2px 0 0 0 !important;
        order: 4 !important;
        cursor: pointer !important;
        gap: 8px !important;
    }

    .cost-topbar-primary .cost-add-button:active,
    .cost-add-button:active {
        transform: scale(0.98) !important;
    }

    .cost-topbar-primary .cost-add-button[hidden],
    .cost-add-button[hidden],
    body.overview-view .cost-topbar-primary .cost-add-button,
    body.overview-view .cost-add-button {
        display: none !important;
    }

    /* 2. Tabs in 1 row (4 columns) */
    .cost-view-menu,
    .inventory-view .cost-view-menu,
    body.overview-view .cost-view-menu,
    body.chicken-view .cost-view-menu {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
        width: 100% !important;
        padding: 0 !important;
    }

    .cost-view-card,
    .inventory-view .cost-view-card {
        min-height: 40px !important;
        padding: 6px 2px !important;
        font-size: 0.78rem !important;
        border-radius: 10px !important;
        text-align: center !important;
        justify-content: center !important;
        white-space: nowrap !important;
    }

    /* 3. Year Toolbar Single Row */
    body.overview-view .cost-year-toolbar {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 10px 14px !important;
        gap: 8px !important;
    }

    body.overview-view .cost-year-toolbar div h2 {
        font-size: 0.95rem !important;
        margin: 0 !important;
    }

    body.overview-view .cost-year-toolbar div p {
        font-size: 0.75rem !important;
        margin: 0 !important;
    }

    body.overview-view .cost-year-select-field {
        width: auto !important;
        margin: 0 !important;
    }

    body.overview-view .cost-year-select-field span {
        display: none !important;
    }

    body.overview-view .cost-year-select-field select {
        height: 34px !important;
        padding: 4px 10px !important;
        font-size: 0.82rem !important;
        width: auto !important;
        min-width: 90px !important;
    }

    /* 4. Compact 2-row Metric Grid (2 cols top, 3 cols bottom) - Overview only */
    .cost-metric-grid[hidden],
    body:not(.overview-view) .cost-metric-grid {
        display: none !important;
    }

    body.overview-view .cost-metric-grid {
        display: grid !important;
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 8px !important;
        width: 100% !important;
    }

    body.overview-view .cost-metric-card {
        min-height: 64px !important;
        padding: 10px 12px !important;
        border-radius: 12px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        gap: 4px !important;
    }

    /* Cards 1 & 2: 50% width (span 3) */
    body.overview-view .cost-metric-card:nth-child(1),
    body.overview-view .cost-metric-card:nth-child(2) {
        grid-column: span 3 !important;
    }

    /* Cards 3, 4, 5: 33.33% width (span 2) */
    body.overview-view .cost-metric-card:nth-child(3),
    body.overview-view .cost-metric-card:nth-child(4),
    body.overview-view .cost-metric-card:nth-child(5) {
        grid-column: span 2 !important;
    }

    body.overview-view .cost-metric-card span {
        font-size: 0.72rem !important;
        color: #64748b !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    body.overview-view .cost-metric-card strong {
        font-size: 1.05rem !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}

/* =====================================================
   INVENTORY VIEW FULL WIDTH & SPATIAL STYLING
   ===================================================== */
body.inventory-view .cost-overview-grid,
.inventory-view .cost-overview-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr) !important;
    grid-template-rows: auto auto !important;
    gap: 10px 18px !important;
    margin-bottom: 12px !important;
    align-items: start !important;
}

body.inventory-view .cost-view-menu,
.inventory-view .cost-view-menu {
    grid-column: 1 !important;
    grid-row: 1 !important;
    align-self: start !important;
    width: 100% !important;
    margin: 0 !important;
}

/* 3 Inventory Summary Cards under Menu (Inventory View ONLY) */
body.inventory-view .cost-inventory-summary-cards,
.inventory-view .cost-inventory-summary-cards {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 10px !important;
    grid-column: 1 !important;
    grid-row: 2 !important;
    align-self: start !important;
    width: 100% !important;
    margin: 0 !important;
}

body:not(.inventory-view) .cost-inventory-summary-cards,
.cost-inventory-summary-cards[hidden] {
    display: none !important;
}

.cost-inventory-summary-cards .cost-summary-card {
    min-height: 0 !important;
    border-radius: 16px !important;
    padding: 13px 15px !important;
    background: #ffffff !important;
    border: 1px solid #edf1ee !important;
    box-shadow: 0 4px 18px rgba(28, 55, 40, .05) !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
}

.cost-inventory-summary-cards .cost-summary-title {
    color: var(--cost-polish-muted, #64748b) !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
}

.cost-inventory-summary-cards .cost-summary-value {
    font-size: clamp(1.15rem, 1.4vw, 1.4rem) !important;
    font-weight: 700 !important;
    color: var(--cost-polish-text, #0f172a) !important;
    margin-top: 4px !important;
    display: block !important;
}

.cost-inventory-summary-cards .cost-summary-caption {
    font-size: 0.72rem !important;
    color: var(--cost-polish-muted, #64748b) !important;
    margin-top: 2px !important;
    display: block !important;
}

body.inventory-view #inventory-right-rail,
.inventory-view #inventory-right-rail,
.inventory-view .cost-inventory-right-rail {
    grid-column: 2 !important;
    grid-row: 1 / span 2 !important;
    align-self: start !important;
    width: 100% !important;
    margin: 0 !important;
}

body.inventory-view #inventory-top-chart,
.inventory-view #inventory-top-chart {
    padding: 16px 18px !important;
    border-radius: 18px !important;
    margin: 0 !important;
}

body.inventory-view .cost-inventory-chart-header,
.inventory-view .cost-inventory-chart-header {
    margin-bottom: 10px !important;
}

body.inventory-view .cost-inventory-donut,
.inventory-view .cost-inventory-donut {
    width: 130px !important;
    height: 130px !important;
}

body.inventory-view .cost-inventory-donut::before,
.inventory-view .cost-inventory-donut::before {
    inset: 22px !important;
}

body.inventory-view .cost-inventory-donut-center strong,
.inventory-view .cost-inventory-donut-center strong {
    font-size: 1.6rem !important;
}

body.inventory-view .cost-inventory-chart-body,
.inventory-view .cost-inventory-chart-body {
    grid-template-columns: 130px minmax(0, 1fr) !important;
    gap: 14px !important;
}

/* Hide the 3 mini KPI boxes in the right chart */
body.inventory-view .cost-inventory-kpis,
.inventory-view .cost-inventory-kpis {
    display: none !important;
}

body.inventory-view #cost-inventory-panel,
.inventory-view #cost-inventory-panel,
.inventory-view .cost-inventory-panel,
body.inventory-view #cost-inventory-history-panel,
.inventory-view #cost-inventory-history-panel,
.inventory-view .cost-inventory-history-panel {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-top: 4px !important;
    background: #ffffff !important;
    border: 1px solid var(--cost-polish-border, #e3e9e5) !important;
    border-radius: 18px !important;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05) !important;
    overflow: hidden !important;
    position: static !important;
}

/* Header inside inventory panel */
.cost-inventory-panel .cost-records-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 16px 20px 8px 20px !important;
    gap: 8px !important;
    width: 100% !important;
}

.cost-inventory-panel .cost-records-header h2 {
    font-size: 1.15rem !important;
    margin: 0 !important;
}

.cost-inventory-panel .cost-filter-stage {
    padding-left: 20px !important;
    padding-right: 20px !important;
    margin-bottom: 6px !important;
}

.cost-inventory-filterbar {
    gap: 8px !important;
}

.cost-inventory-layout,
.cost-inventory-main,
.cost-inventory-grid {
    width: 100% !important;
    max-width: 100% !important;
}

.cost-inventory-table-wrap,
.cost-inventory-grid > .cost-table-wrap {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 0 20px 10px !important;
}

.cost-inventory-table {
    width: 100% !important;
    min-width: 860px !important;
    border-collapse: collapse !important;
}

.cost-inventory-table th,
.cost-inventory-table td {
    padding: 11px 14px !important;
    font-size: 0.84rem !important;
}

.cost-inventory-section {
    padding: 0 !important;
}

.cost-inventory-section-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 12px 20px 8px !important;
}

.cost-inventory-section-title {
    font-size: 0.98rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    margin: 0 !important;
    padding: 4px 20px 6px !important;
}

/* History filter capsule pill */
.cost-inventory-hist-filterbar .inventory-static-pill,
.cost-inventory-hist-filterbar .cost-inventory-hist-filter {
    min-height: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #f5f7f5;
    border: 1px solid var(--cost-polish-border, #dce5df);
    color: #344139;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.cost-inventory-hist-filterbar .inventory-static-pill select,
.cost-inventory-hist-filterbar .cost-inventory-hist-filter {
    width: 100%;
    min-width: 140px;
    height: 38px;
    min-height: 38px;
    padding: 0 32px 0 14px;
    margin: 0;
    border: 0;
    border-radius: 999px;
    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;
    appearance: none;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: #242424;
    cursor: pointer;
    outline: none;
}

.cost-inventory-hist-filterbar .inventory-static-pill:hover,
.cost-inventory-hist-filterbar .inventory-static-pill:focus-within {
    background: #eef3f0;
    border-color: #cfdcd4;
    box-shadow: 0 4px 12px rgba(24, 63, 44, 0.06);
}

.cost-inventory-hist-filterbar .inventory-static-pill:has(select.is-active-filter),
.cost-inventory-hist-filterbar .inventory-static-pill select.is-active-filter {
    color: var(--cost-polish-green, #1e4d38);
    background-color: var(--cost-polish-green-soft, #eaf2ed);
    border-color: #bfd3c6;
}

/* Modern Pagination for Inventory & History tables */
.cost-inventory-pagination[hidden],
.cost-inventory-hist-pagination[hidden],
.cost-inventory-history-pagination[hidden],
#cost-records-pagination[hidden],
#inventory-pagination[hidden] {
    display: none !important;
}

.cost-inventory-pagination:not([hidden]),
.cost-inventory-hist-pagination:not([hidden]),
.cost-inventory-history-pagination:not([hidden]) {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 12px 20px 14px !important;
    border-top: 1px solid #f1f5f9 !important;
    margin-top: 4px !important;
}

.cost-inventory-pagination p,
.cost-inventory-hist-pagination p,
.cost-inventory-hist-summary,
#inventory-pagination-summary {
    margin: 0 !important;
    font-size: 0.82rem !important;
    color: #64748b !important;
    font-weight: 500 !important;
}

.cost-inventory-pagination nav,
.cost-inventory-hist-pagination nav,
.cost-inventory-history-pagination nav {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.cost-inventory-pagination nav button,
.cost-inventory-hist-pagination nav button,
.cost-inventory-history-pagination nav button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 34px !important;
    height: 34px !important;
    padding: 0 10px !important;
    border: 1px solid #e2e8e4 !important;
    border-radius: 10px !important;
    background: #ffffff !important;
    color: #334155 !important;
    font: inherit !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    outline: none !important;
}

.cost-inventory-pagination nav button:hover:not(:disabled),
.cost-inventory-hist-pagination nav button:hover:not(:disabled),
.cost-inventory-history-pagination nav button:hover:not(:disabled) {
    border-color: #b9d2c2 !important;
    background: #f4f8f5 !important;
    color: var(--cost-polish-green, #1e4d38) !important;
}

.cost-inventory-pagination nav button.is-active,
.cost-inventory-hist-pagination nav button.is-active,
.cost-inventory-history-pagination nav button.is-active,
.cost-inventory-pagination nav button[aria-current="page"],
.cost-inventory-hist-pagination nav button[aria-current="page"],
.cost-inventory-history-pagination nav button[aria-current="page"] {
    background: var(--cost-polish-green, #1e4d38) !important;
    color: #ffffff !important;
    border-color: var(--cost-polish-green, #1e4d38) !important;
    font-weight: 700 !important;
    box-shadow: 0 3px 10px rgba(30, 77, 56, 0.22) !important;
}

.cost-inventory-pagination nav button:disabled,
.cost-inventory-hist-pagination nav button:disabled,
.cost-inventory-history-pagination nav button:disabled {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    background: #f8faf9 !important;
    border-color: #e2e8e4 !important;
}

.cost-inventory-pagination nav span,
.cost-inventory-hist-pagination nav span,
.cost-inventory-history-pagination nav span {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 24px !important;
    color: #94a3b8 !important;
    font-size: 0.85rem !important;
    user-select: none !important;
}

@media (max-width: 980px) {
    body.inventory-view .cost-overview-grid,
    .inventory-view .cost-overview-grid {
        grid-template-columns: 1fr !important;
    }

    body.inventory-view .cost-view-menu,
    .inventory-view .cost-view-menu {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    body.inventory-view .cost-inventory-summary-cards,
    .inventory-view .cost-inventory-summary-cards {
        grid-column: 1 !important;
        grid-row: 2 !important;
    }

    body.inventory-view #inventory-right-rail,
    .inventory-view #inventory-right-rail,
    .inventory-view .cost-inventory-right-rail {
        grid-column: 1 !important;
        grid-row: 3 !important;
    }
}

@media (max-width: 640px) {
    body.inventory-view .cost-inventory-summary-cards,
    .inventory-view .cost-inventory-summary-cards {
        grid-template-columns: 1fr !important;
    }
}

/* =====================================================
   Chicken & Farm View - Overview Grid Compact Spacing
   ===================================================== */
@media (min-width: 981px) {
    body.chicken-view .cost-overview-grid,
    body.farm-view .cost-overview-grid {
        grid-template-rows: auto auto !important;
        gap: 10px 18px !important;
        margin-bottom: 12px !important;
        align-items: start !important;
    }

    body.chicken-view .cost-view-menu,
    body.farm-view .cost-view-menu {
        grid-row: 1 !important;
        margin: 0 !important;
    }

    body.chicken-view .cost-inventory-right-rail,
    body.farm-view .cost-inventory-right-rail {
        grid-row: 1 / span 2 !important;
        align-self: start !important;
        margin: 0 !important;
    }

    body.chicken-view .cost-overview-grid > .cost-summary-card,
    body.farm-view .cost-overview-grid > .cost-summary-card {
        grid-row: 2 !important;
        min-height: 0 !important;
        padding: 16px 18px !important;
        border-radius: 18px !important;
        margin: 0 !important;
    }
}

@media (max-width: 980px) {
    body.chicken-view .cost-overview-grid,
    body.farm-view .cost-overview-grid {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        gap: 12px !important;
        margin-bottom: 12px !important;
    }

    body.chicken-view .cost-view-menu,
    body.farm-view .cost-view-menu {
        grid-column: 1 !important;
        grid-row: 1 !important;
        margin: 0 !important;
    }

    body.chicken-view .cost-overview-grid > .cost-summary-card,
    body.farm-view .cost-overview-grid > .cost-summary-card {
        grid-column: 1 !important;
        grid-row: auto !important;
        min-height: 0 !important;
        padding: 14px 16px !important;
        border-radius: 16px !important;
        margin: 0 !important;
    }

    body.chicken-view .cost-inventory-right-rail,
    body.farm-view .cost-inventory-right-rail {
        grid-column: 1 !important;
        grid-row: auto !important;
        align-self: stretch !important;
        margin: 0 !important;
    }
}

/* =====================================================
   Chicken View - Highest Cost Chicken Card Layout
   - Profile with large image and code on top (Left)
   - Donut chart and cost breakdown in right column (Right)
   ===================================================== */
body.chicken-view #cost-context-chart {
    padding: 16px 18px !important;
    border-radius: 18px !important;
    margin: 0 !important;
}

body.chicken-view .cost-inventory-chart-header {
    margin-bottom: 10px !important;
}

body.chicken-view .cost-context-chart-content {
    display: grid !important;
    grid-template-columns: minmax(130px, 148px) minmax(0, 1fr) !important;
    gap: 12px 16px !important;
    align-items: center !important;
    width: 100% !important;
}

body.chicken-view #cost-context-chicken {
    grid-column: 1 !important;
    grid-row: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 6px !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    width: 100% !important;
}

body.chicken-view .cost-context-chicken-profile {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 6px !important;
    width: 100% !important;
}

body.chicken-view .cost-context-chicken-code {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 2px 10px !important;
    background: #f0f5f2 !important;
    color: var(--cost-polish-green, #1e4d38) !important;
    border: 1px solid #dbe6df !important;
    border-radius: 999px !important;
    font-size: 0.76rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em !important;
    width: fit-content !important;
}

body.chicken-view .cost-context-chicken-avatar-wrap {
    width: 100% !important;
    max-width: 140px !important;
    height: 140px !important;
    border-radius: 18px !important;
    overflow: hidden !important;
    border: 2px solid #ffffff !important;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1) !important;
    background: #f8faf9 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

body.chicken-view .cost-context-chicken-avatar-wrap img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

body.chicken-view .cost-context-chicken-name {
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    margin-top: 1px !important;
    max-width: 140px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    text-align: center !important;
}

body.chicken-view .cost-context-donut-layout {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
}

body.chicken-view #cost-context-donut {
    width: 96px !important;
    height: 96px !important;
    margin: 0 auto !important;
    flex-shrink: 0 !important;
}

body.chicken-view #cost-context-donut::before {
    inset: 16px !important;
}

body.chicken-view #cost-context-donut .cost-inventory-donut-center span {
    font-size: 0.6rem !important;
    color: #64748b !important;
}

body.chicken-view #cost-context-donut .cost-inventory-donut-center strong {
    font-size: 0.9rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    line-height: 1.1 !important;
    margin-top: 1px !important;
}

body.chicken-view #cost-context-legend {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

body.chicken-view #cost-context-legend div {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    font-size: 0.78rem !important;
}

body.chicken-view #cost-context-legend div > i {
    width: 6px !important;
    height: 6px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    margin-right: 6px !important;
}

body.chicken-view #cost-context-legend div > span {
    flex: 1 1 auto !important;
    color: #475569 !important;
    font-weight: 500 !important;
    font-size: 0.76rem !important;
}

body.chicken-view #cost-context-legend div > strong {
    flex-shrink: 0 !important;
    color: #0f172a !important;
    font-weight: 700 !important;
    font-size: 0.8rem !important;
    margin: 0 !important;
}