/* App — Cards, Tables, Filters, Modals, Alerts */
.filter-bar {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.filter-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-bar label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.filter-bar .form-select,
.filter-bar .form-control {
    font-size: 0.875rem;
    min-width: 140px;
}

.content-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.content-card .card-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.9375rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-card .card-body {
    padding: 1.25rem;
}

/* KPI Cards */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.kpi-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--primary);
}

.kpi-card .kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kpi-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    margin: 0.25rem 0;
}

.kpi-card .kpi-sub {
    font-size: 0.8125rem;
    color: #94a3b8;
}

.kpi-card.status-success .kpi-value { color: var(--success); }
.kpi-card.status-warning .kpi-value { color: var(--warning); }
.kpi-card.status-danger .kpi-value { color: var(--danger); }
.kpi-card.status-critical .kpi-value { color: var(--critical); }

/* Tables */
.data-table {
    width: 100%;
    font-size: 0.875rem;
}

.data-table thead th {
    background: #f1f5f9;
    font-weight: 600;
    color: #475569;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.65rem 0.75rem;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table tbody tr.clickable {
    cursor: pointer;
}

.data-table .text-end {
    text-align: right;
}

/* Status badges */
.badge-status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.badge-normal { background: #dcfce7; color: #166534; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-attention { background: #fef3c7; color: #92400e; }
.badge-critical { background: #fee2e2; color: #991b1b; }
.badge-p1 { background: #991b1b; color: #fff; }
.badge-p2 { background: #dc2626; color: #fff; }
.badge-p3 { background: #d97706; color: #fff; }
.badge-p4 { background: #2563eb; color: #fff; }

/* Matrix table (Excel-style) */
.norm-matrix-table {
    font-size: 0.8125rem;
}

.norm-matrix-table th,
.norm-matrix-table td {
    text-align: center;
    min-width: 90px;
}

.norm-matrix-table th:first-child,
.norm-matrix-table td:first-child {
    text-align: left;
    font-weight: 600;
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 1;
}

.norm-matrix-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Drawer */
.offcanvas-drawer .offcanvas-body {
    padding: 0;
}

.drawer-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
}

.drawer-detail-row .label {
    color: #64748b;
}

/* Chart containers */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

.chart-container-sm {
    height: 200px;
}

/* Drill-down breadcrumb trail */
.drill-trail {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.drill-trail .drill-item {
    cursor: pointer;
    color: var(--primary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: #eff6ff;
}

.drill-trail .drill-item:hover {
    background: #dbeafe;
}

.drill-trail .drill-sep {
    color: #94a3b8;
}

/* Action bar */
.action-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

/* Print styles */
@media print {
    .app-sidebar, .app-header, .filter-bar, .action-bar, .sidebar-toggle {
        display: none !important;
    }
    .app-main {
        margin: 0;
        padding: 0;
    }
    .content-card {
        break-inside: avoid;
        border: 1px solid #ccc;
    }
}
