/* CSS DESIGN SYSTEM - HOSPITAL EXPENSE & SALARY DASHBOARD */

:root {
    /* Color Palette */
    --primary-dark: #0f172a;        /* Deep Slate 900 */
    --primary-navy: #1e3a8a;        /* Dark Blue 900 */
    --primary-blue: #2563eb;        /* Blue 600 */
    --accent-blue: #3b82f6;         /* Blue 500 */
    --light-blue: #e0f2fe;          /* Sky 100 */
    --pale-blue: #f0f9ff;           /* Sky 50 */
    --neutral-white: #ffffff;
    --bg-body: #f8fafc;             /* Slate 50 */
    --text-main: #1e293b;           /* Slate 800 */
    --text-muted: #64748b;          /* Slate 500 */
    --border-color: #e2e8f0;        /* Slate 200 */
    
    /* Semantic Colors */
    --success: #10b981;             /* Emerald 500 */
    --success-bg: #ecfdf5;          /* Emerald 50 */
    --warning: #f59e0b;             /* Amber 500 */
    --warning-bg: #fffbeb;          /* Amber 50 */
    --danger: #ef4444;              /* Red 500 */
    --danger-bg: #fef2f2;           /* Red 50 */
    
    /* Layout & Shadows */
    --sidebar-width: 260px;
    --header-height: 80px;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.08);
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Plus Jakarta Sans', 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--primary-dark);
}

a {
    text-decoration: none;
    color: inherit;
}

/* Helper Utilities */
.text-muted {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.hidden {
    display: none !important;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-col { display: flex; flex-direction: column; }

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 1. LOGIN SCREEN */
#login-view {
    display: none;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #2563eb 100%);
    padding: 20px;
}

#login-view.active {
    display: flex;
}

.login-container {
    width: 100%;
    max-width: 460px;
    perspective: 1000px;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    animation: slideInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--primary-blue);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: -0.5px;
}

.login-header h2 {
    font-size: 1.35rem;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    padding: 12px 12px 12px 42px;
    font-size: 0.95rem;
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    transition: var(--transition-fast);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-blue);
    background-color: var(--neutral-white);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.login-error {
    color: var(--danger);
    background-color: var(--danger-bg);
    border: 1px solid #fee2e2;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    text-align: center;
    display: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-block {
    width: 100%;
}

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

.btn-primary:hover {
    background-color: #1d4ed8;
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

.login-info {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px dashed var(--border-color);
}

.info-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    font-size: 0.8rem;
}

.test-cred {
    background-color: var(--border-color);
    padding: 1px 4px;
    border-radius: 4px;
    font-family: monospace;
}

/* 2. CORE LAYOUT (AFTER LOGIN) */
.layout {
    display: none;
    height: 100vh;
    overflow: hidden;
}

.layout.active {
    display: flex;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--primary-dark);
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    overflow-y: auto;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand .logo-text {
    color: var(--neutral-white);
}

.user-profile-summary {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.avatar {
    width: 42px;
    height: 42px;
    background-color: var(--primary-blue);
    color: var(--neutral-white);
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.user-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    color: var(--neutral-white);
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 20px;
    width: fit-content;
}

.user-role.badge {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--accent-blue);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--neutral-white);
}

.nav-item.active {
    background-color: var(--primary-blue);
    color: var(--neutral-white);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

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

.btn-logout {
    background-color: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    gap: 8px;
}

.btn-logout:hover {
    background-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-body);
}

.top-header {
    height: var(--header-height);
    background-color: var(--neutral-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    flex-shrink: 0;
    z-index: 10;
}

.header-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

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

/* 30% Toggle CSS Slider */
.overhead-toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--pale-blue);
    padding: 8px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--light-blue);
}

.toggle-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-navy);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
}

input:checked + .slider {
    background-color: var(--primary-blue);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-blue);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.current-date-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    background-color: var(--border-color);
    padding: 8px 16px;
    border-radius: var(--radius-lg);
}

.badge-icon {
    width: 16px;
    height: 16px;
}

/* Content Body */
.content-body {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* View switcher */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease-in-out;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 100%;
}

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

/* Card Styles */
.card {
    background-color: var(--neutral-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: var(--transition-normal);
}

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

/* Metric Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 30px;
}

.kpi-card {
    background-color: var(--neutral-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    transition: var(--transition-normal);
    min-height: 98px;
}

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

.kpi-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon svg {
    width: 20px;
    height: 20px;
}

/* Background helpers */
.bg-blue-light { background-color: var(--pale-blue); }
.bg-navy-light { background-color: #e0e7ff; }
.bg-green-light { background-color: var(--success-bg); }
.bg-orange-light { background-color: var(--warning-bg); }
.bg-danger-light { background-color: var(--danger-bg); }

.kpi-content {
    flex: 1;
    min-width: 0;
}

.kpi-content h3 {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: visible;
    line-height: 1.3;
}

.kpi-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-dark);
    white-space: nowrap;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.kpi-subtext {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: visible;
    line-height: 1.3;
}

#kpi-time-subtext {
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
}

/* Alert styles for KPI */
.kpi-card.alert-active {
    border-color: #fca5a5;
    background-color: var(--danger-bg);
}

.kpi-card.alert-active .kpi-value {
    color: var(--danger);
}

/* Charts Row */
.charts-row {
    display: flex;
    gap: 24px;
    margin-bottom: 30px;
}

.chart-container {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.chart-header {
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.chart-wrapper {
    position: relative;
    flex: 1;
    min-height: 280px;
}

.doughnut-wrapper {
    min-height: 220px;
    max-height: 240px;
}

.chart-legend-custom {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    font-size: 0.8rem;
    font-weight: 600;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.spent { background-color: var(--primary-blue); }
.legend-dot.remaining { background-color: #cbd5e1; }

/* Table styling */
.hospitals-section {
    padding: 24px;
}

.hospitals-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-title-group h3 {
    font-size: 1.15rem;
    margin-bottom: 4px;
}

.search-filter-bar input {
    padding: 10px 16px;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 260px;
    transition: var(--transition-fast);
    background-color: var(--bg-body);
}

.search-filter-bar input:focus {
    outline: none;
    border-color: var(--primary-blue);
    background-color: var(--neutral-white);
    width: 320px;
}

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

.hospital-table,
.salary-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.hospital-table th,
.salary-table th {
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.hospital-table td,
.salary-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

.hospital-table tbody tr:hover,
.salary-table tbody tr:hover {
    background-color: var(--pale-blue);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-badge.normal {
    background-color: var(--success-bg);
    color: var(--success);
}

.status-badge.warning {
    background-color: var(--warning-bg);
    color: var(--warning);
}

.status-badge.danger {
    background-color: var(--danger-bg);
    color: var(--danger);
    animation: flashDanger 2s infinite;
}

@keyframes flashDanger {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* Red alert table row override */
tr.row-danger {
    background-color: rgba(254, 242, 242, 0.7);
}

tr.row-danger:hover {
    background-color: rgba(254, 242, 242, 1);
}

/* Progress bar indicators */
.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar-bg {
    flex: 1;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: #3b82f6; /* Softer modern blue */
    border-radius: 4px;
    transition: width 0.8s ease-out;
}

.progress-bar-fill.warning {
    background-color: var(--warning);
}

.progress-bar-fill.danger {
    background-color: var(--danger);
}

.progress-text {
    font-size: 0.85rem;
    font-weight: 600;
    width: 48px;
    text-align: right;
}

/* 3. SALARY VIEW SPECIFIC STYLES */
.salary-alerts-section {
    padding: 24px;
    margin-top: 30px;
}

.section-header {
    margin-bottom: 20px;
}

.section-header h3 {
    font-size: 1.15rem;
}

/* 4. DATA ENTRY VIEW */
.entry-layout-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.form-container-card {
    padding: 30px;
}

.form-header {
    margin-bottom: 24px;
}

.badge-role {
    display: inline-block;
    padding: 4px 10px;
    background-color: var(--pale-blue);
    color: var(--primary-blue);
    border: 1px solid var(--light-blue);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.form-grid-row {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}

.form-divider {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

.form-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-navy);
    margin-bottom: 16px;
}

.input-currency {
    position: relative;
    display: flex;
    align-items: center;
}

.input-currency input {
    width: 100%;
    padding: 12px 50px 12px 16px;
    font-size: 0.95rem;
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    transition: var(--transition-fast);
}

.input-currency input:focus {
    outline: none;
    border-color: var(--primary-blue);
    background-color: var(--neutral-white);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-currency .unit {
    position: absolute;
    right: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 30px;
}

/* Success alert upon saving cost */
.form-success-alert {
    display: none;
    align-items: center;
    background-color: var(--success-bg);
    color: var(--success);
    border: 1px solid #a7f3d0;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 20px;
    animation: fadeIn 0.4s ease-out;
}

/* Info Sidebar in Data Entry */
.info-sidebar {
    gap: 24px;
}

.entry-instructions {
    padding: 24px;
}

.entry-instructions h4 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.styled-list {
    list-style-type: none;
}

.styled-list li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--text-main);
}

.styled-list li::before {
    content: "•";
    position: absolute;
    left: 6px;
    color: var(--primary-blue);
    font-size: 1.25rem;
    line-height: 1;
    top: -2px;
}

.recent-records-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.recent-records-card h4 {
    font-size: 1rem;
    margin-bottom: 16px;
}

.recent-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    max-height: 380px;
}

.recent-item {
    background-color: var(--pale-blue);
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--light-blue);
    font-size: 0.8rem;
    transition: var(--transition-fast);
}

.recent-item:hover {
    transform: translateX(2px);
    background-color: var(--light-blue);
}

.recent-item-header {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    color: var(--primary-navy);
    margin-bottom: 6px;
}

.recent-item-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    color: var(--text-main);
}

.recent-item-footer {
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: right;
}

/* RESPONSIVE DESIGN */
@media (max-width: 1200px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .charts-row {
        flex-direction: column;
    }
    
    .entry-layout-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .layout {
        flex-direction: column;
        height: auto !important;
        min-height: 100vh;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
    }
    
    .main-content {
        height: auto !important;
        overflow-y: visible !important;
    }
    
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }
    
    .nav-item {
        padding: 8px 12px;
        white-space: nowrap;
    }
    
    .top-header {
        flex-direction: column;
        height: auto;
        padding: 20px;
        gap: 16px;
        align-items: flex-start;
    }
    
    .content-body {
        padding: 20px;
        overflow-y: visible !important;
        height: auto !important;
    }
}

@media (max-width: 600px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .form-grid-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .login-card {
        padding: 24px;
    }
    
    .content-body {
        padding: 12px;
    }
    
    .card {
        padding: 16px !important;
    }
    
    .top-header {
        padding: 16px;
    }
    
    .modal-content {
        padding: 16px !important;
        margin: 10px;
        width: calc(100% - 20px) !important;
        max-height: 90vh;
    }
}

/* --- HOSPITAL CARDS GRID SYSTEM --- */
.hospitals-section-grid {
    margin-top: 30px;
}
.hospital-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 20px;
}
.hospital-card {
    background-color: var(--neutral-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}
.hospital-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: #3b82f6;
}
.hospital-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}
.hospital-card-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-dark);
}
.hospital-card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.hosp-card-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}
.hosp-card-stat span:first-child {
    color: var(--text-muted);
}
.hosp-card-stat span:last-child {
    font-weight: 700;
    color: var(--primary-dark);
}

/* Card Warning Highlights */
.hospital-card.card-warning {
    border-color: #fca5a5;
    background-color: rgba(254, 242, 242, 0.4);
}
.hospital-card.card-warning:hover {
    border-color: var(--danger);
    box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.1), 0 4px 6px -4px rgba(239, 68, 68, 0.1);
}

/* --- OFFICIAL SPLIT PORTAL LOGIN SCREEN --- */
.login-portal-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 480px;
    background-color: var(--neutral-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
    animation: slideInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 40px;
}

.portal-deco-panel {
    flex: 1.1;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #2563eb 100%);
    color: rgba(255, 255, 255, 0.85);
    padding: 45px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.white-logo {
    margin-bottom: 24px;
}

.white-logo .logo-icon {
    color: var(--neutral-white);
}

.white-logo .logo-text {
    color: var(--neutral-white);
}

.portal-deco-content h1 {
    color: var(--neutral-white);
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.3;
    margin-top: 20px;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.portal-deco-content p {
    color: #93c5fd; /* light blue */
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 30px;
}

.portal-features-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 30px;
}

.feat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.88rem;
}

.feat-item svg {
    width: 20px;
    height: 20px;
    color: #60a5fa; /* light accent blue */
    flex-shrink: 0;
}

.deco-footer {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.portal-form-panel {
    width: 100%;
    background-color: transparent;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.login-card-v2 {
    width: 100%;
}

.form-title-group h2 {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

.form-title-group p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.form-link {
    font-size: 0.82rem;
    color: var(--primary-blue);
    font-weight: 600;
    transition: var(--transition-fast);
}

.form-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.bold-link {
    font-weight: 700;
}

/* Modal and Form switches transition */
.login-card-v2.hidden {
    display: none !important;
}

/* Terms / Policy Text footer inside panel */
.terms-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 20px;
    line-height: 1.4;
}

/* Screen compatibility overrides for login portal page */
@media (max-width: 960px) {
    .login-portal-wrapper {
        flex-direction: column;
        max-width: 480px;
        height: auto;
        min-height: auto;
    }
    
    .portal-deco-panel {
        display: none;
    }
    
    .portal-form-panel {
        width: 100%;
        padding: 30px;
    }
}

/* --- FILE UPLOAD ZONE & OCR AUTO-EXTRACTOR --- */
.file-upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    background-color: var(--neutral-white);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-normal);
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.file-upload-zone:hover,
.file-upload-zone.dragover {
    border-color: var(--primary-blue);
    background-color: var(--pale-blue);
}
.upload-icon svg {
    width: 36px;
    height: 36px;
    color: var(--text-muted);
    transition: var(--transition-fast);
}
.file-upload-zone:hover .upload-icon svg {
    color: var(--primary-blue);
    transform: translateY(-2px);
}
.upload-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.upload-text strong {
    font-size: 0.9rem;
    color: var(--primary-dark);
}
.upload-text span {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.browse-link {
    color: var(--primary-blue);
    font-weight: 700;
    text-decoration: underline;
}

/* Upload Status / OCR Spinner */
.upload-status-indicator {
    display: flex;
    align-items: center;
    gap: 15px;
    background-color: var(--pale-blue);
    border: 1px solid var(--light-blue);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
    animation: pulseBorder 1.5s infinite;
}
@keyframes pulseBorder {
    0%, 100% { border-color: var(--light-blue); }
    50% { border-color: var(--primary-blue); }
}
.upload-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(37, 99, 235, 0.1);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.status-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.status-info strong {
    font-size: 0.85rem;
    color: var(--primary-navy);
}
.status-info span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Extracted Highlight input styles */
input.extracted-highlight,
select.extracted-highlight {
    border-color: var(--success) !important;
    background-color: var(--success-bg) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
    transition: all 0.5s ease;
}

/* Circular progress ring (gauge) styles */
.progress-ring-wrapper {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-ring-circle-bg {
    stroke: #e2e8f0;
}

.progress-ring-circle {
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s ease, stroke 0.3s ease;
}
.progress-ring-text {
    position: absolute;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-navy);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1050;
    align-items: center;
    justify-content: center;
}
.modal.open {
    display: flex !important;
}
.modal-content {
    background-color: var(--neutral-white);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: zoomIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes zoomIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.btn-close-modal {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}
.btn-close-modal:hover {
    color: var(--danger);
}

/* Dynamic sub-item styles */
.sub-item-row {
    animation: slideInDownFast 0.2s ease-out;
}
@keyframes slideInDownFast {
    from { transform: translateY(-8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.btn-delete-sub:hover {
    color: #ef4444 !important;
    transform: scale(1.1);
    transition: all 0.2s ease;
}
.category-block {
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}
.category-block:focus-within {
    border-color: var(--light-blue) !important;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.08);
}
.summary-box h4 {
    color: #ffffff !important;
}


/* WCAG AAA High Contrast for Sidebar and Status labels (BUG-016) */
.sidebar .nav-section-label {
    color: #e2e8f0 !important;
}
.kpi-subtext {
    color: #334155 !important;
}
.status-subtext {
    color: #334155 !important;
}
