/* =============================================================================
   ماژول بهای تمام‌شده — داشبورد، فرم‌ها، جداول ثبت
   ============================================================================= */

.cost-page {
    --cost-accent: #1565c0;
    --cost-accent-dark: #0d47a1;
    --cost-surface: var(--mud-palette-surface, #fff);
}

.cost-page {
    padding-left: 12px !important;
    padding-right: 12px !important;
}

.cost-page .cost-header-paper {
    border-radius: 12px;
    padding: 14px 18px !important;
    border: 1px solid color-mix(in srgb, var(--cost-accent) 22%, transparent);
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--cost-accent) 7%, var(--cost-surface)),
        var(--cost-surface));
}

.cost-page .cost-header-paper .mud-typography-h5 {
    font-weight: 700;
}

.cost-selection-banner {
    border-radius: 10px;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
    border: 1px solid color-mix(in srgb, var(--cost-accent) 18%, transparent);
    background: color-mix(in srgb, var(--cost-accent) 5%, var(--cost-surface));
}

.cost-selection-banner--missing {
    border-color: color-mix(in srgb, #f57c00 35%, transparent);
    background: color-mix(in srgb, #fff3e0 80%, var(--cost-surface));
}

.cost-selection-label {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    margin-bottom: 2px;
}

.cost-selection-value {
    font-weight: 600;
}

/* KPI داشبورد */
.cost-dash-kpi {
    border-radius: 11px;
    padding: 13px 15px !important;
    border: 1px solid color-mix(in srgb, var(--cost-accent) 14%, transparent);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    height: 100%;
}

.cost-dash-kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px color-mix(in srgb, var(--cost-accent) 12%, transparent);
}

.cost-dash-kpi--warn {
    border-color: color-mix(in srgb, #f57c00 35%, transparent);
    background: linear-gradient(160deg, color-mix(in srgb, #fff3e0 80%, var(--cost-surface)), var(--cost-surface));
}

.cost-dash-kpi--ok {
    border-color: color-mix(in srgb, #43a047 30%, transparent);
    background: linear-gradient(160deg, color-mix(in srgb, #e8f5e9 70%, var(--cost-surface)), var(--cost-surface));
}

.cost-dash-kpi--money {
    border-color: color-mix(in srgb, var(--cost-accent) 28%, transparent);
    background: linear-gradient(160deg, color-mix(in srgb, var(--cost-accent) 10%, var(--cost-surface)), var(--cost-surface));
}

.cost-dash-kpi__value {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.03em;
    font-weight: 700;
    direction: ltr;
    unicode-bidi: plaintext;
    display: inline-block;
    line-height: 1.45;
}

.cost-dash-section-title {
    font-weight: 700;
    margin: 14px 0 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid color-mix(in srgb, var(--cost-accent) 20%, transparent);
}

.cost-dash-section-sub {
    font-weight: 400;
    font-size: 0.85em;
    color: var(--mud-palette-text-secondary);
    margin-right: 6px;
}

/* ─── Hero metrics ─── */
.cost-hero-metrics {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 12px;
}

@media (min-width: 600px) {
    .cost-hero-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1100px) {
    .cost-hero-metrics {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.cost-hero-metric {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(21, 101, 192, 0.18);
    background: linear-gradient(135deg, rgba(227, 242, 253, 0.95), var(--mud-palette-surface, #fff));
    box-shadow: 0 4px 14px rgba(21, 101, 192, 0.08);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.cost-hero-metric:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(21, 101, 192, 0.14);
}

.cost-hero-metric--egg {
    border-color: rgba(21, 101, 192, 0.32);
    background: linear-gradient(135deg, rgba(227, 242, 253, 0.98), rgba(255, 255, 255, 0.95));
}

.cost-hero-metric--chick {
    border-color: rgba(46, 125, 50, 0.32);
    background: linear-gradient(135deg, rgba(232, 245, 233, 0.98), rgba(255, 255, 255, 0.95));
}

.cost-hero-metric--amort {
    border-color: rgba(99, 102, 241, 0.35);
    background: linear-gradient(135deg, rgba(238, 242, 255, 0.98), rgba(255, 255, 255, 0.95));
}

.cost-hero-metric--rearing {
    border-color: rgba(126, 87, 194, 0.35);
    background: linear-gradient(135deg, rgba(237, 231, 246, 0.98), rgba(255, 255, 255, 0.95));
}

.cost-hero-metric__icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(21, 101, 192, 0.12);
    color: #1565c0;
    flex-shrink: 0;
}

.cost-hero-metric--chick .cost-hero-metric__icon {
    background: rgba(46, 125, 50, 0.12);
    color: #2e7d32;
}

.cost-hero-metric--amort .cost-hero-metric__icon {
    background: rgba(99, 102, 241, 0.14);
    color: #4f46e5;
}

.cost-hero-metric__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cost-hero-metric__label {
    font-size: 0.74rem;
    color: var(--mud-palette-text-secondary);
}

.cost-hero-metric__value {
    font-size: 1.15rem;
    font-weight: 800;
}

.cost-hero-metric__hint {
    font-size: 0.72rem;
    color: var(--mud-palette-text-secondary);
}

.cost-hero-metric__badge {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    width: fit-content;
}

.cost-hero-metric__ring {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: conic-gradient(#7e57c2 calc(var(--ring-pct, 0) * 1%), rgba(126, 87, 194, 0.15) 0);
    position: relative;
}

.cost-hero-metric__ring::before {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: var(--mud-palette-surface, #fff);
}

.cost-hero-metric__ring-pct {
    position: relative;
    z-index: 1;
    font-size: 0.68rem;
    font-weight: 800;
    color: #7e57c2;
}

/* KPI icons */
.cost-dash-kpi--icon .cost-dash-kpi__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.cost-dash-kpi__icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cost-dash-kpi__icon--primary {
    background: rgba(21, 101, 192, 0.12);
    color: #1565c0;
}

.cost-dash-kpi__icon--ok {
    background: rgba(67, 160, 71, 0.12);
    color: #2e7d32;
}

.cost-dash-kpi__icon--warn {
    background: rgba(245, 124, 0, 0.14);
    color: #ef6c00;
}

/* کارت‌های دسترسی سریع */
.cost-nav-card {
    border-radius: 11px;
    padding: 12px 14px !important;
    cursor: pointer;
    text-decoration: none !important;
    border: 1px solid color-mix(in srgb, var(--cost-accent) 12%, transparent);
    transition: all 0.15s ease;
    height: 100%;
    display: block;
}

.cost-nav-card:hover {
    border-color: var(--cost-accent);
    background: color-mix(in srgb, var(--cost-accent) 6%, var(--cost-surface));
    transform: translateY(-2px);
}

.cost-nav-card__icon {
    margin-bottom: 5px;
}

.cost-nav-card__title {
    font-weight: 600;
    font-size: 0.9rem;
}

.cost-nav-card__desc {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    margin-top: 4px;
}

.cost-dashboard-alert {
    border-radius: 11px !important;
    margin-bottom: 12px;
}

.cost-health-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 10px;
}

@media (min-width: 960px) {
    .cost-health-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.cost-health-card {
    border-radius: 12px;
    padding: 12px 14px !important;
    border: 1px solid color-mix(in srgb, var(--cost-accent) 16%, transparent);
    background: var(--cost-surface);
    cursor: default;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.cost-health-card:has(.cost-health-card__action) {
    cursor: pointer;
}

.cost-health-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--cost-accent) 10%, transparent);
}

.cost-health-card--success {
    border-color: color-mix(in srgb, #43a047 38%, transparent);
    background: linear-gradient(160deg, color-mix(in srgb, #e8f5e9 74%, var(--cost-surface)), var(--cost-surface));
}

.cost-health-card--warning {
    border-color: color-mix(in srgb, #f57c00 42%, transparent);
    background: linear-gradient(160deg, color-mix(in srgb, #fff3e0 78%, var(--cost-surface)), var(--cost-surface));
}

.cost-health-card--error {
    border-color: color-mix(in srgb, #d32f2f 42%, transparent);
    background: linear-gradient(160deg, color-mix(in srgb, #ffebee 78%, var(--cost-surface)), var(--cost-surface));
}

.cost-health-card--info {
    border-color: color-mix(in srgb, #0288d1 36%, transparent);
    background: linear-gradient(160deg, color-mix(in srgb, #e1f5fe 74%, var(--cost-surface)), var(--cost-surface));
}

.cost-health-card__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.cost-health-card__title {
    font-weight: 700;
}

.cost-health-card__message {
    color: var(--mud-palette-text-secondary);
    font-size: 0.82rem;
    line-height: 1.85;
}

.cost-health-card__action {
    display: inline-flex;
    margin-top: 8px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--cost-accent-dark);
    background: color-mix(in srgb, var(--cost-accent) 10%, transparent);
}

.cost-dash-status-paper {
    border-radius: 11px;
    border: 1px solid color-mix(in srgb, var(--cost-accent) 16%, transparent);
}

.cost-dash-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
}

@media (min-width: 600px) {
    .cost-dash-stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 960px) {
    .cost-dash-stats-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

.cost-dash-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 52px;
    padding: 8px 10px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--cost-accent) 4%, var(--cost-surface, #fff));
    border: 1px solid color-mix(in srgb, var(--cost-accent) 10%, transparent);
}

.cost-dash-stat--accent {
    background: linear-gradient(160deg, rgba(227, 242, 253, 0.95), rgba(255, 255, 255, 0.9));
    border-color: rgba(21, 101, 192, 0.28);
}

.cost-dash-stat--accent-green {
    background: linear-gradient(160deg, rgba(232, 245, 233, 0.95), rgba(255, 255, 255, 0.9));
    border-color: rgba(46, 125, 50, 0.28);
}

.cost-dash-stat--info {
    background: linear-gradient(160deg, rgba(225, 245, 254, 0.95), rgba(255, 255, 255, 0.9));
    border-color: rgba(2, 136, 209, 0.25);
}

.cost-dash-stat--success {
    background: linear-gradient(160deg, rgba(232, 245, 233, 0.85), rgba(255, 255, 255, 0.9));
    border-color: rgba(67, 160, 71, 0.22);
}

.cost-dash-stat--money {
    background: linear-gradient(160deg, rgba(255, 243, 224, 0.9), rgba(255, 255, 255, 0.9));
    border-color: rgba(239, 108, 0, 0.22);
}

.cost-dash-stat--money .cost-dash-stat__value {
    color: #e65100;
}

.cost-dash-stat--muted {
    background: rgba(236, 239, 241, 0.6);
    border-color: rgba(120, 144, 156, 0.2);
}

.cost-dash-stat--accent .cost-dash-stat__value {
    color: #1565c0;
}

.cost-dash-stat--accent-green .cost-dash-stat__value {
    color: #2e7d32;
}

.cost-dash-stat--info .cost-dash-stat__value {
    color: #0277bd;
}

.cost-dash-stat--success .cost-dash-stat__value {
    color: #388e3c;
}

.cost-dash-stat__label {
    font-size: 0.72rem;
    color: var(--mud-palette-text-secondary);
}

.cost-dash-stat__value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    direction: ltr;
    unicode-bidi: plaintext;
    display: inline-block;
}

.cost-dash-stat__value--sm {
    font-size: 0.78rem;
    font-weight: 600;
    direction: rtl;
    unicode-bidi: normal;
}

.cost-breakdown-chart {
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--cost-accent) 14%, transparent);
    height: 100%;
    box-shadow: 0 4px 18px rgba(21, 101, 192, 0.07);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.cost-breakdown-chart:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(21, 101, 192, 0.12);
}

.cost-breakdown-chart--egg {
    border-color: rgba(21, 101, 192, 0.28);
    background: linear-gradient(165deg, rgba(227, 242, 253, 0.55), var(--mud-palette-surface, #fff));
}

.cost-breakdown-chart--chick {
    border-color: rgba(46, 125, 50, 0.28);
    background: linear-gradient(165deg, rgba(232, 245, 233, 0.55), var(--mud-palette-surface, #fff));
}

.cost-breakdown-chart__title {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cost-breakdown-chart__wrap {
    position: relative;
}

.cost-breakdown-chart__center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cost-breakdown-chart__center-label {
    font-size: 0.72rem;
    color: var(--mud-palette-text-secondary);
}

.cost-breakdown-chart__center-value {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--mud-palette-text-primary);
}

.cost-breakdown-legend {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cost-breakdown-legend__row {
    display: grid;
    grid-template-columns: 14px 1fr auto auto;
    gap: 8px;
    align-items: center;
    font-size: 0.82rem;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.cost-breakdown-legend__swatch {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.cost-breakdown-legend__label {
    text-align: right;
}

.cost-breakdown-legend__amount {
    font-weight: 600;
    white-space: nowrap;
}

.cost-breakdown-legend__pct {
    color: var(--mud-palette-text-secondary);
    min-width: 3.5rem;
    text-align: left;
    direction: ltr;
}

.cost-dashboard-sync {
    min-width: 160px;
}

/* جداول ثبت */
.cost-entry-paper {
    border-radius: 11px;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--cost-accent) 15%, transparent);
}

.cost-entry-toolbar {
    padding: 10px 14px;
    background: color-mix(in srgb, var(--cost-accent) 5%, var(--cost-surface));
    border-bottom: 1px solid color-mix(in srgb, var(--cost-accent) 12%, transparent);
}

.cost-entry-table.mud-table .mud-table-head .mud-table-cell,
.cost-entry-table.mud-table thead .mud-th {
    padding: 9px 11px !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    text-align: center !important;
    background: linear-gradient(135deg, var(--cost-accent), var(--cost-accent-dark)) !important;
    color: #fff !important;
    white-space: nowrap;
}

.cost-entry-table.mud-table .mud-table-body .mud-table-cell,
.cost-entry-table.mud-table tbody .mud-td {
    padding: 8px 11px !important;
    font-size: 0.82rem !important;
    text-align: center !important;
    vertical-align: middle !important;
    border-bottom: 1px solid color-mix(in srgb, var(--cost-accent) 8%, transparent) !important;
}

.cost-entry-table.mud-table .mud-table-body .mud-table-row:nth-child(even) .mud-table-cell {
    background: color-mix(in srgb, var(--cost-accent) 4%, var(--cost-surface));
}

.cost-entry-table.mud-table .mud-table-body .mud-table-row:hover .mud-table-cell {
    background: color-mix(in srgb, var(--cost-accent) 8%, var(--cost-surface)) !important;
}

.cost-entry-table .cost-td-money {
    background: #fff8e1 !important;
}

.cost-entry-table .cost-td-money .cost-num {
    color: #e65100;
    font-weight: 700;
}

.cost-entry-table .cost-td-text {
    text-align: right !important;
    min-width: 160px;
}

.cost-num {
    display: inline-block;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.05em;
    font-weight: 600;
    direction: ltr;
    unicode-bidi: plaintext;
    padding: 2px 6px;
}

/* فیلد مبلغ */
.cost-money-field .mud-input-root {
    font-size: 0.98rem !important;
    font-weight: 600 !important;
}

.cost-money-field .mud-input-root input {
    text-align: left !important;
    direction: ltr !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

.cost-money-field .mud-input-slot {
    min-height: 44px !important;
}

.cost-money-field--inline .mud-input-slot {
    min-height: 38px !important;
}

.cost-money-field--inline .mud-input-label {
    display: none !important;
}

/* دیالوگ ثبت */
.cost-form-dialog .mud-dialog-content {
    padding: 14px 18px !important;
}

.cost-form-dialog .mud-input-slot {
    min-height: 42px !important;
}

.cost-form-dialog .cost-form-total {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
    border: 1px solid #81c784;
    text-align: center;
    font-weight: 700;
    font-size: 1.05rem;
}

.cost-form-dialog .mud-grid {
    row-gap: 8px !important;
}

.cost-form-dialog .cost-form-total .cost-num {
    color: #2e7d32;
    font-size: 1.15rem;
}

.cost-form-dialog.dialog-rtl .mud-dialog-actions {
    flex-direction: row-reverse;
    justify-content: flex-start;
    padding: 8px 16px 12px !important;
}

.cost-form-dialog .cost-form-info {
    border-radius: 10px;
    background: #e3f2fd;
    border: 1px solid #90caf9;
}

.cost-col-action {
    width: 52px;
    text-align: center;
}

.cost-dash-kpi--accent {
    background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
    border: 1px solid #a5d6a7;
}

.cost-info-alert {
    border-radius: 10px !important;
}

.cost-entry-total {
    margin: 10px 12px 4px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    text-align: center;
}

.cost-manual-price-panel {
    margin: 10px 12px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #ffb74d;
    background: #fff8e1;
}

.cost-empty-state {
    margin: 12px;
    padding: 22px 16px;
    border-radius: 12px;
    text-align: center;
    border: 1px dashed color-mix(in srgb, var(--cost-accent) 25%, transparent);
    background: color-mix(in srgb, var(--cost-accent) 4%, var(--cost-surface));
}

.cost-empty-state .mud-icon-root {
    margin-bottom: 6px;
    opacity: 0.75;
}

.cost-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 960px) {
    .cost-page {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }

    .cost-page .cost-header-paper {
        padding: 12px !important;
    }
}

[data-theme="dark"] .cost-hero-metric {
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.22), rgba(15, 23, 42, 0.88));
    border-color: rgba(147, 197, 253, 0.22);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .cost-hero-metric__ring::before {
    background: rgba(15, 23, 42, 0.95);
}

[data-theme="dark"] .cost-breakdown-chart--egg,
[data-theme="dark"] .cost-breakdown-chart--chick {
    background: linear-gradient(165deg, rgba(30, 41, 59, 0.72), rgba(15, 23, 42, 0.88));
}

[data-theme="dark"] .cost-breakdown-legend__row {
    background: rgba(30, 41, 59, 0.55);
    border-color: rgba(148, 163, 184, 0.15);
}

[data-theme="dark"] .cost-dash-stat--accent,
[data-theme="dark"] .cost-dash-stat--accent-green,
[data-theme="dark"] .cost-dash-stat--info,
[data-theme="dark"] .cost-dash-stat--success,
[data-theme="dark"] .cost-dash-stat--money {
    background: rgba(30, 41, 59, 0.65);
}

