/* === Base Reset & Variables === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --navy: #0B1F3A;
    --navy-light: #132D50;
    --blue: #1B6CA8;
    --blue-hover: #1558889;
    --gold: #C9973A;
    --gold-light: #E8C476;
    --bg: #F7F8FA;
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --success: #1A7F5A;
    --warning: #E67E22;
    --danger: #C0392B;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --transition: 0.2s ease;
}

body {
    font-family: 'DM Sans', Arial, sans-serif;
    background: var(--bg);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* === Header === */
.header {
    background: var(--navy);
    color: var(--white);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px 0;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.logo-divider {
    color: var(--gold);
    font-size: 24px;
    font-weight: 300;
}

.logo-subtitle {
    font-size: 15px;
    font-weight: 400;
    color: var(--gray-300);
}

.nav-tabs {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 0;
    margin-top: 12px;
}

.nav-tab {
    background: none;
    border: none;
    color: var(--gray-400);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
}

.nav-tab:hover {
    color: var(--white);
}

.nav-tab.active {
    color: var(--white);
    border-bottom-color: var(--gold);
}

/* === Main Content === */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Dashboard KPI Cards === */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--gray-200);
    transition: var(--transition);
}

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

.kpi-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-500);
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.kpi-value {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-blue { color: #1B6CA8; }
.kpi-orange { color: #E67E22; }
.kpi-gold { color: #D4A017; }
.kpi-green { color: #1A7F5A; }
.kpi-purple { color: #7C3AED; }
.kpi-red { color: #C0392B; }

.kpi-sub {
    font-size: 12px;
    color: var(--gray-400);
    font-weight: 500;
}

/* === Charts === */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.chart-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 16px;
}

.chart-container {
    min-height: 200px;
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bar-label {
    width: 110px;
    font-size: 13px;
    color: var(--gray-600);
    text-align: right;
    flex-shrink: 0;
}

.bar-track {
    flex: 1;
    height: 28px;
    background: var(--gray-100);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s ease;
    display: flex;
    align-items: center;
    padding-left: 8px;
    min-width: fit-content;
}

.bar-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--white);
    white-space: nowrap;
}

/* === Tables === */
.section-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 16px;
}

.recent-section {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: var(--gray-50);
    color: var(--gray-600);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    padding: 12px 14px;
    text-align: left;
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.loading-row {
    text-align: center;
    color: var(--gray-400);
    padding: 40px !important;
}

/* === Badges === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-logged { background: #FEF3C7; color: #92400E; }
.badge-under-review { background: #DBEAFE; color: #1E40AF; }
.badge-closed { background: #D1FAE5; color: #065F46; }
.badge-member-notified { background: #EDE9FE; color: #5B21B6; }

.badge-low { background: #D1FAE5; color: #065F46; }
.badge-medium { background: #FEF3C7; color: #92400E; }
.badge-high { background: #FDE8D8; color: #C2410C; }
.badge-critical { background: #FEE2E2; color: #991B1B; }

/* === Forms === */
.form-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
    max-width: 900px;
    margin: 0 auto;
}

.form-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gold);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 24px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}

.required {
    color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
    font-family: inherit;
    font-size: 14px;
    padding: 10px 12px;
    border: 1.5px solid var(--gray-300);
    border-radius: 6px;
    color: var(--gray-800);
    background: var(--white);
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(27,108,168,0.1);
}

.form-group textarea {
    resize: vertical;
}

.readonly-field {
    background: var(--gray-100) !important;
    color: var(--gray-500) !important;
    cursor: default;
}

/* === Buttons === */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

.btn {
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--navy);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--navy-light);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

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

.btn-outline {
    background: var(--white);
    color: var(--navy);
    border: 1.5px solid var(--gray-300);
}

.btn-outline:hover {
    border-color: var(--navy);
    background: var(--gray-50);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    color: var(--gray-500);
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--blue);
}

/* === Spinner === */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Success Panel === */
.success-panel {
    background: var(--white);
    border-radius: var(--radius);
    padding: 48px 32px;
    box-shadow: var(--shadow);
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.success-icon {
    margin-bottom: 16px;
}

.success-panel h2 {
    font-size: 22px;
    color: var(--navy);
    margin-bottom: 8px;
}

.success-panel p {
    color: var(--gray-500);
    margin-bottom: 24px;
}

.success-details {
    background: var(--gray-50);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 24px;
    text-align: left;
}

.success-details .detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-200);
}

.success-details .detail-row:last-child {
    border-bottom: none;
}

.success-details .detail-label {
    color: var(--gray-500);
    font-weight: 500;
}

.success-details .detail-value {
    color: var(--navy);
    font-weight: 600;
}

/* === Cases Header === */
.cases-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.cases-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--white);
    border: 1.5px solid var(--gray-300);
    border-radius: 6px;
    padding: 8px 12px;
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(27,108,168,0.1);
}

.search-box input {
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 13px;
    background: none;
    width: 180px;
    color: var(--gray-700);
}

.filter-select {
    font-family: inherit;
    font-size: 13px;
    padding: 8px 12px;
    border: 1.5px solid var(--gray-300);
    border-radius: 6px;
    background: var(--white);
    color: var(--gray-700);
    cursor: pointer;
    outline: none;
}

.filter-select:focus {
    border-color: var(--blue);
}

/* Case management table inside white card */
#tab-cases .table-wrapper {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0;
}

#tab-cases .data-table td:last-child {
    white-space: nowrap;
}

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

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(11, 31, 58, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 18px;
    color: var(--navy);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-700);
}

.modal-body {
    padding: 24px;
}

/* === Toast === */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--white);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideUp 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--blue); }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Responsive === */
@media (max-width: 1024px) {
    .dashboard-stats { grid-template-columns: repeat(3, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .header-content { padding: 12px 16px 0; }
    .nav-tabs { padding: 0 16px; }
    .main-content { padding: 16px; }
    .logo-section { flex-wrap: wrap; }
    .logo-subtitle { display: none; }
    .nav-tab { font-size: 13px; padding: 8px 14px; }
    .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .form-card { padding: 20px; }
    .cases-header { flex-direction: column; align-items: flex-start; }
    .cases-controls { width: 100%; }
    .search-box input { width: 120px; }
    .modal-content { max-width: 100%; }
}

@media (max-width: 480px) {
    .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
    .nav-tabs { overflow-x: auto; flex-wrap: nowrap; }
    .stat-value { font-size: 22px; }
}
