/* ==========================================================================
   A.M GORI Pharmacy & Stores — Design System
   Visual rebrand only; legacy --careplus-* aliases kept for compatibility
   ========================================================================== */

/* --------------------------------------------------------------------------
   DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root {
    /* A.M GORI 2026 design system */
    --brand-primary: #00552f;
    --brand-primary-hover: #004525;
    --brand-primary-active: #00381e;
    --brand-primary-soft: #e8f5ed;
    --brand-primary-dark: var(--brand-primary-hover);
    --brand-primary-deep: #002f1b;
    --brand-primary-light: var(--brand-primary-soft);

    --brand-secondary: #62b83f;
    --brand-secondary-hover: #50a232;
    --brand-secondary-soft: #eaf7e5;
    --brand-secondary-light: var(--brand-secondary-soft);

    --brand-accent: #a51008;
    --brand-accent-hover: #850d07;
    --brand-accent-soft: #fbeae8;
    --brand-accent-dark: var(--brand-accent-hover);
    --brand-accent-light: var(--brand-accent-soft);

    --background-app: #f5f8f6;
    --background-subtle: #edf3ef;
    --surface-primary: #ffffff;
    --surface-secondary: #f9fbfa;
    --surface-elevated: #ffffff;

    --text-primary: #17251e;
    --text-secondary: #53665c;
    --text-muted: #75867d;
    --text-inverse: #ffffff;

    --border-light: #e4ebe6;
    --border-default: #d5e0d8;
    --border-strong: #bbcbbf;

    --success: #21864a;
    --success-soft: #e7f6ed;
    --warning: #c98212;
    --warning-soft: #fff4dc;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --info: #2673b8;
    --info-soft: #e8f2fc;

    --shadow-xs: 0 1px 2px rgba(16, 50, 31, 0.05);
    --shadow-sm: 0 2px 8px rgba(16, 50, 31, 0.07);
    --shadow-md: 0 8px 24px rgba(16, 50, 31, 0.09);
    --shadow-lg: 0 18px 48px rgba(16, 50, 31, 0.13);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --radius-pill: 999px;

    --transition-fast: 140ms ease;
    --transition-normal: 220ms ease;
    --focus-ring: 0 0 0 3px rgba(98, 184, 63, 0.28);

    /* Compat aliases used across existing CSS/JS */
    --brand-surface: var(--surface-primary);
    --brand-background: var(--background-app);
    --brand-border: var(--border-default);
    --brand-text: var(--text-primary);
    --brand-text-muted: var(--text-muted);
    --brand-success: var(--success);
    --brand-warning: var(--warning);
    --brand-danger: var(--danger);
    --brand-info: var(--info);

    --color-primary: var(--brand-primary);
    --color-primary-hover: var(--brand-primary-hover);
    --color-primary-active: var(--brand-primary-active);
    --color-secondary: var(--brand-secondary);
    --color-accent: var(--brand-accent);
    --color-background: var(--background-app);
    --color-surface: var(--surface-primary);
    --color-border: var(--border-default);
    --color-text: var(--text-primary);
    --color-text-muted: var(--text-muted);
    --color-success: var(--success);
    --color-warning: var(--warning);
    --color-danger: var(--danger);
    --color-info: var(--info);
    --sidebar-bg: var(--brand-primary-deep);
    --sidebar-active: rgba(98, 184, 63, 0.22);
    --header-bg: var(--surface-primary);
    --table-header-bg: var(--brand-primary-soft);
    --card-shadow: var(--shadow-sm);

    --careplus-green: var(--brand-primary);
    --careplus-green-light: var(--brand-primary-hover);
    --careplus-green-lighter: var(--brand-secondary);
    --careplus-blue: var(--brand-primary);
    --careplus-blue-dark: var(--brand-primary-hover);
    --careplus-blue-light: var(--brand-secondary);
    --careplus-white: var(--surface-primary);
    --careplus-gray: var(--text-muted);
    --careplus-gray-light: var(--background-app);

    --surface-1: var(--surface-primary);
    --surface-2: var(--surface-secondary);
    --surface-3: var(--background-app);

    --text-heading-weight: 600;
    --text-body-weight: 400;
    --text-medium-weight: 500;

    /* Existing px spacing (keep — many layouts depend on these) */
    --space-1: 8px;
    --space-2: 12px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    --radius-card: var(--radius-md);
    --shadow-card: var(--shadow-sm);
    --shadow-card-hover: var(--shadow-md);
    --transition-base: var(--transition-normal);

    --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Brand logo helper */
.brand-logo {
    width: auto;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}
.brand-logo--sidebar {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
}
.brand-logo--login {
    max-width: 160px;
    max-height: 160px;
    margin: 0 auto 16px;
    background: #fff;
    border-radius: 12px;
    padding: 8px;
}
.brand-logo--receipt {
    max-width: 72px;
    max-height: 48px;
    margin: 0 auto 4px;
}

/* --------------------------------------------------------------------------
   GLOBAL SEARCH MODAL (Ctrl/Cmd + K)
   -------------------------------------------------------------------------- */
.gs-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 16px 24px 16px;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9999;
}

.gs-modal {
    width: min(760px, 96vw);
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.gs-top {
    padding: 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
}

.gs-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    outline: none;
}
.gs-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.gs-results {
    max-height: 52vh;
    overflow: auto;
    padding: 10px;
    background: #ffffff;
}

.gs-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    padding: 10px 10px 6px 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.gs-item {
    padding: 10px 10px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}
.gs-item:hover,
.gs-item.active {
    background: #f3f4f6;
}

.gs-title {
    font-weight: 700;
    color: #111827;
}
.gs-sub {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.gs-empty {
    padding: 18px 12px;
    color: #6b7280;
    text-align: center;
}

.gs-footer {
    padding: 10px 14px 14px 14px;
    border-top: 1px solid #e5e7eb;
    color: #6b7280;
    font-size: 12px;
    background: #ffffff;
}

.kbd {
    display: inline-block;
    min-width: 18px;
    text-align: center;
    padding: 2px 6px;
    margin: 0 3px;
    border: 1px solid #d1d5db;
    border-bottom-width: 2px;
    border-radius: 6px;
    background: #f9fafb;
    color: #111827;
    font-weight: 700;
    font-size: 11px;
    line-height: 16px;
}

/* --------------------------------------------------------------------------
   OFFLINE / SYNC STATUS BADGE
   -------------------------------------------------------------------------- */
.sync-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    margin-right: 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: #ecfdf5;
    color: #166534;
    border: 1px solid #a7f3d0;
    min-width: 70px;
    text-transform: uppercase;
}

.sync-status-badge.is-offline {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.sync-status-badge.is-syncing {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.sync-status-badge.has-pending {
    background: #fffbeb;
    color: #92400e;
    border-color: #fcd34d;
}

.sync-status-badge.is-ok {
    background: #ecfdf5;
    color: #166534;
    border-color: #a7f3d0;
}

/* --------------------------------------------------------------------------
   GLOBAL
   -------------------------------------------------------------------------- */
html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans, Inter, ui-sans-serif, system-ui, sans-serif);
    background: var(--background-app, var(--surface-3));
    color: var(--text-primary, #17251e);
    overflow-x: hidden;
    line-height: 1.55;
}

/* --------------------------------------------------------------------------
   SIDEBAR
   -------------------------------------------------------------------------- */
.sidebar {
    width: 240px;
    height: 100vh;
    background: var(--sidebar-bg);
    color: #f5faf7;
    position: fixed;
    top: 0;
    left: 0;
    padding: var(--space-3) var(--space-3) var(--space-5) var(--space-3);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base);
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    overflow-anchor: none;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.sidebar.collapsed {
    width: 64px;
    padding: var(--space-3) var(--space-1);
    min-width: 64px;
}

.sidebar.collapsed .sidebar-logo-section {
    justify-content: center;
    padding-bottom: var(--space-2);
}

.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .sidebar-menu h4,
.sidebar.collapsed .sidebar-menu a span,
.sidebar.collapsed .chevron-icon,
.sidebar.collapsed .submenu {
    display: none !important;
}

.sidebar.collapsed .sidebar-menu a {
    justify-content: center;
    padding: var(--space-2);
}

.sidebar.collapsed .sidebar-menu .has-submenu > a {
    padding: var(--space-2);
}

.sidebar.collapsed .menu-icon {
    margin: 0;
}

.sidebar.collapsed .sidebar-menu [data-tooltip] {
    position: relative;
}

.sidebar.collapsed .sidebar-menu [data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: var(--space-2);
    padding: 6px 10px;
    background: #1f2937;
    color: white;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
    pointer-events: none;
    z-index: 1002;
}

.sidebar.collapsed .sidebar-menu [data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

.sidebar.collapsed .sidebar-menu [data-tooltip].active::after {
    background: var(--careplus-green);
}

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

.sidebar-toggle {
    position: fixed;
    top: var(--space-4);
    left: 240px;
    width: 35px;
    height: 35px;
    background: var(--surface-1);
    border: 1px solid #e5e7eb;
    border-left: none;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: left var(--transition-base);
    z-index: 1001;
}

.sidebar-toggle:hover {
    background: var(--surface-2);
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
    stroke: #6b7280;
    stroke-width: 2;
    transition: transform 0.3s ease;
}

.sidebar-toggle.collapsed {
    left: 64px;
}

.sidebar-toggle.collapsed svg {
    transform: rotate(180deg);
}

/* Sidebar overlay backdrop (used on mobile when sidebar is open) */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    display: none;
    animation: sidebarBackdropFade 0.2s ease;
}

@keyframes sidebarBackdropFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.sidebar-logo-section {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    padding: 4px;
}

.sidebar-logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.sidebar-logo-text {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    letter-spacing: 0.02em;
}

.sidebar-search {
    position: relative;
    margin-bottom: var(--space-4);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 36px 10px 36px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: var(--text-medium-weight);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    transition: all var(--transition-base);
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: var(--brand-secondary);
    background: rgba(255, 255, 255, 0.14);
    box-shadow: 0 0 0 3px var(--focus-ring);
    color: #ffffff;
}

.search-input::placeholder {
    color: rgba(245, 250, 247, 0.55);
}

.search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: transparent;
    color: #9ca3af;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-base), background var(--transition-base);
}

.search-clear:hover {
    color: #6b7280;
    background: var(--surface-3);
}

.sidebar.collapsed .search-clear {
    display: none;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-footer-link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    color: #fca5a5;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.sidebar-footer-link:hover {
    background: rgba(165, 16, 8, 0.22);
    color: #ffffff;
}

.sidebar.collapsed .sidebar-footer-link span {
    display: none;
}

.sidebar.collapsed .sidebar-footer-link {
    justify-content: center;
}

.sidebar.collapsed .sidebar-menu [data-tooltip],
.sidebar.collapsed .sidebar-footer-link[data-tooltip] {
    position: relative;
}

.sidebar.collapsed .sidebar-footer-link[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: var(--space-2);
    padding: 6px 10px;
    background: #1f2937;
    color: white;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
    pointer-events: none;
    z-index: 1002;
}

.sidebar.collapsed .sidebar-footer-link[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li {
    margin: 4px 0;
}

.sidebar-menu a {
    color: rgba(245, 250, 247, 0.78);
    text-decoration: none;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 10px var(--space-2);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    font-weight: var(--text-medium-weight);
    position: relative;
}

.sidebar-menu a:hover {
    background: rgba(98, 184, 63, 0.16);
    color: #ffffff;
}

.sidebar-menu a.active {
    background: var(--sidebar-active);
    color: #ffffff;
    font-weight: var(--text-heading-weight);
    border-left: 3px solid var(--brand-secondary);
    margin-left: 0;
    padding-left: calc(var(--space-2) - 3px);
}

.sidebar-menu a.active .menu-icon {
    color: var(--brand-secondary);
}

.sidebar-menu a.active .chevron-icon {
    color: var(--brand-secondary);
}

.sidebar-menu .submenu a.active {
    border-left: none;
    padding-left: 40px;
    background: rgba(98, 184, 63, 0.12);
}

.menu-icon {
    width: 18px;
    height: 18px;
    color: rgba(245, 250, 247, 0.7);
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.sidebar-menu a.active .menu-icon {
    color: var(--brand-secondary);
}

.chevron-icon {
    width: 12px;
    height: 12px;
    color: #9ca3af;
    margin-left: auto;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.sidebar-menu a span {
    flex: 1;
}

.sidebar-menu h4 {
    margin-top: var(--space-5);
    margin-bottom: var(--space-1);
    font-size: 10px;
    letter-spacing: 1.2px;
    color: rgba(245, 250, 247, 0.45);
    text-transform: uppercase;
    font-weight: var(--text-heading-weight);
    padding: 0 var(--space-2);
}

.sidebar-menu h4:first-child {
    margin-top: 0;
}

/* SUBMENU STYLES */
.sidebar-menu .has-submenu {
    position: relative;
}

.sidebar-menu .submenu {
    list-style: none;
    padding: 0;
    margin: 4px 0 0 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-menu .has-submenu.active .submenu {
    max-height: 500px;
}

/* Skip animation when programmatically opening for scroll-into-view */
.sidebar-menu .has-submenu.sidebar-expand-instant .submenu {
    transition: none !important;
}

.sidebar-menu .submenu li {
    margin: 2px 0;
}

.sidebar-menu .submenu a {
    padding: 8px var(--space-2) 8px 40px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.sidebar-menu .submenu-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--careplus-green);
    flex-shrink: 0;
}

.sidebar-menu .submenu a.active .submenu-dot {
    background: var(--careplus-green);
    box-shadow: 0 0 0 2px rgba(0, 85, 47, 0.2);
}

.sidebar-menu .submenu-toggle {
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.sidebar-menu .submenu-toggle:hover {
    text-decoration: none;
}

.sidebar-menu .has-submenu.active .submenu-toggle .chevron-icon {
    transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   MAIN CONTENT
   -------------------------------------------------------------------------- */
.main-content {
    margin-left: 240px;
    padding: var(--space-4) var(--space-4) var(--space-4) 60px;
    background: var(--surface-3);
    min-height: 100vh;
    transition: margin-left var(--transition-base), width var(--transition-base), padding var(--transition-base);
    width: calc(100% - 240px);
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    max-width: 100%;
    overflow-x: hidden;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 64px;
    width: calc(100% - 64px);
    padding: var(--space-4);
}

.sidebar.collapsed ~ .sidebar-toggle {
    left: 64px;
}

/* --------------------------------------------------------------------------
   HEADER
   -------------------------------------------------------------------------- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-1);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-card);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-card);
    max-width: 100%;
    box-sizing: border-box;
    gap: var(--space-4);
}

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

.header-menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.header-menu-toggle:hover {
    background: var(--surface-2);
    color: var(--careplus-green);
}

.header-menu-toggle:focus-visible {
    outline: 2px solid var(--careplus-green);
    outline-offset: 2px;
}

.language-selector {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: var(--text-medium-weight);
}

.language-selector:hover {
    background: var(--surface-2);
}

.language-selector:focus-visible {
    outline: 2px solid var(--careplus-green);
    outline-offset: 2px;
}

.flag-icon {
    font-size: 18px;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.pos-button {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    background: var(--brand-primary);
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: var(--text-heading-weight);
    font-size: 14px;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm), 0 2px 8px rgba(0, 85, 47, 0.22);
}

.pos-button:hover {
    background: var(--brand-primary-dark);
    box-shadow: var(--shadow-card), 0 4px 12px rgba(0, 85, 47, 0.3);
}

.pos-button:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

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

.header-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    position: relative;
}

.header-icon-btn:hover {
    background: var(--surface-2);
    color: var(--careplus-green);
}

.header-icon-btn:focus-visible {
    outline: 2px solid var(--careplus-green);
    outline-offset: 2px;
}

.notification-btn {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #dc2626;
    color: white;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.4);
    z-index: 10;
    line-height: 1;
    transform: translate(50%, -50%);
}

.notification-badge.has-alerts {
    display: flex;
    animation: pulse 2s infinite;
}

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

/* For numbers 10+ make it wider */
.notification-badge:has-text {
    min-width: 20px;
    border-radius: 9px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    margin-left: var(--space-2);
    position: relative;
    border: 1px solid transparent;
}

.user-profile:hover {
    background: var(--surface-2);
}

.user-profile:focus-visible {
    outline: 2px solid var(--careplus-green);
    outline-offset: 2px;
}

.user-profile.active {
    background: var(--surface-3);
}

.user-profile.active .dropdown-arrow {
    transform: rotate(180deg);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-name {
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
}

.dropdown-arrow {
    transition: transform 0.2s ease;
}

/* USER DROPDOWN MENU */
.user-dropdown {
    position: absolute;
    top: calc(100% + var(--space-1));
    right: 0;
    background: var(--surface-1);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card-hover);
    min-width: 240px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-base);
    z-index: 10000;
    overflow: hidden;
    pointer-events: none;
}

.user-profile.active .user-dropdown {
    pointer-events: auto;
}

.user-profile.active .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: var(--space-3);
    background: var(--surface-2);
    border-bottom: 1px solid #e5e7eb;
}

.dropdown-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dropdown-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.dropdown-name {
    font-size: 15px;
    font-weight: var(--text-heading-weight);
    color: #1f2937;
    margin-bottom: 2px;
}

.dropdown-email {
    font-size: 13px;
    color: var(--text-muted);
}

.dropdown-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 8px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    font-weight: var(--text-medium-weight);
    transition: all var(--transition-base);
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--surface-3);
    color: var(--careplus-green);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    color: #6b7280;
    transition: color 0.2s ease;
}

.dropdown-item:hover svg {
    color: #00552F;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.date {
    color: var(--careplus-gray);
    font-size: 14px;
}

.user-icon {
    width: 35px;
    border-radius: 50%;
}

/* --------------------------------------------------------------------------
   DASHBOARD CONTENT
   -------------------------------------------------------------------------- */
.dashboard-content {
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.dashboard-content h2 {
    color: var(--careplus-green);
    margin-bottom: var(--space-2);
    font-weight: var(--text-heading-weight);
    word-wrap: break-word;
}

/* SPA Loading state — overlay and skeleton polish */
.spa-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    position: relative;
    background: rgba(255, 255, 255, 0.85);
    border-radius: var(--radius-card);
    transition: opacity var(--transition-base);
}

.spa-loader-inner {
    text-align: center;
    z-index: 1;
}

.spa-loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--surface-3);
    border-top-color: var(--careplus-green);
    border-radius: 50%;
    animation: spa-spin 0.8s linear infinite;
    margin: 0 auto var(--space-2);
}

.spa-loader-text {
    font-size: 14px;
    color: var(--text-muted);
}

/* Optional skeleton placeholders (use class spa-skeleton on empty blocks during load) */
.spa-skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.2s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

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

@keyframes skeleton-pulse {
    0%, 100% { background-position: 200% 0; }
    50% { background-position: -200% 0; }
}

/* --------------------------------------------------------------------------
   BUTTONS
   -------------------------------------------------------------------------- */
.btn-primary {
    background: var(--brand-primary);
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 14px;
    font-weight: var(--text-medium-weight);
    transition: all var(--transition-base);
    border: none;
    cursor: pointer;
    display: inline-block;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 85, 47, 0.25);
}

.btn-secondary {
    background: var(--brand-secondary);
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 14px;
    font-weight: var(--text-medium-weight);
    transition: all var(--transition-base);
    border: none;
    cursor: pointer;
    display: inline-block;
}

.btn-secondary:hover {
    background: var(--brand-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 85, 47, 0.25);
}

.btn-light {
    background: #f3f4f6;
    color: #374151;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    border: 1px solid #e5e7eb;
    font-size: 14px;
    cursor: pointer;
}
.btn-light:hover {
    background: #e5e7eb;
}

/* --------------------------------------------------------------------------
   CARDS & CONTAINERS
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface-1);
    padding: var(--space-4);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    transition: all var(--transition-base);
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

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

.card-title {
    color: var(--careplus-green);
    font-size: 14px;
    text-transform: uppercase;
    font-weight: var(--text-heading-weight);
    margin: 0 0 var(--space-2) 0;
    letter-spacing: 0.5px;
}

.card-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--careplus-blue);
    margin: 0;
}

.card-subtitle {
    color: var(--text-muted);
    font-size: 12px;
    margin: var(--space-1) 0 0 0;
}

/* STATS CARDS */
.stat-card {
    background: var(--surface-1);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border-top: 2px solid var(--careplus-blue);
    transition: all var(--transition-base);
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    word-wrap: break-word;
}

.stat-card:hover {
    box-shadow: var(--shadow-card);
    transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   TABLE CARD & LIST PAGES
   -------------------------------------------------------------------------- */
.table-card,
.table-container {
    background: var(--surface-1);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    padding: 0;
}

.table-card .table-scroll-wrapper,
.table-container .table-scroll-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: min(70vh, 600px);
}

.table-card table,
.table-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table-card th,
.table-card td,
.table-container th,
.table-container td {
    padding: var(--space-2) var(--space-3);
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.table-card thead th,
.table-container thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-2);
    font-weight: var(--text-heading-weight);
    color: var(--careplus-green);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-card tbody tr:nth-child(even),
.table-container tbody tr:nth-child(even) {
    background: rgba(249, 250, 251, 0.6);
}

.table-card tbody tr:hover,
.table-container tbody tr:hover {
    background: var(--surface-2);
}

.table-card .table-card-header,
.table-container .table-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid #e5e7eb;
    background: var(--surface-1);
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid #e5e7eb;
}

.pill {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.pill--queued { background: #ffe8a1; color: #6b4e00; }
.pill--syncing { background: #cfe8ff; color: #004a7c; }
.pill--failed { background: #ffd6d6; color: #7c0000; }

.badge {
    background: #1e8f4d;
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
}

.muted {
    color: var(--text-muted, #6b7280);
    font-size: 14px;
}

/* Empty state component */
.empty-state {
    text-align: center;
    padding: var(--space-5);
    color: var(--text-muted);
}

.empty-state-icon {
    margin-bottom: var(--space-3);
}

.empty-state-icon svg {
    width: 64px;
    height: 64px;
    color: #d1d5db;
}

.empty-state-title {
    font-size: 16px;
    font-weight: var(--text-heading-weight);
    color: #374151;
    margin: 0 0 var(--space-1) 0;
}

.empty-state-text {
    font-size: 14px;
    margin: 0 0 var(--space-3) 0;
}

.empty-state .btn-primary {
    margin-top: var(--space-1);
}

/* Empty state inside table cell */
td.empty-state-cell {
    padding: var(--space-5) !important;
    vertical-align: middle;
}

td.empty-state-cell .empty-state {
    padding: 0;
}

/* Table action buttons - compact */
.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

.table-actions .btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid #e5e7eb;
    background: var(--surface-1);
    color: var(--text-muted);
    transition: all var(--transition-base);
}

.table-actions .btn-icon:hover {
    background: var(--surface-2);
    color: var(--careplus-green);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.page-header h2 {
    margin: 0;
    color: var(--careplus-green);
}

/* --------------------------------------------------------------------------
   INPUT FIELDS
   -------------------------------------------------------------------------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm);
    padding: 10px var(--space-2);
    font-size: 14px;
    line-height: 1.55;
    transition: all var(--transition-base);
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--careplus-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* LINKS */
a {
    color: var(--careplus-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--careplus-blue-dark);
}

/* FORM CONTROLS */
.form-control {
    width: 100%;
    padding: 10px var(--space-2);
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.55;
    transition: all var(--transition-base);
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--careplus-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Form UX - labels, required, sections */
.form-group {
    margin-bottom: var(--space-4);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-1);
    color: var(--careplus-green);
    font-weight: var(--text-medium-weight);
    font-size: 14px;
}

.form-group label .required {
    color: #ef4444;
}

.form-section {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid #e5e7eb;
}

.form-section-title {
    font-size: 14px;
    font-weight: var(--text-heading-weight);
    color: var(--careplus-green);
    margin: 0 0 var(--space-3) 0;
}

.form-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* Sticky form action bar */
.form-actions-sticky {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3) 0;
    margin-top: var(--space-4);
    background: var(--surface-1);
    border-top: 1px solid #e5e7eb;
}

/* Validation styling hooks (visual only) */
.field-error {
    color: #ef4444;
    font-size: 12px;
    margin-top: var(--space-1);
}

.field-hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: var(--space-1);
}

.form-control.field-error-input {
    border-color: #ef4444;
}

.form-container {
    background: var(--surface-1);
    border-radius: var(--radius-card);
    padding: var(--space-4);
    box-shadow: var(--shadow-card);
    max-width: 100%;
}

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

/* Tablet: <= 1024px */
@media (max-width: 1024px) {
    .main-content {
        padding: var(--space-3) var(--space-3) var(--space-3) 24px;
    }

    .table-card .table-card-header,
    .table-container .table-card-header {
        padding: var(--space-2) var(--space-3);
    }

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

    .header {
        padding: var(--space-2) var(--space-3);
        gap: var(--space-2);
    }
}

/* Small tablet / large phone: <= 768px — sidebar off-canvas */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: 260px;
        padding: var(--space-3);
    }

    .sidebar.collapsed .sidebar-logo-text,
    .sidebar.collapsed .sidebar-search,
    .sidebar.collapsed .sidebar-menu h4,
    .sidebar.collapsed .sidebar-menu a span,
    .sidebar.collapsed .chevron-icon,
    .sidebar.collapsed .submenu {
        display: block !important;
    }

    .sidebar.collapsed .sidebar-menu a {
        justify-content: flex-start;
        padding: 10px var(--space-2);
    }

    .sidebar.collapsed .sidebar-menu .has-submenu > a {
        padding: 10px var(--space-2);
    }

    .sidebar.collapsed .menu-icon {
        margin-right: var(--space-2);
    }

    .sidebar.collapsed .sidebar-menu [data-tooltip]::after,
    .sidebar.collapsed .sidebar-footer-link[data-tooltip]::after {
        display: none;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: var(--space-3) var(--space-3) var(--space-3) var(--space-3);
    }

    .sidebar-toggle {
        left: 0;
        border-radius: 0 var(--radius-md) var(--radius-md) 0;
    }

    .sidebar.collapsed ~ .sidebar-toggle {
        left: 0;
    }

    .sidebar.collapsed ~ .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

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

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

    .header-left,
    .header-center,
    .header-right {
        flex: 0 1 auto;
    }
}

/* Phones: <= 480px */
@media (max-width: 480px) {
    .main-content {
        padding: var(--space-2) var(--space-2) var(--space-3);
    }

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

    .table-card .table-card-header,
    .table-container .table-card-header {
        padding: var(--space-2) var(--space-2);
    }

    .table-card th,
    .table-card td,
    .table-container th,
    .table-container td {
        padding: var(--space-1) var(--space-2);
    }

    .form-actions-sticky,
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions-sticky .btn-primary,
    .form-actions-sticky .btn-secondary,
    .form-actions-sticky a.btn-primary,
    .form-actions-sticky a.btn-secondary,
    .page-header .btn-primary,
    .page-header .btn-secondary,
    .page-header a.btn-primary,
    .page-header a.btn-secondary {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

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

/* ==========================================================================
   ACCESSIBILITY: FOCUS & TAP TARGETS
   ========================================================================== */

/* Consistent :focus-visible (do not remove outlines) */
.sidebar-menu a:focus-visible,
.sidebar-footer-link:focus-visible {
    outline: 2px solid var(--careplus-green);
    outline-offset: 2px;
}

.header-icon-btn:focus-visible,
.header-menu-toggle:focus-visible,
.pos-button:focus-visible {
    outline: 2px solid var(--careplus-green);
    outline-offset: 2px;
}

.table-actions .btn-icon:focus-visible,
.table-actions button:focus-visible,
.table-actions a:focus-visible,
.action-buttons .btn-edit:focus-visible,
.action-buttons .btn-delete:focus-visible {
    outline: 2px solid var(--careplus-green);
    outline-offset: 2px;
}

input[type="text"]:focus-visible,
input[type="email"]:focus-visible,
input[type="password"]:focus-visible,
input[type="number"]:focus-visible,
input[type="date"]:focus-visible,
select:focus-visible,
textarea:focus-visible,
.form-control:focus-visible,
.search-input:focus-visible {
    outline: 2px solid var(--careplus-blue);
    outline-offset: 0;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.search-clear:focus-visible {
    outline: 2px solid var(--careplus-green);
    outline-offset: 2px;
}

/* Tap targets: key buttons >= 44px on touch devices */
@media (max-width: 768px) {
    .header-menu-toggle,
    .header-icon-btn {
        min-width: 44px;
        min-height: 44px;
        padding: var(--space-2);
    }

    .sidebar-toggle {
        min-width: 44px;
        min-height: 44px;
    }

    .table-actions .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }

    .sidebar-menu a {
        min-height: 44px;
        padding: 12px var(--space-2);
    }

    .sidebar-footer-link {
        min-height: 44px;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */
@media print {
    html, body {
        background: #fff;
        color: #000;
    }

    .sidebar,
    .sidebar-toggle,
    .sidebar-backdrop,
    .header,
    .pos-button,
    .header-icon-btn,
    .header-menu-toggle,
    .user-profile,
    .language-selector,
    .btn-primary,
    .btn-secondary,
    .table-actions,
    .action-buttons,
    .form-actions-sticky,
    .page-header .btn-primary,
    .page-header .btn-secondary,
    .page-header a[href*="create"],
    .page-header a[href*="add"],
    .empty-state .btn-primary,
    .card .btn-primary,
    .card .btn-secondary,
    nav,
    [role="navigation"] {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 0 !important;
        background: #fff !important;
    }

    .dashboard-content {
        padding: 0;
    }

    .card,
    .table-card,
    .table-container {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .table-card .table-scroll-wrapper,
    .table-container .table-scroll-wrapper {
        overflow: visible;
        max-height: none;
    }

    .table-card table,
    .table-container table {
        font-size: 12px;
    }

    .table-card th,
    .table-card td,
    .table-container th,
    .table-container td {
        padding: 6px 8px;
        border: 1px solid #ddd;
    }

    .table-card thead th,
    .table-container thead th {
        background: #f5f5f5;
        color: #000;
    }

    a[href]::after {
        content: none;
    }

    .page-header h2 {
        color: #000;
    }

    .card-title {
        color: #000;
    }
}

/* Report filters sticky (desktop) */
@media (min-width: 1024px) {
    .report-filters-sticky { position: sticky; top: 0; z-index: 5; background: var(--surface-1, #fff); padding: 12px 0; margin: -12px 0 16px 0; border-bottom: 1px solid #e5e7eb; box-shadow: 0 1px 0 rgba(0,0,0,0.04); }
}

/* Report table loading skeleton */
.report-table-skeleton { padding: 24px; text-align: center; color: var(--text-muted, #6b7280); }
.report-table-skeleton .skeleton-row { height: 40px; background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%); background-size: 200% 100%; animation: report-skeleton 1s ease-in-out infinite; margin-bottom: 8px; border-radius: 4px; }
@keyframes report-skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Report table pager */
.report-pager { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 12px; padding: 8px 0; }
.report-pager .pager-info { color: var(--text-muted, #6b7280); font-size: 13px; }
.report-pager select { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; }
.report-pager button { padding: 6px 12px; border: 1px solid #d1d5db; background: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; }
.report-pager button:hover:not(:disabled) { background: #f3f4f6; }
.report-pager button:disabled { opacity: 0.5; cursor: not-allowed; }
.report-pager button:focus-visible { outline: 2px solid var(--careplus-green, #00552F); outline-offset: 2px; }
