/* ========================================
   BILAIN ANALYTICS — Modern Dashboard CSS
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --sidebar-bg: #0f172a;
    --sidebar-width: 260px;
    --header-height: 64px;
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --pink: #ec4899;
    --bg-body: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 16px;
    --radius-sm: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    color-scheme: light;
}

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-body) !important;
    color: var(--text-main);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ========================================
   LAYOUT
   ======================================== */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-close-btn {
    display: none;
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.12);
    border: none;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    padding: 0;
}
.sidebar-close-btn:hover { background: rgba(255,255,255,0.22); }

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
}

.sidebar-brand .logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.sidebar-brand .logo-text {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.3px;
}

.sidebar-brand .logo-sub {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    font-weight: 500;
    margin-top: -2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.35);
    padding: 12px 16px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
}

.nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.nav-link.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-light);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 15px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius-sm);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
}

.user-info {
    flex: 1;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.user-role {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Header */
.top-header {
    height: var(--header-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.3px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.header-period-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-period-form label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.header-period-form input[type="date"] {
    width: 136px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 10px;
    font: inherit;
    font-size: 13px;
    color: var(--text-main);
    background: #fff;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-body);
    color: var(--text-main);
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 28px;
}

/* ========================================
   CARDS
   ======================================== */

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.card-body {
    padding: 24px;
}

/* Metric Cards */
.metric-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    text-align: center;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--purple));
}

.metric-card.success::before {
    background: linear-gradient(90deg, var(--success), #34d399);
}

.metric-card.warning::before {
    background: linear-gradient(90deg, var(--warning), #fbbf24);
}

.metric-card.danger::before {
    background: linear-gradient(90deg, var(--danger), #f87171);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}

.metric-icon.blue {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.metric-icon.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.metric-icon.orange {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.metric-icon.red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.metric-icon.purple {
    background: rgba(139, 92, 246, 0.1);
    color: var(--purple);
}

.metric-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.metric-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
    line-height: 1;
}

.metric-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.metric-group {
    display: grid;
    gap: 10px;
    width: 100%;
    min-width: 0;
}

.metric-group-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-group-item {
    min-width: 0;
}

/* Manager Cards */
.manager-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.manager-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.manager-avatar {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    margin-bottom: 14px;
}

.manager-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.manager-dept {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.manager-stats {
    display: flex;
    gap: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.manager-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.manager-stat i {
    font-size: 12px;
}

/* ========================================
   TABLES
   ======================================== */

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 14px 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 14px 20px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

.data-table tr:hover td {
    background: #f8fafc;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* ========================================
   BADGES
   ======================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.badge-blue {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

/* ========================================
   ALERTS
   ======================================== */

.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #047857;
}

.alert-error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #b91c1c;
}

/* ========================================
   TRANSCRIPT MODAL
   ======================================== */

body.modal-open {
    overflow: hidden;
}

.transcript-modal[hidden] {
    display: none;
}

.transcript-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.transcript-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.54);
    backdrop-filter: blur(4px);
}

.transcript-modal__dialog {
    position: relative;
    width: min(860px, 100%);
    max-height: min(760px, calc(100vh - 48px));
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.transcript-modal__header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.transcript-modal__header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text-main);
}

.transcript-modal__header p {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

.transcript-modal__body {
    padding: 18px 22px 22px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

.transcript-block {
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.transcript-speaker {
    margin-bottom: 6px;
    color: var(--primary);
    font-weight: 700;
    font-size: 13px;
}

.transcript-block p {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--text-main);
}

.transcript-empty {
    padding: 28px;
    color: var(--text-muted);
    text-align: center;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: #fff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: var(--bg-body);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

/* ========================================
   CHARTS
   ======================================== */

.chart-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.chart-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-container {
    position: relative;
    height: 300px;
}

.chart-container-tall {
    height: 450px;
}

.chart-list-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.legend-row {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-main);
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

.legend-label {
    min-width: 0;
    overflow-wrap: anywhere;
}

.legend-value {
    color: var(--text-muted);
    font-weight: 700;
}

.legend-empty,
.muted-code {
    color: var(--text-muted);
    font-size: 12px;
}

.rejection-reasons-table {
    table-layout: fixed;
}

.rejection-reasons-table th:nth-child(1),
.rejection-reasons-table td:nth-child(1) {
    width: 180px;
}

.rejection-reasons-table th:nth-child(2),
.rejection-reasons-table td:nth-child(2) {
    width: auto;
}

.rejection-reasons-table th:nth-child(3),
.rejection-reasons-table td:nth-child(3) {
    width: 210px;
}

.rejection-reasons-table th:nth-child(4),
.rejection-reasons-table td:nth-child(4) {
    width: 110px;
}

.reason-type-badge {
    max-width: 100%;
    white-space: normal;
    line-height: 1.2;
    border-radius: 12px;
}

.reason-text-cell {
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.reason-manager-cell,
.reason-date-cell {
    overflow-wrap: normal;
    word-break: normal;
}

.reason-date-cell {
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
}

/* ========================================
   LOGIN
   ======================================== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    margin-bottom: 16px;
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-main);
}

.login-logo p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    background: #fff;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ========================================
   MOBILE MENU (Hamburger)
   ======================================== */

.mobile-menu-btn {
    display: none;
    width: 44px;
    height: 44px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: #fff;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
    backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
    display: block;
}

/* ========================================
   TABLE RESPONSIVE WRAPPER
   ======================================== */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table-responsive .data-table {
    min-width: 600px;
}

/* Managers grid */
.managers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

/* Filter form */
.filters-form {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.filters-form .form-group {
    margin-bottom: 0;
}

.filters-form .form-input,
.filters-form select.form-input {
    width: auto;
    min-width: 140px;
}

/* Messages container */
.messages-container {
    padding: 0 28px;
    margin-top: 20px;
}

/* Chart canvas fix */
.chart-container canvas {
    max-width: 100%;
}

/* Form grids */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* Calendar */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-day {
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
    padding: 10px;
}

.calendar-cell {
    min-height: 90px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1024px) {
    .mobile-menu-btn {
        display: flex;
    }
    .sidebar-close-btn {
        display: flex;
    }
    .sidebar {
        transform: translateX(-100%);
        width: 85%;
        max-width: 320px;
        box-shadow: 10px 0 40px rgba(0,0,0,0.3);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar.open + .sidebar-overlay,
    .sidebar-overlay.active {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .top-header {
        padding: 0 16px;
        height: 56px;
    }
    .page-title {
        font-size: 16px;
    }
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }
    .grid-3 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }
    .chart-container {
        height: 250px;
    }
}

@media (max-width: 640px) {
    html, body {
        background: var(--bg-body) !important;
        color-scheme: light !important;
    }
    .mobile-menu-btn {
        display: flex;
        width: 44px;
        height: 44px;
    }
    .sidebar {
        width: 85vw;
        min-width: 280px;
    }
    .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
    .grid-3, .grid-2 {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
    .content-area {
        padding: 12px;
    }
    .top-header {
        height: auto;
        min-height: 56px;
        padding: 8px 12px;
        align-items: flex-start;
        gap: 8px;
        flex-wrap: wrap;
    }
    .top-header > div:first-child {
        min-height: 44px;
    }
    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }
    .header-period-form {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr 40px 40px;
        gap: 8px;
    }
    .header-period-form label {
        display: block;
        font-size: 11px;
    }
    .header-period-form label span {
        display: block;
        margin-bottom: 4px;
    }
    .header-period-form input[type="date"] {
        width: 100%;
        height: 40px;
        font-size: 13px;
        padding: 0 8px;
    }
    .header-period-form .btn-icon {
        align-self: end;
        width: 40px;
        height: 40px;
    }
    .metric-card {
        padding: 18px;
        min-height: 104px;
        text-align: left;
    }
    .metric-card > div[style*="grid-template-columns"] {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
    .metric-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
        margin-bottom: 12px;
    }
    .metric-value {
        font-size: 26px;
    }
    .metric-label {
        font-size: 12px;
        line-height: 1.25;
    }
    .card-header {
        padding: 16px 18px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .card-body {
        padding: 16px;
    }
    .table-responsive {
        overflow: visible;
    }
    .table-responsive .data-table {
        min-width: 0;
    }
    .data-table thead {
        display: none;
    }
    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block !important;
        width: 100%;
    }
    .data-table tr {
        padding: 12px;
        border-bottom: 1px solid var(--border);
        background: #fff;
    }
    .data-table td {
        display: flex !important;
        justify-content: space-between;
        gap: 14px;
        padding: 8px 0;
        border-bottom: 0;
        font-size: 13px;
        text-align: right;
    }
    .data-table td::before {
        content: attr(data-label);
        flex: 0 0 42%;
        color: var(--text-muted);
        font-weight: 600;
        text-align: left;
        text-transform: none;
    }
    .data-table td[colspan] {
        text-align: center;
        display: block;
    }
    .data-table td[colspan]::before {
        content: none;
    }
    .chart-container {
        height: 240px;
    }
    .chart-container-tall {
        height: 320px;
    }
    .login-card {
        padding: 28px 20px;
        margin: 16px;
    }
    .manager-card {
        padding: 16px;
    }
    .manager-avatar {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    .manager-name {
        font-size: 16px;
    }
    .manager-stats {
        flex-wrap: wrap;
        gap: 10px;
    }
    .form-group {
        margin-bottom: 16px;
    }
    .form-input, .form-label {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    .btn {
        font-size: 16px;
        padding: 12px 20px;
    }
    .badge {
        font-size: 13px;
        padding: 5px 12px;
    }
    .top-header .badge {
        display: none;
    }
    /* Filters mobile */
    .filters-form {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    .filters-form .form-group {
        width: 100% !important;
        margin-bottom: 0;
    }
    .filters-form .form-input,
    .filters-form select.form-input {
        width: 100% !important;
    }
    /* Managers grid mobile */
    .managers-grid {
        grid-template-columns: 1fr !important;
    }
    /* Messages mobile */
    .messages-container {
        padding: 0 12px;
        margin-top: 12px;
    }
    /* Audio player mobile */
    audio {
        max-width: 150px;
        height: 28px;
    }
    /* Error cards */
    .manager-dashboard .grid-2 > .card {
        min-width: 0;
    }
    /* Form grids mobile */
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
    /* Calendar mobile */
    .calendar-grid {
        gap: 4px;
    }
    .calendar-day {
        padding: 6px 2px;
        font-size: 12px;
    }
    .calendar-cell {
        min-height: 60px;
        padding: 4px;
        font-size: 12px;
    }
}

/* Grid helpers */
.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 640px) {
    .content-area {
        padding: 12px !important;
    }

    .table-responsive {
        overflow: visible !important;
    }

    .table-responsive .data-table {
        min-width: 0 !important;
    }

    .data-table thead {
        display: none !important;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block !important;
        width: 100% !important;
    }

    .data-table tr {
        padding: 12px !important;
        border-bottom: 1px solid var(--border) !important;
        background: #fff !important;
    }

    .data-table td {
        display: flex !important;
        justify-content: space-between;
        gap: 14px;
        padding: 8px 0 !important;
        border-bottom: 0 !important;
        text-align: right;
    }

    .data-table td::before {
        content: attr(data-label);
        flex: 0 0 42%;
        color: var(--text-muted);
        font-weight: 600;
        text-align: left;
    }

    .data-table td[colspan] {
        display: block !important;
        text-align: center;
    }

    .data-table td[colspan]::before {
        content: none;
    }
}

/* ========================================
   LAYOUT GUARDRAILS
   Keep dashboard stable across all viewport widths.
   ======================================== */

.app-wrapper,
.main-content,
.content-area,
.card,
.card-body,
.chart-box,
.metric-card,
.manager-card,
.data-table,
.table-responsive,
.top-header,
.header-actions,
.header-period-form,
.grid-2,
.grid-3,
.grid-4,
.managers-grid {
    min-width: 0;
}

img,
svg,
canvas,
video,
audio {
    max-width: 100%;
}

.top-header {
    min-height: var(--header-height);
    height: auto;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title,
.card-title,
.metric-label,
.metric-sub,
.manager-name,
.manager-dept,
.nav-link span,
.legend-label,
.data-table td,
.data-table th {
    overflow-wrap: anywhere;
}

.header-actions {
    flex: 0 1 auto;
    min-width: min(100%, 360px);
    justify-content: flex-end;
}

.header-period-form {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
}

.header-period-form label {
    min-width: 0;
}

.header-period-form input[type="date"] {
    max-width: 100%;
}

.content-area {
    width: 100%;
    max-width: 100%;
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}

.metric-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 190px;
}

.metric-card > * {
    max-width: 100%;
}

.metric-icon {
    flex: 0 0 auto;
}

.metric-label {
    line-height: 1.25;
    min-height: 16px;
}

.metric-value {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.metric-group {
    align-items: start;
}

.metric-group-item {
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 4px;
}

.metric-group-item .metric-label {
    min-height: 32px;
    display: flex;
    align-items: end;
    justify-content: center;
    text-align: center;
}

.manager-card {
    min-height: 182px;
}

.manager-stats {
    min-width: 0;
}

.manager-stat {
    min-width: 0;
    white-space: nowrap;
}

.table-responsive {
    max-width: 100%;
}

@media (max-width: 1180px) and (min-width: 1025px) {
    .top-header {
        padding: 14px 24px;
    }

    .header-actions {
        width: 100%;
    }
}

@media (max-width: 760px) {
    .header-title-group {
        width: 100%;
    }

    .header-actions {
        width: 100%;
        min-width: 0;
    }

    .header-period-form {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px 40px;
        gap: 8px;
    }
}

@media (max-width: 420px) {
    .header-period-form {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .header-period-form .btn-icon {
        width: 100%;
    }

    .metric-group-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .metric-group-item .metric-label {
        font-size: 11px;
    }

    .metric-group-item .metric-value {
        font-size: 24px;
    }
}

.rejection-reasons-table .reason-type-cell,
.rejection-reasons-table .reason-manager-cell,
.rejection-reasons-table .reason-date-cell,
.rejection-reasons-table .reason-type-badge {
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}

.rejection-reasons-table .reason-manager-cell {
    white-space: normal;
}

.rejection-reasons-table .reason-type-badge {
    display: inline-flex;
    width: auto;
    max-width: 150px;
    justify-content: center;
    text-align: center;
}

.rejection-reasons-table .reason-text-cell {
    overflow-wrap: break-word;
    word-break: normal;
}

/* Department Tabs */
.dept-tabs {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
    width: 100%;
}

.dept-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 24px;
    font-size: 18px;
    font-weight: 700;
    color: #475569;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 14px;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}

.dept-tab:hover {
    color: #1e293b;
    border-color: #cbd5e1;
    box-shadow: 0 4px 16px -2px rgb(0 0 0 / 0.08);
    transform: translateY(-1px);
}

.dept-tab.active {
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-color: transparent;
    box-shadow: 0 8px 24px -4px rgba(59, 130, 246, 0.3);
}

.dept-tab i {
    font-size: 20px;
    opacity: 0.8;
}

.dept-tab.active i {
    opacity: 1;
}

.dept-tab .dept-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    font-size: 14px;
    font-weight: 700;
    color: #64748b;
    background: #f1f5f9;
    border-radius: 16px;
    transition: all 0.2s ease;
}

.dept-tab.active .dept-count {
    color: #4f46e5;
    background: rgba(255, 255, 255, 0.95);
}

.dept-panel {
    display: none;
}

.dept-panel.active {
    display: block;
}

.manager-report-list {
    display: grid;
    gap: 10px;
}

.manager-report-row {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.manager-report-index {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    font-weight: 800;
}

.manager-report-title {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 4px;
}

.manager-report-value {
    color: var(--text-main);
    font-weight: 600;
    line-height: 1.45;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.manager-report-recommendations {
    font-weight: 500;
}
