:root {
    /* Branding Palette (Logo Inspired) */
    --primary: #F08080;
    /* Coral Pink */
    --primary-dark: #cc6b6b;
    --secondary: #1a2a3a;
    /* Deep Slate (Darker for contrast) */
    --accent-teal: #4db6ac;
    /* More vibrant teal */
    --accent-lavender: #9575cd;
    /* Richer lavender */
    --accent-orange: #ffb74d;
    /* For alerts/growth */

    --bg: #f5f7fa;
    --bg-dark: #0f172a;
    --bg-soft: #fff5f5;
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.75);

    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;

    --radius-sm: 8px;
    --radius: 16px;
    --radius-lg: 24px;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode {
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --surface: #1e293b;
    --surface-glass: rgba(30, 41, 59, 0.85);

    --border: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
}

/* Dark Mode Overrides for interactive and static UI elements */
body.dark-mode .g-badge.success,
body.dark-mode .badge.paid {
    background: rgba(22, 163, 74, 0.2);
    color: #4ade80;
}

body.dark-mode .g-badge.warning {
    background: rgba(202, 138, 4, 0.2);
    color: #facc15;
}

body.dark-mode .g-badge.danger,
body.dark-mode .badge.unpaid {
    background: rgba(220, 38, 38, 0.2);
    color: #f87171;
}

body.dark-mode .g-badge.info {
    background: rgba(2, 132, 199, 0.2);
    color: #38bdf8;
}

body.dark-mode .btn-primary {
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background: var(--bg-soft);
    color: var(--text);
    border-color: var(--border);
}

body.dark-mode .btn-icon:hover {
    background: var(--border);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.app-sidebar {
    width: 280px;
    background: var(--secondary);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-btn {
    display: none;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
    padding: 1rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.03);
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    background: white;
    /* Added to keep logo clean if transparent */
}

.brand-img {
    width: 110px;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: white;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: none;
}

.brand-info h1 {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.brand-info p {
    font-size: 0.8rem;
    color: #94a3b8;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border: none;
    background: transparent;
    color: #94a3b8;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 1rem;
    text-align: left;
    width: 100%;
}

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

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 8px 16px rgba(13, 148, 136, 0.2);
}

.nav-item i {
    width: 22px;
    height: 22px;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 2rem;
}

.btn-doctor {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.btn-doctor:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}

/* Main Header */
.main-header {
    height: 80px;
    padding: 0 3rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-breadcrumb {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary);
}

.search-box {
    position: relative;
    width: 300px;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 3rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    font-size: 0.9rem;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

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

/* Dashboard Specifics */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-info .kpi-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-info .kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary);
    display: block;
}

.chart-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    padding: 1.5rem;
    height: 350px;
}

.chart-card h3 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--secondary);
}

/* Content Area */
.content-viewport {
    flex: 1;
    padding: 2.5rem 3rem;
    overflow-y: auto;
}

/* Dashboard Actions (Home) */
.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.action-card {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
}

.action-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, transparent 100%);
    opacity: 0;
    transition: var(--transition);
}

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

.action-card:hover::after {
    opacity: 0.03;
}

.action-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius);
    background: rgba(13, 148, 136, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-card:hover .action-icon {
    background: var(--primary);
    color: white;
    transform: rotate(-5deg);
    transition: var(--transition);
}

.action-info h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.action-info p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Tables */
.data-table-container {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-top: 1.5rem;
    box-shadow: var(--shadow);
}

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

th {
    background: #f8fafc;
    padding: 1.25rem 1.5rem;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

tr:hover {
    background: #f8faff;
}

/* Form Styles */
.form-row {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-group input,
.form-group select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: var(--transition);
    background: var(--bg);
    color: var(--text);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Base Responsive Elements */
.content-viewport {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 1024px) {
    .main-header {
        padding: 0 2rem;
    }

    .content-viewport {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }

    .mobile-menu-btn {
        display: block;
    }

    .main-header {
        padding: 0 1rem;
        height: 70px;
    }

    .content-viewport {
        padding: 1rem;
    }

    /* Stack cards vertically */
    .dashboard-stats,
    .dashboard-charts {
        grid-template-columns: 1fr !important;
    }

    /* Stack forms */
    .form-row {
        grid-template-columns: 1fr !important;
    }

    /* Adjust page headers */
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .page-header>div:last-child {
        width: 100%;
        flex-direction: column;
    }

    .page-header>div:last-child input {
        width: 100% !important;
    }

    .page-header>div:last-child button {
        width: 100%;
        justify-content: center;
    }

    /* Make tables scrollable horizontally */
    .data-table-container {
        overflow-x: auto;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 1.5rem;
    }
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(13, 148, 136, 0.2);
}

.btn-primary.sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: #f1f5f9;
    border-color: var(--text-muted);
}

/* Global Data Tables (G-Standard) */
.g-table-container {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.g-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.g-table th {
    background: #f8fafc;
    padding: 1rem 1.25rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.g-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--secondary);
}

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

.g-table tr:hover {
    background: rgba(240, 128, 128, 0.02);
}

/* Premium Badges */
.g-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.g-badge.success {
    background: #dcfce7;
    color: #166534;
}

.g-badge.warning {
    background: #fef9c3;
    color: #854d0e;
}

.g-badge.danger {
    background: #fee2e2;
    color: #991b1b;
}

.g-badge.info {
    background: #e0f2fe;
    color: #075985;
}

/* Dashboard Cards (Refined) */
.g-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.g-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.g-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.g-card-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--secondary);
}

/* Utility */
.badge {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge.paid {
    background: #dcfce7;
    color: #166534;
}

.badge.unpaid {
    background: #fee2e2;
    color: #991b1b;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: var(--transition);
}

.modal-content {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 650px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-secondary {
    background: #edf2f7;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        padding: 0 1rem;
    }

    .app-nav {
        padding: 0.5rem 1rem;
    }

    .header-titles {
        display: none;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}