/* EHR System - Apple-Inspired Professional Theme */
/* Clean, modern, light design system */

/* ===== CSS Variables - Design Tokens ===== */
:root {
    /* Primary Colors - Warmer Blue */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.10);
    --primary-dark: #1e40af;
    --primary-bg: rgba(37, 99, 235, 0.05);

    /* Secondary/Accent Colors - Teal (practice branding) */
    --secondary: #0d9488;
    --secondary-hover: #0f766e;
    --secondary-light: rgba(13, 148, 136, 0.10);
    --accent: #0d9488;
    --accent-hover: #0f766e;
    --accent-light: rgba(13, 148, 136, 0.10);

    /* Neutral Colors - Warmer Slate Grays */
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-elevated: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Text Colors - Warmer */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --text-inverse: #ffffff;

    /* Semantic Colors - Richer */
    --success: #16a34a;
    --success-light: rgba(22, 163, 74, 0.10);
    --success-bg: rgba(22, 163, 74, 0.05);
    --warning: #d97706;
    --warning-light: rgba(217, 119, 6, 0.10);
    --warning-bg: rgba(217, 119, 6, 0.05);
    --error: #dc2626;
    --error-light: rgba(220, 38, 38, 0.10);
    --danger: #dc2626;
    --danger-light: rgba(220, 38, 38, 0.10);
    --info: #0284c7;
    --info-light: rgba(2, 132, 199, 0.10);

    /* Shadows - Slightly more depth */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.07);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.10), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #2563eb, #0d9488);
    --gradient-sidebar: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    --gradient-header: linear-gradient(135deg, #f8fafc 0%, #f0f9ff 50%, #f0fdfa 100%);
    --gradient-card-accent: linear-gradient(135deg, #eff6ff, #f0fdfa);

    /* Sidebar Colors - Dark branded sidebar */
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active-bg: rgba(13, 148, 136, 0.15);
    --sidebar-active-border: #0d9488;
    --sidebar-section-text: #64748b;

    /* Border Radius - Apple-like rounded corners */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Typography - Apple System Fonts */
    --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, Monaco, 'Cascadia Mono', monospace;

    /* Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;

    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --header-height: 64px;
    --content-max-width: 1400px;

    /* Touch Target Sizes (Apple HIG recommends 44px minimum) */
    --touch-target-min: 44px;
    --touch-target-comfortable: 48px;
}

/* ===== Dark Mode ===== */
[data-theme="dark"] {
    /* Primary Colors */
    --primary: #60a5fa;
    --primary-hover: #93bbfd;
    --primary-light: rgba(96, 165, 250, 0.15);
    --primary-dark: #3b82f6;
    --primary-bg: rgba(96, 165, 250, 0.08);

    /* Secondary/Accent */
    --secondary: #2dd4bf;
    --secondary-hover: #5eead4;
    --secondary-light: rgba(45, 212, 191, 0.15);
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-light: rgba(45, 212, 191, 0.15);

    /* Neutral Colors */
    --background: #0f172a;
    --surface: #1e293b;
    --surface-elevated: #334155;
    --surface-hover: #334155;
    --border: #334155;
    --border-light: #1e293b;

    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-inverse: #0f172a;

    /* Semantic Colors */
    --success: #4ade80;
    --success-light: rgba(74, 222, 128, 0.15);
    --success-bg: rgba(74, 222, 128, 0.08);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --warning-bg: rgba(251, 191, 36, 0.08);
    --error: #f87171;
    --error-light: rgba(248, 113, 113, 0.15);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);
    --info: #38bdf8;
    --info-light: rgba(56, 189, 248, 0.15);

    /* Shadows — lighter on dark backgrounds */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.35);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.4);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #3b82f6, #2dd4bf);
    --gradient-sidebar: linear-gradient(180deg, #020617 0%, #0f172a 100%);
    --gradient-header: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --gradient-card-accent: linear-gradient(135deg, #1e293b, #1a2332);

    /* Sidebar */
    --sidebar-bg: #020617;
    --sidebar-text: #64748b;
    --sidebar-text-active: #f1f5f9;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-hover: rgba(255, 255, 255, 0.04);
    --sidebar-active-bg: rgba(45, 212, 191, 0.12);
    --sidebar-active-border: #2dd4bf;
    --sidebar-section-text: #475569;
}

/* ===== Base Styles ===== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--text-base);
    font-weight: var(--font-normal);
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--background);
    margin: 0;
    padding: 0;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-4);
    font-weight: var(--font-semibold);
    line-height: 1.2;
    color: var(--text-primary);
}

h1 { font-size: var(--text-3xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-2xl); letter-spacing: -0.01em; }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); }

p {
    margin: 0 0 var(--space-4);
    color: var(--text-secondary);
}

/* ===== Layout Components ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    background-color: var(--background);
    transition: margin-left var(--transition-base);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* ===== Card Component ===== */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    transition: box-shadow var(--transition-base);
}

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

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

.card-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin: 0;
}

.card-body {
    background: var(--surface);
    color: var(--text-primary);
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-light);
}

/* Interactive Card - Clickable */
.card-interactive {
    cursor: pointer;
    transition: all var(--transition-base);
}

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

.card-interactive:active {
    transform: translateY(0);
}

/* Card Size Variants */
.card-sm {
    padding: var(--space-4);
}

.card-lg {
    padding: var(--space-8);
}

/* Card with no padding (for embedded content) */
.card-flush {
    padding: 0;
}

.card-flush .card-header {
    padding: var(--space-4) var(--space-5);
    margin-bottom: 0;
}

.card-flush .card-body {
    padding: var(--space-5);
}

.card-flush .card-footer {
    padding: var(--space-4) var(--space-5);
    margin-top: 0;
}

/* ===== Button Styles - Apple-Inspired Design System ===== */

/* Base Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 20px;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: var(--font-medium);
    line-height: 1;
    text-decoration: none;
    border: 1.5px solid transparent;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Button Sizes */
.btn-xs {
    padding: 6px 12px;
    font-size: 11px;
    gap: var(--space-1);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-md {
    padding: 10px 20px;
    font-size: 14px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-xl {
    padding: 18px 36px;
    font-size: 18px;
}

/* Primary Button - Solid Apple Blue */
.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: none;
}

/* Secondary Button - Outlined (White BG + Colored Border) */
.btn-secondary {
    background: var(--surface);
    color: var(--primary);
    border-color: var(--primary);
}

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

.btn-secondary:active {
    background: var(--primary-light);
}

/* Tertiary/Ghost Button - No Border, Text Only */
.btn-tertiary,
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn-tertiary:hover,
.btn-ghost:hover {
    background: var(--background);
    color: var(--text-primary);
}

.btn-tertiary:active,
.btn-ghost:active {
    background: var(--border-light);
}

/* Outline Button - Neutral Gray Border */
.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-outline:hover {
    background: var(--background);
    border-color: var(--text-tertiary);
    color: var(--text-primary);
}

.btn-outline:active {
    background: var(--border-light);
}

/* Danger Button - Destructive Actions */
.btn-danger,
.btn-error {
    background: var(--error);
    color: var(--text-inverse);
    border-color: var(--error);
}

.btn-danger:hover,
.btn-error:hover {
    background: var(--error);
    border-color: var(--error);
    filter: brightness(1.1);
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.btn-danger:active,
.btn-error:active {
    transform: scale(0.98);
}

/* Danger Outline */
.btn-danger-outline {
    background: transparent;
    color: var(--error);
    border-color: var(--error);
}

.btn-danger-outline:hover {
    background: var(--error-light);
}

/* Success Button - Positive Actions */
.btn-success {
    background: var(--success);
    color: var(--text-inverse);
    border-color: var(--success);
}

.btn-success:hover {
    background: var(--success);
    border-color: var(--success);
    filter: brightness(1.1);
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.btn-success:active {
    transform: scale(0.98);
}

/* Warning Button */
.btn-warning {
    background: var(--warning);
    color: #1d1d1f;
    border-color: var(--warning);
}

.btn-warning:hover {
    background: var(--warning);
    border-color: var(--warning);
    filter: brightness(1.1);
    transform: scale(1.02);
}

.btn-warning:active {
    transform: scale(0.98);
}

/* Info Button */
.btn-info {
    background: var(--info);
    color: var(--text-inverse);
    border-color: var(--info);
}

.btn-info:hover {
    background: var(--info);
    border-color: var(--info);
    filter: brightness(1.1);
}

/* Outline Variants - Transparent BG with Colored Border */
.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: var(--text-inverse);
}

.btn-outline-secondary {
    background: transparent;
    color: var(--secondary);
    border-color: var(--secondary);
}

.btn-outline-secondary:hover {
    background: var(--secondary);
    color: var(--text-inverse);
}

.btn-outline-success {
    background: transparent;
    color: var(--success);
    border-color: var(--success);
}

.btn-outline-success:hover {
    background: var(--success);
    color: var(--text-inverse);
}

.btn-outline-warning {
    background: transparent;
    color: #92400e;
    border-color: var(--warning);
}

.btn-outline-warning:hover {
    background: var(--warning);
    color: #1d1d1f;
}

.btn-outline-info {
    background: transparent;
    color: #0284c7;
    border-color: var(--info);
}

.btn-outline-info:hover {
    background: var(--info);
    color: var(--text-inverse);
}

/* Compact Size - Extra small for inline/dense UI */
.btn-compact {
    padding: 4px 10px;
    font-size: 12px;
    gap: var(--space-1);
}

.btn-compact svg {
    width: 14px;
    height: 14px;
}

/* Icon Button - Square/Circle for Icons Only */
.btn-icon {
    padding: var(--space-2);
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-full);
}

.btn-icon:hover {
    background: var(--background);
    color: var(--text-primary);
}

.btn-icon:active {
    background: var(--border-light);
}

.btn-icon svg,
.btn-icon-only {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-icon.btn-xs svg { width: 14px; height: 14px; }
.btn-icon.btn-sm svg { width: 16px; height: 16px; }
.btn-icon.btn-lg svg { width: 22px; height: 22px; }
.btn-icon.btn-xl svg { width: 26px; height: 26px; }

/* Icon inside regular buttons */
.btn svg:not(.btn-icon-only),
.btn svg.btn-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: inherit;
}

.btn-lg svg:not(.btn-icon-only) { width: 18px; height: 18px; }
.btn-sm svg:not(.btn-icon-only) { width: 14px; height: 14px; }
.btn-xs svg:not(.btn-icon-only) { width: 12px; height: 12px; }

/* Full Width Button */
.btn-full,
.btn-block {
    width: 100%;
}

/* Button Group */
.btn-group {
    display: inline-flex;
    gap: var(--space-2);
}

.btn-group-tight {
    gap: var(--space-1);
}

/* Disabled State */
.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    transform: none !important;
    box-shadow: none !important;
}

/* Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

.btn-loading.btn-primary::after,
.btn-loading.btn-danger::after,
.btn-loading.btn-success::after {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

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

/* Action Button - Table Row Actions */
.action-btn,
.icon-btn {
    padding: var(--space-2);
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover,
.icon-btn:hover {
    background: var(--background);
    color: var(--text-primary);
}

.action-btn svg,
.icon-btn svg {
    width: 16px;
    height: 16px;
}

/* ===== Sidebar Navigation ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition-base);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
}

.sidebar-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--sidebar-text-active);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-4);
    overflow-y: auto;
    min-height: 0;
}

.nav-section {
    margin-bottom: var(--space-5);
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: var(--font-semibold);
    color: var(--sidebar-section-text);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-1);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    transition: all var(--transition-fast);
    margin-bottom: var(--space-1);
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    border-left: 3px solid var(--sidebar-active-border);
    font-weight: var(--font-semibold);
}

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

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

.header-title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: -12px 0 14px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
}
.breadcrumb a:hover {
    color: var(--primary);
    text-decoration: underline;
}
.breadcrumb .sep {
    color: var(--text-muted, #9ca3af);
    user-select: none;
}
.breadcrumb .current {
    color: var(--text-primary);
    font-weight: 500;
}

/* ===== Page Header ===== */
.page-header {
    margin-bottom: var(--space-6);
}

.page-header h1,
.page-header h2,
.page-header h3 {
    color: var(--text-primary);
}

.page-header p,
.page-header .text-muted {
    color: var(--text-secondary);
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin: 0;
}

/* ===== Search Input ===== */
.search-input {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-4);
    transition: all var(--transition-fast);
}

.search-input:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-input input {
    border: none;
    background: transparent;
    outline: none;
    font-size: var(--text-sm);
    color: var(--text-primary);
    width: 200px;
}

.search-input input::placeholder {
    color: var(--text-tertiary);
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.form-label.required::after {
    content: " *";
    color: var(--error);
}

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-hint {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    margin-top: var(--space-1);
}

.form-error {
    font-size: var(--text-sm);
    color: var(--error);
    margin-top: var(--space-1);
}

.form-success {
    font-size: var(--text-sm);
    color: var(--success);
    margin-top: var(--space-3);
}

/* Form Grid Layout */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
}

.form-grid .form-group-wide {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .form-grid .form-group-wide {
        grid-column: span 1;
    }
}

/* Form Section Spacing */
.form-section {
    margin-top: var(--space-6);
}

.form-section-title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border-light);
}

/* Portal Form Actions */
.portal-form-actions {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-top: var(--space-6);
}

/* Form Input Size Variants */
.form-input-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
}

.form-input-lg {
    padding: var(--space-4) var(--space-5);
    font-size: var(--text-lg);
}

/* Form Validation States */
.form-input.is-valid,
.form-input:valid:not(:placeholder-shown) {
    border-color: var(--success);
}

.form-input.is-valid:focus,
.form-input:valid:not(:placeholder-shown):focus {
    border-color: var(--success);
    box-shadow: 0 0 0 3px var(--success-light);
}

.form-input.is-invalid,
.form-input:invalid:not(:placeholder-shown) {
    border-color: var(--error);
}

.form-input.is-invalid:focus,
.form-input:invalid:not(:placeholder-shown):focus {
    border-color: var(--error);
    box-shadow: 0 0 0 3px var(--error-light);
}

/* Form Input Group */
.form-input-group {
    display: flex;
    align-items: stretch;
}

.form-input-group .form-input {
    border-radius: 0;
}

.form-input-group .form-input:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.form-input-group .form-input:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.form-input-group-addon {
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    background: var(--background);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.form-input-group-addon:first-child {
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.form-input-group-addon:last-child {
    border-left: none;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Textarea */
.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* Select */
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b6b6b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

/* ===== Status Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    border-radius: var(--radius-full);
    line-height: 1.4;
    white-space: nowrap;
}

/* Badge Size Variants */
.badge-sm {
    padding: 2px 8px;
    font-size: 10px;
}

.badge-lg {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
}

/* Badge Color Variants */
.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: #cc7a00;
}

.badge-error,
.badge-danger {
    background: var(--error-light);
    color: var(--error);
}

.badge-info {
    background: var(--info-light);
    color: var(--info);
}

.badge-neutral {
    background: var(--background);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* Dot Badge - Status Indicator */
.badge-dot {
    padding: 0;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
}

.badge-dot.badge-success { background: var(--success); }
.badge-dot.badge-warning { background: var(--warning); }
.badge-dot.badge-error,
.badge-dot.badge-danger { background: var(--error); }
.badge-dot.badge-info { background: var(--info); }
.badge-dot.badge-primary { background: var(--primary); }

/* Count Badge - Numbers */
.badge-count {
    padding: 2px 6px;
    min-width: 20px;
    text-align: center;
    font-size: 11px;
    font-weight: var(--font-semibold);
}

/* Badge with Icon */
.badge svg,
.badge .icon {
    width: 12px;
    height: 12px;
}

.badge-lg svg,
.badge-lg .icon {
    width: 14px;
    height: 14px;
}

/* ===== Alert Styles ===== */
.alert {
    padding: var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.alert-success {
    background: var(--success-light);
    border: 1px solid var(--success);
    color: #1a7f37;
}

.alert-warning {
    background: var(--warning-light);
    border: 1px solid var(--warning);
    color: #9a6700;
}

.alert-error {
    background: var(--error-light);
    border: 1px solid var(--error);
    color: #cf1124;
}

.alert-info {
    background: var(--info-light);
    border: 1px solid var(--info);
    color: #0969da;
}

/* ===== Data Table Styles ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-light);
    background: var(--background);
}

.data-table td {
    padding: var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    background: var(--surface);
}

.data-table tr:hover td {
    background: var(--background);
}

/* ===== Avatar ===== */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary) 0%, var(--info) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: var(--text-xs);
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: var(--text-lg);
}

/* ===== Stats Card ===== */
.stats-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--primary);
    transition: all var(--transition-fast);
}

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

.stats-card-value {
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
    letter-spacing: -0.02em;
}

.stats-card-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.stats-card-trend {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    margin-top: var(--space-2);
}

.stats-card-trend.up {
    color: var(--success);
}

.stats-card-trend.down {
    color: var(--error);
}

/* Hide grid ARIA/accessibility text that bleeds through headers */


/* Hide raw header table ID text */

/* Hide screen reader text in grid headers */


/* Grid - Base styles */
/* Base Button - Pill Shape */


/* Primary Button */


/* Outline Button (Secondary) */


/* Flat Button (Tertiary/Ghost) */


/* Danger Button */


/* Success Button */


/* Warning Button */


/* Info Button */


/* Size Variants */


/* Icon Button */


/* Disabled State */


/* Block Button */

/* Button with Icon */


/* Button Groups */


/* Input */


/* Dropdowns */


/* Dialog/Modal */

/* Global Dialog Centering - ensures all modal dialogs are centered */


/* Toast/Notifications */

/* Spinner */

/* Card overrides for content */

/* Tabs */


/* Checkbox and Radio */


/* TextBox */

/* DatePicker */


/* Numeric TextBox */

/* ===== Syncfusion Layout Integration (sizing only, colors from Fluent 2) ===== */

/* Make Syncfusion inputs fill their form containers */
.form-group .e-input-group,
.form-group .e-input-group.e-control-wrapper,
.form-group .e-ddl.e-control-wrapper,
.form-group .e-float-input,
.form-group .e-multi-select-wrapper {
    width: 100%;
}

/* Syncfusion multiline textbox should respect rows attribute */
.form-group .e-input-group textarea.e-input,
.form-group .e-input-group.e-control-wrapper textarea.e-input {
    width: 100%;
    min-height: 80px;
}

/* Grid: ensure it fills container width */
.e-grid {
    width: 100%;
}

/* Dialog: center modals */
.e-dlg-container {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
}

.e-dlg-modal.e-dialog,
.e-popup-open.e-dialog {
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    max-height: 90vh;
}

.e-dlg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* ===== Form Controls ===== */
.form-control,
.form-select {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
    border-radius: var(--radius-md) !important;
}

.form-control:focus,
.form-select:focus {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px var(--primary-light) !important;
}

.form-control::placeholder {
    color: var(--text-tertiary) !important;
}
.table {
    color: var(--text-primary) !important;
}

.table th {
    background: var(--background) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-light) !important;
    font-weight: var(--font-semibold) !important;
}

.table td {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-light) !important;
}

.table-striped tbody tr:nth-of-type(odd) td {
    background: var(--background) !important;
}

.table-hover tbody tr:hover td {
    background: var(--background) !important;
}

/* Modal/Dialog generic */
.modal-content {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
    border-radius: var(--radius-lg) !important;
}

.modal-header {
    background: var(--surface) !important;
    border-color: var(--border-light) !important;
    color: var(--text-primary) !important;
}

.modal-body {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
}

.modal-footer {
    background: var(--surface) !important;
    border-color: var(--border-light) !important;
}

/* List groups */
.list-group-item {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-light) !important;
}

/* Pagination */
.page-link {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

.page-item.active .page-link {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
}

/* Breadcrumbs */
.breadcrumb {
    background: transparent !important;
}

.breadcrumb-item a {
    color: var(--primary) !important;
}

.breadcrumb-item.active {
    color: var(--text-secondary) !important;
}

/* Dropdown menus (Bootstrap) */
.dropdown-menu {
    background: var(--surface) !important;
    border-color: var(--border) !important;
    box-shadow: var(--shadow-lg) !important;
    border-radius: var(--radius-md) !important;
}

.dropdown-item {
    color: var(--text-primary) !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--background) !important;
    color: var(--text-primary) !important;
}

/* Input groups */
.input-group-text {
    background: var(--background) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border) !important;
}

/* Nav tabs */
.nav-tabs {
    border-color: var(--border-light) !important;
}

.nav-tabs .nav-link {
    color: var(--text-secondary) !important;
}

.nav-tabs .nav-link:hover {
    border-color: var(--border) !important;
}

.nav-tabs .nav-link.active {
    background: var(--surface) !important;
    color: var(--primary) !important;
    border-color: var(--border-light) var(--border-light) var(--surface) !important;
}

/* Search boxes and inputs */
input[type="search"],
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
textarea,
select {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

/* Spinner */
.spinner-border {
    color: var(--primary) !important;
}

/* Text utilities */
.text-muted {
    color: var(--text-tertiary) !important;
}

/* Links */
.main-content a:not(.btn):not(.nav-link):not(.nav-item) {
    color: var(--primary);
}

.main-content a:not(.btn):not(.nav-link):not(.nav-item):hover {
    color: var(--primary-hover);
}

/* ===== Page Transitions ===== */
.page-enter {
    opacity: 0;
    transform: translateY(10px);
}

.page-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: all var(--transition-base);
}

/* ===== Loading Container ===== */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    gap: var(--space-4);
    color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }

    .sidebar-title,
    .nav-item span,
    .nav-section-title,
    .user-info {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: var(--space-3);
    }

    .sidebar-header {
        justify-content: center;
        padding: var(--space-4);
    }

    .sidebar-footer {
        padding: var(--space-3);
    }

    .user-profile {
        justify-content: center;
    }

    .logout-btn {
        display: none;
    }
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: var(--space-4);
    left: var(--space-4);
    z-index: 101;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: white;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-fast);
}


.mobile-menu-toggle:hover {
    background: var(--primary-hover);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        transition: transform var(--transition-base);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-title,
    .nav-item span,
    .nav-section-title,
    .user-info {
        display: block;
    }

    .nav-item {
        justify-content: flex-start;
    }

    .logout-btn {
        display: flex;
    }
}

/* ===== Utility Classes ===== */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }

.bg-primary { background: var(--primary); }
.bg-surface { background: var(--surface); }
.bg-background { background: var(--background); }

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

/* ===== Dashboard Layouts ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: calc(-1 * var(--space-6)) calc(-1 * var(--space-6)) var(--space-6) calc(-1 * var(--space-6));
    padding: var(--space-6) var(--space-6) var(--space-5) var(--space-6);
    background: var(--gradient-header);
    border-bottom: 1px solid var(--border);
}

.page-header .page-title {
    letter-spacing: -0.01em;
}

.page-header-actions {
    display: flex;
    gap: var(--space-3);
}

.page-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: var(--space-1) 0 0 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-6);
    margin-bottom: var(--space-6);
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Stats Card Link */
.stats-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.stats-card-link:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Stats Card Content */
.stats-card-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stats-card-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

/* Stats Icon */
.stats-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stats-icon.primary { background: var(--primary-light); color: var(--primary); }
.stats-icon.secondary { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.stats-icon.success { background: var(--success-light); color: var(--success); }
.stats-icon.warning { background: var(--warning-light); color: var(--warning); }
.stats-icon.danger { background: var(--error-light); color: var(--error); }
.stats-icon.info { background: var(--info-light); color: var(--info); }

/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-6);
}

.dashboard-main,
.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Card Link */
.card-link {
    font-size: var(--text-sm);
    color: var(--primary);
    text-decoration: none;
}

.card-link:hover {
    text-decoration: underline;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    padding: var(--space-2);
}

.quick-action {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.quick-action:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    color: var(--text-tertiary);
    text-align: center;
}

.empty-state p {
    margin-top: var(--space-3);
}

.empty-state-small {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-6);
    color: var(--text-tertiary);
    text-align: center;
    gap: var(--space-2);
}

/* Highlight Cards */
.stats-card.highlight-primary {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--surface) 0%, var(--primary-light) 100%);
}

.stats-card.highlight-warning {
    border-color: var(--warning);
    background: linear-gradient(135deg, var(--surface) 0%, var(--warning-light) 100%);
}

.stats-card.highlight-danger {
    border-color: var(--error);
    background: linear-gradient(135deg, var(--surface) 0%, var(--error-light) 100%);
}

.stats-card.highlight-success {
    border-color: var(--success);
    background: linear-gradient(135deg, var(--surface) 0%, var(--success-light) 100%);
}

/* ===== Portal Settings Styles ===== */

/* Portal Status Banner */
.portal-status {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.portal-status.active {
    background: var(--success-light);
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.portal-status.active .portal-status-icon {
    color: var(--success);
}

.portal-status.inactive {
    background: var(--info-light);
    border: 1px solid rgba(90, 200, 250, 0.2);
}

.portal-status.inactive .portal-status-icon {
    color: var(--info);
}

.portal-status-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.portal-status-text strong {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.portal-status-text p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Portal Password Modal */
.portal-password-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.portal-password-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.portal-password-modal .modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.portal-password-modal .modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.portal-password-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

/* Password Input Group */
.password-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-group .form-control {
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    right: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background 0.15s ease;
}

.password-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* Badge Variants for Portal */
.badge-warning {
    background: var(--warning-light);
    color: #b36b00;
    border: 1px solid rgba(255, 159, 10, 0.3);
}

/* Portal Status Badges Container */
.portal-status-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    min-height: 38px;
    padding: var(--space-2) 0;
}

/* Portal Password Requirements Box */
.portal-password-requirements {
    margin-top: var(--space-4);
    padding: var(--space-4);
    background: var(--background);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.portal-password-requirements strong {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.portal-password-requirements ul {
    margin: 0;
    padding-left: var(--space-5);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.portal-password-requirements li {
    margin-bottom: var(--space-1);
}

.portal-password-requirements li:last-child {
    margin-bottom: 0;
}

/* ===== iPad & Touch Device Optimizations ===== */


/* iPad Pro breakpoint (1100px for iPad Pro portrait + buffer) */
@media (max-width: 1100px) and (min-width: 769px) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }

    .sidebar-title,
    .nav-item span,
    .nav-section-title,
    .user-info {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: var(--space-3);
    }

    .sidebar-header {
        justify-content: center;
        padding: var(--space-4);
    }

    .sidebar-footer {
        padding: var(--space-3);
    }

    .user-profile {
        justify-content: center;
    }

    .logout-btn {
        display: none;
    }
}

/* iPad portrait - always collapsed sidebar */
@media (max-width: 1100px) and (orientation: portrait) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    .sidebar-title,
    .nav-item span,
    .nav-section-title,
    .user-info {
        display: none;
    }
}

/* iPad landscape - full sidebar if screen is wide enough */
@media (min-width: 1100px) and (orientation: landscape) {
    .sidebar {
        width: var(--sidebar-width);
    }

    .sidebar-title,
    .nav-item span,
    .nav-section-title,
    .user-info {
        display: block;
    }

    .nav-item {
        justify-content: flex-start;
    }

    .logout-btn {
        display: flex;
    }
}

/* Touch device-specific styles - using CSS-only detection */
@media (pointer: coarse) {
    .btn,
    .nav-item,

    .form-input,
    .form-select,

    .btn-sm,

    .btn-xs,

    /* Touch-optimized grid rows */


    /* Touch-optimized action buttons in tables */
    .action-btn,
    .icon-btn {
        min-width: var(--touch-target-min);
        min-height: var(--touch-target-min);
        padding: var(--space-3);
    }

    /* Touch-optimized nav items */
    .nav-item {
        padding: var(--space-3) var(--space-4);
        min-height: var(--touch-target-min);
    }

    /* Touch-optimized quick actions */
    .quick-action {
        padding: var(--space-4);
        min-height: var(--touch-target-min);
    }

    /* Prevent text selection on touch for interactive elements */
    .btn,
    .nav-item,
    .action-btn {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    /* Touch scrolling */
    body {
        -webkit-overflow-scrolling: touch;
    }

    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    ::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: var(--radius-full);
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }
}

/* Swipe-open sidebar for touch devices */
@media (pointer: coarse) {
    .sidebar {
        transition: transform var(--transition-slow), width var(--transition-base);
    }

    .sidebar.open {
        transform: translateX(0) !important;
        width: var(--sidebar-width) !important;
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open .sidebar-title,
    .sidebar.open .nav-item span,
    .sidebar.open .nav-section-title,
    .sidebar.open .user-info {
        display: block !important;
    }

    .sidebar.open .nav-item {
        justify-content: flex-start !important;
    }

    .sidebar.open .logout-btn {
        display: flex !important;
    }

    /* Overlay when sidebar is open on touch devices */
    .sidebar.open ~ .main-content::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 99;
        transition: opacity var(--transition-slow);
    }
}

/* ===== Responsive Dialogs ===== */

/* Responsive dialog sizes for iPad and smaller */
@media (max-width: 1100px) {

}

@media (max-width: 768px) {


}

/* Dialog size utility classes */
.dialog-sm {
    width: 400px !important;
}

.dialog-md {
    width: 600px !important;
}

.dialog-lg {
    width: 800px !important;
}

.dialog-xl {
    width: 1000px !important;
}

.dialog-full {
    width: calc(100vw - 48px) !important;
    height: calc(100vh - 48px) !important;
}

/* ===== Responsive Form Grids ===== */
@media (max-width: 1100px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .form-group-wide {
        grid-column: span 1;
    }
}

/* ===== iPad-specific Grid Adjustments ===== */
@media (max-width: 1400px) and (pointer: coarse) {

}

/* Hide less important columns on narrower screens */
@media (max-width: 1100px) {
    .hide-on-ipad {
        display: none !important;
    }
}

@media (max-width: 900px) {
    .hide-on-tablet {
        display: none !important;
    }
}

/* ===== Touch-optimized Scheduler ===== */
@media (pointer: coarse) {
    /* Active States for Touch Feedback */
    .btn:active,
    .nav-item:active,
    .action-btn:active {
        opacity: 0.7;
        transition: opacity 0.1s ease;
    }
}

/* ===================================================================
   GLOBAL RESPONSIVE FIXES FOR TABLETS (iPad Pro 12.9" and similar)
   =================================================================== */

/* ---- SYNCFUSION TABS - Always scrollable, never wrap ---- */


/* ---- Custom nav tabs - Also scrollable ---- */
.nav-tabs,
.tab-navigation,
.sub-tabs,
.client-tabs,
.detail-tabs {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap !important;
    white-space: nowrap;
    display: flex;
}

.nav-tabs::-webkit-scrollbar,
.tab-navigation::-webkit-scrollbar,
.sub-tabs::-webkit-scrollbar {
    display: none;
}

.nav-tabs > *,
.tab-navigation > *,
.sub-tabs > * {
    flex-shrink: 0;
}

/* ---- GRIDS - Horizontal scroll within container ---- */

.card-body,
.grid-wrapper,
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== iPad Landscape & Portrait (max-width: 1366px) ===== */
@media (max-width: 1366px) {
    /* Page content should not overflow horizontally */
    .page-content,
    .content-wrapper,
    .main-content {
        overflow-x: hidden;
        max-width: 100%;
    }

    /* Reduce main content padding */
    .main-content {
        padding: var(--space-4);
    }

    /* Stats grid - 2 columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Dashboard grid - single column */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* Page header - stack */
    .page-header {
        flex-direction: column;
        gap: var(--space-3);
        align-items: stretch;
    }

    .page-header-actions {
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    /* Filter/toolbar - wrap */
    .filter-bar,
    .toolbar-actions,
    .action-bar {
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    /* Cards - reduce padding */
    .card-body {
        padding: var(--space-3);
    }

    /* Breadcrumbs - scrollable */
    .breadcrumb {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .breadcrumb::-webkit-scrollbar {
        display: none;
    }
}

/* ===== iPad Portrait (max-width: 1100px) ===== */
@media (max-width: 1100px) {
    /* Even smaller padding */
    .main-content {
        padding: var(--space-3);
    }

    /* Two-column layouts become single column */
    .client-detail-grid,
    .info-cards-row,
    .detail-grid,
    .two-column-layout,
    .split-layout {
        display: flex;
        flex-direction: column;
        gap: var(--space-4);
    }

    /* Info grids single column */
    .info-grid,
    .detail-section,
    .form-row {
        grid-template-columns: 1fr !important;
    }

    /* Form grids - reduce columns */
    .form-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .form-grid .form-group-wide {
        grid-column: span 2 !important;
    }

    /* Dialogs - nearly full width */

    /* Stats - single column */
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Narrow Portrait (max-width: 900px) ===== */
@media (max-width: 900px) {
    /* Form grids single column */
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .form-grid .form-group-wide {
        grid-column: span 1 !important;
    }

    /* Smaller grid text */

    /* Stack button groups */
    .btn-group,
    .button-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group > .btn,
    .button-group > .btn {
        width: 100%;
    }
}

/* ===== iPad Tab Overflow Fix ===== */
/* Ensure tabs are scrollable on iPad and don't overflow the viewport */
@media (max-width: 1366px) {
    /* Main page container - prevent horizontal overflow */
    .page-content {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Client tabs wrapper - allow horizontal scroll */
    .client-tabs {
        max-width: 100%;
        overflow: visible;
    }


    /* Show a subtle scrollbar on iPad for discoverability */


    /* Ensure toolbar items don't wrap */

    /* Crisis Plan Editor tabs - ensure scrollable */

    /* Quick view panels - stack on narrower screens */
    .quick-view-panels {
        grid-template-columns: 1fr !important;
    }

    /* Info grids in client header - reduce */
    .client-header-info {
        max-width: calc(100vw - 300px);
    }

    /* Authorization/Source text - allow wrap */
    .case-info {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* ===== iPad Portrait specific ===== */
@media (max-width: 1024px) {
    /* Tabs - smaller text */

    /* Client header - stack */
    .client-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .client-header-info {
        max-width: 100%;
    }

    /* Reduce client avatar size */
    .client-avatar-container,
    .client-avatar-img,
    .client-initials {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.25rem !important;
    }

    /* Crisis plan quick panels - ensure proper stacking */
    .quick-view-panels {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem;
    }

    .quick-panel {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ===== UI Enhancement: Micro-Interactions & Animations ===== */

/* Page content fade-in */
.page-content {
    animation: fadeInUp 0.3s ease-out;
}

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

/* Card hover lift */
.card {
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

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

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

/* Grid header styling */

/* Alternating rows */

/* Row hover */

/* Selected row */

/* Grid border cleanup */

/* ===== Enhanced Status Badges ===== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.badge.bg-success, .badge.bg-green { background: rgba(22, 163, 74, 0.12) !important; color: #15803d !important; }
.badge.bg-danger, .badge.bg-red { background: rgba(220, 38, 38, 0.12) !important; color: #dc2626 !important; }
.badge.bg-warning { background: rgba(217, 119, 6, 0.12) !important; color: #b45309 !important; }
.badge.bg-info { background: rgba(2, 132, 199, 0.12) !important; color: #0369a1 !important; }
.badge.bg-secondary { background: rgba(100, 116, 139, 0.12) !important; color: #475569 !important; }
.badge.bg-primary { background: rgba(37, 99, 235, 0.12) !important; color: #1d4ed8 !important; }
.badge.bg-light { background: var(--surface-hover) !important; color: var(--text-secondary) !important; }

/* ===== Enhanced Button Polish ===== */

.btn-primary {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
    background: var(--primary-hover) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

/* ===== Summary Cards (Dashboard) ===== */
.dashboard-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.summary-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

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

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

.summary-icon.primary { background: var(--primary-light); color: var(--primary); }
.summary-icon.success { background: var(--success-light); color: var(--success); }
.summary-icon.warning { background: var(--warning-light); color: var(--warning); }
.summary-icon.danger { background: var(--danger-light); color: var(--danger); }
.summary-icon.total { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }

.summary-value {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1;
}

.summary-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ===== Filter Bar Improvements ===== */
.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding: var(--space-4);
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    margin-bottom: var(--space-4);
}
