.dashboard-ux {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.07);
}

.dashboard-ux .summary-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1rem;
}

@media (min-width: 768px) {
    .dashboard-ux .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .dashboard-ux .summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1536px) {
    .dashboard-ux .summary-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.dashboard-ux .summary-heading {
    grid-column: 1 / -1;
    margin: 0;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 1.18rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: 0.01em;
}

.dashboard-ux .summary-heading.second {
    margin-top: 0.35rem;
}

.dashboard-ux .summary-item {
    width: 100%;
    max-width: none;
}

.zone-dashboard {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.07);
}

.zone-dashboard .zone-section + .zone-section {
    margin-top: 2rem;
}

.zone-dashboard .summary-heading.second {
    margin-top: 0;
}

.zone-dashboard .zone-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

@media (min-width: 768px) {
    .zone-dashboard .zone-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .zone-dashboard .zone-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1536px) {
    .zone-dashboard .zone-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.zone-dashboard .zone-item {
    min-width: 0;
}

.dashboard-ux .metric-card {
    height: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 0.9rem;
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dashboard-ux .metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 24px rgba(15, 23, 42, 0.12);
}

.dashboard-ux .metric-body {
    padding: 1rem 1rem 0.95rem;
}

.dashboard-ux .metric-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.dashboard-ux .metric-value {
    margin: 0;
    font-size: 1.6rem;
    line-height: 1.2;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.02em;
}

.dashboard-ux .metric-label {
    margin: 0.35rem 0 0;
    font-size: 0.92rem;
    line-height: 1.32;
    font-weight: 500;
    color: #64748b;
}

.dashboard-ux .metric-icon {
    width: 2.3rem;
    height: 2.3rem;
    min-width: 2.3rem;
    border-radius: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    color: #3730a3;
    font-size: 0.95rem;
}

/* Solid FA icons need the icon font; avoids blank glyphs if `i` inherits body font */
.dashboard-ux .metric-icon .fa-solid,
.dashboard-ux .metric-icon .fas {
    font-family: "Font Awesome 6 Free", sans-serif !important;
    font-weight: 900 !important;
}

/* Monthly Comparison Styles */
.monthly-comparison-panel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

.monthly-header-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid #e2e8f0;
}

.monthly-title-group h4 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.monthly-period-badges {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.badge-period {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.badge-current {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-previous {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.monthly-filter-wrap {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.55rem;
    padding: 0.3rem 0.55rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.monthly-filter-wrap .filter-month-group {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.monthly-filter-wrap .filter-month-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #475569;
    margin: 0;
    white-space: nowrap;
}

.monthly-filter-wrap .filter-month-input {
    font-size: 0.82rem;
    font-weight: 600;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-radius: 0.4rem;
    padding: 0.28rem 0.5rem;
    background-color: #f8fafc;
    height: auto;
    width: auto;
    min-width: 135px;
    cursor: pointer;
}

.monthly-filter-wrap .filter-month-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
    background-color: #ffffff;
}

.monthly-filter-wrap .filter-select {
    font-size: 0.83rem;
    font-weight: 600;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-radius: 0.4rem;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    background-color: #f8fafc;
    height: auto;
}

.monthly-filter-wrap .filter-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
    background-color: #ffffff;
}

.monthly-filter-wrap .btn-filter-submit {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.32rem 0.75rem;
    border-radius: 0.4rem;
}

.monthly-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1rem;
}

@media (min-width: 640px) {
    .monthly-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .monthly-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1400px) {
    .monthly-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.monthly-card {
    height: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 0.9rem;
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.monthly-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.09);
    border-color: #cbd5e1;
}

.monthly-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem 0.65rem;
    border-bottom: 1px solid #f1f5f9;
    background: #fbfcfe;
}

.monthly-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.monthly-card-icon {
    width: 2.1rem;
    height: 2.1rem;
    min-width: 2.1rem;
    border-radius: 0.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    color: #3730a3;
    font-size: 0.88rem;
}

.monthly-card-body {
    padding: 0.85rem 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.monthly-values-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    margin-bottom: 0.75rem;
}

.monthly-val-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    padding: 0.55rem 0.7rem;
}

.monthly-val-box.current-month {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.monthly-val-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.monthly-val-box.current-month .monthly-val-label {
    color: #166534;
}

.monthly-val-number {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.25;
    word-break: break-word;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.monthly-val-box.current-month .monthly-val-number {
    color: #15803d;
}

.monthly-agg-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9.5px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.04em;
    padding: 2px 5px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    background: #f1f5f9;
    color: #64748b;
    vertical-align: middle;
    text-transform: uppercase;
    user-select: none;
}

.monthly-val-box.current-month .monthly-agg-badge {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #166534;
}

.monthly-diff-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.65rem;
    border-top: 1px dashed #e2e8f0;
    font-size: 0.82rem;
    gap: 0.5rem;
}

.monthly-diff-label {
    font-weight: 600;
    color: #64748b;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.monthly-diff-badge-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.monthly-diff-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.22rem 0.55rem;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.76rem;
}

.diff-positive {
    background-color: #dcfce7;
    color: #15803d;
}

.diff-negative {
    background-color: #fee2e2;
    color: #b91c1c;
}

.diff-neutral {
    background-color: #f1f5f9;
    color: #64748b;
}

/* Machine Production & Wastage Tables Section */
.machine-tables-section {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
    margin-bottom: 2rem;
    overflow: hidden;
}

.machine-tables-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
    border-bottom: 1px solid #e2e8f0;
}

.machine-tables-title h5 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.machine-tables-title p {
    font-size: 0.82rem;
    color: #64748b;
    margin: 0.25rem 0 0 0;
}

.machine-tables-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.machine-subcard {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.machine-subcard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.15rem;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.machine-subcard-header.twisted {
    background: #eff6ff;
    color: #1d4ed8;
    border-bottom: 1px solid #bfdbfe;
}

.machine-subcard-header.braided {
    background: #f0fdf4;
    color: #15803d;
    border-bottom: 1px solid #bbf7d0;
}

.machine-data-table {
    font-size: 0.82rem;
    margin-bottom: 0;
}

.machine-data-table thead th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.6rem 0.65rem;
    white-space: nowrap;
    border-bottom: 2px solid #e2e8f0;
}

.machine-data-table tbody td {
    padding: 0.55rem 0.65rem;
    color: #334155;
    vertical-align: middle;
    white-space: nowrap;
}

.machine-data-table tbody tr:hover {
    background-color: #f8fafc;
}

.machine-data-table tfoot th {
    background: #f1f5f9;
    color: #1e293b;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 0.65rem;
    white-space: nowrap;
    border-top: 2px solid #cbd5e1;
}

.table-batch-badge {
    font-weight: 700;
    color: #0f172a;
    background: #e2e8f0;
    padding: 0.18rem 0.45rem;
    border-radius: 4px;
    font-size: 0.78rem;
}

.table-batch-subtotal {
    border-top: 1px solid #cbd5e1;
    border-bottom: 2px solid #cbd5e1;
}

.table-batch-subtotal td {
    font-weight: 700 !important;
    color: #0f172a !important;
    background-color: #f8fafc !important;
    padding: 0.55rem 0.65rem !important;
}

/* Table Month Headers & Cells matching top period badges */
.machine-data-table thead th.th-this-month {
    background-color: #dcfce7 !important;
    color: #166534 !important;
    border-color: #bbf7d0 !important;
    font-weight: 700;
    white-space: nowrap;
}

.machine-data-table thead th.th-last-month {
    background-color: #f1f5f9 !important;
    color: #334155 !important;
    border-color: #cbd5e1 !important;
    font-weight: 700;
    white-space: nowrap;
}

.machine-data-table tbody td.td-this-month {
    color: #166534 !important;
    background-color: rgba(220, 252, 231, 0.22) !important;
}

.machine-data-table tbody td.td-last-month {
    color: #334155 !important;
    background-color: rgba(241, 245, 249, 0.35) !important;
}

.machine-data-table tbody tr:hover td.td-this-month {
    background-color: rgba(220, 252, 231, 0.38) !important;
}

.machine-data-table tbody tr:hover td.td-last-month {
    background-color: rgba(241, 245, 249, 0.6) !important;
}

.machine-data-table tr.table-batch-subtotal td.subtotal-this-month {
    color: #166534 !important;
    background-color: #dcfce7 !important;
}

.machine-data-table tr.table-batch-subtotal td.subtotal-last-month {
    color: #334155 !important;
    background-color: #e2e8f0 !important;
}

.machine-data-table tfoot th.tfoot-this-month {
    background-color: #dcfce7 !important;
    color: #166534 !important;
    border-color: #bbf7d0 !important;
}

.machine-data-table tfoot th.tfoot-last-month {
    background-color: #e2e8f0 !important;
    color: #334155 !important;
    border-color: #cbd5e1 !important;
}

