/* ========================================
   GLOBAL SCROLLBAR & SELECTION
   ======================================== */

/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--neutral-100);
}

::-webkit-scrollbar-thumb {
    background: var(--neutral-300);
    border-radius: 10px;
    border: 2px solid var(--neutral-100);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-400);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--neutral-300) var(--neutral-100);
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

::selection {
    background: var(--primary-100);
    color: var(--primary-900);
}


/* Modern Color System - CSS Custom Properties */
:root {
    /* Primary Brand Blues - Organization Colors */
    --primary-50: #f1f6fb;
    --primary-100: #dceaf5;
    --primary-200: #bad4e8;
    --primary-300: #89b3d1;
    --primary-400: #4f86ad;
    --primary-500: #173863;
    /* Main Brand Blue */
    --primary-600: #173863;
    --primary-700: #123154;
    --primary-800: #0d2745;
    --primary-900: #081d34;
    --shopmaster-orange: #f89820;

    /* Neutral Colors - Professional Whites & Grays */
    --neutral-50: #ffffff;
    --neutral-100: #f8fafc;
    --neutral-200: #f1f5f9;
    --neutral-300: #e2e8f0;
    --neutral-400: #94a3b8;
    --neutral-500: #64748b;
    --neutral-600: #475569;
    --neutral-700: #334155;
    --neutral-800: #1e293b;
    --neutral-900: #0f172a;


    /* Glassmorphic Effects */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px 0 rgba(26, 56, 98, 0.07);


    /* Success Colors */
    --success-50: #f0fdf4;
    --success-100: #dcfce7;
    --success-500: #22c55e;
    --success-600: #16a34a;
    --success-700: #15803d;

    /* Warning Colors */
    --warning-50: #fffbeb;
    --warning-100: #fef3c7;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --warning-700: #b45309;

    /* Error/Danger Colors */
    --error-50: #fef2f2;
    --error-100: #fee2e2;
    --error-500: #ef4444;
    --error-600: #dc2626;
    --error-700: #b91c1c;

    /* Semantic Colors */
    --background: var(--neutral-100);
    --surface: #ffffff;
    --text-primary: var(--neutral-900);
    --text-secondary: var(--neutral-600);
    --text-tertiary: var(--neutral-500);
    --border: var(--neutral-300);
    --border-light: var(--neutral-200);

    /* Names some rules and templates use without a fallback; without these
       their borders, hover fills and text colours drop out. */
    --primary: #2563eb;
    --hover-bg: #f1f5f9;
    --success: #15803d;
    --warning: #b45309;
    --danger: #b91c1c;
    --error-200: #fecaca;
    --error-300: #fca5a5;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}


/* Screen Management */
.screen {
    display: none;
}

.screen.active {
    display: flex;
}

/* Login Screen - 50/50 Split */
#loginScreen.active {
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

.login-split-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Left Side - Elite Blue Branding */
.login-branding {
    flex: 1;
    background: linear-gradient(135deg, #102A43 0%, #1A3862 100%);
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    position: relative;
    overflow: hidden;
}


.login-branding::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -20%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.branding-content {
    width: 100%;
    max-width: 480px;
    text-align: center;
    z-index: 1;
}


.branding-content h1 {
    font-size: 42px;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: 0;
    line-height: 1;
    color: #ffffff;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.branding-subtitle {
    font-size: 17px;
    font-weight: 500;
    opacity: 0.9;
    line-height: 1.4;
    margin-bottom: 32px;
    color: #ffffff;
}

.branding-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.feature-item {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}


.feature-item:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateX(10px) translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.feature-text strong {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 3px;
    letter-spacing: 0;
}

.feature-text span {
    font-size: 13.5px;
    opacity: 0.85;
    color: #ffffff;
    line-height: 1.4;
    font-weight: 400;
}




/* Right Side - White Login Form */
.login-form-section {
    flex: 1;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 40px;
    position: relative;
    overflow-y: hidden;
}


/* Restored & Scaled Brand Logo */
.login-logo-top {
    position: absolute;
    top: 30px;
    right: 30px;
    z-index: 10;
}

.login-logo-top img {
    width: 220px;
    max-width: min(220px, 32vw);
    height: auto;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.95;
}

.login-logo-top img.lefori-mark-logo {
    width: 112px;
    max-width: min(112px, 28vw);
    border-radius: 50%;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
}

.login-logo-top img:hover {
    transform: scale(1.05);
    opacity: 1;
}



.login-form-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-form-wrapper h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-600);
    margin-bottom: 12px;
    letter-spacing: 0;
    text-align: center;
}

.reset-progress {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    align-items: stretch;
    width: 100%;
    margin-bottom: 24px;
    padding: 4px;
    background: var(--neutral-100);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.reset-progress span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 36px;
    padding: 7px 5px;
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    overflow-wrap: anywhere;
}

.reset-progress span.is-active {
    background: var(--primary-600);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

.reset-progress span.is-complete {
    color: var(--primary-600);
}



.login-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: left;
}

.login-form .form-group label {
    font-size: 12px;
    font-weight: 500;
    color: #334155;
    margin-bottom: 1px;
}

.login-form .form-group small {
    font-size: 10px;
    margin-top: 1px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--neutral-50);
    color: var(--neutral-900);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-500);
    background: #ffffff;
    box-shadow: 0 0 0 4px var(--primary-50);
}


.login-form input::placeholder {
    color: #64748b;
}

.btn-login {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #ffab2d 0%, #f7941d 100%);
    color: #102A43;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 6px;
    box-shadow: 0 4px 12px rgba(247, 148, 29, 0.24);
}


.btn-login:hover {
    background: linear-gradient(135deg, #ffb642 0%, #f79f31 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(247, 148, 29, 0.25);
}


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

/* Registration Screen Optimizations */
#registrationScreen .login-form-section {
    padding: 60px 40px;
    align-items: flex-start;
    overflow-y: hidden;
}

#registrationScreen .login-form-wrapper {
    max-width: 650px;
}

#registrationScreen .login-form-wrapper h2 {
    margin-bottom: 25px;
    font-size: 30px;
}

.registration-grid-container {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 15px 25px !important;
}

.registration-grid-container .full-width {
    grid-column: span 2;
    margin-top: 10px;
}

#registrationScreen .login-form .form-group {
    gap: 6px;
}

#registrationScreen .login-form label {
    font-size: 13px;
    font-weight: 600;
}

#registrationScreen .login-form input {
    padding: 12px 16px;
    font-size: 14px;
}

/* Mobile Responsive Login */
@media (max-width: 768px) {
    .login-split-container {
        flex-direction: column;
    }

    .login-branding {
        padding: 30px 20px;
        min-height: 40vh;
    }

    .branding-content h1 {
        font-size: 28px;
    }

    .branding-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .branding-features {
        gap: 10px;
    }

    .feature-item {
        padding: 12px 16px;
    }

    .feature-text strong {
        font-size: 14px;
    }

    .feature-text span {
        font-size: 12px;
    }

    .login-form-section {
        padding: 30px 20px;
    }

    .login-logo-top {
        top: 20px;
        right: 20px;
    }

    .login-logo-top img {
        max-width: 120px;
    }

    .login-form-wrapper h2 {
        font-size: 28px;
        margin-bottom: 24px;
    }

    /* Enable scrolling on login screen for mobile */
    #loginScreen.active,
    #registrationScreen.active,
    #forgotPasswordScreen.active {
        overflow-y: auto !important;
        height: auto !important;
        display: block !important;
        /* Allow normal block flow for scrolling */
    }

    .login-split-container {
        height: auto !important;
        /* Allow container to grow */
        min-height: 100vh;
    }

    .login-form-section {
        padding: 30px 20px;
        overflow-y: visible !important;
        /* Allow content to overflow/scroll within parent */
        height: auto !important;
    }

    /* Force registration to single column on mobile */
    .registration-grid-container {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .registration-grid-container .full-width {
        grid-column: auto !important;
    }

    .reset-progress {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        padding: 6px;
    }
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

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

.login-form button:active {
    transform: translateY(0);
}

.demo-credentials {
    margin-top: 24px;
    padding: 16px;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 13px;
    border-left: 3px solid #1A3862;
}

.demo-credentials p {
    margin: 6px 0;
    color: #475569;
}

.demo-credentials strong {
    color: #1e293b;
}

/* Premium Loader Styles */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loader-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--primary-100);
    border-top-color: var(--primary-600);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loader-text {
    font-family: inherit;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-900);
    letter-spacing: 0;
    animation: pulse 2s ease-in-out infinite;
}

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

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* Skeleton Screens & Shimmer */
@keyframes shimmer {
    0% {
        background-position: -468px 0;
    }

    100% {
        background-position: 468px 0;
    }
}

.skeleton {
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 800px 104px;
    display: inline-block;
    position: relative;
    animation: shimmer 1.2s linear infinite forwards;
    border-radius: 4px;
}

.skeleton-card {
    height: 120px;
    width: 100%;
    border-radius: 16px;
    margin-bottom: 20px;
}

.skeleton-row {
    height: 50px;
    width: 100%;
    border-radius: 8px;
    margin-bottom: 12px;
}

.skeleton-text {
    height: 14px;
    width: 70%;
    margin-bottom: 8px;
    border-radius: 2px;
}

/* Staggered Entry Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

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

.fade-in-up {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.stagger-1 {
    animation-delay: 0.05s;
}

.stagger-2 {
    animation-delay: 0.1s;
}

.stagger-3 {
    animation-delay: 0.15s;
}

.stagger-4 {
    animation-delay: 0.2s;
}

.stagger-5 {
    animation-delay: 0.25s;
}


/* Micro-animations & Glassmorphism */
.sidebar {
    backdrop-filter: blur(10px);
    background: var(--glass-bg);
    border-right: 1px solid var(--glass-border);
}

.metric-card {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: var(--shadow-xl);
}

.nav-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn:hover {
    transform: translateX(4px);
}

.btn-primary,
.btn-login {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn-primary:active,
.btn-login:active {
    transform: scale(0.98);
}


.error-message {
    color: #c0392b;
    margin-top: 10px;
    font-size: 14px;
}

/* Main App Layout */
#mainApp {
    display: none;
    height: 100vh;
}

#mainApp.active {
    display: flex;
}

/* ========================================
/* ========================================
   SIDEBAR NAVIGATION - Premium Dark Design
   ======================================== */

/* Sidebar Container */
.sidebar {
    width: 260px;
    background: #ffffff;
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
}


/* Brand Header */
.nav-brand {
    padding: 26px 20px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-light);
    text-align: center;
    background: linear-gradient(180deg, rgba(240, 247, 255, 0.9) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.sidebar-logo {
    height: 32px;
    width: auto;
}

.sidebar-brand-app {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary-500);
    letter-spacing: 0;
    margin: 0;
    line-height: 1.2;
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-800) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-brand-logo-shell {
    width: 126px;
    height: 126px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.sidebar-brand-logo {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
    border-radius: 999px;
}

.sidebar-brand-logo-fallback {
    width: 100%;
    height: 100%;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: var(--primary-600);
    font-size: 40px;
    font-weight: 800;
    letter-spacing: 0;
}

@media (max-width: 768px) {
    .nav-brand {
        padding: 22px 18px 18px;
        gap: 10px;
    }

    .sidebar-brand-logo-shell {
        width: 104px;
        height: 104px;
        border-radius: 999px;
    }

    .sidebar-brand-logo,
    .sidebar-brand-logo-fallback {
        width: 100%;
        height: 100%;
    }

    .sidebar-brand-logo-fallback {
        font-size: 34px;
    }
}


/* Navigation Menu */
.nav-menu {
    display: flex;
    flex-direction: column;
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    gap: 4px;
}

/* Scrollbar styling for sidebar */
.nav-menu::-webkit-scrollbar {
    width: 4px;
}

.nav-menu::-webkit-scrollbar-track {
    background: transparent;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: var(--neutral-200);
    border-radius: 2px;
}

/* Section Labels */
.nav-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #475569;
    padding: 20px 12px 10px 12px;
    margin: 0;
}

.nav-section-label:first-child {
    padding-top: 0;
}

/* Collapsible Section Label */
.collapsible-section {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: color 0.2s ease;
}

.collapsible-section:hover {
    color: #94a3b8;
}

.section-arrow {
    font-size: 8px;
    transition: transform 0.2s ease;
    color: #64748b;
}

/* Collapsible Items Container */
.collapsible-items {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.collapsible-items.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Navigation Buttons */
.nav-btn {
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    color: var(--neutral-600);
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    min-height: 44px;
    margin-bottom: 2px;
}

.nav-btn:hover {
    background-color: var(--neutral-50);
    color: var(--primary-700);
}

.nav-btn.active {
    background-color: var(--accent-50);
    color: var(--primary-700);
    font-weight: 700;
    border-left: 4px solid var(--accent-500);
    border-radius: 0 8px 8px 0;
}


/* Icons */
.nav-icon {
    display: block;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.nav-text {
    flex: 1;
    line-height: normal;
}

.nav-tooltip {
    background: var(--primary-900);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    position: absolute;
    left: 270px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
}

.nav-btn:hover .nav-tooltip {
    opacity: 1;
    left: 250px;
}


/* Hover State */
/* Conflicting dark theme styles removed */

/* User Section */
/* User Section */
/* User Section */
.nav-user {
    padding: 16px 16px 14px;
    border-top: 1px solid var(--border-light);
    background: var(--neutral-50);
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.nav-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: default;
    transition: none;
}

.nav-user-info:hover {
    border-color: transparent;
    box-shadow: none;
}

.nav-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--primary-100);
    color: var(--primary-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
    box-shadow: none;
    border: 1px solid var(--primary-200);
}

.nav-user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.nav-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--neutral-900);
    line-height: 1.2;
}

.nav-user-role {
    font-size: 11px;
    color: var(--neutral-500);
    line-height: 1.2;
}

/* Logout Button */
.nav-logout-btn {
    width: 100%;
    padding: 8px 0 4px;
    background: transparent;
    border: none;
    font-size: 13px;
    font-weight: 500;
    color: #ef4444;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-top: 4px;
    opacity: 0.8;
}

.nav-logout-btn:hover {
    color: #f87171;
    opacity: 1;
}

.nav-logout-btn .nav-icon {
    display: block;
}

/* ========================================
   OFFLINE STATUS INDICATORS
   ======================================== */

.offline-status-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    margin: 0;
    border-top: 1px solid var(--neutral-200);
    border-bottom: 1px solid var(--neutral-200);
}

.offline-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
    animation: pulse-offline 2s ease-in-out infinite;
}

.offline-indicator svg {
    flex-shrink: 0;
}

@keyframes pulse-offline {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.offline-queue-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
    transition: all 0.2s ease;
}

.offline-queue-badge:hover {
    transform: scale(1.1);
    background: linear-gradient(135deg, #f87171, #ef4444);
}



/* Offline Queue Modal Styles */
.offline-queue-list {
    max-height: 400px;
    overflow-y: auto;
}

.offline-queue-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--neutral-700);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--neutral-200);
}

.offline-queue-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.offline-queue-item {
    padding: 12px;
    background: var(--neutral-50);
    border-radius: 8px;
    border-left: 4px solid var(--primary-500);
}

.offline-queue-item.status-failed {
    border-left-color: #ef4444;
    background: #fef2f2;
}

.offline-queue-item.status-pending {
    border-left-color: #f59e0b;
}

.oqi-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.oqi-type {
    font-weight: 600;
    color: var(--neutral-800);
    text-transform: uppercase;
    font-size: 11px;
    padding: 2px 8px;
    background: var(--primary-100);
    border-radius: 4px;
}

.oqi-amount {
    font-weight: 700;
    color: var(--neutral-900);
    font-size: 14px;
}

.oqi-date {
    font-size: 11px;
    color: var(--neutral-500);
    margin-left: auto;
}

.oqi-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.oqi-status-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
}

.oqi-status-badge.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.oqi-status-badge.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.oqi-error {
    font-size: 11px;
    color: #dc2626;
    font-style: italic;
}

.oqi-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.oqi-actions .btn-sm {
    padding: 4px 12px;
    font-size: 11px;
}

.offline-queue-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--neutral-200);
    display: flex;
    justify-content: flex-end;
}

/* Offline Mode Toggle */
.offline-toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
    margin-bottom: 0;
}

.offline-toggle-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--neutral-600);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--neutral-300);
    transition: 0.3s;
    border-radius: 22px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(18px);
}

.toggle-switch input:disabled+.toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Main Content Area */
.main-content {
    margin-left: 260px;
    width: calc(100% - 260px);
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    background: #f8fafc;
}

/* Fix for User Management and Subscription scroll issues */
#users,
#settings-team,
#settings-subscription {
    overflow-x: hidden;
    height: auto;
    /* Ensure no fixed height causes double scroll */
}

/* ========================================
   MOBILE RESPONSIVENESS
   ======================================== */

/* Mobile Menu Button - Hidden (using bottom nav instead) */
.mobile-menu-btn {
    display: none !important;
    visibility: hidden;
}

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

/* Mobile Overlay - Hidden (using bottom nav instead) */
.mobile-overlay {
    display: none !important;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* Media Queries */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        /* Slightly wider on mobile for better touch */
        box-shadow: none;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 10px 0 25px rgba(0, 0, 0, 0.2);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding-top: 60px;
        /* Space for hidden header/button */
    }

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

/* Tab Content */
[hidden] {
    display: none !important;
}

.tab-content {
    display: none;
    padding: 20px 24px 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content.active {
    display: block;
}

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

.tab-header h2 {
    color: #333;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Custom Dashboard Layout: 2 cards on top, 3 below */
.dashboard-grid-custom {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 25px;
    margin-bottom: 30px;
}

/* User View: Simple 3-column layout */
.dashboard-grid-custom.user-view {
    grid-template-columns: repeat(3, 1fr) !important;
}

.dashboard-grid-custom.user-view .metric-card {
    grid-column: span 1 !important;
}

/* Profit Metrics Layout: 2 cards on top, 3 below */
.profit-metrics-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profit-metrics-top {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.profit-metrics-bottom {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Large cards span 3 columns each (2 cards = 6 columns) */
.metric-card-large {
    grid-column: span 3;
    padding: 50px 40px;
    min-height: 180px;
}

/* Large card values - bigger font size */
.metric-card-large .metric-value {
    font-size: 56px;
}

.metric-card-large h3 {
    font-size: 15px;
}

/* Small cards span 2 columns each (3 cards = 6 columns) */
.metric-card-small {
    grid-column: span 2;
    padding: 35px 30px;
    min-height: 140px;
}

/* Small card values - standard size */
.metric-card-small .metric-value {
    font-size: 44px;
}

.metric-card {
    background: white;
    padding: 40px 35px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    border-color: #cbd5e1;
}

.metric-card h3 {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 16px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 48px;
    font-weight: 700;
    background: linear-gradient(135deg, #1A3862 0%, #102A43 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    word-break: break-word;
}

.metric-card.alert .metric-value {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dashboard-section {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.dashboard-section h3 {
    margin-bottom: 15px;
    color: #333;
}

.restaurant-dashboard-shell,
.restaurant-order-actions,
.restaurant-dashboard-columns {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.restaurant-dashboard-grid,
.restaurant-orders-grid {
    grid-template-columns: repeat(4, 1fr);
}

.restaurant-dashboard-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.restaurant-order-feed-item {
    cursor: pointer;
}

.restaurant-order-feed-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.restaurant-order-queue-item {
    align-items: center;
}

.restaurant-order-settlement-item {
    gap: 24px;
    padding: 18px 20px;
    align-items: center;
}

.restaurant-order-settlement-main {
    flex: 1 1 auto;
    min-width: 0;
}

.restaurant-order-settlement-main strong {
    display: block;
    margin-bottom: 6px;
}

.restaurant-order-settlement-main small {
    display: block;
    color: #64748b;
    line-height: 1.45;
}

.restaurant-order-settlement-side {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    flex-wrap: wrap;
}

.restaurant-order-settlement-summary {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    min-width: 120px;
}

.restaurant-order-settlement-total {
    color: var(--success-700);
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
}

.restaurant-order-settlement-actions .restaurant-ticket-actions {
    width: auto;
    min-width: 220px;
    max-width: 220px;
    gap: 8px;
}

.restaurant-order-settlement-actions .restaurant-order-inline-action {
    min-height: 38px;
    padding: 8px 12px;
}

.restaurant-order-inline-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 132px;
    min-height: 42px;
    padding: 10px 14px;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
    line-height: 1;
    text-decoration: none;
    user-select: none;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.restaurant-order-inline-action:hover {
    transform: translateY(-1px);
    border-color: #94a3b8;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.restaurant-order-inline-action:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.18);
    outline-offset: 2px;
}

.restaurant-order-inline-action:active {
    transform: translateY(0);
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.1);
}

.restaurant-order-feed-meta .restaurant-order-inline-action {
    align-self: flex-end;
    min-height: 40px;
    padding: 8px 16px;
}

.restaurant-ticket-actions {
    width: 100%;
    max-width: 250px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    justify-self: end;
}

.restaurant-ticket-actions .restaurant-order-inline-action {
    width: 100%;
    min-width: 0;
}

.restaurant-ticket-actions-has-primary .restaurant-order-inline-primary,
.restaurant-ticket-actions .restaurant-order-inline-danger:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.restaurant-order-inline-primary {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: #ffffff;
    box-shadow: 0 10px 18px rgba(249, 115, 22, 0.22);
}

.restaurant-order-inline-subtle {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    color: #334155;
    border-color: #d7dee7;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.restaurant-order-inline-danger {
    color: #be123c;
    border-color: #fecdd3;
    background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
    box-shadow: 0 6px 14px rgba(190, 24, 93, 0.08);
}

.bulk-order-table-customer strong {
    display: block;
    color: #0f172a;
    font-size: 14px;
    line-height: 1.45;
}

.bulk-order-table-customer small,
.bulk-order-table-sale-ref {
    display: block;
    margin-top: 4px;
    color: #64748b;
    line-height: 1.45;
}

.bulk-order-table-amounts {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #475569;
    font-size: 13px;
}

.bulk-order-table-amounts strong {
    color: #0f172a;
}

[data-theme="dark"] #bulkOrders .search-bar input,
[data-theme="dark"] #bulkOrders .search-bar select {
    background: #243247;
    color: #eef4ff;
    border-color: #42526a;
}

[data-theme="dark"] #bulkOrders .search-bar input::placeholder {
    color: #93a6c5;
}

[data-theme="dark"] #bulkOrders .dashboard-section,
[data-theme="dark"] #bulkOrders .table-container {
    background: #243249;
    border-color: #41516a;
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.18);
}

[data-theme="dark"] #bulkOrders thead {
    background: #172338;
}

[data-theme="dark"] #bulkOrders th {
    color: #9ebbe8;
    border-bottom-color: #41516a;
}

[data-theme="dark"] #bulkOrders td {
    color: #e8eef9;
    border-bottom-color: #33445c;
}

[data-theme="dark"] #bulkOrders tbody tr:hover {
    background: #2a3951;
}

[data-theme="dark"] #bulkOrders .bulk-order-table-customer strong,
[data-theme="dark"] #bulkOrders .bulk-order-table-amounts strong {
    color: #f8fbff;
}

[data-theme="dark"] #bulkOrders .bulk-order-table-customer small,
[data-theme="dark"] #bulkOrders .bulk-order-table-sale-ref,
[data-theme="dark"] #bulkOrders .bulk-order-table-amounts {
    color: #9caecc;
}

.restaurant-bulk-order-actions-menu,
.restaurant-bulk-order-documents-menu {
    width: 100%;
    min-width: 150px;
}

.restaurant-bulk-order-actions-menu summary,
.restaurant-bulk-order-documents-menu summary {
    list-style: none;
}

.restaurant-bulk-order-actions-menu summary::-webkit-details-marker,
.restaurant-bulk-order-documents-menu summary::-webkit-details-marker {
    display: none;
}

.restaurant-bulk-order-actions-menu > summary,
.restaurant-bulk-order-documents-menu > summary {
    width: 100%;
}

.restaurant-bulk-order-actions-menu[open] > summary,
.restaurant-bulk-order-documents-menu[open] > summary {
    border-color: #94a3b8;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.restaurant-bulk-order-actions-panel,
.restaurant-bulk-order-documents-panel {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid #dbe4f0;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.restaurant-bulk-order-documents-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.restaurant-bulk-order-actions-panel .restaurant-order-inline-action,
.restaurant-bulk-order-documents-panel .restaurant-order-inline-action {
    width: 100%;
    min-width: 0;
}

.kitchen-ticket-list {
    border: 1px solid #dbe4f0;
    border-radius: 16px;
    overflow: hidden;
    background: #ffffff;
}

.kitchen-ticket-list-head,
.kitchen-ticket-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.15fr) minmax(240px, 1.3fr) minmax(120px, 0.6fr) minmax(110px, 0.5fr) minmax(210px, 0.9fr);
    gap: 16px;
    padding: 16px 18px;
}

.kitchen-ticket-list-head {
    background: #f8fafc;
    border-bottom: 1px solid #dbe4f0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.kitchen-ticket-row {
    border-bottom: 1px solid #e2e8f0;
    align-items: start;
}

.kitchen-ticket-row:last-child {
    border-bottom: none;
}

.kitchen-ticket-ticket,
.kitchen-ticket-items,
.kitchen-ticket-status,
.kitchen-ticket-timer,
.kitchen-ticket-action {
    min-width: 0;
}

.kitchen-ticket-ticket {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kitchen-ticket-ticket strong {
    color: #0f172a;
    font-size: 16px;
}

.kitchen-ticket-ticket small {
    color: #64748b;
    line-height: 1.5;
}

.kitchen-ticket-notes {
    color: #92400e;
    font-size: 13px;
    line-height: 1.5;
}

.kitchen-ticket-items ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kitchen-ticket-items li {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    color: #1e293b;
    line-height: 1.5;
}

.kitchen-ticket-items li strong {
    min-width: 42px;
    color: #0f172a;
}

.kitchen-ticket-item-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kitchen-ticket-item-copy small {
    color: #92400e;
    font-size: 12px;
}

.kitchen-ticket-status,
.kitchen-ticket-timer,
.kitchen-ticket-action {
    display: flex;
    align-items: center;
}

.kitchen-ticket-timer span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 700;
}

.kitchen-ticket-action {
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
}

.kitchen-ticket-finished {
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
}

.restaurant-order-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.restaurant-action-card {
    appearance: none;
    width: auto;
    min-width: 260px;
    min-height: 44px;
    border: none;
    background: var(--accent-500);
    border-radius: 10px;
    padding: 13px 28px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(247, 148, 29, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.restaurant-action-card::after {
    display: none;
}

.restaurant-action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(247, 148, 29, 0.3);
    background: var(--accent-600);
}

.restaurant-action-card:active {
    transform: translateY(0);
    box-shadow: 0 6px 14px rgba(247, 148, 29, 0.22);
}

.restaurant-action-card:focus-visible {
    outline: 3px solid rgba(247, 148, 29, 0.28);
    outline-offset: 3px;
}

.restaurant-action-card strong {
    color: #ffffff;
    font-size: 16px;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.restaurant-action-card span {
    display: none;
}

.restaurant-plan-banner {
    border: 1px solid #fdba74;
    background: linear-gradient(135deg, #fffaf0 0%, #fff7ed 100%);
}

.restaurant-plan-banner-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.restaurant-plan-banner-copy {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.restaurant-plan-banner-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-left: auto;
}

@media (max-width: 768px) {
    .onboarding-card-header,
    .onboarding-compact,
    .onboarding-complete {
        flex-direction: column;
        align-items: stretch;
    }

    .restaurant-dashboard-columns,
    .restaurant-order-actions,
    .restaurant-plan-banner-head {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .restaurant-order-actions {
        align-items: stretch;
    }

    .restaurant-action-card {
        width: 100%;
        min-width: 0;
    }

    .restaurant-dashboard-grid,
    .restaurant-orders-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .restaurant-order-feed-meta {
        align-items: flex-start;
    }

    .restaurant-order-settlement-item,
    .restaurant-order-settlement-side {
        flex-direction: column;
        align-items: stretch;
    }

    .restaurant-order-settlement-side {
        margin-left: 0;
        gap: 14px;
    }

    .restaurant-order-settlement-summary {
        align-items: flex-start;
        min-width: 0;
    }

    .restaurant-order-settlement-actions .restaurant-ticket-actions {
        min-width: 0;
        max-width: none;
        width: 100%;
    }

    .kitchen-ticket-list-head,
    .kitchen-ticket-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .kitchen-ticket-list-head {
        display: none;
    }

    .kitchen-ticket-row {
        padding: 18px 16px;
    }

    .kitchen-ticket-action {
        justify-content: flex-start;
        align-items: flex-start;
    }

    .restaurant-ticket-actions {
        max-width: none;
        justify-self: stretch;
    }

    .onboarding-step-list {
        grid-template-columns: 1fr;
    }
}

#onboardingChecklistPanel {
    margin-bottom: 20px;
}

.onboarding-shell {
    margin-bottom: 20px;
}

.onboarding-card {
    background: linear-gradient(145deg, #fffaf2 0%, #ffffff 62%);
    border: 1px solid #f6d7a8;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.onboarding-card-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 24px 12px;
}

.onboarding-card-header h3 {
    margin: 0 0 6px;
    font-size: 22px;
    color: #102a43;
}

.onboarding-card-header p {
    margin: 0;
    color: #52606d;
}

.onboarding-card-actions {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.onboarding-progress {
    padding: 0 24px 18px;
}

.onboarding-progress-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    color: #52606d;
}

.onboarding-progress-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #f1f5f9;
    overflow: hidden;
}

.onboarding-progress-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #f59e0b 0%, #f97316 100%);
}

.onboarding-step-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 0 24px 24px;
}

.onboarding-step {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #fff;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.onboarding-step.is-complete {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.onboarding-step.is-locked {
    opacity: 0.7;
}

.onboarding-step-top {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.onboarding-step-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fdba74;
    flex-shrink: 0;
}

.onboarding-step.is-complete .onboarding-step-icon {
    background: #15803d;
    border-color: #15803d;
    color: #fff;
}

.onboarding-step-title {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.onboarding-step-title strong {
    color: #102a43;
}

.onboarding-step p {
    margin: 0;
    color: #52606d;
    font-size: 14px;
    line-height: 1.5;
}

.onboarding-step-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.onboarding-compact,
.onboarding-complete {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 18px 22px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.onboarding-complete {
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border-color: #bbf7d0;
}

.onboarding-compact strong,
.onboarding-complete strong {
    display: block;
    margin-bottom: 4px;
    color: #102a43;
}

.onboarding-compact p,
.onboarding-complete p {
    margin: 0;
    color: #52606d;
}

.onboarding-import-note {
    padding: 14px 16px;
    border-radius: 12px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    line-height: 1.5;
    margin-bottom: 16px;
}

.onboarding-import-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.onboarding-import-selected,
.onboarding-import-status {
    padding: 12px 14px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569;
    margin-bottom: 12px;
}

.onboarding-import-results {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    background: #fff;
    max-height: 260px;
    overflow-y: auto;
}

.onboarding-import-results h4 {
    margin: 0 0 10px;
    color: #102a43;
}

.onboarding-import-results ul {
    margin: 0;
    padding-left: 18px;
    color: #475569;
}

.inventory-import-stepper {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.inventory-import-step {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 14px;
    background: #f8fafc;
    color: #64748b;
}

.inventory-import-step.is-active {
    border-color: #f59e0b;
    background: #fff7ed;
    color: #9a3412;
}

.inventory-import-step strong {
    display: block;
    color: #102a43;
    margin-bottom: 4px;
}

.inventory-import-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.inventory-import-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.inventory-import-field {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    background: #fff;
}

.inventory-import-field label {
    display: block;
    font-weight: 600;
    color: #102a43;
    margin-bottom: 8px;
}

.inventory-import-field select {
    width: 100%;
}

.inventory-import-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    background: #e2e8f0;
    color: #334155;
}

.inventory-import-badge.required {
    background: #fee2e2;
    color: #b91c1c;
}

.inventory-import-badge.optional {
    background: #dbeafe;
    color: #1d4ed8;
}

.inventory-import-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.inventory-import-summary-card {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    background: #fff;
}

.inventory-import-summary-card strong {
    display: block;
    font-size: 24px;
    color: #102a43;
}

.inventory-import-table-wrap {
    max-height: 360px;
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #fff;
}

.inventory-import-table {
    width: 100%;
    border-collapse: collapse;
}

.inventory-import-table th,
.inventory-import-table td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
    text-align: left;
}

.inventory-import-row-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
}

.inventory-import-warning {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #fde68a;
    background: #fef3c7;
    color: #92400e;
}

.inventory-import-error {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.inventory-import-actions-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

.inventory-import-primary-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .inventory-import-stepper,
    .inventory-import-summary,
    .inventory-import-grid {
        grid-template-columns: 1fr;
    }

    .inventory-import-actions-row {
        align-items: stretch;
    }
}

.alert-list,
.recent-list {
    max-height: 300px;
    overflow-y: auto;
}

.alert-item,
.recent-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-item:last-child,
.recent-item:last-child {
    border-bottom: none;
}

.alert-item.critical {
    background: #ffe6e6;
    border-left: 4px solid #e74c3c;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-info,
.btn-warning {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
    background: var(--accent-500);
    color: #102A43;
    border-color: var(--accent-500);
}

.btn-primary:hover {
    background: var(--accent-600);
    border-color: var(--accent-600);
    box-shadow: 0 6px 14px rgba(247, 148, 29, 0.18);
}

.btn-secondary {
    background: var(--neutral-100);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--neutral-200);
    border-color: var(--neutral-300);
}

.btn-success {
    background: #15803d;
    color: white;
    border-color: #15803d;
}

.btn-success:hover {
    background: #166534;
    border-color: #166534;
    box-shadow: 0 6px 14px rgba(34, 197, 94, 0.18);
}

.btn-danger {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    box-shadow: 0 6px 14px rgba(239, 68, 68, 0.18);
}

.btn-info {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
}

.btn-info:hover {
    background: var(--primary-700);
    border-color: var(--primary-700);
    box-shadow: 0 6px 14px rgba(26, 56, 98, 0.18);
}

.btn-warning {
    background: #b45309;
    color: white;
    border-color: #b45309;
}

.btn-warning:hover {
    background: #92400e;
    border-color: #92400e;
    box-shadow: 0 6px 14px rgba(245, 158, 11, 0.18);
}

.btn-remove {
    background: #c0392b;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

/* Button loading spinner for preventing double-clicks */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.75s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

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

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Sub-tab Buttons */
/* Sub-Navigation Tabs */
.sub-nav-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.sub-nav-btn {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 8px 14px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.15;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.sub-nav-btn:hover {
    color: var(--primary-700);
    background: var(--primary-50);
    border-color: var(--primary-100);
}

.sub-nav-btn.active {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
    box-shadow: 0 6px 14px rgba(26, 56, 98, 0.16);
}

.sub-nav-btn .notification-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    /* Red */
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
}

/* Mobile: scrollable sub-nav tabs */
@media (max-width: 768px) {
    .sub-nav-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 6px;
        padding: 6px;
        margin-bottom: 16px;
        justify-content: flex-start;
    }

    .sub-nav-btn {
        white-space: nowrap;
        flex: 0 0 auto;
        min-width: max-content;
        min-height: 38px;
        font-size: 13px;
        padding: 8px 14px;
    }
}

/* Profit Section Visibility */
.profit-section {
    display: none !important;
}

.profit-section.active {
    display: block !important;
}

/* Search Bar */
.search-bar {
    margin-bottom: 20px;
}

.search-bar input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

#receivables .receivables-search-bar input {
    min-height: 46px;
    padding: 11px 16px;
    border: 1.5px solid var(--neutral-300);
    border-radius: 10px;
    background: #ffffff;
    color: var(--neutral-900);
    caret-color: var(--primary-600);
    outline: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

#receivables .receivables-search-bar input::placeholder {
    color: var(--neutral-500);
}

#receivables .receivables-search-bar input:hover {
    border-color: var(--neutral-400);
}

#receivables .receivables-search-bar input:focus {
    border-color: var(--primary-600);
    box-shadow: 0 0 0 3px rgba(23, 56, 99, 0.14);
}

/* Tables */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    border: 1px solid #e2e8f0;
}

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

thead {
    background: #f8fafc;
}

th {
    padding: 10px 12px;
    /* Compact padding */
    text-align: center;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

th.sortable:hover {
    background: #e2e8f0;
    color: #1A3862;
}

td {
    padding: 10px 12px;
    /* Compact padding */
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-size: 14px;
    vertical-align: middle;
    height: 48px;
    /* Compact row height */
    line-height: 1.2;
    text-align: center;
}

tbody tr:hover {
    background: #f8fafc;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.status-badge.low-stock {
    background: #fee2e2;
    color: #b91c1c;
}

.status-badge.in-stock {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.pending_settlement {
    background: #ffedd5;
    color: #c2410c;
}

.status-badge.draft {
    background: #e2e8f0;
    color: #475569;
}

.status-badge.confirmed {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-badge.approved {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.rejected {
    background: #fee2e2;
    color: #b91c1c;
}

.status-badge.completed,
.status-badge.settled {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.partial-return {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.returned {
    background: #fee2e2;
    color: #b91c1c;
}

.status-badge.paid {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.partial {
    background: #dbeafe;
    color: #173863;
}

.status-badge.credit {
    background: #fef3c7;
    color: #92400e;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1200;
}

.modal-overlay.active {
    display: block;
}

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    z-index: 1201;
    max-height: 90vh;
    overflow-y: auto;
}

.modal.active {
    display: block;
}

.modal-content {
    padding: 32px;
    min-width: 500px;
}

.modal-content.large {
    min-width: 900px;
    max-width: 95vw;
    /* Prevent overflow on slightly smaller screens */
}

@media (max-width: 768px) {
    .modal-content.large {
        min-width: 0 !important;
        /* Allow shrinking on mobile */
    }
}

.modal-content h2 {
    margin-bottom: 24px;
    color: #1e293b;
    font-size: 24px;
    font-weight: 700;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 15px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff;
    color: var(--neutral-900);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-50);
    background: #ffffff;
}

/* ========================================
   FIELD-LEVEL VALIDATION FEEDBACK
   ======================================== */

/* Invalid field state */
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
    border-color: var(--error-500);
    background: var(--error-50);
}

.form-group.has-error input:focus,
.form-group.has-error select:focus,
.form-group.has-error textarea:focus {
    border-color: var(--error-500);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.form-group.has-error label {
    color: var(--error-600);
}

/* Error hint text below fields */
.field-error {
    display: none;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--error-600);
    margin-top: 4px;
    line-height: 1.3;
    align-items: center;
    gap: 4px;
}

.field-error::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background: var(--error-500);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z' clip-rule='evenodd'/%3E%3C/svg%3E") no-repeat center;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z' clip-rule='evenodd'/%3E%3C/svg%3E") no-repeat center;
    flex-shrink: 0;
}

.form-group.has-error .field-error {
    display: flex;
}

/* Valid field state (only after interaction) */
.form-group.has-success input,
.form-group.has-success select,
.form-group.has-success textarea {
    border-color: var(--success-500);
}

.form-group.has-success input:focus,
.form-group.has-success select:focus,
.form-group.has-success textarea:focus {
    border-color: var(--success-500);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.1);
}

.restaurant-stock-kind-picker,
.purchase-restaurant-stock-kind {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.restaurant-stock-kind-option {
    appearance: none;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, var(--neutral-100) 100%);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    text-align: left;
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.restaurant-stock-kind-option:hover {
    transform: translateY(-1px);
    border-color: rgba(247, 148, 29, 0.45);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.restaurant-stock-kind-option:focus-visible {
    outline: none;
    border-color: var(--accent-500);
    box-shadow: 0 0 0 4px rgba(247, 148, 29, 0.14);
}

.restaurant-stock-kind-option strong {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.restaurant-stock-kind-option span {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.45;
}

.restaurant-stock-kind-option.is-active {
    border-color: var(--accent-500);
    background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
    box-shadow: 0 14px 28px rgba(247, 148, 29, 0.14);
}

.restaurant-stock-kind-option.is-active strong {
    color: var(--accent-600);
}

.restaurant-stock-kind-option.is-active span {
    color: #c2410c;
}

.restaurant-stock-kind-option-compact {
    padding: 12px 14px;
    border-radius: 14px;
}

.restaurant-stock-kind-option-compact strong {
    font-size: 13px;
}

.restaurant-stock-kind-option-compact span {
    font-size: 11px;
}

/* Shake animation for invalid submit */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(6px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }
}

.form-group.shake {
    animation: shake 0.4s ease;
}

/* Login form specific overrides */
.login-form .form-group.has-error input {
    border-color: var(--error-500);
    background: var(--error-50);
}

.login-form .form-group.has-error input:focus {
    border-color: var(--error-500);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.login-form .field-error {
    font-size: 11px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.modal-actions {
    margin-top: 25px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.purchase-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .purchase-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* Sale Items */
#saleItems {
    margin-bottom: 15px;
}

.sale-item {
    display: grid;
    grid-template-columns: 2fr 0.7fr 1fr 1fr auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

/* Ensure grid children respect their column sizes */
.sale-item>* {
    min-width: 0;
}

/* Desktop: Flatten the row structure into grid */
.sale-item .sale-item-row-1 {
    display: contents;
}

.sale-item .sale-item-row-2 {
    display: contents;
}

.sale-item .tax-code-group {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sale-item .item-tax-status {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.sale-item .item-tax-change {
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-600);
    cursor: pointer;
    min-height: 32px;
}

.sale-item .item-tax-change:hover,
.sale-item .item-tax-change:focus-visible {
    color: var(--primary-800);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sale-item .item-tax-code {
    max-width: 240px;
    min-height: 36px;
}

.sale-item .tax-code-group.is-overridden .item-tax-status {
    color: var(--text-primary);
}

.sale-item .price-group,
.sale-item .subtotal-group {
    display: contents;
}

.sale-item .price-group.has-price-type-control {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.sale-item .price-group.has-price-type-control .item-price {
    width: 100%;
    min-width: 100px;
}

.item-price-type-control {
    width: 100%;
}

.item-price-type {
    width: 100%;
    min-width: 100px;
}

.hospitality-pos-price-type {
    min-width: 105px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-primary);
    font-weight: 700;
}

.hospitality-pos-order-controls.has-price-editor {
    grid-template-columns: auto minmax(150px, 1fr) auto;
}

.hospitality-pos-price-editor {
    display: grid;
    grid-template-columns: minmax(100px, auto) minmax(90px, 1fr);
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.hospitality-pos-item-price {
    width: 100%;
    min-width: 90px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-primary);
    font: inherit;
    font-weight: 700;
    text-align: right;
}

.hospitality-pos-item-price:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(23, 56, 99, 0.14);
    outline: none;
}

.hospitality-pos-item-price[aria-invalid="true"] {
    border-color: var(--error-500);
}

.purchase-item-meta.purchase-wholesale-fields {
    margin: -2px 8px 10px 44px;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--neutral-50);
}

.purchase-wholesale-fields label {
    display: grid;
    grid-template-columns: minmax(220px, auto) minmax(180px, 1fr);
    align-items: center;
    gap: 12px;
    margin: 0;
}

.purchase-wholesale-fields input {
    width: 100%;
    margin: 0;
}

/* Hide labels on desktop */
.sale-item .price-label,
.sale-item .subtotal-label {
    display: none;
}

/* Desktop: Hide qty stepper buttons, show simple input */
.sale-item .qty-stepper {
    display: contents;
}

.sale-item .qty-btn {
    display: none;
}

.sale-item select,
.sale-item input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.item-subtotal {
    font-weight: 600;
    color: #173863;
}

.sale-total {
    text-align: right;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #ddd;
}

.sale-total h3 {
    color: #173863;
    font-size: 24px;
}

.info-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.info-box p {
    margin: 5px 0;
}

/* Autocomplete Suggestions */
.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 5px 5px;
    max-height: 350px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

/* Purchase item dropdowns — fixed position to escape scroll container */
.purchase-suggestions.autocomplete-dropdown {
    position: fixed;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    width: 320px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 9999;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
    padding: 4px;
}

.purchase-suggestions .autocomplete-item {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 2px;
    border-bottom: none;
    font-size: 13px;
    line-height: 1.4;
}

.purchase-suggestions .autocomplete-item:last-child {
    margin-bottom: 0;
}

.purchase-suggestions .autocomplete-item:hover {
    background: var(--primary-50);
}

.purchase-suggestions .autocomplete-item strong {
    color: #1e293b;
    font-weight: 600;
}

.purchase-suggestions .autocomplete-item span {
    color: #64748b !important;
    font-size: 11px !important;
    margin-top: 2px;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s;
    color: var(--text-primary);
}

.autocomplete-item:hover {
    background: var(--hover-bg);
}

.autocomplete-item:last-child {
    border-bottom: none;
    border-radius: 0 0 8px 8px;
}

.autocomplete-item span {
    color: var(--text-secondary);
}

.autocomplete-suggestions.show {
    display: block;
}

.suggestion-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f1f1;
    transition: background 0.2s;
}

.suggestion-item:hover {
    background: #f8f9fa;
}

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

.suggestion-name {
    font-weight: 600;
    color: #333;
}

.suggestion-details {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* Action buttons in tables */
.action-buttons {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-menu {
        flex-wrap: wrap;
    }

    .nav-btn {
        font-size: 12px;
        padding: 8px 12px;
    }

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

    .modal-content {
        min-width: 90vw;
    }

    .table-container {
        overflow-x: scroll;
    }

    .sale-item {
        grid-template-columns: 1fr;
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #64748b;
}

.empty-state h3 {
    margin-bottom: 10px;
}

.empty-state-guided {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-state-guided p {
    margin: 0;
    color: var(--text-tertiary);
}

.empty-state-guided-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ========================================
   ENHANCED MOBILE RESPONSIVENESS
   ======================================== */

/* Viewport meta tag reminder - add to index.html if not present:
   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0">
*/

/* ========================================
   TABLET OPTIMIZATION (768px - 1024px)
   ======================================== */
@media (min-width: 769px) and (max-width: 1024px) {

    /* ==========================================
       LOGIN & REGISTER - TABLET OPTIMIZED
       ========================================== */

    /* Keep side-by-side layout on tablet */
    .login-split-container {
        flex-direction: row;
    }

    /* Branding section - narrower on tablet */
    .login-branding {
        flex: 0.45;
        padding: 32px 28px;
        min-height: 100vh;
    }

    .branding-content {
        max-width: 100%;
    }

    .branding-content h1 {
        font-size: 32px;
        margin-bottom: 8px;
    }

    .branding-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .branding-features {
        gap: 10px;
    }

    .feature-item {
        padding: 12px 16px;
    }

    .feature-text strong {
        font-size: 14px;
    }

    .feature-text span {
        font-size: 12px;
    }

    /* Form section - wider on tablet */
    .login-form-section {
        flex: 0.55;
        padding: 32px 40px;
        overflow-y: auto;
    }

    .login-logo-top {
        top: 20px;
        right: 20px;
    }

    .login-logo-top img {
        width: 140px;
    }

    .login-form-wrapper {
        max-width: 380px;
    }

    .login-form-wrapper h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }

    /* Touch-friendly form inputs */
    .login-form .form-group {
        margin-bottom: 16px;
    }

    .login-form .form-group label {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .login-form input {
        padding: 14px 16px;
        font-size: 16px;
        min-height: 50px;
        border-radius: 10px;
    }

    .btn-login {
        padding: 16px;
        font-size: 16px;
        min-height: 52px;
        border-radius: 10px;
        margin-top: 8px;
    }

    /* Registration - Keep side-by-side but stack form fields */
    #registrationScreen .login-form-section {
        padding: 32px 36px;
        align-items: center;
        overflow-y: auto;
    }

    #registrationScreen .login-form-wrapper {
        max-width: 420px;
        width: 100%;
    }

    #registrationScreen .login-form-wrapper h2 {
        font-size: 24px;
        margin-bottom: 20px;
    }

    /* Stack registration form fields on tablet */
    .registration-grid-container {
        display: flex !important;
        flex-direction: column;
        gap: 12px !important;
    }

    .registration-grid-container .form-group {
        width: 100%;
    }

    .registration-grid-container .full-width {
        margin-top: 8px;
    }

    #registrationScreen .login-form input {
        padding: 14px 16px;
        font-size: 16px;
        min-height: 50px;
    }

    #registrationScreen .btn-login {
        padding: 16px;
        font-size: 16px;
        min-height: 52px;
    }

    /* Success message and shop number display */
    .shop-number-display {
        padding: 16px;
        border-radius: 12px;
    }

    /* Links below form */
    .login-form-wrapper a,
    .login-form-wrapper .form-link {
        font-size: 14px;
        padding: 8px 0;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Sidebar - Hidden by default, hamburger menu triggers it */
    .sidebar {
        position: fixed;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Main content takes full width */
    .main-content {
        margin-left: 0;
        width: 100%;
        padding-top: 20px;
    }

    /* Show hamburger menu on tablet */
    .mobile-menu-btn {
        display: flex;
    }

    .mobile-overlay {
        display: block;
    }

    /* Tab content */
    .tab-content {
        padding: 20px;
    }

    /* Dashboard grid - 2 columns */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .dashboard-grid-custom {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .metric-card-large,
    .metric-card-small {
        grid-column: span 1;
    }

    .metric-card {
        padding: 24px 20px;
        min-height: 120px;
    }

    .metric-value {
        font-size: 36px;
    }

    /* ==========================================
       CARD-BASED SALE ITEMS FOR TABLET
       ========================================== */
    .sale-item {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 20px;
        background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
        border-radius: 16px;
        border: 1px solid var(--border-light);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
        margin-bottom: 16px;
        transition: all 0.2s ease;
    }

    .sale-item:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
        border-color: var(--primary-200);
    }

    /* Row 1: Search + Quantity Stepper + Remove */
    .sale-item .sale-item-row-1 {
        display: flex;
        align-items: center;
        gap: 16px;
    }

    .sale-item .searchable-dropdown {
        flex: 1;
    }

    .sale-item .item-select {
        width: 100%;
        padding: 14px 16px;
        font-size: 16px;
        min-height: 52px;
        border-radius: 12px;
        border: 2px solid var(--border);
        background: #ffffff;
        transition: all 0.2s ease;
    }

    .sale-item .item-select:focus {
        border-color: var(--primary-500);
        box-shadow: 0 0 0 4px var(--primary-100);
    }

    /* Quantity Stepper */
    .sale-item .qty-stepper {
        display: flex;
        align-items: center;
        gap: 0;
        background: var(--neutral-100);
        border-radius: 12px;
        padding: 4px;
    }

    .sale-item .qty-btn {
        width: 48px;
        height: 48px;
        border: none;
        background: #ffffff;
        color: var(--primary-600);
        font-size: 24px;
        font-weight: 600;
        cursor: pointer;
        border-radius: 10px;
        transition: all 0.15s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    .sale-item .qty-btn:hover {
        background: var(--primary-50);
        color: var(--primary-700);
    }

    .sale-item .qty-btn:active {
        transform: scale(0.95);
        background: var(--primary-100);
    }

    .sale-item .item-quantity {
        width: 60px;
        text-align: center;
        font-size: 18px;
        font-weight: 700;
        color: var(--text-primary);
        border: none;
        background: transparent;
        padding: 8px 4px;
        -moz-appearance: textfield;
    }

    .sale-item .item-quantity::-webkit-outer-spin-button,
    .sale-item .item-quantity::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    /* Remove button */
    .sale-item .btn-remove {
        width: 48px;
        height: 48px;
        font-size: 24px;
        border-radius: 12px;
        flex-shrink: 0;
    }

    /* Row 2: Price + Subtotal (right-aligned) */
    .sale-item .sale-item-row-2 {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        padding-top: 12px;
        border-top: 1px solid var(--border-light);
        gap: 8px 12px;
    }

    .sale-item .tax-code-group {
        grid-column: auto;
        width: 100%;
        order: 3;
        min-height: 32px;
    }

    .sale-item .price-group {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .sale-item .price-label {
        font-size: 14px;
        color: var(--text-tertiary);
        font-weight: 500;
    }

    .sale-item .item-price {
        width: 120px;
        padding: 10px 12px;
        font-size: 16px;
        font-weight: 600;
        text-align: right;
        border-radius: 8px;
        border: 1.5px solid var(--border);
        background: #ffffff;
        min-height: 44px;
    }

    .sale-item .item-price:focus {
        border-color: var(--primary-500);
        box-shadow: 0 0 0 3px var(--primary-100);
    }

    .sale-item .subtotal-group {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .sale-item .subtotal-label {
        font-size: 14px;
        color: var(--text-tertiary);
        font-weight: 500;
    }

    .sale-item .item-subtotal {
        font-size: 20px;
        font-weight: 700;
        color: var(--primary-700);
        background: var(--primary-50);
        padding: 10px 16px;
        border-radius: 10px;
        min-width: 120px;
        text-align: right;
    }

    /* Modals - Better use of tablet space */
    .modal-content {
        width: 80%;
        max-width: 600px;
        min-width: auto;
        padding: 24px;
        max-height: 85vh;
    }

    .modal-content.large {
        width: 90%;
        max-width: 800px;
        min-width: auto;
    }

    /* Forms - Keep 2 columns on tablet */
    .form-row {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 12px 14px;
        font-size: 15px;
        min-height: 44px;
    }

    /* Tables - Touch-friendly */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 14px;
    }

    th,
    td {
        padding: 14px 12px;
    }

    /* Action buttons - Horizontal but larger */
    .action-buttons {
        display: flex;
        flex-direction: row;
        gap: 6px;
    }

    .action-buttons button {
        padding: 10px 14px;
        font-size: 13px;
        min-height: 40px;
    }

    /* Buttons - Touch-friendly sizes */
    .btn-primary,
    .btn-secondary,
    .btn-success,
    .btn-danger,
    .btn-info,
    .btn-warning {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 14px;
    }

    /* Search bar */
    .search-bar input {
        padding: 12px 16px;
        font-size: 15px;
        min-height: 44px;
    }

    /* Pagination */
    .pagination-controls {
        padding: 16px;
    }

    .btn-pagination {
        min-height: 44px;
        min-width: 44px;
        padding: 10px 14px;
    }

    /* Profit cards */
    .profit-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

    /* Searchable dropdown - Touch optimized */
    .searchable-dropdown .dropdown-option {
        padding: 10px 14px;
        font-size: 14px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Nav buttons in sidebar */
    .nav-btn {
        min-height: 48px;
        padding: 12px 16px;
        font-size: 15px;
    }

    #orders .tab-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    #orders .header-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    #orders .header-actions button {
        width: 100%;
        min-width: 0;
    }

    #orders .restaurant-orders-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px;
    }

    #orders .metric-card-small {
        grid-column: span 1;
        padding: 28px 24px;
        min-height: 124px;
    }

    #orders .metric-card-small .metric-value {
        font-size: 36px;
    }

    #orders .dashboard-section {
        padding: 20px;
    }

    #orders .recent-item.restaurant-order-feed-item {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    #orders .restaurant-order-feed-meta {
        align-items: stretch;
        gap: 12px;
    }

    #orders .restaurant-order-feed-meta .status-badge {
        align-self: flex-start;
    }

    #orders .restaurant-order-feed-meta .restaurant-order-inline-action,
    #orders .restaurant-ticket-actions,
    #orders .restaurant-order-settlement-actions {
        width: 100%;
        max-width: none;
    }

    #orders .restaurant-ticket-actions {
        justify-self: stretch;
    }

    #bulkOrders .bulk-order-table-amounts {
        gap: 2px;
    }

    #orders .restaurant-order-inline-action {
        min-width: 0;
        white-space: normal;
    }

    #orders .restaurant-order-settlement-side {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
        gap: 14px;
    }

    #orders .restaurant-order-settlement-summary {
        align-items: flex-start;
        min-width: 0;
    }
}

/* Tablets and Small Laptops - Legacy support */
@media (max-width: 1024px) {
    .main-container {
        padding: 15px;
    }
}

/* Tablets Portrait */
@media (max-width: 768px) {

    /* Login Screen - Stack vertically on mobile */
    .login-split-container {
        flex-direction: column;
    }

    .login-branding {
        min-height: 40vh;
        padding: 40px 24px;
    }

    .branding-content h1 {
        font-size: 32px;
    }

    .branding-subtitle {
        font-size: 16px;
        margin-bottom: 32px;
    }

    .branding-features {
        gap: 16px;
    }

    .feature-item {
        padding: 16px 20px;
    }

    .feature-icon {
        font-size: 28px;
    }

    .feature-item span:last-child {
        font-size: 14px;
    }

    .login-logo img {
        max-width: 200px;
    }

    .login-form-section {
        padding: 40px 24px;
        min-height: 60vh;
    }

    .login-form-container h2 {
        font-size: 28px;
    }

    .login-subtitle {
        font-size: 14px;
        margin-bottom: 32px;
    }

    /* Sidebar becomes overlay/drawer */
    .sidebar {
        position: fixed;
        left: -250px;
        width: 250px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .content,
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* Header adjustments */
    .header {
        padding: 12px 15px;
        flex-wrap: wrap;
    }

    .header h2 {
        font-size: 20px;
        margin-bottom: 8px;
    }

    /* User info responsive */
    .nav-user {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
        justify-content: space-between;
    }

    /* Dashboard cards */
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    /* Tab content on tablets */
    .tab-content {
        padding: 20px 16px;
    }

    .dashboard-grid-custom {
        grid-template-columns: 1fr 1fr;
        gap: 18px;
    }

    /* Profit Metrics - Keep 2 on top, stack 3 below on tablet */
    .profit-metrics-top {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }

    .profit-metrics-bottom {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }

    .profit-metrics-bottom .metric-card:nth-child(3) {
        grid-column: 1 / -1;
        /* Make 3rd card full width */
    }

    .metric-card-large {
        grid-column: span 1;
        padding: 35px 28px;
        min-height: 150px;
    }

    .metric-card-large .metric-value {
        font-size: 46px;
    }

    .metric-card-small {
        grid-column: span 1;
        padding: 28px 22px;
        min-height: 120px;
    }

    .metric-card-small .metric-value {
        font-size: 38px;
    }

    .metric-card {
        padding: 30px 25px;
        min-height: 130px;
    }

    .metric-value {
        font-size: 42px;
    }

    .stat-card h3 {
        font-size: 14px;
    }

    .stat-card .value {
        font-size: 24px;
    }

    /* Tables */
    table {
        font-size: 13px;
    }

    th,
    td {
        padding: 8px 8px;
        /* Even tighter on tablet */
    }

    /* Hide less important columns on tablet */
    th:nth-child(5),
    td:nth-child(5),
    /* Discount */
    th:nth-child(7),
    td:nth-child(7)

    /* Payment Method */
        {
        display: none;
    }

    /* Action buttons in tables */
    .action-buttons {
        display: flex;
        flex-direction: row;
        gap: 5px;
        align-items: center;
        flex-wrap: nowrap;
    }

    .action-buttons button {
        width: 100%;
        font-size: 12px;
        padding: 6px 10px;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        max-width: 500px;
        padding: 24px 16px;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* Search and filter bars */
    .search-bar {
        flex-direction: column;
        gap: 10px;
    }

    .search-bar input {
        width: 100%;
    }

    .search-bar button {
        width: 100%;
    }
}

/* Mobile Phones */
@media (max-width: 480px) {

    /* Login Screen */
    .login-branding {
        min-height: 35vh;
        padding: 32px 20px;
    }

    .branding-content h1 {
        font-size: 28px;
    }

    .branding-subtitle {
        font-size: 15px;
        margin-bottom: 24px;
    }

    .login-logo img {
        max-width: 160px;
    }

    .login-form-section {
        padding: 32px 20px;
    }

    .login-form-container h2 {
        font-size: 24px;
    }

    .login-form input {
        padding: 14px;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    .btn-login {
        padding: 16px;
        font-size: 16px;
    }

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

    /* Header */
    .header {
        padding: 10px 12px;
    }

    .header h2 {
        font-size: 18px;
    }

    .user-info {
        font-size: 12px;
    }

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

    .dashboard-grid-custom {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Profit Metrics - Stack all vertically on mobile */
    .profit-metrics-top {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .profit-metrics-bottom {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .metric-card-large,
    .metric-card-small {
        grid-column: 1 / -1;
        padding: 25px 20px;
        min-height: 120px;
    }

    .metric-card-large .metric-value,
    .metric-card-small .metric-value {
        font-size: 36px;
    }

    .metric-card {
        padding: 25px 20px;
        min-height: 120px;
    }

    .metric-value {
        font-size: 36px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card h3 {
        font-size: 13px;
    }

    .stat-card .value {
        font-size: 22px;
    }

    /* Tables - Horizontal scroll with better touch support */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        /* Extend to screen edges */
        padding: 0 16px;
    }

    table {
        min-width: 100%;
        /* Responsive width */
        font-size: 12px;
    }

    th,
    td {
        padding: 10px 8px;
        font-size: 12px;
        min-width: 80px;
        /* Minimum column width */
    }

    /* Make action buttons stay horizontal on mobile */
    td .action-buttons {
        display: flex;
        flex-direction: row;
        gap: 4px;
        align-items: center;
        flex-wrap: nowrap;
        min-width: 100px;
    }

    td .action-buttons button {
        width: 100%;
        padding: 6px 10px;
        font-size: 11px;
    }

    /* Alternative: Card view for tables on mobile */
    .table-card-view {
        display: none;
    }

    /* Buttons */
    .btn-primary,
    .btn-success,
    .btn-info,
    .btn-danger {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Modals - Full screen on mobile for better UX */
    .modal {
        padding: 0;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
        /* Let modal-content handle scroll */
        display: none;
        /* Keep hidden by default */
    }

    .modal.active {
        display: block !important;
    }

    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        padding: 0;
        /* Remove padding from container, move to children */
        overflow: hidden;
        /* Prevent container scroll, use flex children */
        display: flex;
        flex-direction: column;
    }

    /* Wrap form content in a scrollable area */
    .modal-content form {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }

    /* The actual scrollable part */
    .modal-content .form-scroll-area,
    /* Fallback for forms without the wrapper class checking direct children could be risky,
       so we will target the scrollable middle part universally */
    .modal-content form>div:not(.modal-header):not(.modal-actions):not(.modal-footer),
    /* Or better, make the detailed form rows scroll */
    .form-row,
    .form-group,
    #saleItems {
        /* This strategy is tricky because structure varies.
            Better strategy: Make the form itself the flex container
            and the actions strictly at bottom. */
    }

    /* NEW STRATEGY:
       Header fixed at top.
       Footer (modal-actions) fixed at bottom.
       Everything in between scrolls.
    */

    .modal-header {
        flex-shrink: 0;
        padding: 16px;
        background: white;
        border-bottom: 1px solid #e2e8f0;
        margin-bottom: 0;
    }

    /* Create a scrollable container for the form inputs */
    .modal-content form {
        flex: 1;
        overflow-y: auto;
        padding: 16px;
        padding-bottom: 80px;
        /* Space for fixed footer */
        -webkit-overflow-scrolling: touch;
        display: block;
        /* Reset flex if it was set */
    }

    /* Fix the actions to the bottom */
    .modal-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 12px 16px;
        border-top: 1px solid #e2e8f0;
        z-index: 20;
        margin-top: 0;
        display: flex;
        gap: 12px;
        box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    }

    .modal-actions button {
        flex: 1;
        /* Make buttons verify full width/equal width */
        margin: 0;
        height: 48px;
        /* Touch friendly height */
    }

    .modal-header {
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        padding-bottom: 12px;
        margin-bottom: 16px;
        border-bottom: 1px solid #e2e8f0;
    }

    .modal-header h3 {
        font-size: 18px;
        padding-right: 40px;
        /* Space for close button */
    }

    .modal-body {
        padding-bottom: 80px;
        /* Space for fixed footer if any */
    }

    /* Forms */
    .form-group label {
        font-size: 13px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px 12px;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Tab content padding adjustment */
    .tab-content {
        padding: 16px;
    }

    /* Sale items in forms */
    .sale-item {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 12px;
    }

    .sale-item select,
    .sale-item input {
        width: 100%;
    }

    /* Search bars and filters */
    .search-bar,
    .filters {
        flex-direction: column;
        gap: 10px;
    }

    .search-bar input,
    .search-bar select,
    .search-bar button {
        width: 100%;
    }

    /* Cards and sections */
    .card,
    .section {
        margin: 0 0 16px 0;
        border-radius: 8px;
    }

    /* Better touch targets for all interactive elements */
    button,
    .btn,
    a.btn {
        min-height: 44px;
        /* iOS recommended touch target */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: rgba(16, 185, 129, 0.3);
        /* Visual feedback on tap */
        touch-action: manipulation;
        /* Disable double-tap zoom on buttons */
    }

    /* Ensure clickable elements are accessible */
    button,
    .btn,
    input[type="button"],
    input[type="submit"],
    select,
    .nav-btn {
        cursor: pointer;
        pointer-events: auto;
    }

    /* Responsive images */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Status badges */
    .status-badge {
        font-size: 11px;
        padding: 4px 8px;
    }

    /* Navigation */
    .nav-btn {
        padding: 10px;
        font-size: 13px;
    }

    .nav-btn i {
        font-size: 16px;
    }

    /* Pagination on mobile */
    .pagination-controls {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }

    .pagination-info {
        width: 100%;
        text-align: center;
        font-size: 13px;
    }

    .pagination-buttons {
        width: 100%;
        justify-content: center;
    }

    .btn-pagination {
        padding: 10px 14px;
        font-size: 13px;
        min-width: 44px;
        /* Better touch target */
    }

    /* Receipt and print styles on mobile */
    .receipt-container {
        width: 100%;
        padding: 16px;
        font-size: 12px;
    }

    /* Better spacing for form groups */
    .form-group {
        margin-bottom: 16px;
    }

    /* Improve modal close button visibility */
    .close-btn {
        position: absolute;
        top: 16px;
        right: 16px;
        width: 32px;
        height: 32px;
        font-size: 24px;
        z-index: 10;
    }
}

/* Very Small Phones */
@media (max-width: 360px) {
    .login-branding {
        padding: 24px 16px;
    }

    .login-form-section {
        padding: 24px 16px;
    }

    .branding-content h1 {
        font-size: 24px;
    }

    .login-form-container h2 {
        font-size: 22px;
    }

    .header h2 {
        font-size: 16px;
    }

    .stat-card .value {
        font-size: 20px;
    }

    table {
        font-size: 11px;
    }

    .btn-primary,
    .btn-success {
        font-size: 13px;
        padding: 8px 12px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {

    /* Larger tap targets for touch devices */
    button,
    .btn-primary,
    .btn-success,
    .btn-info,
    .btn-danger {
        min-height: 44px;
        /* Apple's recommended minimum */
        min-width: 44px;
    }

    .nav-btn {
        min-height: 48px;
    }

    /* Remove hover effects on touch devices */
    button:hover,
    .nav-btn:hover {
        transform: none;
    }

    /* Better focus states for accessibility */
    button:active,
    .nav-btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }
}

/* Landscape mode for phones */
@media (max-width: 768px) and (orientation: landscape) {
    .login-split-container {
        flex-direction: row;
    }

    .login-branding {
        min-height: 100vh;
        flex: 0.4;
    }

    .login-form-section {
        flex: 0.6;
        overflow-y: auto;
    }

    .branding-features {
        display: none;
        /* Hide features in landscape to save space */
    }

    .modal-content {
        max-height: 85vh;
    }
}

/* Print styles */
@media print {

    .sidebar,
    .header,
    .action-buttons,
    .search-bar,
    .btn-primary,
    .btn-success {
        display: none !important;
    }

    .content {
        margin-left: 0;
        width: 100%;
    }

    table {
        page-break-inside: avoid;
    }

    .pagination-controls {
        display: none !important;
    }
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--surface, white);
    border-top: 1px solid var(--border-light, #f1f5f9);
    border-radius: 0 0 12px 12px;
    flex-wrap: wrap;
    gap: 15px;
}

.pagination-info {
    font-size: 14px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.pagination-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.btn-pagination {
    padding: 8px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #475569;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 40px;
}

.btn-pagination:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #173863;
    color: #173863;
    transform: translateY(-1px);
}

.btn-pagination:active:not(:disabled) {
    transform: translateY(0);
}

.btn-pagination.active {
    background: var(--primary-500);
    border-color: var(--primary-500);
    color: white;
    font-weight: 700;
}


.btn-pagination:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f8fafc;
}

/* Responsive pagination */
@media (max-width: 768px) {
    .pagination-controls {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
    }

    .pagination-info {
        text-align: center;
        order: 1;
    }

    .pagination-buttons {
        justify-content: center;
        order: 2;
    }

    .btn-pagination {
        padding: 10px 12px;
        min-width: 35px;
        font-size: 13px;
    }
}

/* Loading spinner animation */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ========================================
   MOBILE MENU BUTTON & OVERLAY
   ======================================== */

/* Mobile Menu Button (Hamburger) */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: #173863;
    border: none;
    border-radius: 8px;
    width: 45px;
    height: 45px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    background: #0d2745;
    transform: scale(1.05);
}

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

/* Hamburger animation when menu is open */
.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.mobile-overlay.active {
    opacity: 1;
}

/* Show mobile menu button and overlay on mobile devices */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }

    .mobile-overlay {
        display: block;
    }

    /* Ensure sidebar is above overlay */
    .sidebar {
        z-index: 1000;
    }
}

/* Tablet size - keep menu button but adjust size */
@media (max-width: 1024px) and (min-width: 769px) {
    .mobile-menu-btn {
        display: flex;
        width: 40px;
        height: 40px;
    }

    .mobile-menu-btn span {
        width: 20px;
    }
}

/* ============================
   PROFIT ANALYSIS SECTION
   ============================ */

.profit-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* Summary cards are plain: no coloured edge per variant (primary, success,
   info, warning stay in the markup but no longer change the look). */
.profit-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: center;
    transition: all 0.2s ease;
}

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

.profit-content {
    flex: 1;
}

.profit-content h3 {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profit-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.profit-subtitle {
    font-size: 10px;
    color: var(--text-tertiary);
}

/* Analysis Grid */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.analysis-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-light);
}

.analysis-header h3 {
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 700;
}

.analysis-badge {
    padding: 4px 12px;
    background: var(--primary-100);
    color: var(--primary-700);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--neutral-50);
    border-radius: 12px;
    border-left: 4px solid var(--primary-500);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--primary-500);
}


.item-row:hover {
    background: var(--primary-50);
    transform: translateX(4px);
}

.item-row.top {
    border-left-color: var(--success-500);
}

.item-row.low {
    border-left-color: var(--error-500);
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 4px;
}

.item-sku {
    font-size: 12px;
    color: var(--text-tertiary);
}

.item-stats {
    text-align: right;
}

.item-value {
    font-weight: 700;
    font-size: 16px;
    color: var(--primary-600);
}

.item-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

/* Analysis Table Section */
.analysis-table-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.analysis-table-section h3 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 700;
}

.profit-positive {
    color: var(--success-600);
    font-weight: 600;
}

.profit-negative {
    color: var(--error-600);
    font-weight: 600;
}

.margin-high {
    background: var(--success-50);
    color: var(--success-700);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.margin-medium {
    background: var(--warning-50);
    color: var(--warning-700);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.margin-low {
    background: var(--error-50);
    color: var(--error-700);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.period-select {
    padding: 8px 16px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.period-select:hover {
    border-color: var(--primary-500);
}

.period-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

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

/* ========================================
   P&L REPORTS & EXPENSE MANAGEMENT STYLES
   ======================================== */

/* Sub-tabs styling */
.sub-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--neutral-200);
    padding-bottom: 0;
}

.sub-tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    color: var(--neutral-600);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.sub-tab-btn:hover {
    color: var(--primary-600);
    background: var(--primary-50);
}

.sub-tab-btn.active {
    color: var(--primary-700);
    border-bottom-color: var(--primary-700);
}

.sub-tab-content {
    display: none;
}

.sub-tab-content.active {
    display: block;
}

/* Section container for grouped content */
.section-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.section-container h3 {
    margin: 0 0 16px 0;
    color: var(--neutral-800);
    font-size: 18px;
    font-weight: 600;
}

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

/* Expense form styling */
#expenseCategory {
    width: 100%;
}

#expenseDescription {
    width: 100%;
    resize: vertical;
    font-family: inherit;
    padding: 10px;
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    font-size: 14px;
}

#expenseDescription:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

/* Button icon styling */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-icon:hover {
    opacity: 1;
    transform: scale(1.1);
}

.btn-icon:active {
    transform: scale(0.95);
}

/* Period select styling enhancement */
.period-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--neutral-200);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.period-select:hover {
    background: var(--neutral-300);
    color: var(--text-primary);
    border-color: var(--neutral-400);
}

/* Status badge enhancements for expense categories */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    /* Prevent wrapping */
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Status variants */
.status-badge.completed,
.status-badge.in-stock,
.status-badge.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-badge.returned,
.status-badge.out-of-stock,
.status-badge.status-inactive {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.partial-return,
.status-badge.low-stock,
.status-badge.status-trial {
    background: #ffedd5;
    color: #9a3412;
}

/* ========================================
   NOTIFICATIONS
   ======================================== */
#notificationContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    /* Allow clicks to pass through container */
}

.notification {
    background: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    pointer-events: auto;
    /* Re-enable clicks on notifications */
    border-left: 4px solid #333;
    font-size: 14px;
    color: #333;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    border-left-color: #22c55e;
}

.notification.success::before {
    content: '✓';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #dcfce7;
    color: #15803d;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
}

.notification.error {
    border-left-color: #ef4444;
}

.notification.error::before {
    content: '!';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
}

.notification.info {
    border-left-color: #3b82f6;
}

.notification.info::before {
    content: 'i';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #dbeafe;
    color: #173863;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
}

.notification.warning {
    border-left-color: #f59e0b;
}

.notification.warning::before {
    content: '⚠';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
}

/* ========================================
   PURCHASE ITEMS UI
   ======================================== */
.purchase-items-section {
    margin-top: 20px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.purchase-items-title,
.purchase-items-header,
.btn-add-purchase-item {
    flex-shrink: 0;
}

.purchase-items-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: transparent;
    border-bottom: 1px solid #e2e8f0;
}

.purchase-items-title h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--neutral-800);
    letter-spacing: 0.3px;
}

.purchase-item-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-700);
    background: var(--primary-50);
    padding: 3px 10px;
    border-radius: 12px;
}

.purchase-items-header {
    display: grid;
    grid-template-columns: 36px 1.2fr 2fr 0.8fr 1.2fr 1.2fr 1.2fr 36px;
    gap: 8px;
    padding: 10px 16px;
    background: #eef2f7;
    font-weight: 600;
    font-size: 11px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
}

#purchaseItems,
#poItemsBody {
    padding: 8px;
    max-height: 38vh;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

/* Purchase modal flex layout — items scroll, header/footer stay fixed */
#addPurchaseModal {
    overflow: hidden !important;
}

#addPurchaseModal .modal-content.large {
    max-height: 88vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#addPurchaseModal #addPurchaseForm {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    flex: 1;
}

#addPurchaseModal .purchase-grid {
    flex-shrink: 0;
}

#addPurchaseModal .purchase-items-section {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#addPurchaseModal .purchase-grand-total,
#addPurchaseModal .modal-actions,
#addPurchaseModal #purchaseError {
    flex-shrink: 0;
}

/* Subtle scroll hint when overflowing */
#purchaseItems::-webkit-scrollbar,
#poItemsBody::-webkit-scrollbar {
    width: 5px;
}

#purchaseItems::-webkit-scrollbar-track,
#poItemsBody::-webkit-scrollbar-track {
    background: transparent;
}

#purchaseItems::-webkit-scrollbar-thumb,
#poItemsBody::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

#purchaseItems::-webkit-scrollbar-thumb:hover,
#poItemsBody::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.purchase-item-row {
    display: grid;
    grid-template-columns: 36px 1.2fr 2fr 0.8fr 1.2fr 1.2fr 1.2fr 36px;
    gap: 8px;
    padding: 10px 8px;
    background: white;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 6px;
    align-items: center;
    transition: all 0.2s ease;
}

.purchase-field {
    min-width: 0;
}

.purchase-field-label {
    display: none;
}

.purchase-field-inline-label {
    display: block;
}

.purchase-field-inline-label .purchase-field-label {
    display: none;
}

.purchase-input-wrap {
    position: relative;
}

.purchase-restaurant-stock-kind {
    margin-top: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.purchase-form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary);
}

.purchase-stock-kind-stack {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.purchase-restaurant-stock-kind .restaurant-stock-kind-option {
    min-height: 46px;
    padding: 10px 14px;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
    gap: 0;
    box-shadow: none;
}

.purchase-restaurant-stock-kind .restaurant-stock-kind-option:hover {
    transform: none;
    box-shadow: none;
}

.purchase-restaurant-stock-kind .restaurant-stock-kind-option strong {
    font-size: 13px;
}

.purchase-restaurant-stock-kind .restaurant-stock-kind-option.is-active {
    background: linear-gradient(180deg, #ffab3d 0%, #f7941d 100%);
    border-color: #f7941d;
    box-shadow: 0 10px 20px rgba(247, 148, 29, 0.2);
}

.purchase-restaurant-stock-kind .restaurant-stock-kind-option.is-active strong {
    color: #ffffff;
}

.purchase-stock-kind-hint {
    font-size: 11px;
    line-height: 1.45;
    color: var(--text-secondary);
}

.purchase-item-row:hover {
    border-color: var(--primary-300);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.purchase-item-row:focus-within {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.purchase-row-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-50);
    color: var(--primary-700);
    font-weight: 700;
    font-size: 12px;
    border-radius: 6px;
}

.purchase-item-row input {
    margin: 0 !important;
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.15s ease;
    background: #fff;
    color: #1e293b;
}

.purchase-item-row input:hover {
    border-color: var(--primary-300);
}

.purchase-item-row input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.purchase-item-row input::placeholder {
    color: #64748b;
    font-weight: 400;
}

.purchase-item-row input[type="number"] {
    font-variant-numeric: tabular-nums;
}

/* Hide number input spinners for cleaner look */
.purchase-item-row input[type="number"]::-webkit-outer-spin-button,
.purchase-item-row input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.purchase-subtotal-inline {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 6px;
    background: #f0fdf4;
    border-radius: 6px;
    border: 1px solid #bbf7d0;
    min-height: 36px;
}

.purchase-subtotal {
    font-weight: 700;
    font-size: 12px;
    color: #15803d;
    font-variant-numeric: tabular-nums;
}

/* Remove button */
.btn-remove-item {
    width: 30px;
    height: 30px;
    padding: 0;
    background: transparent;
    color: #64748b;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s;
}

.btn-remove-item:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #b91c1c;
}

/* Add Item button */
.btn-add-purchase-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    margin: 0;
    background: transparent;
    border: 2px dashed #cbd5e1;
    border-radius: 0 0 10px 10px;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-purchase-item:hover {
    background: #fff;
    border-color: var(--primary-400);
    color: var(--primary-700);
}

.btn-add-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--primary-50);
    color: var(--primary-600);
    border-radius: 50%;
    font-size: 16px;
    font-weight: 700;
    transition: all 0.2s;
}

.btn-add-purchase-item:hover .btn-add-icon {
    background: var(--primary-600);
    color: #fff;
}

/* Grand total */
.purchase-grand-total {
    margin-top: 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1.5px solid #bbf7d0;
    border-radius: 10px;
}

.purchase-grand-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.purchase-grand-total-label {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
}

.purchase-grand-total-amount {
    font-size: 22px;
    font-weight: 800;
    color: #15803d;
    font-variant-numeric: tabular-nums;
}

.purchase-mobile-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.purchase-mobile-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.purchase-mobile-item strong {
    color: var(--neutral-800);
    font-size: 13px;
    line-height: 1.35;
}

.purchase-mobile-item span,
.purchase-mobile-more {
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
}

.purchase-mobile-more {
    font-weight: 600;
}

/* ========================================
   PURCHASE CONFIRMATION MODAL
   ======================================== */
#confirmPurchaseModal {
    z-index: 1300;
}

#confirmPurchaseModal.active~.modal-overlay,
#confirmPurchaseModal.active+.modal-overlay {
    z-index: 1299;
}

.confirm-purchase-header {
    text-align: center;
    margin-bottom: 24px;
}

.confirm-purchase-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: var(--primary-50);
    color: var(--primary-600);
    border-radius: 50%;
    margin-bottom: 12px;
}

.confirm-purchase-header h2 {
    margin: 0 0 4px;
    font-size: 20px;
}

.confirm-purchase-subtitle {
    margin: 0;
    font-size: 13px;
    color: #64748b;
}

.confirm-purchase-body {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.confirm-purchase-info {
    padding: 14px 18px;
    display: flex;
    gap: 24px;
    border-bottom: 1px solid #e2e8f0;
}

.confirm-info-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.confirm-info-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.confirm-info-value {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.confirm-purchase-items-table {
    border-bottom: 1px solid #e2e8f0;
}

/* ========================================
   PURCHASE ORDER ITEMS UI
   ======================================== */
.po-items-section {
    margin-top: 20px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.po-items-header {
    display: grid;
    grid-template-columns: 2.5fr 0.8fr 1.2fr 1.2fr 36px;
    gap: 0;
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1.5px solid #e2e8f0;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.po-item-row {
    display: grid;
    grid-template-columns: 2.5fr 0.8fr 1.2fr 1.2fr 36px;
    gap: 8px;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

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

.po-item-row:hover {
    background: #f8fafc;
}

.po-item-row:focus-within {
    background: #fafbff;
}

.po-item-row select,
.po-item-row input[type="number"] {
    margin: 0 !important;
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    padding: 8px 10px;
    font-size: 13px;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.po-item-row select:hover,
.po-item-row input[type="number"]:hover {
    border-color: var(--primary-300);
}

.po-item-row select:focus,
.po-item-row input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.po-item-row input[type="number"]::-webkit-outer-spin-button,
.po-item-row input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.po-item-row input[type="number"] {
    font-variant-numeric: tabular-nums;
}

.po-row-total {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
    .po-items-header { display: none; }
    .po-item-row {
        display: flex !important;
        flex-direction: column;
        gap: 6px;
        padding: 12px 16px;
    }
    .po-item-row select,
    .po-item-row input[type="number"] { width: 100% !important; }
}

.confirm-items-head {
    display: grid;
    grid-template-columns: 2fr 0.7fr 1fr 1fr;
    gap: 8px;
    padding: 10px 18px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    background: #f1f5f9;
}

.confirm-items-body {
    max-height: 200px;
    overflow-y: auto;
}

.confirm-item-row {
    display: grid;
    grid-template-columns: 2fr 0.7fr 1fr 1fr;
    gap: 8px;
    padding: 10px 18px;
    font-size: 13px;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
}

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

.confirm-item-name {
    font-weight: 500;
}

.confirm-item-name small {
    display: block;
    font-size: 11px;
    color: #64748b;
    font-weight: 400;
}

.confirm-item-total {
    font-weight: 600;
    color: #1e293b;
}

.confirm-purchase-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
}

.confirm-purchase-total span:first-child {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
}

.confirm-purchase-total span:last-child {
    font-size: 20px;
    font-weight: 800;
    color: #15803d;
    font-variant-numeric: tabular-nums;
}

/* Make read-only total input look distinct */
.item-total {
    background-color: #f8fafc !important;
    border-color: #e2e8f0 !important;
    font-weight: 600;
    color: #334155 !important;
}

/* Purchase table group separator */
#purchasesTable td[rowspan] {
    border-top: 2px solid var(--border);
    background: var(--neutral-100);
    vertical-align: middle;
    text-align: center;
}

#purchasesTable .purchase-group-start td {
    border-top: 2px solid var(--border);
}

/* Supplier Autocomplete Suggestions */
.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0 0 8px 8px;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
}

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

.suggestion-item:hover {
    background: #f1f5f9;
    color: #173863;
}

#addPurchaseModal .modal-content {
    padding: 15px 25px;
    max-height: 85vh;
}

#addPurchaseForm .form-row {
    margin-bottom: 8px;
}

#addPurchaseForm .form-group label {
    font-size: 0.9rem;
    margin-bottom: 3px;
}

#addPurchaseForm input,
#addPurchaseForm select {
    padding: 8px 10px;
    font-size: 0.9rem;
}

#addPurchaseForm h3 {
    margin-top: 10px !important;
    margin-bottom: 6px !important;
    font-size: 1rem;
}

/* Hide scrollbar but allow content to fit */
#addPurchaseModal .modal-content {
    overflow-y: hidden !important;
}

/* Filter Section Layout */
.filter-section {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-section .btn-secondary {
    margin-left: auto;
}

@keyframes successPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.success-pulse {
    animation: successPulse 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#notificationContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notification {
    padding: 16px 24px;
    border-radius: 12px;
    background: white;
    color: var(--neutral-900);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid var(--primary-500);
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 300px;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification.success {
    border-left-color: #10b981;
}

.notification.error {
    border-left-color: #ef4444;
}

.notification.warning {
    border-left-color: #f59e0b;
}

/* ========================================
   ENHANCED DROPDOWN & SELECT STYLES
   ======================================== */

/* Base select styling */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.22 4.22a.75.75 0 0 1 1.06 0L6 6.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L2.22 5.28a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 36px !important;
    cursor: pointer;
}

select:hover {
    border-color: var(--primary-400);
}

/* Enhanced form select styling */
.form-group select {
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%234f46e5' d='M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
    background-position: right 14px center;
    background-size: 14px;
    padding-right: 40px !important;
    font-weight: 500;
    transition: all 0.2s ease;
}

.form-group select:hover {
    border-color: var(--primary-400);
    background-color: var(--primary-50);
}

.form-group select:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-100);
    background-color: #ffffff;
}

/* Select option styling */
select option {
    padding: 12px 16px;
    background: #ffffff;
    color: var(--neutral-900);
    font-weight: 400;
}

select option:hover,
select option:focus,
select option:checked {
    background: var(--primary-50);
    color: var(--primary-700);
}


/* Sale item grid children sizing */
.sale-item .searchable-dropdown {
    width: 100%;
    min-width: 0;
}

/* Sale item select (item picker in sales modal) */
.sale-item .item-select {
    width: 100%;
    min-width: 0;
    background: #ffffff;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--neutral-800);
    transition: all 0.2s ease;
}

.sale-item .item-select:hover {
    border-color: var(--primary-400);
    background-color: var(--primary-50);
}

.sale-item .item-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
    background-color: #ffffff;
}

.sale-item .item-select::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

/* Enhanced sale item inputs */
.sale-item input[type="number"] {
    width: 100%;
    min-width: 0;
    background: #ffffff;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--neutral-800);
    transition: all 0.2s ease;
    text-align: center;
}

.sale-item input[type="number"]:hover {
    border-color: var(--primary-400);
}

.sale-item input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

/* Enhanced period select styling override */
.period-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 10px 40px 10px 16px;
    border: 2px solid var(--border-light);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    background: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%236366f1' d='M3.22 5.22a.75.75 0 0 1 1.06 0L7 7.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L3.22 6.28a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 140px;
}

.period-select:hover {
    border-color: var(--primary-400);
    background-color: var(--primary-50);
}

.period-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-100);
    background-color: white;
}

/* Return invoice select */
#returnInvoice {
    padding: 12px 40px 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    background: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%236366f1' d='M3.22 5.22a.75.75 0 0 1 1.06 0L7 7.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L3.22 6.28a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
    width: 100%;
    cursor: pointer;
    transition: all 0.2s ease;
}

#returnInvoice:hover {
    border-color: var(--primary-400);
}

#returnInvoice:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-100);
}

/* Report modal selects */
#reportType,
#dateRange,
#exportFormat {
    padding: 12px 40px 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    background: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%236366f1' d='M3.22 5.22a.75.75 0 0 1 1.06 0L7 7.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L3.22 6.28a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#reportType:hover,
#dateRange:hover,
#exportFormat:hover {
    border-color: var(--primary-400);
    background-color: var(--primary-50);
}

#reportType:focus,
#dateRange:focus,
#exportFormat:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-100);
    background-color: white;
}

/* Purchase form selects */
#addPurchaseForm select,
#purchasePaymentMethod {
    appearance: none;
    -webkit-appearance: none;
    padding: 12px 40px 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    background: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%236366f1' d='M3.22 5.22a.75.75 0 0 1 1.06 0L7 7.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L3.22 6.28a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#addPurchaseForm select:hover,
#purchasePaymentMethod:hover {
    border-color: var(--primary-400);
}

#addPurchaseForm select:focus,
#purchasePaymentMethod:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-100);
}

/* User role select */
#newUserRole {
    padding: 12px 40px 12px 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%236366f1' d='M3.22 5.22a.75.75 0 0 1 1.06 0L7 7.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L3.22 6.28a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
}

/* Payment method selects */
#salePaymentMethod,
#expensePaymentMethod {
    padding: 12px 40px 12px 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%236366f1' d='M3.22 5.22a.75.75 0 0 1 1.06 0L7 7.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L3.22 6.28a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
}

.sale-item:hover {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-color: var(--primary-200);
}

/* Remove button styling */
.sale-item .btn-remove {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--error-50);
    color: var(--error-700);
    border: 1px solid var(--error-200);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sale-item .btn-remove:hover {
    background: var(--error-100);
    border-color: var(--error-300);
    color: var(--error-700);
    transform: scale(1.05);
}

/* Enhanced subtotal display */
.item-subtotal {
    font-weight: 700;
    color: var(--primary-700);
    font-size: 15px;
    background: var(--primary-50);
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    min-width: 100px;
}

/* ========================================
   SEARCHABLE DROPDOWN COMPONENT
   ======================================== */

.searchable-dropdown {
    position: relative;
    width: 100%;
}

.searchable-dropdown input {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--neutral-50);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.searchable-dropdown input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(23, 56, 99, 0.1);
}

.searchable-dropdown input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

.searchable-dropdown .dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
}

.searchable-dropdown .dropdown-options.show {
    display: block;
}

.searchable-dropdown .dropdown-option {
    padding: 6px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-primary);
    transition: background 0.1s ease;
    line-height: 1.3;
}

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

.searchable-dropdown .dropdown-option:hover {
    background: var(--primary-50);
}

.searchable-dropdown .dropdown-option.selected {
    background: var(--primary-100);
    font-weight: 600;
}

.searchable-dropdown .no-options {
    padding: 10px;
    text-align: center;
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 13px;
}

/* Return Items List Styling */
.return-item-row {
    background: white;
    border: 1px solid transparent;
}

.return-item-checkbox {
    width: 18px;
    height: 18px;
}

.item-details {
    flex: 1;
}

.return-qty-label {
    font-size: 12px;
    margin-right: 5px;
}

.return-qty-input {
    width: 60px;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

/* Clickable Dashboard Cards */
.clickable-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.clickable-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Non-clickable Dashboard Cards (for non-admin users) */
.non-clickable-card {
    cursor: default !important;
    pointer-events: none;
}

.non-clickable-card:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* ========================================
   MOBILE ENHANCEMENTS - SMARTPHONE OPTIMIZATION
   ======================================== */

/* Bottom Navigation Bar */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

.bottom-nav-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 100%;
    margin: 0 auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.bottom-nav-container::-webkit-scrollbar {
    display: none;
}

.bottom-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 8px 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 60px;
    min-height: 56px;
    border-radius: 12px;
    -webkit-tap-highlight-color: rgba(23, 56, 99, 0.2);
    touch-action: manipulation;
    user-select: none;
    position: relative;
    z-index: 1;
}

.bottom-nav-btn svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    stroke-width: 1.8;
    pointer-events: none;
}

.bottom-nav-btn span {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    pointer-events: none;
}

.bottom-nav-btn.active {
    color: var(--primary-500);
    background: var(--primary-50);
}

.bottom-nav-btn:active {
    transform: scale(0.92);
    background: var(--primary-100);
}

.restaurant-mobile-workflow-nav {
    display: none;
}

.restaurant-mobile-workflow-backdrop {
    position: absolute;
    inset: 0;
    border: none;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.12) 0%, rgba(15, 23, 42, 0.48) 100%);
    cursor: pointer;
}

.restaurant-mobile-workflow-drawer {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 20px 20px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--neutral-100) 100%);
    border: 1px solid var(--border);
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.26);
    overflow: hidden;
    animation: restaurant-mobile-workflow-drawer-in 0.24s ease-out;
}

.restaurant-mobile-workflow-handle {
    width: 46px;
    height: 5px;
    margin: 12px auto 6px;
    border-radius: 999px;
    background: var(--text-tertiary);
}

.restaurant-mobile-workflow-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 4px 16px 12px;
}

.restaurant-mobile-workflow-header-copy h3 {
    margin: 2px 0 4px;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.restaurant-mobile-workflow-header-copy p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.45;
}

.restaurant-mobile-workflow-eyebrow {
    display: inline-block;
    color: var(--primary-500);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.restaurant-mobile-workflow-close {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.restaurant-mobile-workflow-close:active {
    transform: scale(0.96);
}

.restaurant-mobile-workflow-scroll {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 16px 16px;
}

.restaurant-mobile-workflow-scroll::-webkit-scrollbar {
    display: none;
}

.restaurant-mobile-workflow-btn {
    min-height: 68px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.restaurant-mobile-workflow-btn-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.restaurant-mobile-workflow-btn-title {
    color: var(--text-primary);
    font-size: 0.93rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.restaurant-mobile-workflow-btn-desc {
    color: var(--text-tertiary);
    font-size: 0.76rem;
    line-height: 1.35;
}

.restaurant-mobile-workflow-btn-meta {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--neutral-100);
    color: var(--text-primary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.restaurant-mobile-workflow-btn.active {
    border-color: var(--primary-500);
    background: linear-gradient(135deg, var(--primary-50) 0%, var(--surface) 100%);
    box-shadow: 0 16px 32px rgba(37, 99, 235, 0.12);
}

.restaurant-mobile-workflow-btn.active .restaurant-mobile-workflow-btn-title {
    color: var(--primary-500);
}

.restaurant-mobile-workflow-btn.active .restaurant-mobile-workflow-btn-desc {
    color: var(--primary-800);
}

.restaurant-mobile-workflow-btn.active .restaurant-mobile-workflow-btn-meta {
    background: var(--primary-500);
    color: var(--neutral-50);
}

.restaurant-mobile-workflow-btn:active {
    transform: scale(0.98);
}

@keyframes restaurant-mobile-workflow-drawer-in {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

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

/* Settings — Sign Out section (mobile/tablet only — desktop uses sidebar logout) */
.settings-signout-section {
    display: none;
    margin-top: 40px;
    padding-top: 28px;
    border-top: 1px solid var(--border-light);
    flex-direction: column;
    gap: 16px;
}


.settings-signout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(239, 68, 68, 0.2);
}

.settings-signout-btn:hover {
    background: var(--error-600);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

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

.settings-signout-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    pointer-events: none;
}

/* Mobile Table Card View */
@media (max-width: 768px) {

    /* Show sign-out section on mobile (hidden on desktop — sidebar has logout there) */
    .settings-signout-section {
        display: flex;
    }

    .restaurant-mobile-workflow-nav {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1000;
    }

    /* Show bottom navigation - managed by JS to show only after login */
    .bottom-nav {
        display: none;
    }

    /* Hide FAB on mobile as it duplicates bottom nav functionality */
    .fab {
        display: none !important;
    }

    /* Ensure body and html allow scrolling */
    html,
    body {
        overflow-x: hidden;
        overflow-y: auto !important;
        height: auto;
        min-height: 100vh;
        -webkit-overflow-scrolling: touch;
    }

    body.restaurant-mobile-workflow-active {
        overflow: hidden !important;
    }

    /* Add padding to main content to account for bottom nav */
    .main-content {
        padding-top: 0 !important;
        margin-top: 0 !important;
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
        overflow-y: auto !important;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        height: auto;
        min-height: 100vh;
    }

    body.restaurant-mobile-workflow-active .main-content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }

    /* Tab content should scroll */
    .tab-content {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        max-height: none;
    }

    /* Screen containers */
    .screen {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* Allow mainApp to expand beyond viewport */
    #mainApp {
        height: auto !important;
        min-height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #mainApp.active {
        display: block !important;
    }

    /* Hide scrollbar on mobile for cleaner look */
    .table-container {
        -ms-overflow-style: none;
        scrollbar-width: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-container::-webkit-scrollbar {
        display: none;
    }

    /* Table to Card Transformation */
    .data-table.mobile-cards,
    #inventoryTable.mobile-cards,
    #salesTable.mobile-cards,
    #customersTable.mobile-cards,
    #returnsTable.mobile-cards,
    #purchasesTable.mobile-cards {
        display: block;
    }

    .data-table.mobile-cards thead,
    #inventoryTable.mobile-cards thead,
    #salesTable.mobile-cards thead,
    #customersTable.mobile-cards thead,
    #returnsTable.mobile-cards thead,
    #purchasesTable.mobile-cards thead {
        display: none;
    }

    .data-table.mobile-cards tbody,
    #inventoryTable.mobile-cards tbody,
    #salesTable.mobile-cards tbody,
    #customersTable.mobile-cards tbody,
    #returnsTable.mobile-cards tbody,
    #purchasesTable.mobile-cards tbody {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .data-table.mobile-cards tr,
    #inventoryTable.mobile-cards tr,
    #salesTable.mobile-cards tr,
    #customersTable.mobile-cards tr,
    #returnsTable.mobile-cards tr,
    #purchasesTable.mobile-cards tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 16px;
        box-shadow: var(--shadow-sm);
    }

    .data-table.mobile-cards td,
    #inventoryTable.mobile-cards td,
    #salesTable.mobile-cards td,
    #customersTable.mobile-cards td,
    #returnsTable.mobile-cards td,
    #purchasesTable.mobile-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid var(--border-light);
        font-size: 14px;
    }

    .data-table.mobile-cards td:last-child,
    #inventoryTable.mobile-cards td:last-child,
    #salesTable.mobile-cards td:last-child,
    #customersTable.mobile-cards td:last-child,
    #returnsTable.mobile-cards td:last-child,
    #purchasesTable.mobile-cards td:last-child {
        border-bottom: none;
        padding-top: 12px;
    }

    .data-table.mobile-cards td::before,
    #inventoryTable.mobile-cards td::before,
    #salesTable.mobile-cards td::before,
    #customersTable.mobile-cards td::before,
    #returnsTable.mobile-cards td::before,
    #purchasesTable.mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        flex-shrink: 0;
        margin-right: 16px;
    }

    /* Action buttons in card view — equal 2-col grid, no staggered wrap */
    .data-table.mobile-cards td[data-label="Actions"],
    .data-table.mobile-cards td[data-label="Action"],
    #inventoryTable.mobile-cards td[data-label="Actions"],
    #salesTable.mobile-cards td[data-label="Actions"],
    #customersTable.mobile-cards td[data-label="Actions"],
    #returnsTable.mobile-cards td[data-label="Actions"],
    #purchasesTable.mobile-cards td[data-label="Actions"],
    #quotationsTable.mobile-cards td[data-label="Actions"],
    #purchaseOrdersTable.mobile-cards td[data-label="Actions"],
    #invoicesTable.mobile-cards td[data-label="Actions"],
    #suppliersTable.mobile-cards td[data-label="Actions"],
    #usersTable.mobile-cards td[data-label="Actions"],
    #batchesTable.mobile-cards td[data-label="Actions"],
    #stockAdjustmentsTable.mobile-cards td[data-label="Actions"],
    #bulkOrdersTable.mobile-cards td[data-label="Actions"],
    #menuItemsTable.mobile-cards td[data-label="Actions"],
    #returnedItemsTable.mobile-cards td[data-label="Actions"] {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        align-items: stretch;
        justify-content: stretch;
        padding-top: 12px;
    }

    .data-table.mobile-cards td[data-label="Actions"]::before,
    .data-table.mobile-cards td[data-label="Action"]::before,
    #inventoryTable.mobile-cards td[data-label="Actions"]::before,
    #salesTable.mobile-cards td[data-label="Actions"]::before,
    #customersTable.mobile-cards td[data-label="Actions"]::before,
    #returnsTable.mobile-cards td[data-label="Actions"]::before,
    #purchasesTable.mobile-cards td[data-label="Actions"]::before,
    #quotationsTable.mobile-cards td[data-label="Actions"]::before,
    #purchaseOrdersTable.mobile-cards td[data-label="Actions"]::before,
    #invoicesTable.mobile-cards td[data-label="Actions"]::before,
    #suppliersTable.mobile-cards td[data-label="Actions"]::before,
    #usersTable.mobile-cards td[data-label="Actions"]::before,
    #batchesTable.mobile-cards td[data-label="Actions"]::before,
    #stockAdjustmentsTable.mobile-cards td[data-label="Actions"]::before,
    #bulkOrdersTable.mobile-cards td[data-label="Actions"]::before,
    #menuItemsTable.mobile-cards td[data-label="Actions"]::before,
    #returnedItemsTable.mobile-cards td[data-label="Actions"]::before {
        grid-column: 1 / -1;
        margin: 0 0 2px;
        width: auto;
    }

    .data-table.mobile-cards td[data-label="Actions"] > .btn-group,
    .data-table.mobile-cards td[data-label="Actions"] > .action-buttons,
    .data-table.mobile-cards td[data-label="Actions"] > .table-actions,
    .data-table.mobile-cards td[data-label="Actions"] > .table-actions-inner,
    .mobile-cards td[data-label="Actions"] > .action-buttons,
    .mobile-cards td[data-label="Actions"] > .table-actions,
    .mobile-cards td[data-label="Actions"] > .table-actions-inner {
        display: contents;
    }

    .data-table.mobile-cards td[data-label="Actions"] button,
    .data-table.mobile-cards td[data-label="Actions"] a,
    .data-table.mobile-cards td[data-label="Actions"] .btn,
    .mobile-cards td[data-label="Actions"] button,
    .mobile-cards td[data-label="Actions"] a,
    .mobile-cards .action-buttons button,
    .mobile-cards .table-actions button,
    .mobile-cards .table-actions-inner button {
        flex: none !important;
        width: 100%;
        min-width: 0 !important;
        min-height: 40px;
        margin: 0 !important;
        padding: 8px 10px !important;
        font-size: 13px;
        font-weight: 600;
        border-radius: 8px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        cursor: pointer;
        justify-self: stretch;
    }

    /* Card header styling for first cell */
    .data-table.mobile-cards td:first-child {
        font-weight: 600;
        font-size: 15px;
        color: var(--text-primary);
        padding-bottom: 12px;
        margin-bottom: 4px;
        border-bottom: 2px solid var(--primary-100);
    }

    .data-table.mobile-cards td:first-child::before {
        display: none;
    }

    /* Global mobile button improvements */
    button,
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-success,
    .btn-danger,
    .btn-info,
    .btn-warning,
    [type="button"],
    [type="submit"] {
        min-height: 44px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(23, 56, 99, 0.2);
        cursor: pointer;
    }

    /* Ensure buttons in tables are clickable */
    table button,
    .table-container button,
    td button {
        position: relative;
        z-index: 1;
        min-height: 36px;
        padding: 8px 12px;
    }

    /* Nav buttons in sidebar */
    .nav-btn {
        min-height: 48px;
        touch-action: manipulation;
    }

    /* Hide company name in dashboard header on mobile, show only 'Dashboard' */
    #dashboardBusinessName {
        display: none !important;
    }
}

/* Purchase/Inventory Form Mobile Optimization */
@media (max-width: 768px) {

    #purchases .tab-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    #purchases .tab-header .btn-primary {
        width: 100%;
    }

    #purchases .search-bar input {
        min-height: 48px;
        font-size: 16px;
    }

    #purchasesTable.mobile-cards td {
        align-items: flex-start;
    }

    #purchasesTable.mobile-cards td[data-label="Product"] {
        display: block;
    }

    .purchase-items-header {
        display: none !important;
    }

    .purchase-items-section {
        margin-top: 18px;
        border: none;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }

    .purchase-items-title {
        padding: 0 0 12px;
        border-bottom: none;
    }

    .purchase-row-num {
        display: none !important;
    }

    .purchase-subtotal-inline {
        grid-column: 1 / -1;
        justify-content: space-between;
        padding: 12px 0 0;
        background: transparent;
        border: none;
        border-top: 1px solid var(--border-light);
        border-radius: 0;
        min-height: 0;
    }

    .purchase-subtotal-inline::before {
        content: 'Subtotal:';
        font-size: 12px;
        font-weight: 500;
        color: #64748b;
    }

    .purchase-item-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        padding: 16px !important;
        margin-bottom: 16px;
        background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
        border: 1px solid var(--border-light);
        border-radius: 16px;
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    }

    .purchase-field {
        width: 100%;
    }

    .purchase-field-label {
        display: block;
        margin-bottom: 6px;
        color: var(--text-tertiary);
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .purchase-field-inline-label {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .purchase-field-inline-label .purchase-field-label {
        display: block;
        margin-bottom: 0;
    }

    .purchase-item-row .btn-remove-item {
        align-self: flex-end;
        order: 0;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: #ffffff;
    }

    .purchase-item-row:hover,
    .purchase-item-row:focus-within {
        border-color: var(--primary-200);
        box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    }

    /* Purchase item grid - stack on mobile */
    .inventory-form-grid,
    .sale-item-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        padding: 16px !important;
        background: var(--neutral-50);
        border-radius: 12px;
        margin-bottom: 12px;
        border: 1px solid var(--border);
    }

    .purchase-item-row input,
    .purchase-item-row select,
    .inventory-form-grid input,
    .inventory-form-grid select {
        width: 100% !important;
        min-height: 48px;
        font-size: 16px !important;
    }

    #purchaseItems {
        padding: 0;
        max-height: none;
        overflow: visible;
    }

    #addPurchaseModal .modal-content.large {
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
        padding: 0;
        overflow: hidden;
    }

    #addPurchaseModal h2 {
        margin: 0 !important;
        padding: 18px 16px 0;
        font-size: 22px;
        flex-shrink: 0;
    }

    #addPurchaseModal #addPurchaseForm {
        display: block;
        overflow-y: auto;
        min-height: 0;
        padding: 16px 16px calc(104px + env(safe-area-inset-bottom, 0px));
        -webkit-overflow-scrolling: touch;
    }

    #addPurchaseModal .purchase-grid {
        margin-bottom: 18px;
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 0;
        gap: 16px;
    }

    #addPurchaseModal .purchase-items-section {
        flex: none;
        min-height: auto;
        overflow: visible;
    }

    #addPurchaseModal .purchase-items-title {
        flex-wrap: wrap;
        gap: 10px;
        align-items: flex-start;
    }

    #addPurchaseModal .btn-add-purchase-item {
        justify-content: center;
        width: 100%;
        padding: 14px 16px;
        margin-top: 4px;
        border: 1.5px dashed var(--border);
        border-radius: 14px;
        background: var(--neutral-50);
    }

    #addPurchaseModal .purchase-grand-total {
        margin-top: 8px;
        padding: 16px;
    }

    #addPurchaseModal .purchase-grand-total-row {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }

    #addPurchaseModal .purchase-grand-total-amount {
        font-size: 20px;
    }

    #addPurchaseModal .modal-actions {
        margin-top: 0;
        flex-direction: row;
        background: var(--surface);
        border-top: 1px solid var(--border);
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    #addPurchaseModal .modal-actions button {
        width: auto;
    }

    /* Form sections */
    .form-section {
        padding: 16px;
        margin-bottom: 16px;
    }

    .form-section h3,
    .form-section h4 {
        font-size: 16px;
        margin-bottom: 16px;
    }

    /* Form grid single column on mobile */
    .form-grid,
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* Input groups */
    .input-group {
        flex-direction: column;
    }

    .input-group label {
        margin-bottom: 6px;
        font-size: 13px;
        font-weight: 600;
        color: var(--text-secondary);
    }

    .input-group input,
    .input-group select,
    .input-group textarea {
        width: 100%;
        min-height: 48px;
        font-size: 16px;
        padding: 12px 14px;
        border-radius: 10px;
    }

    /* Remove item button in forms */
    .remove-item-btn,
    .delete-row-btn {
        position: static !important;
        width: 100% !important;
        margin-top: 8px;
        min-height: 44px;
    }

    /* Quantity steppers */
    .quantity-stepper,
    .qty-stepper {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .quantity-stepper button,
    .qty-stepper button {
        min-width: 48px;
        min-height: 48px;
        font-size: 20px;
    }

    .quantity-stepper input,
    .qty-stepper input {
        width: 80px;
        text-align: center;
        font-size: 18px;
        font-weight: 600;
    }
}

/* Very Small Screen Optimizations (360px and below) */
@media (max-width: 360px) {
    .bottom-nav-btn {
        padding: 6px 5px;
        min-width: 48px;
    }

    .bottom-nav-btn svg {
        width: 22px;
        height: 22px;
    }

    .bottom-nav-btn span {
        font-size: 9px;
    }

    /* Smaller card padding */
    .data-table.mobile-cards tr {
        padding: 12px;
    }

    .data-table.mobile-cards td {
        font-size: 13px;
    }

    /* Compact form inputs */
    .input-group input,
    .input-group select {
        min-height: 44px;
        padding: 10px 12px;
    }
}

/* Touch Device Specific Enhancements */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .bottom-nav-btn {
        min-height: 56px;
    }

    /* Disable hover effects */
    .bottom-nav-btn:hover {
        background: transparent;
    }

    .bottom-nav-btn.active:hover {
        background: var(--primary-50);
    }

    /* Better tap feedback */
    .data-table.mobile-cards tr:active {
        background: var(--neutral-100);
        transform: scale(0.99);
    }

    /* Ensure all buttons are easily tappable */
    button,
    .btn,
    [type="button"],
    [type="submit"],
    a.btn {
        min-height: 44px;
        min-width: 44px;
        position: relative;
    }

    /* Active state feedback for all buttons */
    button:active,
    .btn:active,
    [type="button"]:active,
    [type="submit"]:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    /* Prevent text selection on buttons */
    button,
    .btn {
        user-select: none;
        -webkit-user-select: none;
    }

    /* Swipe hint for tables not in card mode */
    .table-container::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 40px;
        background: linear-gradient(to left, var(--surface), transparent);
        pointer-events: none;
        opacity: 0.8;
    }

    .table-container.scrolled-right::after {
        opacity: 0;
    }
}

/* Landscape Orientation Adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .bottom-nav {
        padding: 6px 0;
        padding-bottom: calc(6px + env(safe-area-inset-bottom));
    }

    .bottom-nav-btn svg {
        width: 20px;
        height: 20px;
        margin-bottom: 2px;
    }

    .bottom-nav-btn span {
        font-size: 9px;
    }

    /* Reduce main content bottom padding in landscape */
    .main-content {
        padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important;
    }
}

/* Mobile Modal Improvements */
@media (max-width: 768px) {
    .modal-content {
        border-radius: 20px 20px 0 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: none !important;
        max-height: 90vh !important;
        width: 100% !important;
        animation: slideUpModal 0.3s ease-out;
        overflow-y: auto !important;
        /* Ensure content is scrollable */
    }

    @keyframes slideUpModal {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .modal-header {
        padding: 20px 16px 16px;
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        background: var(--surface);
        z-index: 1;
        border-radius: 20px 20px 0 0;
    }

    .modal-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: var(--neutral-300);
        border-radius: 2px;
    }

    .modal-body {
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        max-height: calc(90vh - 140px);
        overscroll-behavior: contain;
    }

    .modal-footer {
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--border);
        position: sticky;
        bottom: 0;
        background: var(--surface);
    }

    .modal-footer .btn {
        width: 100%;
        min-height: 48px;
        margin: 4px 0;
    }
}

/* Mobile Search and Filter Improvements */
@media (max-width: 768px) {

    .search-filters,
    .filter-bar,
    .toolbar {
        flex-direction: column !important;
        gap: 12px !important;
        padding: 12px !important;
    }

    .search-filters input,
    .search-filters select,
    .filter-bar input,
    .filter-bar select {
        width: 100% !important;
        min-height: 48px;
    }

    .search-box {
        width: 100% !important;
    }

    .search-box input {
        width: 100%;
        padding-left: 44px;
    }

    /* Action buttons in toolbar */
    .toolbar .btn,
    .filter-bar .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Mobile Dashboard Cards */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .stat-card,
    .dashboard-card {
        padding: 16px !important;
    }

    .stat-card h3,
    .card-value {
        font-size: 24px !important;
    }

    .stat-card p,
    .card-label {
        font-size: 12px !important;
    }

    /* Ensure all scrollable containers work on mobile */
    .dashboard-grid-custom,
    .card-content,
    .table-wrapper,
    .form-container,
    .content-wrapper {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Tab header should not block scrolling */
    .tab-header {
        position: relative;
        z-index: 1;
    }

    /* Ensure cards and lists are scrollable */
    .metric-card,
    .stat-card,
    .dashboard-card {
        overflow: visible;
    }

    /* Fix any height constraints */
    .tab-content.active {
        display: block;
        height: auto;
        min-height: auto;
    }
}

/* Pull to Refresh Indicator (visual only - JS required for functionality) */
.pull-to-refresh {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--primary-50);
    justify-content: center;
    align-items: center;
    z-index: 999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.pull-to-refresh.active {
    transform: translateY(0);
}

.pull-to-refresh .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--primary-200);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Floating Action Button for Quick Actions */
.fab {
    display: none;
    position: fixed;
    bottom: calc(85px + env(safe-area-inset-bottom));
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--primary-500);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(23, 56, 99, 0.4);
    cursor: pointer;
    z-index: 998;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3);
}

.fab svg {
    width: 24px;
    height: 24px;
    pointer-events: none;
}

.fab:active {
    transform: scale(0.9);
    background: var(--primary-600);
}

@media (max-width: 768px) {
    .fab {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Hide sidebar completely on mobile - using bottom nav instead */
@media (max-width: 768px) {
    .sidebar {
        display: none !important;
        visibility: hidden;
    }

    /* Adjust main content to take full width */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* ========================================
   OFFLINE MODE STYLES
   ======================================== */

/* Persistent Offline Banner */
.offline-banner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    padding: 10px 20px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease-out;
}

.offline-banner.show {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.offline-banner svg {
    flex-shrink: 0;
}

.offline-banner-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.offline-banner-dismiss {
    position: absolute;
    right: 15px;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.offline-banner-dismiss:hover {
    opacity: 1;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

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

/* Adjust body padding when banner is visible */
body.offline-banner-visible {
    padding-top: 44px;
}

body.offline-banner-visible .sidebar {
    top: 44px;
    height: calc(100vh - 44px);
}

/* Disabled Navigation Items (Offline) */
.nav-btn.offline-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    position: relative;
}

.nav-btn.offline-disabled::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='1' y1='1' x2='23' y2='23'%3E%3C/line%3E%3Cpath d='M16.72 11.06A10.94 10.94 0 0 1 19 12.55'%3E%3C/path%3E%3Cpath d='M5 12.55a10.94 10.94 0 0 1 5.17-2.39'%3E%3C/path%3E%3Cpath d='M10.71 5.05A16 16 0 0 1 22.58 9'%3E%3C/path%3E%3Cpath d='M1.42 9a15.91 15.91 0 0 1 4.7-2.88'%3E%3C/path%3E%3Cpath d='M8.53 16.11a6 6 0 0 1 6.95 0'%3E%3C/path%3E%3Cline x1='12' y1='20' x2='12.01' y2='20'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
}

/* Offline Tooltip */
.nav-btn.offline-disabled .offline-tooltip {
    display: none;
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 10px;
    padding: 8px 12px;
    background: #333;
    color: white;
    font-size: 12px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nav-btn.offline-disabled .offline-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #333;
}

.nav-btn.offline-disabled:hover .offline-tooltip {
    display: block;
}

/* Bottom nav offline disabled state */
.bottom-nav-btn.offline-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.bottom-nav-btn.offline-disabled .bottom-nav-icon {
    position: relative;
}

.bottom-nav-btn.offline-disabled::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 50%;
    transform: translateX(50%) translateX(12px);
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='1' y1='1' x2='23' y2='23'%3E%3C/line%3E%3Cpath d='M16.72 11.06A10.94 10.94 0 0 1 19 12.55'%3E%3C/path%3E%3Cpath d='M5 12.55a10.94 10.94 0 0 1 5.17-2.39'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
}

/* Disabled buttons within content */
.btn.offline-disabled,
button.offline-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    position: relative;
}

/* Card/Section disabled state */
.card.offline-disabled,
.section.offline-disabled {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.card.offline-disabled::before,
.section.offline-disabled::before {
    content: 'Requires Internet';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    z-index: 10;
    white-space: nowrap;
}

/* Dark mode adjustments */
[data-theme="dark"] .offline-banner {
    background: linear-gradient(135deg, #d35400 0%, #c0392b 100%);
}

[data-theme="dark"] .nav-btn.offline-disabled .offline-tooltip {
    background: #1a1a2e;
    border: 1px solid #333;
}

[data-theme="dark"] .nav-btn.offline-disabled .offline-tooltip::before {
    border-right-color: #1a1a2e;
}

/* Subscription Status Badges */
.status-badge.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.status-inactive {
    background: #f1f5f9;
    color: #475569;
}

.status-badge.status-trial {
    background: #dbeafe;
    color: #173863;
}

.status-badge.status-overdue {
    background: #fef3c7;
    color: #92400e;
}

/* Grace period warning banner */
.grace-period-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 20px;
    color: #92400e;
}

.grace-period-banner svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.grace-period-banner .grace-banner-title {
    display: block;
    font-size: 14px;
    margin-bottom: 2px;
}

.grace-period-banner span {
    font-size: 13px;
}

.grace-period-banner .grace-renew-btn {
    margin-left: auto;
    flex-shrink: 0;
    background: #b45309;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.grace-period-banner .grace-renew-btn:hover {
    background: #d97706;
}

/* ========================================
   NOTIFICATIONS
   ======================================== */

.notification-btn {
    position: relative;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-btn:hover {
    background-color: var(--hover-bg);
    color: var(--primary-600);
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background-color: #dc2626;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.notification-modal {
    width: 400px;
    max-width: min(400px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    max-height: min(80vh, calc(100vh - 88px));
    position: fixed;
    top: 72px;
    right: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.notification-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 1;
}

.notification-modal .modal-header::before {
    display: none;
}

.notification-modal .modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}

.notification-modal .modal-body {
    padding: 0;
    background: var(--surface);
}

.notification-modal .modal-actions {
    position: static;
    bottom: auto;
    left: auto;
    right: auto;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 12px;
}

.notification-modal .modal-actions button {
    flex: none;
    height: auto;
    min-height: auto;
}

@media (max-width: 640px) {
    .notification-modal {
        top: 72px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        max-height: calc(100vh - 84px);
    }
}

.notification-list {
    overflow-y: auto;
    max-height: min(60vh, calc(100vh - 160px));
    padding: 0;
    background: var(--surface);
}

.notification-item {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    transition: background 0.2s ease, border-color 0.2s ease;
}

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

.notification-item.unread {
    background-color: var(--primary-50);
    border-left: 3px solid var(--primary-500);
}

.notification-item:hover {
    background-color: var(--neutral-50);
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.notification-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.notification-time {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    margin-left: 8px;
}

.notification-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.notification-type {
    display: inline-block;
    font-size: 10px;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    margin-bottom: 4px;
}

.notification-type.info {
    background: var(--primary-50);
    color: var(--primary-600);
}

.notification-type.warning {
    background: var(--warning-50);
    color: var(--warning-700);
}

.notification-type.critical {
    background: var(--error-50);
    color: var(--error-700);
}

.notification-type.success {
    background: var(--success-50);
    color: var(--success-700);
}

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

.btn-text {
    background: none;
    border: none;
    color: var(--primary-600);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

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



/* ========================================
   SUBSCRIPTION EXPIRED MODAL
   ======================================== */

.expired-modal-content {
    max-width: 500px;
    text-align: center;
    border-top: 4px solid #ef4444;
}

.expired-modal-header {
    justify-content: center;
    border: none;
    padding-bottom: 0;
}

.expired-modal-icon {
    background: #fee2e2;
    padding: 16px;
    border-radius: 50%;
    display: inline-flex;
}

.expired-modal-title {
    color: var(--neutral-900, #1f2937);
    margin: 16px 0 8px;
}

.expired-modal-desc {
    color: var(--neutral-600, #4b5563);
    font-size: 16px;
    line-height: 1.5;
}

.expired-modal-info {
    background: var(--neutral-100, #f3f4f6);
    padding: 16px;
    border-radius: 8px;
    margin: 20px 0;
    text-align: left;
}

.expired-modal-info-label {
    margin: 0 0 8px;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    color: var(--neutral-500, #6b7280);
}

.expired-modal-list {
    margin: 0;
    padding-left: 20px;
    color: var(--neutral-700, #374151);
}

.expired-modal-list li {
    margin-bottom: 4px;
}

.expired-modal-contact {
    margin-top: 16px;
    font-size: 13px;
    color: #6b7280;
    text-align: center;
}

.expired-modal-footer {
    justify-content: center;
    gap: 12px;
    border: none;
    padding-top: 0;
}

.debt-primary-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.debt-primary-ref {
    font-weight: 700;
    color: var(--text-primary);
}

.debt-primary-subtitle,
.debt-date {
    color: var(--text-secondary);
    font-size: 13px;
}

.debt-balance {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 96px;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
}

.debt-balance.due {
    background: var(--error-50, #fee2e2);
    color: var(--error-700, #b91c1c);
}

.debt-balance.settled {
    background: var(--success-50, #dcfce7);
    color: var(--success-700, #15803d);
}

.debt-actions {
    gap: 8px;
}

.statement-view {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.statement-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 16px;
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, var(--surface) 0%, var(--neutral-50, #f8fafc) 100%);
}

.statement-hero.due {
    border-color: rgba(220, 38, 38, 0.2);
}

.statement-hero.settled {
    border-color: rgba(22, 163, 74, 0.18);
}

.statement-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--primary-100);
    color: var(--primary-700);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.statement-hero-copy h3 {
    margin: 10px 0 8px;
    font-size: 26px;
    line-height: 1.1;
    color: var(--text-primary);
}

.statement-party-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.statement-meta-chip {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
}

.statement-meta-chip.muted {
    color: var(--text-muted, #64748b);
}

.statement-balance-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
}

/* Tint over the theme's surface so the card stays readable in dark mode. */
.statement-balance-card.due {
    border-color: rgba(220, 38, 38, 0.3);
    background: linear-gradient(180deg, rgba(220, 38, 38, 0.14) 0%, rgba(220, 38, 38, 0) 100%), var(--surface);
}

.statement-balance-card.settled {
    border-color: rgba(22, 163, 74, 0.3);
    background: linear-gradient(180deg, rgba(22, 163, 74, 0.14) 0%, rgba(22, 163, 74, 0) 100%), var(--surface);
}

.statement-balance-label,
.statement-balance-caption {
    color: var(--text-secondary);
    font-size: 12px;
}

.statement-balance-card strong {
    font-size: 24px;
    line-height: 1.1;
    color: var(--text-primary);
}

.statement-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.statement-kpi-card {
    padding: 16px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.statement-kpi-card span {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.statement-kpi-card strong {
    font-size: 20px;
    color: var(--text-primary);
}

.statement-section {
    padding: 18px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.statement-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.statement-section-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 18px;
}

.statement-section-header p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.statement-entry-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.statement-entry-card {
    padding: 14px;
    border-radius: 16px;
    background: var(--neutral-50, #f8fafc);
    border: 1px solid var(--border);
}

.statement-entry-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.statement-entry-top h5 {
    margin: 0 0 4px;
    font-size: 15px;
    color: var(--text-primary);
}

.statement-entry-top p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.45;
}

.statement-entry-date {
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.statement-entry-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.statement-entry-metrics div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.statement-entry-metrics span {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.statement-entry-metrics strong {
    font-size: 15px;
    color: var(--text-primary);
}

.statement-entry-metrics strong.is-due {
    color: var(--error-700, #b91c1c);
}

.statement-entry-metrics strong.is-settled {
    color: var(--success-700, #15803d);
}

.statement-empty {
    padding: 16px;
    border-radius: 14px;
    border: 1px dashed var(--border);
    color: var(--text-secondary);
    text-align: center;
    background: var(--neutral-50, #f8fafc);
}

.statement-actions-bar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    position: sticky;
    bottom: 0;
    padding-top: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, var(--surface) 35%);
}

@media (max-width: 900px) {
    .statement-hero {
        grid-template-columns: 1fr;
    }

    .statement-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .debt-actions {
        width: 100%;
    }

    .debt-actions .btn-small {
        flex: 1;
        min-width: 120px;
    }

    .statement-view {
        gap: 14px;
    }

    .statement-hero,
    .statement-section {
        padding: 14px;
        border-radius: 16px;
    }

    .statement-hero-copy h3 {
        font-size: 22px;
    }

    .statement-kpis {
        grid-template-columns: 1fr;
    }

    .statement-entry-top,
    .statement-entry-metrics {
        grid-template-columns: 1fr;
        display: grid;
    }

    .statement-entry-date {
        white-space: normal;
    }

    .statement-actions-bar {
        flex-direction: column;
    }

    .statement-actions-bar .btn-primary,
    .statement-actions-bar .btn-secondary {
        width: 100%;
    }
}

/* Fix for Sales, Inventory, and Purchases Scroll Issue - keeping header fixed */
#sales.active,
#inventory.active,
#purchases.active {
    height: 100vh;
    /* Fill full viewport height */
    padding-bottom: 0;
    /* Remove bottom padding to extend to bottom edge */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent container from causing main-content scroll */
}

#sales .table-container,
#inventory .table-container,
#purchases .table-container {
    flex: 1;
    /* Take all remaining vertical space */
    overflow-y: auto;
    /* Scroll internally */
    min-height: 0;
    /* Required for flex child scrolling */
}

#sales .sub-nav-tabs,
#sales .tab-header,
#sales .search-bar,
#inventory .sub-nav-tabs,
#inventory .tab-header,
#inventory .search-bar,
#purchases .sub-nav-tabs,
#purchases .tab-header,
#purchases .search-bar {
    flex-shrink: 0;
    /* Prevent header elements from shrinking */
}

/* ========================================
   SEARCHABLE DROPDOWN COMPONENT
   ======================================== */

.custom-dropdown-container {
    background: var(--surface);
    /* Fallback */
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-xl);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--neutral-400) transparent;
}

/* Scrollbar tweaks for dropdown */
.custom-dropdown-container::-webkit-scrollbar {
    width: 6px;
}

.custom-dropdown-container::-webkit-scrollbar-thumb {
    background-color: var(--neutral-400);
    border-radius: 4px;
}

/* Dropdown Items */
.dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: 6px;
    transition: all 0.15s ease;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-item:hover,
.dropdown-item.selected {
    background: var(--primary-100);
    color: var(--primary-900);
}

.dropdown-item .sub-text {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Dark Mode Specific overrides */
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item.selected {
    background: rgba(26, 56, 98, 0.2);
    color: var(--primary-400);
    border: 1px solid rgba(26, 56, 98, 0.3);
}

[data-theme="dark"] .dropdown-item .sub-text {
    color: var(--neutral-500);
}

/* Loading & Empty States */
.dropdown-loading,
.dropdown-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 13px;
}

/* Animations */
.dropdown-enter {
    opacity: 0;
    transform: translateY(-5px);
}

.custom-dropdown-container[data-placement="top"].dropdown-enter {
    transform: translateY(5px);
}

.dropdown-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Input enhancements when dropdown attached */
input[data-dropdown-attached="true"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

/* Clickable table rows */
.clickable-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.clickable-row:hover {
    background-color: var(--primary-50) !important;
}

/* Ensure empty state is not clickable if it gets the class somehow */
.clickable-row .empty-state {
    cursor: default;
}

/* ========================================
   BUSINESS BRANDING SECTION
   ======================================== */

.branding-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 0;
}

.migration-hub {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 0;
}

.migration-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.migration-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 18px;
    min-height: 220px;
}

.migration-card-copy {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.migration-card-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.branding-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow-sm);
}

.branding-card h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.branding-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.branding-readonly-note {
    margin-bottom: 20px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--primary-200);
    background: var(--primary-50);
    color: var(--primary-700);
    font-size: 13px;
    line-height: 1.5;
}

.logo-upload-area {
    position: relative;
}

/* Dropzone */
.logo-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    background: var(--neutral-50);
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
}

.logo-dropzone:hover {
    border-color: var(--primary-400);
    background: var(--primary-50);
}

.logo-dropzone.drag-over {
    border-color: var(--primary-500);
    background: var(--primary-100);
    transform: scale(1.01);
}

.logo-dropzone svg {
    color: var(--text-tertiary);
    margin-bottom: 16px;
    transition: color 0.2s ease;
}

.logo-dropzone:hover svg {
    color: var(--primary-500);
}

.dropzone-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

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

.dropzone-link {
    color: var(--primary-600);
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.dropzone-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin: 0;
}

/* Logo Preview */
.logo-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--neutral-50);
}

.logo-preview-img {
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

.logo-readonly-state {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 28px 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--neutral-50);
    text-align: center;
    color: var(--text-secondary);
}

.logo-readonly-state strong {
    color: var(--text-primary);
    font-size: 15px;
}

.logo-readonly-state span {
    max-width: 320px;
    font-size: 13px;
    line-height: 1.5;
}

.btn-sm {
    padding: 8px 16px !important;
    font-size: 13px !important;
    min-height: 36px !important;
    border-radius: 8px;
}

/* Upload Status */
.upload-status {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.upload-status.success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.upload-status.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.upload-status.loading {
    background: #eff6ff;
    color: #173863;
    border: 1px solid #bfdbfe;
}

/* URA EFRIS settings */
.efris-status {
    margin: 8px 0 0;
    font-weight: 600;
    color: var(--text-secondary);
}

.efris-status[data-tone="success"] {
    color: var(--success-700);
}

.efris-status[data-tone="error"] {
    color: var(--error-700);
}

.efris-mono {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    word-break: break-all;
}

.efris-own-keys {
    margin-top: 12px;
}

.efris-own-keys summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
}

.efris-check-steps {
    margin: 12px 0 0;
    padding-left: 20px;
    display: grid;
    gap: 6px;
    font-size: 13px;
}

.efris-check-steps li[data-ok="true"] {
    color: var(--success-700);
}

.efris-check-steps li[data-ok="false"] {
    color: var(--error-700);
}

.efris-work {
    display: grid;
    gap: 16px;
    margin-top: 16px;
}

.efris-unit-rows {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px 16px;
}

.efris-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 8px 0;
}

.efris-toolbar input,
.efris-toolbar select {
    flex: 1 1 200px;
    min-width: 0;
}

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

.efris-table th,
.efris-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    vertical-align: top;
}

.efris-table small {
    color: var(--text-secondary);
}

.efris-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.efris-badge-registered {
    color: var(--success-700);
    border-color: currentColor;
}

.efris-badge-failed,
.efris-badge-needs_details {
    color: var(--error-700);
    border-color: currentColor;
}

.efris-problems {
    margin: 8px 0;
    padding-left: 18px;
    display: grid;
    gap: 4px;
    font-size: 13px;
}

.efris-diff {
    color: var(--error-700);
    font-weight: 600;
}

/* URA status on the sales and returns lists */
.efris-list-status:not(:empty) {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
}

.efris-list-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 999px;
    border: 1px solid currentColor;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.efris-list-badge-ok {
    color: var(--success-700);
}

.efris-list-badge-bad {
    color: var(--error-700);
}

.efris-list-badge-wait {
    color: var(--text-secondary);
}

.efris-send-again {
    padding: 1px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-primary, inherit);
    font-size: 11px;
    cursor: pointer;
}

.efris-send-again:hover {
    background: var(--hover-bg);
}

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

.branding-feature-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.branding-feature-copy {
    flex: 1 1 280px;
}

.branding-feature-title {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.branding-feature-description {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.branding-feature-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-theme-toggle-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
}

.language-segmented-control {
    display: inline-grid;
    grid-template-columns: minmax(92px, 1fr) minmax(92px, 1fr);
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--neutral-100);
    min-width: 196px;
}

.language-option {
    min-height: 36px;
    padding: 8px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.language-option:hover {
    color: var(--text-primary);
}

.language-option.active {
    background: var(--surface);
    color: var(--primary-700);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.branding-feature-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 82px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
}

.branding-feature-status.enabled {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.branding-feature-status.disabled {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.currency-settings-rows {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.currency-settings-row {
    display: grid;
    grid-template-columns: minmax(90px, 0.8fr) minmax(160px, 1.3fr) minmax(130px, 1fr) auto;
    gap: 12px;
    align-items: end;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.currency-settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.currency-settings-field input {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--neutral-50);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.currency-settings-field input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-50);
    background: #ffffff;
}

.currency-settings-field input[readonly] {
    background: var(--neutral-100);
    color: var(--text-secondary);
    cursor: default;
}

.currency-active-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.currency-settings-actions {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.late-interest-config-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-top: 12px;
}

.late-interest-config-field {
    display: grid;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
}

.late-interest-config-field input {
    width: 110px;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--border-color, #d9dee7);
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text-primary, #1f2937);
}

.uom-settings-block {
    display: grid;
    gap: 16px;
}

.uom-settings-add {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(110px, 0.8fr) auto;
    gap: 12px;
    align-items: end;
}

.uom-settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.uom-settings-field input {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--neutral-50);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.uom-settings-field input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-50);
    background: #ffffff;
}

.uom-settings-table-wrap {
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.uom-settings-table {
    margin: 0;
}

.uom-settings-table th,
.uom-settings-table td {
    padding: 10px 12px;
}

.uom-unit-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.uom-default-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--primary-50);
    color: var(--primary-700);
    border: 1px solid var(--primary-200);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.uom-settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quantity-with-unit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(112px, 0.72fr);
    gap: 8px;
    align-items: stretch;
}

.quantity-with-unit select {
    min-height: 42px;
    width: 100%;
}

.inventory-unit-abbr {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    margin-left: 4px;
}

.inventory-currency-prices-heading {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.inventory-currency-prices-heading label {
    margin: 0;
    color: var(--text-primary);
    font-weight: 700;
}

.inventory-currency-prices-heading small {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
}

.inventory-currency-price-rows {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.inventory-currency-price-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.inventory-currency-price-row input {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--neutral-50);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.inventory-currency-price-row input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-50);
    background: #ffffff;
}

@media (max-width: 768px) {
    .branding-feature-toggle {
        align-items: stretch;
    }

    .restaurant-stock-kind-picker {
        grid-template-columns: 1fr;
    }

    .purchase-restaurant-stock-kind {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .branding-feature-control {
        width: 100%;
        justify-content: space-between;
    }

    .language-segmented-control {
        width: 100%;
    }

    .currency-settings-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .uom-settings-add {
        grid-template-columns: 1fr;
    }

    .uom-settings-add .btn-primary {
        width: 100%;
    }

    .quantity-with-unit {
        grid-template-columns: 1fr;
    }

    .currency-active-toggle {
        justify-content: space-between;
    }
}

#hospitalitySaleModal .hospitality-pos-modal {
    --modal-width: 1480px;
    width: min(1480px, 98vw) !important;
    max-width: 98vw !important;
    height: min(94vh, 980px) !important;
    max-height: min(94vh, 980px) !important;
    padding: 20px !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

#hospitalitySaleModal {
    max-width: 98vw;
    max-height: 96vh;
    overflow: hidden;
}

#hospitalityPosRoot {
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    overflow: hidden !important;
    padding: 0 !important;
    overscroll-behavior: contain;
}

#hospitalitySaleModal .hospitality-pos-header {
    flex: 0 0 auto !important;
    display: flex !important;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin: 0 0 18px !important;
    padding: 0 !important;
    border-bottom: 0 !important;
    background: transparent !important;
    overflow: visible !important;
}

#hospitalitySaleModal .hospitality-pos-header h2 {
    margin: 0 0 6px !important;
    font-size: 22px;
}

#hospitalitySaleModal .hospitality-pos-header p {
    margin: 0;
    color: var(--text-secondary);
}

.hospitality-pos-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 20px;
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.hospitality-pos-browser,
.hospitality-pos-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    min-width: 0;
    height: 100%;
}

.hospitality-pos-browser {
    padding: 18px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: contain;
}

.hospitality-pos-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.hospitality-pos-search {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 14px;
    font-size: 14px;
    background: var(--neutral-50);
}

.hospitality-pos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    scrollbar-gutter: stable;
    align-content: start;
    padding-right: 2px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.hospitality-pos-grid::-webkit-scrollbar {
    width: 12px;
}

.hospitality-pos-grid::-webkit-scrollbar-track {
    background: var(--neutral-100);
    border-radius: 999px;
}

.hospitality-pos-grid::-webkit-scrollbar-thumb {
    background: var(--neutral-400);
    border-radius: 999px;
    border: 3px solid var(--neutral-100);
}

.hospitality-pos-grid::-webkit-scrollbar-thumb:hover {
    background: var(--primary-500);
}

.hospitality-pos-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.hospitality-pos-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-300);
}

.hospitality-pos-card:disabled {
    opacity: 0.58;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.hospitality-pos-card-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.35;
}

.hospitality-pos-card-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.hospitality-pos-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: auto;
}

.hospitality-pos-card-price {
    font-size: 15px;
    font-weight: 800;
    color: var(--primary-700);
}

.hospitality-pos-card-stock {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
}

.hospitality-pos-summary {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 0;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
}

.hospitality-pos-summary h3 {
    margin: 0;
    font-size: 18px;
}

.hospitality-pos-receipt-card {
    border: 1px solid rgba(22, 163, 74, 0.18);
    border-radius: 8px;
    padding: 14px;
    background: rgba(240, 253, 244, 0.98);
}

.hospitality-pos-receipt-title {
    font-size: 14px;
    font-weight: 800;
    color: #166534;
}

.hospitality-pos-receipt-meta {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.5;
    color: #166534;
}

.hospitality-pos-receipt-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hospitality-pos-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.restaurant-check-selector {
    display: grid;
    gap: 6px;
    margin-bottom: 2px;
}

.restaurant-check-selector select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 38px 8px 12px;
    background-color: var(--neutral-50);
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
}

.restaurant-check-selector label,
.hospitality-pos-field label {
    display: block;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
}

.restaurant-check-selector small {
    color: var(--text-secondary);
    line-height: 1.35;
}

.restaurant-table-check-item {
    border-left: 4px solid var(--primary);
}

.hospitality-pos-field {
    min-width: 0;
}

.hospitality-pos-field-span-2 {
    grid-column: 1 / -1;
}

.hospitality-pos-fields-finalize {
    gap: 8px;
}

.hospitality-pos-fields input,
.hospitality-pos-fields select,
.hospitality-pos-fields textarea,
.hospitality-pos-item-note {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 14px;
    font-size: 14px;
    background-color: var(--neutral-50);
}

.hospitality-pos-fields textarea,
.hospitality-pos-item-note {
    padding: 12px 14px;
    resize: vertical;
    font-family: inherit;
}

.hospitality-pos-editing-banner {
    margin: 10px 0 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(249, 115, 22, 0.12);
    color: #c2410c;
    font-size: 13px;
    font-weight: 700;
}

.hospitality-pos-queued-banner {
    margin: 12px 0 0;
    padding: 12px 14px;
    border: 1px solid rgba(249, 115, 22, 0.18);
    border-radius: 8px;
    background: rgba(255, 247, 237, 0.98);
}

.hospitality-pos-queued-copy {
    color: #9a3412;
    font-size: 13px;
    line-height: 1.5;
}

.hospitality-pos-queued-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.hospitality-pos-order-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 240px;
    min-height: 150px;
    max-height: none;
    overflow: auto;
    padding-right: 6px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.hospitality-pos-order-list.is-empty {
    flex: 0 0 auto;
    min-height: 0;
}

.hospitality-pos-empty {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    text-align: center;
    color: var(--text-secondary);
    background: var(--neutral-50);
}

.hospitality-pos-order-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
}

.hospitality-pos-order-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.hospitality-pos-order-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.hospitality-pos-order-sku {
    font-size: 12px;
    color: var(--text-secondary);
}

.hospitality-pos-order-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.hospitality-pos-qty {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hospitality-pos-qty button {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--neutral-50);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.hospitality-pos-qty span {
    min-width: 26px;
    text-align: center;
    font-weight: 700;
}

/* Typed quantity for stock lines (1.5 kg of fish); menu lines keep the plain count. */
.hospitality-pos-qty .hospitality-pos-qty-input {
    width: 64px;
    min-height: 44px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    -moz-appearance: textfield;
}

.hospitality-pos-qty .hospitality-pos-qty-input::-webkit-outer-spin-button,
.hospitality-pos-qty .hospitality-pos-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.hospitality-pos-order-total {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    justify-self: end;
}

.hospitality-pos-remove {
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    border: none;
    background: transparent;
    color: #b91c1c;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.hospitality-pos-summary-footer {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.hospitality-pos-saving {
    border-radius: 8px;
    padding: 12px 14px;
    background: rgba(30, 64, 175, 0.08);
    color: var(--primary-700);
    font-size: 13px;
    font-weight: 700;
}

.hospitality-pos-total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.hospitality-pos-total-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 700;
}

.hospitality-pos-total-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
}

.hospitality-pos-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 980px) {
    .hospitality-pos-layout {
        grid-template-columns: 1fr;
    }

    .hospitality-pos-order-list {
        max-height: none;
    }
}

@media (max-width: 1100px) {
    #hospitalitySaleModal {
        padding: 0 !important;
        background: var(--neutral-50) !important;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        overflow: hidden !important;
    }

    #hospitalitySaleModal .hospitality-pos-modal {
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        padding: 16px !important;
    }

    #hospitalityPosRoot {
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .hospitality-pos-header {
        flex-shrink: 0;
        align-items: center;
        margin-bottom: 12px !important;
    }

    .hospitality-pos-header h2 {
        font-size: 20px;
    }

    .hospitality-pos-header p {
        font-size: 13px;
    }

    .hospitality-pos-layout {
        height: 100%;
        min-height: 0;
        grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
        gap: 14px;
    }

    .hospitality-pos-browser,
    .hospitality-pos-summary {
        min-height: 0;
        overflow: hidden;
        border-radius: 8px;
        padding: 14px;
    }

    .hospitality-pos-toolbar {
        flex-shrink: 0;
    }

    .hospitality-pos-grid {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        align-content: start;
        padding-right: 2px;
        -webkit-overflow-scrolling: touch;
    }

    .hospitality-pos-summary {
        padding: 14px;
    }

    .hospitality-pos-order-list {
        flex: 1;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 980px) {
    #hospitalitySaleModal .hospitality-pos-modal {
        padding: 12px !important;
    }

    .hospitality-pos-layout {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto;
    }

    .hospitality-pos-browser {
        min-height: 0;
    }

    .hospitality-pos-summary {
        max-height: 42vh;
    }

    .hospitality-pos-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 640px) {
    .hospitality-pos-header {
        gap: 10px;
    }

    .hospitality-pos-header p {
        display: none;
    }

    .hospitality-pos-toolbar {
        grid-template-columns: 1fr;
    }

    .hospitality-pos-card {
        min-height: 116px;
        padding: 14px;
        border-radius: 8px;
    }

    .hospitality-pos-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .hospitality-pos-summary {
        max-height: 46vh;
    }

    .hospitality-pos-actions,
    .hospitality-pos-receipt-actions,
    .hospitality-pos-queued-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .hospitality-pos-actions button,
    .hospitality-pos-receipt-actions button,
    .hospitality-pos-queued-actions button {
        width: 100%;
    }
    .hospitality-pos-card-name {
        min-height: 2.7em;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
    }

    .hospitality-pos-card-meta,
    .hospitality-pos-card-stock {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 420px) {
    .hospitality-pos-fields {
        grid-template-columns: 1fr;
    }

    .hospitality-pos-field-span-2 {
        grid-column: auto;
    }

}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

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

/* Pharmacy parity: consistent compact action buttons on mobile table cards.
   Keep flex on an inner wrapper, never on the <td> itself — flex on table-cells
   does not grow row height when buttons wrap, which caused View/PDF/Mark Sent
   overlap in quotations and purchase orders. */
td.action-buttons,
td.table-actions {
    display: table-cell;
    vertical-align: middle;
    max-width: none;
    width: 1%;
    white-space: normal;
}

.action-buttons:not(td),
.table-actions:not(td),
.table-actions-inner {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px !important;
    flex-wrap: wrap;
    white-space: normal;
    max-width: none;
    min-width: 0;
}

td.action-buttons {
    min-width: max-content;
}

.action-buttons > button,
.action-buttons > a,
.table-actions > button,
.table-actions > a,
.table-actions-inner > button,
.table-actions-inner > a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px !important;
    min-width: 72px;
    padding: 6px 10px !important;
    margin: 0 !important;
    border: 1px solid transparent !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 1.1 !important;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.action-buttons > button:hover,
.action-buttons > a:hover,
.table-actions > button:hover,
.table-actions > a:hover,
.table-actions-inner > button:hover,
.table-actions-inner > a:hover {
    box-shadow: none !important;
    transform: none !important;
    filter: brightness(0.97);
}

.action-buttons .btn-primary,
.action-buttons .btn-info,
.table-actions .btn-primary,
.table-actions .btn-info,
.table-actions-inner .btn-primary,
.table-actions-inner .btn-info {
    background: var(--primary-600) !important;
    color: #fff !important;
    border-color: var(--primary-600) !important;
}

.action-buttons .btn-secondary,
.table-actions .btn-secondary,
.table-actions-inner .btn-secondary {
    background: var(--neutral-100) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

.action-buttons .btn-success,
.table-actions .btn-success,
.table-actions-inner .btn-success {
    background: #15803d !important;
    color: #fff !important;
    border-color: #15803d !important;
}

.action-buttons .btn-danger,
.action-buttons .btn-danger-outline,
.table-actions .btn-danger,
.table-actions .btn-danger-outline,
.table-actions-inner .btn-danger,
.table-actions-inner .btn-danger-outline {
    background: #dc2626 !important;
    color: #fff !important;
    border-color: #dc2626 !important;
}

.action-buttons .btn-warning,
.table-actions .btn-warning,
.table-actions-inner .btn-warning {
    background: #b45309 !important;
    color: #fff !important;
    border-color: #b45309 !important;
}

@media (max-width: 768px) {
    .action-buttons:not(td),
    .table-actions:not(td),
    .table-actions-inner {
        justify-content: stretch;
        width: 100%;
    }

    .action-buttons > button,
    .action-buttons > a,
    .table-actions > button,
    .table-actions > a,
    .table-actions-inner > button,
    .table-actions-inner > a {
        flex: 0 1 auto;
        min-height: 38px !important;
        min-width: 0;
        width: auto;
    }

    .table-container table.mobile-cards tbody td.action-buttons {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 8px !important;
        width: 100%;
    }

    .table-container table.mobile-cards tbody td.action-buttons::before {
        flex: 0 0 100%;
    }

    .table-container table.mobile-cards tbody td.action-buttons > button,
    .table-container table.mobile-cards tbody td.action-buttons > a {
        align-self: center;
        flex: 0 1 auto;
        height: auto !important;
        min-height: 40px !important;
        min-width: 0;
        padding: 8px 12px !important;
        border-radius: 6px !important;
    }
}

/* Lefori auth shell tuned to the pharmacy sizing and fixed viewport */
#loginScreen.active,
#registrationScreen.active {
    min-height: 100vh;
    min-height: 100svh;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
}

#loginScreen.active {
    background:
        linear-gradient(180deg, #eef2f6 0%, #e6ebf1 100%);
}

#registrationScreen.active {
    display: flex;
    background: #ffffff;
}

#loginScreen .enterprise-login-layout,
#registrationScreen .enterprise-register-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    min-height: 100vh;
    min-height: 100svh;
    height: 100vh;
    height: 100svh;
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #0d2137;
}

#loginScreen .enterprise-login-left,
#registrationScreen .enterprise-register-left {
    position: relative;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0) 24%),
        linear-gradient(160deg, #11263b 0%, #0d1f31 74%);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 30px;
    padding: 44px 48px;
    overflow: hidden;
}

#loginScreen .enterprise-login-left::before,
#registrationScreen .enterprise-register-left::before,
#loginScreen .enterprise-login-left::after,
#registrationScreen .enterprise-register-left::after {
    content: '';
    position: absolute;
    pointer-events: none;
}

#loginScreen .enterprise-login-left::before,
#registrationScreen .enterprise-register-left::before {
    inset: auto 52px 40px 52px;
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 78%);
}

#loginScreen .enterprise-login-left::after,
#registrationScreen .enterprise-register-left::after {
    top: 0;
    right: 0;
    width: 28%;
    height: 100%;
    background: linear-gradient(180deg, rgba(42, 143, 163, 0.08) 0%, rgba(42, 143, 163, 0) 44%);
}

#loginScreen .enterprise-login-brand,
#registrationScreen .enterprise-login-brand,
#loginScreen .enterprise-login-left-body,
#registrationScreen .enterprise-register-left-body,
#loginScreen .enterprise-login-left-footer,
#registrationScreen .enterprise-login-left-footer {
    position: relative;
    z-index: 1;
}

#loginScreen .enterprise-login-brand,
#registrationScreen .enterprise-login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

#loginScreen .enterprise-login-brand-icon,
#registrationScreen .enterprise-login-brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

#loginScreen .enterprise-login-brand-icon img,
#registrationScreen .enterprise-login-brand-icon img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

#loginScreen .enterprise-login-brand-name,
#registrationScreen .enterprise-login-brand-name {
    color: #ffffff;
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

#loginScreen .enterprise-login-brand-meta,
#registrationScreen .enterprise-login-brand-meta {
    display: flex;
    align-items: center;
}

#loginScreen .enterprise-login-brand-sub,
#registrationScreen .enterprise-login-brand-sub {
    font-size: 10px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0;
}

#loginScreen .enterprise-login-left-body,
#registrationScreen .enterprise-register-left-body {
    max-width: 400px;
}

#loginScreen .enterprise-login-badge,
#registrationScreen .enterprise-login-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid rgba(201, 147, 58, 0.45);
    border-radius: 20px;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #e0aa52;
    margin-bottom: 22px;
}

#loginScreen .enterprise-login-badge-dot,
#registrationScreen .enterprise-login-badge-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #c9933a;
}

#loginScreen .enterprise-login-headline,
#registrationScreen .enterprise-login-headline {
    font-size: clamp(30px, 2.8vw, 40px);
    line-height: 1.12;
    color: #ffffff;
    font-weight: 600;
    letter-spacing: -0.035em;
    margin-bottom: 14px;
}

#loginScreen .enterprise-login-desc,
#registrationScreen .enterprise-login-desc {
    font-size: 14px;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.66);
    max-width: 34ch;
    margin-bottom: 18px;
}

#loginScreen .enterprise-login-feature-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

#loginScreen .enterprise-login-feature-item {
    display: block;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

#loginScreen .enterprise-login-feature-text strong {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.88);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 5px;
}

#loginScreen .enterprise-login-feature-text span {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.56);
    line-height: 1.55;
}

#registrationScreen .enterprise-register-side-notes {
    width: 100%;
    display: grid;
    gap: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

#registrationScreen .enterprise-register-side-note {
    padding: 14px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

#registrationScreen .enterprise-register-side-note strong {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.82);
}

#registrationScreen .enterprise-register-side-note span {
    display: block;
    font-size: 13px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.56);
}

#loginScreen .enterprise-login-left-footer,
#registrationScreen .enterprise-login-left-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

#loginScreen .enterprise-login-security-badge,
#registrationScreen .enterprise-login-security-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.44);
    letter-spacing: 0.03em;
}

#loginScreen .enterprise-login-right,
#registrationScreen .enterprise-register-right {
    background: linear-gradient(180deg, #f8fafc 0%, #f2f5f8 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

#loginScreen .enterprise-login-form-area,
#registrationScreen .enterprise-register-form-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 32px;
    overflow: hidden;
}

#registrationScreen .enterprise-register-right {
    overflow-y: auto;
}

#registrationScreen .enterprise-register-form-area {
    align-items: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
}

#loginScreen .enterprise-login-form-card {
    width: 100%;
    max-width: 440px;
    padding: 28px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(13, 33, 55, 0.08);
    border-radius: 18px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

#registrationScreen .enterprise-register-form-card {
    width: 100%;
    max-width: 760px;
    padding: 28px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(13, 33, 55, 0.08);
    border-radius: 18px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

#loginScreen .enterprise-login-form-header,
#registrationScreen .enterprise-login-form-header {
    margin-bottom: 22px;
}

#loginScreen .enterprise-login-form-eyebrow,
#registrationScreen .enterprise-login-form-eyebrow {
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #1a6b7c;
    font-weight: 600;
    margin-bottom: 8px;
}

#loginScreen .enterprise-login-form-title,
#registrationScreen .enterprise-login-form-title {
    font-size: clamp(25px, 2.4vw, 32px);
    line-height: 1.12;
    color: #0d2137;
    letter-spacing: -0.04em;
    margin-bottom: 8px;
}

#loginScreen .enterprise-login-form-subtitle,
#registrationScreen .enterprise-login-form-subtitle {
    font-size: 13.5px;
    color: #5a7080;
    line-height: 1.55;
}

#loginScreen .enterprise-login-divider,
#registrationScreen .enterprise-login-divider {
    height: 1px;
    background: rgba(13, 33, 55, 0.12);
    margin: 18px 0 20px;
}

#loginScreen .enterprise-login-mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin-bottom: 20px;
    border: 1px solid rgba(13, 33, 55, 0.1);
    border-radius: 11px;
    background: #f4f7f8;
}

#loginScreen .enterprise-login-mode-button {
    min-height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #5a7080;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

#loginScreen .enterprise-login-mode-button:hover {
    color: #0d2137;
}

#loginScreen .enterprise-login-mode-button.is-active {
    color: #0d2137;
    background: #ffffff;
    box-shadow: 0 2px 7px rgba(13, 33, 55, 0.1);
}

#loginScreen .enterprise-login-form {
    display: block;
}

#loginScreen .enterprise-login-field {
    margin-bottom: 14px;
}

#loginScreen .enterprise-login-field:last-of-type {
    margin-bottom: 0;
}

#registrationScreen .enterprise-register-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}

#registrationScreen .enterprise-register-form-grid .full-width {
    grid-column: 1 / -1;
}

#loginScreen .enterprise-login-field-label,
#registrationScreen .enterprise-login-field-label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #0d2137;
    margin-bottom: 5px;
}

#loginScreen .enterprise-login-field-hint,
#registrationScreen .enterprise-login-field-hint {
    font-size: 12px;
    color: #5a7080;
    margin-bottom: 6px;
    line-height: 1.4;
}

#loginScreen .enterprise-login-input-wrap,
#registrationScreen .enterprise-login-input-wrap {
    position: relative;
}

#loginScreen .enterprise-login-field-input,
#registrationScreen .enterprise-login-field-input {
    width: 100%;
    height: 44px;
    padding: 0 44px 0 16px;
    border: 1px solid rgba(13, 33, 55, 0.14);
    border-radius: 10px;
    font-size: 15px;
    color: #0d2137;
    background: #ffffff;
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    letter-spacing: 0.2px;
}

#registrationScreen .enterprise-login-field-input {
    padding-right: 16px;
}

#loginScreen .enterprise-login-field-input::placeholder,
#registrationScreen .enterprise-login-field-input::placeholder {
    color: #64748b;
    font-size: 14px;
}

#loginScreen .enterprise-login-field-input:focus,
#registrationScreen .enterprise-login-field-input:focus {
    border-color: #1a6b7c;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(26, 107, 124, 0.08);
}

#loginScreen .enterprise-login-field-input[type="email"] {
    padding-right: 16px;
}

#loginScreen .enterprise-login-pin-input {
    letter-spacing: 3px;
    font-size: 18px;
    font-weight: 600;
}

#loginScreen .enterprise-login-pin-input::placeholder {
    letter-spacing: 1px;
    font-size: 14px;
    font-weight: 400;
}

#registrationScreen .enterprise-login-pin-input {
    letter-spacing: 1px;
    font-size: 15px;
    font-weight: 500;
}

#loginScreen .enterprise-login-input-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #5a7080;
    opacity: 0.45;
    pointer-events: none;
    display: inline-flex;
}

#loginScreen .enterprise-login-toggle-pin {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #5a7080;
    opacity: 0.5;
    transition: opacity 0.2s;
}

#loginScreen .enterprise-login-toggle-pin:hover {
    opacity: 0.9;
}

#loginScreen .enterprise-login-cta,
#registrationScreen .enterprise-login-cta {
    width: 100%;
    height: 46px;
    margin-top: 8px;
    border: none;
    border-radius: 10px;
    background: #0d2137;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

#loginScreen .enterprise-login-cta:hover,
#registrationScreen .enterprise-login-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(13, 33, 55, 0.22);
}

#loginScreen .enterprise-login-cta[disabled] {
    cursor: wait;
}

#loginScreen .enterprise-login-error {
    min-height: 18px;
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.45;
    color: #c62828;
}

#loginScreen .enterprise-login-links {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

#loginScreen .enterprise-login-link {
    font-size: 13px;
    color: #1a6b7c;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

#loginScreen .enterprise-login-link:hover {
    color: #0d2137;
}

#loginScreen .enterprise-login-link-muted {
    color: #5a7080;
    font-weight: 400;
}

#loginScreen .enterprise-login-link-muted strong {
    color: #0d2137;
    font-weight: 600;
}

#registrationScreen .enterprise-register-section {
    display: grid;
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding-top: 12px;
    border-top: 1px solid rgba(13, 33, 55, 0.12);
}

#registrationScreen .enterprise-register-form-grid .enterprise-register-section:first-child {
    padding-top: 0;
    border-top: none;
}

#registrationScreen .enterprise-register-section span {
    font-size: 14px;
    font-weight: 700;
    color: #0d2137;
    line-height: 1.3;
}

#registrationScreen .enterprise-register-section p {
    font-size: 12.5px;
    color: #5a7080;
    line-height: 1.5;
    max-width: 42ch;
}

#registrationScreen .enterprise-register-error {
    margin-top: 2px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(185, 28, 28, 0.18);
    background: #fef2f2;
    color: #b91c1c;
    font-size: 12px;
    line-height: 1.45;
}

#registrationScreen .enterprise-register-success {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(21, 128, 61, 0.18);
    background: #f0fdf4;
    color: #166534;
    font-size: 12px;
    line-height: 1.45;
}

#registrationScreen .enterprise-register-result {
    padding: 18px 20px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f7f4ef 0%, #ffffff 100%);
    border: 1px solid rgba(201, 147, 58, 0.22);
}

#registrationScreen .enterprise-register-result-label {
    margin-bottom: 8px;
    color: #1a6b7c;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

#registrationScreen .enterprise-register-result-caption {
    color: #5a7080;
    font-size: 13px;
    font-weight: 600;
}

#registrationScreen .enterprise-register-result-number {
    margin: 8px 0 10px;
    color: #0d2137;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1;
}

#registrationScreen .enterprise-register-result-helper {
    color: #5a7080;
    font-size: 12.5px;
    line-height: 1.5;
}

#registrationScreen .enterprise-register-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
    text-align: center;
}

#registrationScreen .enterprise-register-footer p {
    font-size: 12.5px;
    color: #5a7080;
}

#registrationScreen .enterprise-register-footer a {
    color: #0d2137;
    font-weight: 600;
    text-decoration: none;
}

#registrationScreen .enterprise-register-footer a:hover {
    color: #1a6b7c;
}

#registrationScreen .enterprise-register-footer-note {
    font-size: 12px;
}

@media (max-width: 1080px) {
    #loginScreen .enterprise-login-layout,
    #registrationScreen .enterprise-register-layout {
        grid-template-columns: minmax(290px, 0.86fr) minmax(0, 1fr);
    }

    #loginScreen .enterprise-login-left,
    #registrationScreen .enterprise-register-left {
        padding: 32px 26px;
        gap: 22px;
    }

    #loginScreen .enterprise-login-headline,
    #registrationScreen .enterprise-login-headline {
        font-size: clamp(26px, 2.6vw, 34px);
    }

    #loginScreen .enterprise-login-form-area,
    #registrationScreen .enterprise-register-form-area {
        padding: 22px 22px;
    }

    #loginScreen .enterprise-login-desc,
    #registrationScreen .enterprise-login-desc {
        margin-bottom: 14px;
    }

    #registrationScreen .enterprise-register-side-notes {
        gap: 0;
    }
}

@media (max-width: 900px) {
    #loginScreen .enterprise-login-layout,
    #registrationScreen .enterprise-register-layout {
        grid-template-columns: 1fr;
    }

    #loginScreen .enterprise-login-left,
    #registrationScreen .enterprise-register-left {
        display: none;
    }

    #loginScreen .enterprise-login-form-area,
    #registrationScreen .enterprise-register-form-area {
        padding: 32px 28px;
    }
}

@media (max-width: 640px) {
    #loginScreen .enterprise-login-form-area,
    #registrationScreen .enterprise-register-form-area {
        padding: 24px 18px;
    }

    #loginScreen .enterprise-login-form-header {
        margin-bottom: 26px;
    }

    #loginScreen .enterprise-login-form-title,
    #registrationScreen .enterprise-login-form-title {
        font-size: 30px;
    }

    #loginScreen .enterprise-login-divider,
    #registrationScreen .enterprise-login-divider {
        margin: 22px 0;
    }

    #registrationScreen .enterprise-register-form-grid {
        grid-template-columns: 1fr;
    }

    #registrationScreen .enterprise-register-section {
        grid-template-columns: 1fr;
        gap: 6px;
        padding-top: 14px;
    }

    #registrationScreen .enterprise-register-result-number {
        font-size: 28px;
    }

    #loginScreen .enterprise-login-links {
        flex-direction: column;
        align-items: flex-start;
    }

    #registrationScreen .enterprise-register-result {
        padding: 16px;
    }
}

.section-subtitle {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 14px;
}

.menu-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.menu-status-badge.active {
    background: rgba(16, 185, 129, 0.14);
    color: #0f8a63;
}

.menu-status-badge.inactive {
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-secondary);
}

.menu-recipe-section {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #f8fafc;
}

.menu-recipe-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.menu-recipe-header h3 {
    margin: 0 0 6px;
}

.menu-recipe-rows {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.menu-recipe-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(140px, 0.8fr) minmax(140px, 0.8fr) auto;
    gap: 14px;
    align-items: end;
    padding: 14px;
    border: 1px solid #dbe4f0;
    border-radius: 12px;
    background: #fff;
}

.menu-recipe-row-action {
    min-width: 110px;
}

@media (max-width: 768px) {
    .menu-recipe-header,
    .menu-recipe-row {
        grid-template-columns: 1fr;
        flex-direction: column;
    }
}

.btn-small {
    padding: 8px 12px;
    font-size: 12px;
}

/* Batch tracking workspace */
.batch-tracking-nav-btn {
    position: relative;
}

.batch-tracking-nav-btn .badge {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 18px;
    min-height: 18px;
    padding: 2px 6px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.batch-tracking-header > div {
    min-width: 0;
}

.expiry-alerts-dashboard {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 20px 0;
}

.alert-card {
    min-height: 132px;
    padding: 16px;
    border: 1px solid transparent;
    border-left-width: 4px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    cursor: pointer;
    box-shadow: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.alert-card.expired,
.alert-card.critical {
    background: #fee2e2;
    border-color: #fecaca;
    border-left-color: #ef4444;
}

.alert-card.warning {
    background: #fef3c7;
    border-color: #fde68a;
    border-left-color: #f59e0b;
}

.alert-card.info {
    background: #eff6ff;
    border-color: #bfdbfe;
    border-left-color: var(--primary-600);
}

.alert-card .alert-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.alert-card .alert-count {
    margin: 8px 0 4px;
    color: var(--text-primary);
    font-size: 32px;
    line-height: 1;
}

.alert-card.expired .alert-count,
.alert-card.critical .alert-count {
    color: #dc2626;
}

.alert-card.warning .alert-count {
    color: #92400e;
}

.alert-card.info .alert-count {
    color: var(--primary-700);
}

.alert-card .alert-desc {
    color: var(--text-secondary);
    font-size: 13px;
}

.batch-toolbar {
    margin: 18px 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(210px, 260px);
    gap: 12px;
    align-items: end;
    background: var(--surface);
}

.batch-search-field input,
.batch-filter-field select {
    width: 100%;
    min-height: 44px;
    margin: 0;
}

/* A search-type input, which the app's text-input styles do not cover. */
.batch-search-field input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: var(--surface);
    color: var(--text-primary);
}

.batch-filter-field {
    margin: 0;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.batch-filter-field span {
    display: block;
    margin-bottom: 5px;
}

.expiry-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.expiry-badge.expired {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.expiry-badge.critical {
    background: #ffedd5;
    border-color: #fdba74;
    color: #c2410c;
}

.expiry-badge.warning {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #854d0e;
}

.expiry-badge.info {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.expiry-badge.normal {
    background: #dcfce7;
    border-color: #86efac;
    color: #15803d;
}

.expiry-status {
    font-weight: 700;
}

.expiry-status.expired {
    color: #b91c1c;
}

.expiry-status.critical {
    color: #c2410c;
}

.expiry-status.warning {
    color: #a16207;
}

.expiry-status.info {
    color: #1d4ed8;
}

#batchesTable tbody tr {
    transition: background-color 0.15s ease;
}

#batchesTable tbody tr:hover {
    background: var(--neutral-50);
}

.batch-product-link,
.batch-expiry-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary-700);
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.batch-product-link:hover,
.batch-expiry-link:hover {
    text-decoration: underline;
}

.batch-no-expiry {
    color: var(--text-secondary);
    font-size: 12px;
}

.batch-state-badge {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 999px;
    background: var(--neutral-100);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.batch-state-badge.available {
    background: #dcfce7;
    color: #15803d;
}

.batch-state-badge.disposed {
    background: #fee2e2;
    color: #b91c1c;
}

.batch-row.expired {
    background: #fff5f5;
}

.batch-row.critical {
    background: #fffaf0;
}

.batch-row.warning {
    background: #fffbeb;
}

.batch-help-box {
    margin-top: 20px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--neutral-50);
    color: var(--text-secondary);
    font-size: 13px;
}

.batch-help-box strong {
    display: block;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.batch-help-box ul {
    margin: 0;
    padding-left: 20px;
}

.batch-help-box li + li {
    margin-top: 6px;
}

.batch-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.batch-detail-list {
    display: grid;
    gap: 14px;
}

.batch-detail-card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.batch-detail-heading {
    margin-bottom: 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.batch-detail-heading strong,
.batch-detail-heading span {
    display: block;
}

.batch-detail-heading > div > span {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 12px;
}

.batch-detail-grid > div {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--neutral-50);
}

.batch-detail-grid > div > span {
    display: block;
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.batch-detail-note {
    margin: 12px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.batch-detail-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.batch-detail-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--neutral-50);
}

.batch-detail-item span {
    display: block;
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.purchase-item-meta.batch-purchase-fields {
    margin: -2px 8px 10px 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    background: var(--neutral-50);
}

.purchase-item-meta.batch-purchase-fields .purchase-field-label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.purchase-item-meta.batch-purchase-fields label > span {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.purchase-item-meta.batch-purchase-fields > small {
    grid-column: 1 / -1;
    color: var(--text-secondary);
}

.purchase-item-meta.batch-purchase-fields input {
    width: 100%;
    min-height: 40px;
    margin: 0;
    padding: 8px 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: #1e293b;
}

@media (max-width: 900px) {
    .expiry-alerts-dashboard {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    #restaurantQuickServiceActionCard {
        display: inline-flex !important;
        min-height: 44px;
    }

    #customersTable.mobile-cards tbody td.action-buttons {
        box-sizing: border-box;
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
        gap: 8px !important;
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        margin: 0 !important;
        padding: 12px 0 0 !important;
        align-items: stretch;
        overflow: visible;
    }

    #customersTable.mobile-cards tbody td.action-buttons::before {
        grid-column: 1 / -1;
        width: 100%;
        margin: 0 0 2px;
        text-align: center;
    }

    #customersTable.mobile-cards tbody td.action-buttons > button,
    #customersTable.mobile-cards tbody td.action-buttons > a {
        box-sizing: border-box;
        position: static !important;
        width: 100% !important;
        max-width: 100%;
        min-width: 0 !important;
        margin: 0 !important;
        align-self: stretch;
    }

    .batch-tracking-header {
        align-items: stretch;
    }

    .batch-tracking-header .btn-secondary {
        width: 100%;
    }

    .expiry-alerts-dashboard {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin: 14px 0;
    }

    .alert-card {
        min-height: 116px;
        padding: 12px;
    }

    .alert-card .alert-label {
        font-size: 10px;
    }

    .alert-card .alert-count {
        font-size: 27px;
    }

    .alert-card .alert-desc {
        font-size: 11px;
    }

    .batch-toolbar {
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .batch-table-container {
        overflow: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    #batchesTable.mobile-cards tbody tr {
        border-left: 4px solid var(--primary-500);
    }

    #batchesTable.mobile-cards tbody tr.expired {
        border-left-color: var(--error-500);
    }

    #batchesTable.mobile-cards tbody tr.critical {
        border-left-color: var(--warning-600);
    }

    #batchesTable.mobile-cards td.action-buttons {
        display: flex;
        align-items: stretch;
        gap: 8px !important;
    }

    #batchesTable.mobile-cards td.action-buttons button {
        flex: 1 1 120px;
    }

    .batch-detail-grid,
    .purchase-item-meta.batch-purchase-fields {
        grid-template-columns: 1fr;
    }

    .batch-detail-heading,
    .batch-detail-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .batch-detail-actions button {
        width: 100%;
    }

    .purchase-item-meta.batch-purchase-fields {
        margin: -8px 0 16px;
        padding: 12px;
    }
}

/* Pharmacy parity: standard mobile dialogs open as bottom sheets. */
.modal-close {
    appearance: none;
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
    color: var(--text-primary);
    border-color: var(--primary-300);
    background: var(--primary-50);
}

@media (max-width: 768px) {
    .modal:not(#hospitalitySaleModal) {
        display: none !important;
        position: fixed !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 10px !important;
        transform: none !important;
        align-items: flex-end !important;
        justify-content: center !important;
        overflow: hidden !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: rgba(15, 23, 42, 0.64) !important;
        backdrop-filter: blur(4px);
        box-shadow: none !important;
    }

    .modal:not(#hospitalitySaleModal).active {
        display: flex !important;
    }

    .modal:not(#hospitalitySaleModal) > .modal-content {
        position: relative !important;
        inset: auto !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 92vh !important;
        max-height: 92dvh !important;
        padding: 0 !important;
        transform: none !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        border: 1px solid var(--border) !important;
        border-bottom: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        background: var(--surface) !important;
        box-shadow: 0 -18px 50px rgba(15, 23, 42, 0.28) !important;
        animation: pharmacySheetUp 0.28s ease-out !important;
    }

    .modal:not(#hospitalitySaleModal) .modal-header,
    .modal:not(#hospitalitySaleModal) .modal-content > h2 {
        position: relative;
        flex: 0 0 auto;
        margin: 0 !important;
        padding: 28px 16px 14px !important;
        border-bottom: 1px solid var(--border) !important;
        border-radius: 20px 20px 0 0 !important;
        background: var(--surface) !important;
    }

    .modal:not(#hospitalitySaleModal) .modal-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    .modal:not(#hospitalitySaleModal) .modal-header::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        width: 48px;
        height: 5px;
        transform: translateX(-50%);
        border-radius: 999px;
        background: var(--neutral-400);
    }

    .modal:not(#hospitalitySaleModal) .modal-header h2,
    .modal:not(#hospitalitySaleModal) .modal-content > h2 {
        margin: 0 !important;
        color: var(--text-primary);
        font-size: 20px;
        line-height: 1.25;
    }

    .modal:not(#hospitalitySaleModal) .modal-close {
        width: 44px;
        height: 44px;
        min-height: 44px;
        font-size: 24px;
    }

    .modal:not(#hospitalitySaleModal) .modal-body,
    .modal:not(#hospitalitySaleModal) .modal-content > div:not(.modal-header):not(.modal-actions):not(.modal-footer) {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        padding: 16px !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .modal:not(#hospitalitySaleModal) .modal-content > form {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        padding: 16px 16px 0 !important;
        display: block !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .modal:not(#hospitalitySaleModal) .modal-actions,
    .modal:not(#hospitalitySaleModal) .modal-footer,
    .modal:not(#hospitalitySaleModal) .modal-content > form > .modal-actions {
        position: sticky !important;
        inset: auto !important;
        bottom: 0 !important;
        z-index: 2;
        display: flex;
        flex-wrap: wrap;
        justify-content: stretch;
        gap: 8px;
        margin: 0 -16px !important;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom)) !important;
        border-top: 1px solid var(--border) !important;
        background: var(--surface) !important;
        box-shadow: none !important;
    }

    .modal:not(#hospitalitySaleModal) .modal-content > .modal-actions,
    .modal:not(#hospitalitySaleModal) .modal-content > .modal-footer {
        margin: 0 !important;
    }

    .modal:not(#hospitalitySaleModal) .modal-actions button,
    .modal:not(#hospitalitySaleModal) .modal-footer button {
        flex: 1 1 140px;
        min-width: 0;
        min-height: 48px;
        margin: 0 !important;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 700;
    }

    @keyframes pharmacySheetUp {
        from {
            transform: translateY(100%);
        }

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

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    .modal:not(#hospitalitySaleModal) > .modal-content {
        animation: none !important;
    }
}

/* Desktop workspace top bar */
.app-topbar {
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    z-index: 160;
    display: none;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-height: 60px;
    padding: 8px 24px 8px 20px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid #e2e8f0;
    backdrop-filter: blur(14px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

body.dashboard-topbar-visible .app-topbar {
    display: flex;
}

.app-topbar[hidden] {
    display: none !important;
}

.app-topbar-context {
    min-width: 0;
    flex: 0 1 620px;
}

.app-topbar-page-title {
    font-size: clamp(20px, 1.7vw, 24px);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.04em;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-topbar-spacer {
    flex: 1;
}

.app-topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.app-topbar .app-topbar-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    box-shadow: none;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.app-topbar .app-topbar-icon-btn:hover {
    background: #f8fafc;
    color: #475569;
    transform: translateY(-1px);
}

.app-topbar .app-topbar-icon-btn:active {
    transform: translateY(0);
}

.app-topbar .app-topbar-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    width: auto;
    height: 16px;
    padding: 0 4px;
    display: none;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.25);
}

.app-topbar .app-topbar-offline-indicator {
    color: #d97706;
    background: rgba(245, 158, 11, 0.12);
}

.app-topbar-profile {
    position: relative;
}

.app-topbar-profile-trigger {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 2px 4px 8px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #475569;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.app-topbar-profile-trigger:hover,
.app-topbar-profile.open .app-topbar-profile-trigger {
    background: #f8fafc;
    color: #1e293b;
}

.app-topbar .app-topbar-avatar {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: #f8fbff;
    color: #1d4ed8;
    border: 2px solid #9fc0ff;
    box-shadow: none;
    font-weight: 700;
}

.app-topbar-profile-name {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 15px;
    font-weight: 700;
    color: inherit;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.app-topbar-profile-caret {
    color: #94a3b8;
    transition: transform 0.2s ease;
}

.app-topbar-profile.open .app-topbar-profile-caret {
    transform: rotate(180deg);
}

.app-topbar-user-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 280px;
    padding: 12px;
    display: none;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.16);
}

.app-topbar-user-menu.show {
    display: block;
}

.app-topbar-user-menu-header {
    padding: 6px 6px 12px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 10px;
}

.app-topbar-user-menu-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-topbar-menu-avatar {
    flex-shrink: 0;
}

.app-topbar-user-menu-identity {
    min-width: 0;
}

.app-topbar-user-menu-name {
    font-size: 15px;
    font-weight: 700;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-topbar-user-menu .nav-user-role {
    margin-top: 4px;
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
}

.app-topbar-menu-row {
    margin: 0;
    padding: 10px 6px;
    border-top: none;
    border-bottom: 1px solid #f1f5f9;
}

.app-topbar-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px;
    margin-top: 8px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: #334155;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.app-topbar-menu-item:hover {
    background: #f8fafc;
}

.app-topbar-menu-danger {
    color: #dc2626;
}

.app-topbar-menu-danger:hover {
    background: #fef2f2;
}

.main-content {
    padding-top: 0;
}

body.dashboard-topbar-visible .main-content {
    padding-top: 68px;
}

body.offline-banner-visible .app-topbar {
    top: 44px;
}

@media (max-width: 768px) {
    .app-topbar,
    body.dashboard-topbar-visible .app-topbar {
        display: none !important;
    }

    .main-content,
    body.dashboard-topbar-visible .main-content {
        padding-top: 60px;
    }
}

@media (min-width: 769px) {
    #addPurchaseModal {
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
    }

    #addPurchaseModal .modal-content.large {
        box-sizing: border-box;
        width: min(1180px, calc(100vw - 32px));
        max-width: calc(100vw - 32px);
        height: min(820px, calc(100vh - 24px));
        height: min(820px, calc(100dvh - 24px));
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        padding: 16px 22px;
    }

    #addPurchaseModal h2 {
        flex-shrink: 0;
        margin: 0 0 12px !important;
        line-height: 1.2;
    }

    #addPurchaseModal .purchase-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px 14px;
        margin-bottom: 12px;
    }

    #addPurchaseModal .purchase-grid .form-group {
        margin-bottom: 0;
    }

    #addPurchaseModal .purchase-items-section {
        min-height: 246px;
    }

    #addPurchaseModal #purchaseItems {
        flex: 1 1 auto;
        min-height: 120px;
        max-height: none;
        overflow-y: auto;
    }

    #addPurchaseModal .purchase-items-title {
        padding: 10px 14px;
    }

    #addPurchaseModal .purchase-items-header {
        padding: 8px 12px;
    }

    #addPurchaseModal .btn-add-purchase-item {
        padding: 9px 12px;
    }

    #addPurchaseModal .purchase-grand-total {
        margin-top: 10px;
        padding: 12px 16px;
    }

    #addPurchaseModal .modal-actions {
        margin-top: 10px;
    }
}

@media (min-width: 769px) and (max-height: 620px) {
    #addPurchaseModal .modal-content.large {
        height: calc(100vh - 16px);
        height: calc(100dvh - 16px);
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
        padding: 12px 18px;
    }

    #addPurchaseModal .purchase-grid {
        gap: 8px 12px;
        margin-bottom: 8px;
    }

    #addPurchaseModal .purchase-items-section {
        min-height: 210px;
    }

    #addPurchaseModal #purchaseItems {
        min-height: 84px;
    }
}

@media (min-width: 769px) and (max-height: 520px) {
    #addPurchaseModal .modal-content.large {
        overflow-y: auto;
    }

    #addPurchaseModal #addPurchaseForm {
        flex: none;
        overflow: visible;
    }

    #addPurchaseModal .purchase-items-section {
        flex: none;
        min-height: 230px;
    }
}

.cashflow-account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.cashflow-account-card {
    text-align: left;
    background: #fff;
    border: 1px solid #dbe3f0;
    border-radius: 16px;
    padding: 18px;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(20, 32, 74, 0.06);
}

.cashflow-account-card:hover {
    border-color: #93c5fd;
}

.cashflow-account-type {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 6px;
}

.cashflow-account-card h3 {
    margin: 0 0 10px;
    font-size: 1.05rem;
}

.cashflow-account-balance {
    font-size: 1.35rem;
    font-weight: 800;
    color: #0f172a;
}

.cashflow-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 16px;
}

.cashflow-toolbar .form-group {
    margin: 0;
    min-width: 180px;
}

.cashflow-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 16px;
}

.cashflow-split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.cashflow-overview-list {
    margin-top: 16px;
}

.cashflow-overview-list h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.cashflow-alert {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.cashflow-alert.over {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.cashflow-alert.threshold {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.cashflow-recon-preview {
    margin-bottom: 24px;
}

.cashflow-budget-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    margin-top: 6px;
    overflow: hidden;
}

.cashflow-budget-bar span {
    display: block;
    height: 100%;
    background: #2563eb;
}

.cashflow-forecast-wrap {
    margin: 16px 0 8px;
    background: #fff;
    border: 1px solid #dbe3f0;
    border-radius: 16px;
    padding: 16px;
    height: 220px;
}

.cashflow-forecast-legend {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    color: #64748b;
    font-size: 0.9rem;
}

.cashflow-forecast-wrap {
    margin: 16px 0 8px;
    background: #fff;
    border: 1px solid #dbe3f0;
    border-radius: 16px;
    padding: 12px 16px 8px;
    height: 220px;
}

.cashflow-forecast-legend {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 8px;
}


/* Shared interaction polish: accessible targets and state transitions. */
body.modal-open {
    overflow: hidden;
}

/* Task & Inquiry Management: uses the existing operational table and modal language. */
.task-inquiry-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 0 0 18px;
    color: var(--text-secondary);
    font-size: 13px;
}

.task-inquiry-summary-item {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
}

.task-inquiry-summary-item strong {
    color: var(--text-primary);
    font-size: 18px;
}

.task-inquiry-kpi {
    min-height: 82px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface, #fff);
    box-shadow: var(--shadow-sm);
}

.task-inquiry-kpi strong {
    color: var(--text-primary, #173863);
    font-size: 28px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.task-inquiry-kpi-label {
    color: var(--text-secondary, #64748b);
    font-size: 13px;
    font-weight: 600;
}

.task-inquiry-kpi-due strong { color: var(--warning-600); }
.task-inquiry-kpi-risk strong { color: var(--error-600); }
.task-inquiry-kpi-escalated strong { color: var(--primary-600); }

.task-inquiry-empty-copy {
    margin: 0;
    padding: 18px 16px;
    color: var(--text-secondary, #64748b);
    font-size: 13px;
}

/* Stays a table cell: two of these sit side by side (Due by, Service target). */
.task-inquiry-sla-cell {
    font-weight: 700;
}

.task-inquiry-sla-cell > span,
.task-inquiry-sla-cell > small {
    display: block;
}

.task-inquiry-sla-cell small {
    margin-top: 3px;
    color: var(--text-secondary, #64748b);
    font-size: 11px;
    font-weight: 500;
}

/* Paired with the cell or tag class so table and tag colours cannot override them. */
.task-inquiry-sla-overdue,
.task-inquiry-sla-breached,
.task-inquiry-sla-missed,
:is(.task-inquiry-sla-cell, .tqi-tag):is(.task-inquiry-sla-overdue, .task-inquiry-sla-breached, .task-inquiry-sla-missed) { color: var(--error-600); }
.task-inquiry-sla-at_risk,
:is(.task-inquiry-sla-cell, .tqi-tag).task-inquiry-sla-at_risk { color: var(--warning-700); }
.task-inquiry-sla-on_track,
.task-inquiry-sla-met,
:is(.task-inquiry-sla-cell, .tqi-tag):is(.task-inquiry-sla-on_track, .task-inquiry-sla-met) { color: var(--success-700); }
.task-inquiry-sla-no_due_date,
.task-inquiry-sla-paused,
.task-inquiry-sla-none,
:is(.task-inquiry-sla-cell, .tqi-tag):is(.task-inquiry-sla-no_due_date, .task-inquiry-sla-paused, .task-inquiry-sla-none) { color: var(--text-secondary); }
.task-inquiry-sla-breached > small { color: inherit; }

.task-inquiry-secondary-panel {
    margin-top: 4px;
}

.task-inquiry-secondary-panel > .tab-header {
    margin-bottom: 16px;
}

.task-inquiry-report-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.task-inquiry-report-summary > div {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    min-height: 126px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.task-inquiry-report-summary span {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.task-inquiry-report-summary strong {
    color: var(--text-primary);
    font-size: clamp(20px, 2vw, 28px);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.task-inquiry-report-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.task-inquiry-report-section {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.task-inquiry-report-section h3 {
    margin: 0 0 14px;
    color: var(--text-primary);
}

.task-inquiry-mini-table {
    overflow-x: auto;
}

.task-inquiry-mini-table table {
    width: 100%;
    min-width: 260px;
    border-collapse: collapse;
    font-size: 12px;
}

.task-inquiry-mini-table th,
.task-inquiry-mini-table td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    white-space: nowrap;
}

.task-inquiry-mini-table th {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.task-inquiry-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.task-inquiry-toolbar input,
.task-inquiry-toolbar select {
    min-height: 42px;
    border: 1px solid var(--border-color, #dbe3ee);
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text-primary, #1f2937);
    padding: 9px 12px;
}

/* Filters share the row with the search and wrap before they would be cut
   off: a select is otherwise as wide as its longest option (a team name). */
.task-inquiry-toolbar input {
    flex: 2 1 240px;
    min-width: 0;
}

.task-inquiry-toolbar select {
    flex: 1 1 150px;
    min-width: 0;
}

.task-inquiry-toolbar input:focus,
.task-inquiry-toolbar select:focus {
    outline: 2px solid rgba(23, 56, 99, 0.2);
    outline-offset: 1px;
    border-color: #173863;
}

.task-inquiry-title-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: left;
}

.task-inquiry-title-cell span,
.task-inquiry-detail-context,
.task-inquiry-detail-meta {
    color: var(--text-secondary, #64748b);
    font-size: 12px;
}

/* Badges use the theme scales, which invert in dark mode (50/100 stay tints, 700 stays readable). */
.task-inquiry-priority {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    background: var(--neutral-200);
    color: var(--neutral-700);
}

.task-inquiry-priority-medium {
    background: var(--primary-100);
    color: var(--primary-700);
}

.task-inquiry-priority-high {
    background: var(--warning-100);
    color: var(--warning-700);
}

.task-inquiry-priority-urgent {
    background: var(--error-100);
    color: var(--error-700);
}

.tqi-status {
    white-space: nowrap;
    background: var(--neutral-200);
    color: var(--neutral-700);
}

.tqi-status-triaged,
.tqi-status-in_progress {
    background: var(--primary-100);
    color: var(--primary-700);
}

.tqi-status-pending_customer,
.tqi-status-pending_internal,
.tqi-status-pending_third_party,
.tqi-status-pending_approval,
.tqi-status-changes_requested,
.tqi-quote-under_review {
    background: var(--warning-100);
    color: var(--warning-700);
}

.tqi-status-resolved,
.tqi-status-completed,
.tqi-status-closed,
.tqi-status-approved,
.tqi-quote-accepted {
    background: var(--success-100);
    color: var(--success-700);
}

.tqi-status-rejected,
.tqi-quote-rejected {
    background: var(--error-100);
    color: var(--error-700);
}

.task-inquiry-overdue {
    color: #b91c1c;
    font-weight: 700;
}

.task-inquiry-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.task-inquiry-detail-wide {
    grid-column: 1 / -1;
}

.task-inquiry-detail-actions {
    margin-top: 16px;
}

.task-inquiry-detail-section {
    border-top: 1px solid var(--border-color, #e2e8f0);
    margin-top: 24px;
    padding-top: 20px;
}

.task-inquiry-detail-section h3 {
    margin: 0 0 12px;
}

.task-inquiry-activity-list {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.task-inquiry-activity-item {
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    padding: 11px 13px;
}

.task-inquiry-activity-item > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-primary, #1f2937);
    font-size: 13px;
}

.task-inquiry-activity-item > div span {
    color: var(--text-secondary, #64748b);
    font-size: 12px;
}

.task-inquiry-activity-item p {
    margin: 7px 0 0;
    white-space: pre-wrap;
    color: var(--text-primary, #334155);
    font-size: 13px;
}

.task-inquiry-activity-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.task-inquiry-activity-actions select {
    min-width: 150px;
}

.task-inquiry-section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.task-inquiry-section-heading h3 {
    margin-bottom: 4px;
}

.task-inquiry-section-heading p {
    margin: 0;
}

.task-inquiry-attachment-upload {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.task-inquiry-file-picker {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    cursor: pointer;
}

.task-inquiry-file-picker input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.task-inquiry-file-picker:focus-within {
    outline: 2px solid rgba(23, 56, 99, 0.2);
    outline-offset: 2px;
}

.task-inquiry-attachment-status {
    min-height: 18px;
}

.task-inquiry-attachment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.task-inquiry-attachment-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.task-inquiry-attachment-main > div {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.task-inquiry-attachment-main strong,
.task-inquiry-attachment-main span:not(.task-inquiry-attachment-icon) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-inquiry-attachment-main span:not(.task-inquiry-attachment-icon) {
    color: var(--text-secondary, #64748b);
    font-size: 12px;
}

.task-inquiry-attachment-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-color, #dbe3ee);
    border-radius: 7px;
    color: var(--primary-700, #173863);
    background: var(--surface-subtle, #f7f8fa);
    font-size: 9px;
    font-weight: 700;
}

.task-inquiry-attachment-actions {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 7px;
}

@media (max-width: 768px) {
    .task-inquiry-summary,
    .task-inquiry-report-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .task-inquiry-report-grid {
        grid-template-columns: 1fr;
    }

    .task-inquiry-toolbar,
    .task-inquiry-activity-actions {
        flex-direction: column;
    }

    .task-inquiry-toolbar input,
    .task-inquiry-toolbar select,
    .task-inquiry-activity-actions select,
    .task-inquiry-activity-actions button {
        width: 100%;
    }

    /* Stacked: the row sizes above would become heights. */
    .task-inquiry-toolbar input,
    .task-inquiry-toolbar select {
        flex: none;
    }

    .task-inquiry-detail-grid {
        grid-template-columns: 1fr;
    }

    .task-inquiry-detail-wide {
        grid-column: auto;
    }

    .task-inquiry-activity-item > div {
        align-items: flex-start;
        flex-direction: column;
        gap: 3px;
    }

    .task-inquiry-section-heading,
    .task-inquiry-attachment-item {
        align-items: stretch;
        flex-direction: column;
    }

    .task-inquiry-attachment-upload,
    .task-inquiry-attachment-actions {
        justify-content: stretch;
    }

    .task-inquiry-attachment-upload > *,
    .task-inquiry-attachment-actions > * {
        flex: 1;
        justify-content: center;
        width: 100%;
    }
}

/* ========================================
   Work items: forms, detail view, approvals, timeline.
   Built on the app's tokens so light and dark themes both hold.
   ======================================== */
.tqi-sr-only {
    position: absolute;
    /* Pinned, not left where it falls: with no positioned ancestor it is placed
       against the page, and at the end of a wide table it widened the whole
       page on phones. */
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.tqi-muted {
    color: var(--text-secondary);
}

.tqi-loading-row {
    padding: 22px;
    text-align: center;
    color: var(--text-secondary);
}

.tqi-number {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tqi-archived-row td {
    color: var(--text-secondary);
}

.tqi-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--primary-100);
    color: var(--primary-700);
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tqi-count-attention {
    background: var(--warning-100);
    color: var(--warning-700);
}

button.task-inquiry-kpi {
    width: 100%;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

button.task-inquiry-kpi:hover {
    border-color: var(--primary-300);
    box-shadow: var(--shadow-md);
}

button.task-inquiry-kpi:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

.task-inquiry-kpi-approval strong {
    color: var(--primary-600);
}

/* ---- Form scaffolding ---- */
/* The shared .modal box shrinks to fit from the middle of the screen, which caps
   "large" modals near half the width on tablets. The work-item form is dense,
   so it claims its width outright (phones keep the bottom sheet). */
@media (min-width: 769px) {
    .modal-content.large.tqi-form-modal {
        width: min(980px, 94vw);
        min-width: min(980px, 94vw);
        max-width: 94vw;
    }
}

.tqi-form {
    display: grid;
    gap: 6px;
}

.tqi-section {
    margin: 0;
    padding: 18px 0 4px;
    border: 0;
    border-top: 1px solid var(--border);
    min-width: 0;
}

.tqi-form > .tqi-section:first-child {
    border-top: 0;
    padding-top: 4px;
}

/* Floated so the heading sits below the section rule instead of on it. */
.tqi-section legend {
    float: left;
    width: 100%;
    padding: 0 0 10px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
}

/* Everything after the heading starts below it. Clearing only the next
   sibling fails when that one is hidden: a grid or flex box that follows
   squeezes into the float's leftover width (zero) instead of dropping below. */
.tqi-section legend ~ * {
    clear: both;
}

/* Textareas otherwise fall back to the browser's monospace font. */
.tqi-form textarea,
.tqi-sheet textarea,
.tqi-approval-form textarea,
.tqi-quote-modal textarea {
    font-family: inherit;
    line-height: 1.5;
}

.tqi-section .form-group,
.tqi-sheet .form-group,
.tqi-approval-form .form-group,
.tqi-quote-modal .form-group {
    margin-bottom: 14px;
}

.tqi-grid {
    display: grid;
    gap: 0 16px;
}

.tqi-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tqi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.tqi-stack {
    display: grid;
}

.tqi-inline {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tqi-inline > input,
.tqi-inline > select {
    flex: 1 1 0;
    min-width: 0;
}

.tqi-inline > select:first-child:not(:only-child) {
    flex: 0 0 auto;
    max-width: 45%;
}

/* Controls outside .form-group get the same treatment as form fields. */
.tqi-inline input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.tqi-inline select,
.tqi-add-record > input:not([type="checkbox"]):not([type="file"]),
.tqi-add-record select {
    min-height: 42px;
    padding: 9px 13px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--neutral-50);
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
}

.tqi-inline input:focus,
.tqi-inline select:focus,
.tqi-add-record input:focus,
.tqi-add-record select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-50);
}

.tqi-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-secondary);
}

.tqi-required {
    color: var(--error-600);
}

.tqi-hint {
    display: block;
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 12.5px;
    line-height: 1.5;
}

.tqi-hint.is-warning,
.tqi-field-error {
    color: var(--error-600);
}

.tqi-field-error {
    margin: 6px 0 0;
    font-size: 13px;
    font-weight: 600;
}

.tqi-check,
.form-group label.tqi-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 8px 0 0;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
}

.form-group .tqi-check input,
.tqi-check input,
.tqi-segmented input,
.tqi-type-option input {
    width: auto;
    margin: 3px 0 0;
    padding: 0;
    accent-color: var(--primary-600);
}

.tqi-toolbar-check {
    align-self: center;
    margin: 0;
    white-space: nowrap;
}

/* Two or three mutually exclusive options, shown side by side. */
.tqi-segmented {
    display: inline-flex;
    flex-wrap: wrap;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--neutral-100);
}

.tqi-segmented label {
    position: relative;
    margin: 0;
    cursor: pointer;
}

.tqi-segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tqi-segmented span {
    display: block;
    padding: 7px 14px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 600;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tqi-segmented input:checked + span {
    background: var(--primary-100);
    color: var(--primary-700);
    box-shadow: var(--shadow-sm);
}

.tqi-segmented input:focus-visible + span {
    outline: 2px solid var(--primary-500);
    outline-offset: 1px;
}

/* Work type choice: the options are the decision, so each says what it is for. */
.tqi-type-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.tqi-type-option {
    position: relative;
    display: grid;
    gap: 4px;
    padding: 12px 14px 12px 38px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.tqi-type-option:hover {
    border-color: var(--primary-300);
}

.tqi-type-option input {
    position: absolute;
    top: 14px;
    left: 14px;
}

.tqi-type-option:has(input:checked) {
    border-color: var(--primary-600);
    background: var(--primary-50);
}

.tqi-type-option:has(input:focus-visible) {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

.tqi-type-name {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
}

.tqi-type-description {
    color: var(--text-secondary);
    font-size: 12.5px;
    line-height: 1.45;
}

/* Picked people and records. */
.tqi-picked,
.tqi-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tqi-chips:empty {
    display: none;
}

.tqi-chips + input,
.tqi-picked + input {
    margin-top: 0;
}

.tqi-chips:not(:empty) {
    margin-bottom: 8px;
}

.tqi-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 6px 6px 6px 12px;
    border: 1px solid var(--primary-200);
    border-radius: 999px;
    background: var(--primary-50);
    color: var(--text-primary);
    font-size: 13px;
}

.tqi-chip > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tqi-chip small {
    color: var(--text-secondary);
}

.tqi-chip-fixed {
    padding-right: 12px;
}

.tqi-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}

.tqi-chip-remove:hover {
    background: var(--primary-100);
    color: var(--text-primary);
}

.tqi-chip-remove:focus-visible {
    outline: 2px solid var(--primary-500);
}

.tqi-suggestions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.tqi-suggestions .tqi-hint {
    margin: 0 4px 0 0;
}

.tqi-suggestion {
    padding: 5px 10px;
    border: 1px dashed var(--primary-300);
    border-radius: 999px;
    background: transparent;
    color: var(--primary-700);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
}

.tqi-suggestion:hover {
    background: var(--primary-50);
}

.tqi-option {
    display: grid;
    gap: 2px;
}

.tqi-option span {
    color: var(--text-secondary);
    font-size: 12px;
}

.tqi-disclosure {
    margin: 12px 0 0;
}

.tqi-disclosure summary {
    width: fit-content;
    color: var(--primary-600);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}

.tqi-disclosure[open] summary {
    margin-bottom: 10px;
}

.tqi-derived {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin: 0;
}

.tqi-derived .tqi-hint {
    margin: 0;
}

/* ---- Detail view ---- */
.tqi-detail-heading h2 {
    margin: 0 0 2px;
    line-height: 1.3;
}

.tqi-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 12px;
}

.tqi-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.tqi-tag-strong {
    border-color: var(--primary-200);
    background: var(--primary-50);
    color: var(--primary-700);
}

.tqi-tag-waiting {
    border-color: transparent;
    background: var(--warning-100);
    color: var(--warning-700);
    white-space: normal;
}

.tqi-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

.tqi-actions .tqi-hint {
    margin: 0;
}

/* Archive, restore and delete sit apart from the status moves. */
.tqi-actions-end {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
}

.tqi-actions .tqi-delete {
    color: var(--error-600);
}

.tqi-actions .tqi-delete:hover,
.tqi-actions .tqi-delete:focus-visible {
    border-color: var(--error-600);
    background: var(--error-50);
    color: var(--error-700);
}

.tqi-sheet {
    margin: 0 0 12px;
    padding: 16px;
    border: 1px solid var(--primary-200);
    border-radius: var(--radius-lg);
    background: var(--primary-50);
    box-shadow: var(--shadow-sm);
}

.tqi-sheet h3 {
    margin: 0 0 12px;
    font-size: 15px;
}

.tqi-sheet-actions,
.tqi-composer-actions,
.tqi-decision-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

.tqi-tabs {
    display: flex;
    gap: 2px;
    margin: 0 0 16px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}

.tqi-tabs::-webkit-scrollbar {
    display: none;
}

.tqi-tabs button {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.tqi-tabs button:hover {
    color: var(--text-primary);
}

.tqi-tabs button[aria-selected="true"] {
    border-bottom-color: var(--primary-600);
    color: var(--primary-700);
}

.tqi-tabs button:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: -2px;
}

.tqi-panel {
    min-height: 120px;
}

.tqi-panel-heading {
    margin: 18px 0 10px;
    color: var(--text-primary);
    font-size: 15px;
}

.tqi-panel > .tqi-panel-heading:first-child {
    margin-top: 0;
}

.tqi-prose {
    margin: 0 0 12px;
    color: var(--text-primary);
    white-space: pre-wrap;
    line-height: 1.6;
    max-width: 72ch;
}

.tqi-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px 20px;
    margin: 8px 0 12px;
}

.tqi-fact dt {
    margin: 0 0 2px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.tqi-fact dd {
    margin: 0;
    color: var(--text-primary);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.tqi-empty {
    margin: 0 0 12px;
    padding: 14px 16px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13.5px;
    line-height: 1.55;
    list-style: none;
}

.tqi-records {
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.tqi-record {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.tqi-record:last-child {
    border-bottom: 0;
}

.tqi-record-main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    min-width: 0;
}

.tqi-record-type {
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.tqi-record-main strong {
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.tqi-flags {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tqi-row-actions {
    display: inline-flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.tqi-link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--primary-600);
    font: inherit;
    font-weight: 600;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    cursor: pointer;
}

.tqi-link-button:hover {
    color: var(--primary-700);
}

.tqi-link-button:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

.tqi-add-record {
    display: grid;
    gap: 6px;
    margin-top: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--neutral-100);
}

.tqi-add-record > label:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

.tqi-add-record input[type="file"] {
    padding: 8px 0;
}

.tqi-banner {
    margin: 0 0 12px;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    line-height: 1.5;
}

.tqi-banner.is-warning {
    background: var(--warning-100);
    color: var(--warning-700);
}

.tqi-banner.is-success {
    background: var(--success-100);
    color: var(--success-700);
}

.tqi-banner.is-info {
    background: var(--primary-50);
    color: var(--primary-700);
}

/* ---- Approvals ---- */
.tqi-round {
    margin: 14px 0 6px;
    color: var(--text-secondary);
    font-size: 13px;
}

.tqi-steps {
    display: grid;
    gap: 8px;
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.tqi-step {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.tqi-step p {
    margin: 6px 0 0;
    white-space: pre-wrap;
}

.tqi-step-approved {
    border-color: var(--success-100);
    background: var(--success-50);
}

.tqi-step-rejected {
    border-color: var(--error-100);
    background: var(--error-50);
}

.tqi-step-changes_requested,
.tqi-step-pending {
    border-color: var(--warning-100);
    background: var(--warning-50);
}

.tqi-step-superseded,
.tqi-step-skipped {
    opacity: 0.72;
}

.tqi-decision,
.tqi-approval-form {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.tqi-decision label {
    display: block;
    margin: 10px 0 5px;
    font-weight: 600;
}

.tqi-decision textarea,
.tqi-composer textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    resize: vertical;
}

.tqi-decision textarea:focus,
.tqi-composer textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-50);
}

/* ---- Timeline ---- */
.tqi-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.tqi-filter-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.tqi-filter-btn.is-active {
    border-color: var(--primary-600);
    background: var(--primary-50);
    color: var(--primary-700);
}

.tqi-filter-btn:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

.tqi-timeline {
    display: grid;
    gap: 2px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.tqi-timeline-entry {
    position: relative;
    padding: 8px 0 8px 22px;
    color: var(--text-primary);
    font-size: 13.5px;
    line-height: 1.5;
}

.tqi-timeline-entry::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 5px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--neutral-400);
}

.tqi-timeline-entry::after {
    content: '';
    position: absolute;
    top: 26px;
    bottom: -6px;
    left: 8px;
    width: 1px;
    background: var(--border);
}

.tqi-timeline-entry:last-child::after {
    display: none;
}

.tqi-timeline-entry p {
    margin: 0;
}

.tqi-timeline-entry time {
    color: var(--text-secondary);
    font-size: 12.5px;
    white-space: nowrap;
}

.tqi-timeline-entry.is-card {
    margin: 6px 0;
    padding: 12px 14px 12px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.tqi-timeline-entry.is-card::before {
    top: 19px;
    left: 19px;
    background: var(--primary-400);
}

.tqi-timeline-entry.is-card::after {
    display: none;
}

.tqi-timeline-entry.is-reply {
    border-color: var(--primary-200);
    background: var(--primary-50);
}

.tqi-timeline-entry.is-attention::before {
    background: var(--warning-500);
}

.tqi-timeline-entry header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-bottom: 6px;
}

.tqi-timeline-entry.is-card > p {
    white-space: pre-wrap;
}

.tqi-timeline-entry footer {
    margin-top: 8px;
    font-size: 12.5px;
}

.tqi-change-list {
    margin: 4px 0 0;
    padding-left: 18px;
    color: var(--text-secondary);
}

.tqi-reason,
.tqi-quote {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-style: italic;
    white-space: pre-wrap;
}

.tqi-quote::before { content: '“'; }
.tqi-quote::after { content: '”'; }

.tqi-delivery {
    font-weight: 600;
    color: var(--text-secondary);
}

.tqi-delivery.is-sent { color: var(--success-700); }
.tqi-delivery.is-failed { color: var(--error-600); }
.tqi-delivery.is-saved { color: var(--warning-700); }

.tqi-composer {
    display: grid;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.tqi-composer .tqi-segmented {
    justify-self: start;
}

.tqi-audience {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.tqi-audience.is-reply {
    color: var(--primary-700);
    font-weight: 600;
}

.tqi-audience.is-warning {
    color: var(--warning-700);
}

.tqi-reply-files {
    display: grid;
    gap: 2px;
}

.tqi-reply-files .tqi-check {
    margin: 2px 0 0;
}

.tqi-quote-modal {
    width: min(640px, 95vw);
}

/* ---- Queues: where open work stands, one tap to see it ---- */
.tqi-queues {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}

.tqi-queue {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-secondary);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.tqi-queue strong {
    color: var(--text-primary);
    font-size: 17px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.tqi-queue small {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
}

.tqi-queue:hover {
    border-color: var(--primary-300);
}

.tqi-queue:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

.tqi-queue.is-alert strong {
    color: var(--error-600);
}

.tqi-queue.is-active {
    border-color: var(--primary-500);
    background: var(--primary-100);
    color: var(--primary-700);
}

.tqi-queue.is-active strong {
    color: var(--primary-700);
}

/* ---- Teams & routing ---- */
.modal-content.large.tqi-teams-modal {
    width: min(860px, 94vw);
}

.tqi-teams-modal > .tqi-hint {
    margin: 0 0 8px;
}

.tqi-admin-section + .tqi-admin-section {
    margin-top: 12px;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

.tqi-admin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tqi-admin-form {
    margin: 4px 0 12px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.tqi-admin-form h4 {
    margin: 0 0 6px;
    color: var(--text-primary);
    font-size: 15px;
}

.tqi-targets table {
    width: 100%;
}

.tqi-targets th[scope="row"] {
    text-align: left;
    white-space: nowrap;
}

.tqi-targets input[type="number"] {
    width: 100%;
    min-width: 72px;
    max-width: 140px;
    min-height: 40px;
    padding: 8px 10px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--neutral-50);
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.tqi-targets input[type="number"]::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.tqi-targets input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-50);
}

.tqi-targets input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-600);
}

/* "This may already be logged": a quiet notice under the title. */
.tqi-similar {
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid var(--warning-100);
    border-radius: 10px;
    background: var(--warning-50);
    color: var(--text-primary);
    font-size: 13.5px;
}

.tqi-similar p {
    margin: 0 0 6px;
}

.tqi-similar ul,
.tqi-similar-list {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tqi-similar-list {
    margin-top: 8px;
}

.tqi-similar li,
.tqi-similar-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
}

.tqi-tag-button {
    font: inherit;
    font-size: 11.5px;
    cursor: pointer;
}

.tqi-tag-button:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* ---- Work item page: the item fills the tab, with a summary beside it ---- */
.tqi-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin: 0 0 4px;
    padding: 0 2px;
    border: 0;
    background: none;
    color: var(--primary-600);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.tqi-back:hover {
    text-decoration: underline;
}

.tqi-back:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

.tqi-page-header {
    margin-bottom: 10px;
}

.tqi-page-header h2 {
    font-size: 24px;
}

.tqi-page-header h2:focus {
    outline: none;
}

.tqi-page-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.tqi-page-main {
    min-width: 0;
    padding: 8px 20px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.tqi-page-aside {
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.tqi-aside-facts {
    grid-template-columns: 1fr;
    gap: 14px;
    margin: 0;
}

/* The approver's decision sits at the top of the side panel. */
.tqi-aside-decision {
    margin: 0 0 18px;
    padding: 14px;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.tqi-aside-decision .tqi-panel-heading {
    margin-top: 0;
}

.tqi-aside-decision .tqi-panel-heading:focus {
    outline: none;
}

.tqi-aside-decision-subject {
    margin: 0 0 4px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* Below the two-column width the panel stacks under the tabs; put it first
   when a decision is waiting so the approver does not have to scroll for it. */
@media (max-width: 1099.98px) {
    .tqi-page-aside.has-decision {
        order: -1;
    }
}

@media (min-width: 1100px) {
    .tqi-page-body {
        grid-template-columns: minmax(0, 1fr) 280px;
    }

    .tqi-page-aside {
        position: sticky;
        top: 16px;
    }

    /* Sticky and taller than a short window would hide its lower half. */
    .tqi-page-aside.has-decision {
        max-height: calc(100vh - 32px);
        overflow-y: auto;
    }

    .tqi-aside-decision .tqi-decision-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 768px) {
    .tqi-page-main {
        padding: 4px 14px 16px;
    }

    /* Settings, teams, refresh and new: wrap into rows like the other tabs,
       below the title rather than squeezed beside it. */
    #tasksInquiries .tab-header {
        flex-wrap: wrap;
        row-gap: 14px;
    }

    #tasksInquiries .tab-header .header-actions {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    #tasksInquiries .tab-header .header-actions > * {
        flex: 1 1 auto;
        min-width: 0;
        margin: 0;
    }

    .tqi-page-header h2 {
        font-size: 20px;
    }
}

.tqi-record-stack {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}

.tqi-record-editing {
    display: block;
}

.tqi-record-editing .tqi-admin-form {
    margin: 0;
}

.tqi-choice {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin: 4px 0 12px;
    padding: 0;
    border: 0;
}

.tqi-choice legend {
    width: 100%;
    margin-bottom: 4px;
    padding: 0;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

.tqi-check-inline {
    align-self: center;
}

.tqi-members {
    display: grid;
    gap: 6px;
    margin: 0 0 8px;
    padding: 0;
    list-style: none;
}

.tqi-members li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 6px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.tqi-members li > span {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text-primary);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.tqi-members select {
    width: auto;
    min-height: 34px;
    padding: 4px 8px;
}

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

    .tqi-type-options {
        grid-template-columns: 1fr;
    }

    .tqi-record {
        align-items: stretch;
        flex-direction: column;
    }

    .tqi-row-actions {
        justify-content: flex-start;
    }

    .tqi-inline {
        flex-wrap: wrap;
    }

    .tqi-inline > select:first-child:not(:only-child) {
        max-width: none;
        flex-basis: 100%;
    }

    .tqi-actions > button,
    .tqi-actions-end > button,
    .tqi-decision-actions > button {
        flex: 1 1 auto;
    }

    .tqi-actions-end {
        flex: 1 1 100%;
        margin-left: 0;
    }

    .tqi-segmented {
        display: flex;
    }

    .tqi-segmented label {
        flex: 1 1 auto;
    }

    .tqi-segmented span {
        text-align: center;
    }

    #taskInquiryTable {
        min-width: 0;
    }
}

.modal-overlay.active {
    animation: modalOverlayIn 250ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.modal-overlay.active.closing {
    animation: modalOverlayOut 150ms ease-in both;
}

.modal.active:not(#hospitalitySaleModal) {
    animation: modalDialogIn 250ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.modal.active.closing:not(#hospitalitySaleModal) {
    pointer-events: none;
    animation: modalDialogOut 150ms ease-in both;
}

.modal-close,
.modal-header .close[role="button"] {
    min-width: 44px;
    width: 44px;
    min-height: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.app-topbar-user-menu {
    display: block;
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
    transform-origin: top right;
    transition: opacity 150ms ease-in, transform 150ms ease-in, visibility 0s linear 150ms;
}

.app-topbar-user-menu.show {
    display: block;
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 250ms cubic-bezier(0.22, 1, 0.36, 1), transform 250ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s;
}

.notification {
    transform: translateY(16px) scale(0.97);
    filter: blur(2px);
    opacity: 0;
    transition: opacity 350ms cubic-bezier(0.22, 1, 0.36, 1), transform 350ms cubic-bezier(0.22, 1, 0.36, 1), filter 350ms cubic-bezier(0.22, 1, 0.36, 1);
}

.notification.show {
    transform: translateY(0) scale(1);
    filter: blur(0);
    opacity: 1;
}

.form-group.has-error {
    animation: fieldErrorShake 280ms ease-out;
}

#loginScreen .enterprise-login-toggle-pin {
    min-width: 44px;
    min-height: 44px;
    padding: 12px;
    right: 4px;
}

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

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

@keyframes modalDialogIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes modalDialogOut {
    from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    to { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
}

@keyframes fieldErrorShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

@media (max-width: 768px) {
    .sub-nav-btn {
        min-height: 44px;
        padding-block: 10px;
    }

    .modal:not(#hospitalitySaleModal) input:not([type="checkbox"]):not([type="radio"]),
    .modal:not(#hospitalitySaleModal) select,
    .modal:not(#hospitalitySaleModal) textarea,
    .modal:not(#hospitalitySaleModal) .modal-actions button {
        min-height: 44px;
    }

    .modal.active:not(#hospitalitySaleModal),
    .modal.active.closing:not(#hospitalitySaleModal) {
        animation: none;
    }

    .modal.active:not(#hospitalitySaleModal) > .modal-content {
        animation: modalSheetIn 250ms cubic-bezier(0.22, 1, 0.36, 1) both !important;
    }

    .modal.active.closing:not(#hospitalitySaleModal) > .modal-content {
        animation: modalSheetOut 150ms ease-in both !important;
    }
}

@keyframes modalSheetIn {
    from { opacity: 0; transform: translateY(24px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modalSheetOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(24px) scale(0.99); }
}

@media (prefers-reduced-motion: reduce) {
    .modal-overlay.active,
    .modal-overlay.active.closing,
    .modal.active:not(#hospitalitySaleModal),
    .modal.active.closing:not(#hospitalitySaleModal),
    .modal.active:not(#hospitalitySaleModal) > .modal-content,
    .modal.active.closing:not(#hospitalitySaleModal) > .modal-content,
    .app-topbar-user-menu,
    .custom-dropdown-container,
    .notification,
    .form-group.has-error,
    .sub-nav-btn {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}


/* Final tap-target refinements from the mobile UX pass. */
body.modal-open {
    overflow: hidden !important;
}

.app-topbar .app-topbar-icon-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
}

.app-topbar-profile-trigger {
    min-height: 44px;
}

#userPermissionGroups label,
#userPermissionGrantGroups label,
.user-permission-fieldset label {
    display: flex;
    gap: 8px;
    align-items: center;
    min-height: 44px;
    margin: 2px 0 !important;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 400;
    transition: background-color 150ms ease, color 150ms ease;
}

#userPermissionGroups legend label,
#userPermissionGrantGroups legend label,
.user-permission-fieldset legend label {
    font-weight: 600;
}

#userPermissionGroups label:hover,
#userPermissionGroups label:focus-within,
#userPermissionGrantGroups label:hover,
#userPermissionGrantGroups label:focus-within,
.user-permission-fieldset label:hover,
.user-permission-fieldset label:focus-within {
    background: var(--primary-50);
}

#userPermissionGroups input[type="checkbox"],
#userPermissionGrantGroups input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    flex: 0 0 20px;
    accent-color: var(--primary-600);
}

.user-permission-fieldset {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 10px 12px;
}

.user-permission-grant {
    margin-top: 16px;
    padding: 14px 14px 12px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    background: var(--surface-muted, #f8fafc);
}

.user-permission-grant h3 {
    margin: 0 0 6px;
    font-size: 1rem;
}

.user-permission-grant-help,
.user-permission-grant-hint {
    margin: 0 0 12px;
    color: var(--text-muted, #64748b);
    font-size: 0.875rem;
    line-height: 1.45;
}

.user-permission-grant-hint {
    margin: 6px 0 0;
}

.user-permission-grant-clear {
    margin-top: 8px;
}

#userPermissionGrantGroups label.is-already-granted {
    opacity: 0.55;
    cursor: default;
}

.user-grant-badge {
    display: inline-flex;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #ecfdf3;
    color: #166534;
    font-size: 0.75rem;
    font-weight: 600;
}

#whatsappBannerDashboard .wa-close {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    min-height: 44px;
    padding: 10px !important;
}

.business-plus-feature[hidden] {
    display: none !important;
}

.sale-payment-schedule-panel,
.document-settings-panel {
    margin-top: 16px;
    border: 1px solid color-mix(in srgb, var(--border-color, #d9dee7) 78%, transparent);
    border-radius: 14px;
    padding: 16px;
    background: var(--surface-muted, rgba(148, 163, 184, 0.08));
}

.schedule-panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.schedule-panel-heading h4,
.document-settings-group h4 {
    margin: 0 0 4px;
    color: var(--text-primary, #1f2937);
}

.schedule-panel-heading p,
.document-settings-panel .branding-feature-description {
    margin: 0;
    color: var(--text-secondary, #64748b);
    font-size: 0.9rem;
    line-height: 1.45;
}

.payment-schedule-rows {
    display: grid;
    gap: 10px;
    margin: 14px 0 10px;
}

.payment-schedule-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.payment-schedule-row label,
.document-settings-group label {
    display: grid;
    gap: 5px;
    color: var(--text-secondary, #64748b);
    font-size: 0.82rem;
}

.payment-schedule-row input,
.document-settings-group input,
.document-settings-group textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    border: 1px solid var(--border-color, #d9dee7);
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text-primary, #1f2937);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.payment-schedule-row input:focus,
.document-settings-group input:focus,
.document-settings-group textarea:focus {
    border-color: var(--primary-color, #2563eb);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color, #2563eb) 16%, transparent);
    outline: none;
}

.payment-schedule-summary {
    margin-top: 10px;
    color: var(--text-secondary, #64748b);
    font-size: 0.88rem;
}

.payment-schedule-summary.is-valid {
    color: var(--success-color, #15803d);
}

.payment-schedule-summary.is-invalid,
.form-error {
    color: var(--danger-color, #b91c1c);
}

.document-settings-heading,
.document-settings-section-heading,
.document-payment-method-heading,
.document-preview-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.document-settings-badge {
    flex: 0 0 auto;
    padding: 5px 9px;
    border: 1px solid color-mix(in srgb, var(--primary-color, #2563eb) 28%, var(--border-color, #d9dee7));
    border-radius: 999px;
    color: var(--primary-color, #1d4ed8);
    background: color-mix(in srgb, var(--primary-color, #2563eb) 8%, transparent);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.document-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.document-settings-group {
    display: grid;
    align-content: start;
    gap: 12px;
    padding: 16px;
    border: 1px solid color-mix(in srgb, var(--border-color, #d9dee7) 82%, transparent);
    border-radius: 12px;
    background: var(--surface, #fff);
}

.document-settings-section-heading h4 {
    margin-bottom: 3px;
}

.document-settings-checkbox {
    display: flex !important;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px !important;
    line-height: 1.4;
}

.document-settings-checkbox input {
    width: 16px;
    min-height: 16px;
    accent-color: var(--primary-color, #2563eb);
}

.document-settings-group input[type="color"] {
    width: 70px;
    min-height: 42px;
    padding: 4px;
    cursor: pointer;
}

.document-settings-subsection {
    display: grid;
    gap: 2px;
    margin-top: 2px;
    padding-top: 12px;
    border-top: 1px solid color-mix(in srgb, var(--border-color, #d9dee7) 82%, transparent);
    color: var(--text-primary, #1f2937);
    font-size: 0.82rem;
}

.document-settings-subsection span {
    color: var(--text-secondary, #64748b);
    font-size: 0.76rem;
    line-height: 1.4;
}

.document-settings-section-heading p,
.document-payment-method-heading span,
.document-preview-heading span {
    color: var(--text-secondary, #64748b);
    font-size: 0.78rem;
    line-height: 1.4;
}

.document-payment-method-editor {
    display: grid;
    gap: 9px;
    padding-top: 2px;
}

.document-payment-method-heading {
    align-items: center;
    font-size: 0.84rem;
    color: var(--text-primary, #1f2937);
}

.document-payment-method-heading div:first-child {
    display: grid;
    gap: 2px;
}

.btn-compact {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.78rem;
}

.document-payment-methods {
    display: grid;
    gap: 9px;
}

.document-payment-method-row {
    display: grid;
    grid-template-columns: minmax(110px, 0.8fr) minmax(120px, 1fr) minmax(160px, 1.45fr) auto;
    gap: 8px;
    align-items: end;
    padding: 10px;
    border: 1px solid var(--border-color, #d9dee7);
    border-radius: 9px;
    background: var(--surface-muted, rgba(148, 163, 184, 0.08));
}

.document-payment-method-row label {
    display: grid;
    gap: 4px;
    color: var(--text-secondary, #64748b);
    font-size: 0.76rem;
}

.document-payment-method-row input,
.document-payment-method-row select,
.document-payment-method-row textarea {
    width: 100%;
    min-height: 38px;
    padding: 8px 9px;
    border: 1px solid var(--border-color, #d9dee7);
    border-radius: 7px;
    background-color: var(--surface, #fff);
    color: var(--text-primary, #1f2937);
    font: inherit;
}

.document-payment-method-row select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.22 4.22a.75.75 0 0 1 1.06 0L6 6.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L2.22 5.28a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 12px;
    padding-right: 28px;
}

.document-payment-method-row textarea {
    resize: vertical;
}

.document-payment-method-row input:focus,
.document-payment-method-row select:focus,
.document-payment-method-row textarea:focus {
    border-color: var(--primary-color, #2563eb);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color, #2563eb) 16%, transparent);
    outline: none;
}

.document-payment-method-remove {
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--danger-color, #b91c1c);
}

.document-payment-method-empty {
    padding: 11px;
    border: 1px dashed var(--border-color, #d9dee7);
    border-radius: 8px;
    color: var(--text-secondary, #64748b);
    font-size: 0.8rem;
    line-height: 1.45;
}

.document-settings-group textarea {
    resize: vertical;
}

.document-settings-inline-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.document-preview-heading {
    align-items: center;
    margin-top: 18px;
    color: var(--text-primary, #1f2937);
}

.document-settings-preview {
    margin-top: 9px;
    padding: 16px;
    border: 1px dashed var(--border-color, #d9dee7);
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface-muted, #f8fafc) 72%, transparent);
}

.document-preview-paper {
    max-width: 760px;
    margin: 0 auto;
    padding: 28px 30px 24px;
    border: 1px solid #d9dee7;
    background: #fff;
    color: #1f2937;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.1);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.76rem;
}

.document-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

.document-preview-header.is-compact .document-preview-logo {
    font-size: 0.92rem;
    line-height: 1.28;
}

.document-preview-header.is-compact .document-preview-contact {
    font-size: 0.7rem;
    gap: 2px;
    line-height: 1.35;
}

.document-preview-header.is-stacked-title {
    flex-wrap: wrap;
}

.document-preview-header.is-stacked-title .document-preview-heading-block {
    order: 3;
    width: 100%;
    justify-items: center;
    text-align: center;
    padding-top: 8px;
}

.document-preview-business,
.document-preview-heading-block {
    display: grid;
    gap: 4px;
}

.document-preview-logo {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    overflow-wrap: anywhere;
}

.document-preview-contact,
.document-preview-date,
.document-preview-number {
    display: grid;
    gap: 2px;
    color: #64748b;
    font-size: 0.68rem;
}

.document-preview-contact span {
    overflow-wrap: anywhere;
}

.document-preview-heading-block {
    justify-items: end;
    text-align: right;
}

.document-preview-title {
    color: var(--preview-accent, #1f2937);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.document-preview-number {
    color: #1f2937;
    font-weight: 700;
}

.document-preview-note {
    margin-top: 13px;
    color: var(--preview-accent, #1f2937);
    font-size: 0.68rem;
    font-weight: 700;
}

.document-preview-rule {
    height: 2px;
    margin: 13px 0 16px;
    background: var(--preview-accent, #1f2937);
}

.document-preview-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    margin-bottom: 16px;
}

.document-preview-meta > div {
    display: grid;
    gap: 3px;
    padding: 10px 12px;
    border-left: 3px solid var(--preview-accent, #1f2937);
    background: #f8fafc;
}

.document-preview-meta strong {
    font-size: 0.78rem;
}

.document-preview-label {
    color: #64748b;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.document-preview-table {
    overflow: hidden;
    border: 1px solid #d9dee7;
    border-radius: 3px;
}

.document-preview-table-head,
.document-preview-table > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px 100px 110px;
    gap: 10px;
    align-items: center;
    padding: 9px 10px;
    border-bottom: 1px solid #e5e7eb;
}

.document-preview-table-head {
    color: #475569;
    background: #f1f5f9;
    font-size: 0.63rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.document-preview-table > div:not(.document-preview-table-head) {
    color: #475569;
}

.document-preview-table > div:last-child {
    border-bottom: 0;
}

.document-preview-table > div > :not(:first-child) {
    text-align: right;
}

.document-preview-bottom-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(210px, 0.85fr);
    gap: 18px;
    align-items: start;
    margin-top: 18px;
}

.document-preview-payment {
    display: grid;
    gap: 7px;
    padding: 13px;
    border: 1px solid #d9dee7;
    background: #f8fafc;
}

.document-preview-payment-title {
    color: var(--preview-accent, #1f2937);
    font-size: 0.76rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.document-preview-payment-line,
.document-preview-payment-method,
.document-preview-payment-copy {
    color: #64748b;
    line-height: 1.4;
}

.document-preview-payment-methods {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.document-preview-payment-method {
    display: grid;
    gap: 2px;
    padding: 7px 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.document-preview-payment-method b,
.document-preview-payment-copy b {
    color: #1f2937;
}

.document-preview-payment-method span,
.document-preview-payment-copy span {
    white-space: pre-line;
}

.document-preview-payment-copy {
    display: grid;
    gap: 2px;
    padding-top: 7px;
    border-top: 1px solid #e2e8f0;
}

.document-preview-empty {
    color: #64748b;
    font-style: italic;
}

.document-preview-summary {
    display: grid;
    gap: 7px;
    padding: 13px;
    border: 1px solid #d9dee7;
}

.document-preview-summary > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #64748b;
}

.document-preview-summary > div span:last-child,
.document-preview-grand-total strong {
    text-align: right;
}

.document-preview-grand-total {
    margin-top: 4px;
    padding-top: 10px;
    border-top: 2px solid var(--preview-accent, #1f2937);
    color: var(--preview-accent, #1f2937) !important;
    font-size: 0.86rem;
}

.document-preview-signature {
    display: grid;
    justify-items: end;
    gap: 5px;
    margin-top: 24px;
    color: #64748b;
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
}

.document-preview-signature i {
    display: block;
    width: 150px;
    border-top: 1px solid #475569;
}
.document-asset-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 0.75fr) minmax(0, 1.25fr);
    gap: 12px;
    align-items: end;
}
.document-asset-toolbar label {
    display: grid;
    gap: 5px;
    color: var(--text-secondary, #64748b);
    font-size: 0.78rem;
}
.document-asset-toolbar select {
    width: 100%;
    min-height: 40px;
    padding: 8px 9px;
    border: 1px solid var(--border-color, #d9dee7);
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text-primary, #1f2937);
    font: inherit;
}
.document-asset-selection-status {
    align-self: center;
    color: var(--text-secondary, #64748b);
    font-size: 0.8rem;
    line-height: 1.4;
}
.document-asset-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.document-asset-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border-color, #d9dee7);
    border-radius: 10px;
    background: var(--surface, #fff);
}
.document-asset-card-heading {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
}
.document-asset-card-heading div {
    display: grid;
    gap: 3px;
}
.document-asset-card-heading strong { color: var(--text-primary, #1f2937); }
.document-asset-card-heading span:not(.document-asset-badge) {
    color: var(--text-secondary, #64748b);
    font-size: 0.72rem;
}
.document-asset-badge {
    padding: 3px 7px;
    border-radius: 999px;
    color: var(--text-secondary, #64748b);
    background: var(--surface-muted, rgba(148, 163, 184, 0.14));
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}
.document-asset-preview {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 1px dashed var(--border-color, #d9dee7);
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text-secondary, #64748b);
    font-size: 0.76rem;
    text-align: center;
}
.document-asset-preview img {
    display: block;
    max-width: 100%;
    max-height: 64px;
    object-fit: contain;
}
.document-asset-card label {
    display: grid;
    gap: 5px;
    color: var(--text-secondary, #64748b);
    font-size: 0.76rem;
}
.document-asset-card input[type="file"] {
    width: 100%;
    min-height: 36px;
    padding: 7px;
    border: 1px solid var(--border-color, #d9dee7);
    border-radius: 7px;
    background: var(--surface, #fff);
    color: var(--text-primary, #1f2937);
    font: inherit;
}
.document-asset-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.document-asset-actions .btn-danger {
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid color-mix(in srgb, var(--danger-color, #b91c1c) 28%, var(--border-color, #d9dee7));
    border-radius: 7px;
    color: var(--danger-color, #b91c1c);
    background: transparent;
    font: inherit;
    cursor: pointer;
}
/* Signing (Business Plus): settings cards, list marks, and the signature windows */
.document-asset-card [hidden],
.sig-modal [hidden] {
    display: none !important;
}
.document-asset-hint {
    margin: 0;
    color: var(--text-secondary, #64748b);
    font-size: 0.74rem;
    line-height: 1.45;
}
.document-signer-list {
    display: grid;
    gap: 2px;
    color: var(--text-secondary, #64748b);
    font-size: 0.78rem;
}
.document-signer-row {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color, rgba(148, 163, 184, 0.3));
}
.document-signer-row:last-child {
    border-bottom: 0;
}
.document-signer-ink {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #e2e8f0;
}
.document-signer-ink img {
    max-width: 88px;
    max-height: 34px;
    object-fit: contain;
}
.document-signer-ink span {
    color: #94a3b8;
    font-size: 0.68rem;
}
.document-signer-name {
    display: grid;
    gap: 2px;
    min-width: 0;
}
.document-signer-name strong {
    color: var(--text-primary, #1f2937);
    font-size: 0.82rem;
}
.document-signer-name span {
    overflow: hidden;
    text-overflow: ellipsis;
}
.document-preview-signoff {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-top: 24px;
}
.document-preview-signoff > div {
    display: grid;
    gap: 3px;
    width: 150px;
}
.document-preview-signoff span {
    color: #64748b;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.document-preview-signoff i {
    display: block;
    border-top: 1px solid #475569;
}
.document-preview-signoff b {
    color: #1f2937;
    font-size: 0.66rem;
}
.document-preview-signoff em {
    color: #64748b;
    font-size: 0.6rem;
    font-style: normal;
}
.document-preview-ink {
    position: relative;
    height: 40px;
    display: flex;
    align-items: flex-end;
}
.document-preview-ink img {
    position: relative;
    z-index: 1;
    max-width: 120px;
    max-height: 38px;
    object-fit: contain;
    margin-bottom: -4px;
}
.document-preview-ink .document-preview-stamp {
    position: absolute;
    z-index: 0;
    right: 0;
    bottom: -14px;
    max-width: 54px;
    max-height: 54px;
    margin: 0;
    opacity: 0.9;
    mix-blend-mode: multiply;
    transform: rotate(-7deg);
}
.doc-signed-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(22, 163, 74, 0.12);
    color: #166534;
    font-size: 0.68rem;
    font-weight: 700;
    vertical-align: middle;
}
.doc-signoff-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px dashed var(--border-color, rgba(148, 163, 184, 0.5));
    border-radius: 8px;
    color: var(--text-secondary, #64748b);
    font-size: 0.85rem;
}
.doc-signoff-panel.is-signed {
    border-style: solid;
    border-color: rgba(22, 163, 74, 0.35);
    background: rgba(22, 163, 74, 0.06);
    color: var(--text-primary, #1f2937);
}
.sig-modal {
    display: grid;
    gap: 14px;
}
.sig-modal .form-group {
    margin: 0;
}
.sig-modal .modal-actions {
    margin-top: 0;
}
.sig-intro,
.sig-tip,
.sig-note,
.sig-clean-status {
    margin: 0;
    color: var(--text-secondary, #64748b);
    font-size: 0.85rem;
    line-height: 1.5;
}
.sig-tip,
.sig-note,
.sig-clean-status {
    font-size: 0.8rem;
}
.sig-current {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.4));
    border-radius: 10px;
}
.sig-current-image {
    flex: 0 0 140px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #e2e8f0;
}
.sig-current-image img {
    max-width: 130px;
    max-height: 50px;
    object-fit: contain;
}
.sig-current p {
    margin: 0;
    color: var(--text-secondary, #64748b);
    font-size: 0.8rem;
    line-height: 1.45;
}
.sig-tabs {
    display: inline-flex;
    justify-self: start;
    gap: 2px;
    padding: 3px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
}
.sig-tab {
    padding: 7px 14px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary, #64748b);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.sig-tab.is-active {
    background: var(--surface, #fff);
    color: var(--text-primary, #1f2937);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.14);
}
.sig-pad-wrap {
    position: relative;
    height: 190px;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background-color: #fff;
    background-image: linear-gradient(#cbd5e1, #cbd5e1);
    background-repeat: no-repeat;
    background-size: calc(100% - 48px) 1px;
    background-position: 24px 74%;
}
.sig-pad {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}
.sig-pad-hint {
    position: absolute;
    left: 24px;
    bottom: calc(26% + 6px);
    color: #94a3b8;
    font-size: 0.8rem;
    pointer-events: none;
}
.sig-pad-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}
.sig-panel {
    display: grid;
    gap: 10px;
}
.sig-file {
    display: grid;
    gap: 6px;
    color: var(--text-secondary, #64748b);
    font-size: 0.85rem;
}
.sig-file input[type="file"] {
    width: 100%;
    min-height: 40px;
    padding: 8px;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.5));
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text-primary, #1f2937);
    font: inherit;
}
.sig-compare {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    gap: 12px;
    align-items: start;
}
.sig-compare figure {
    display: grid;
    gap: 6px;
    margin: 0;
}
.sig-compare figure > img {
    width: 100%;
    max-height: 150px;
    object-fit: contain;
    border-radius: 8px;
    background: #f1f5f9;
}
.sig-compare figcaption {
    color: var(--text-secondary, #64748b);
    font-size: 0.75rem;
}
.sig-compare .sig-doc-preview {
    max-width: none;
}
.sig-strength {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    color: var(--text-secondary, #64748b);
    font-size: 0.8rem;
}
.sig-strength input[type="range"] {
    width: 100%;
}
.sig-strength-end {
    font-size: 0.72rem;
}
.sig-ink {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    margin: 0;
    padding: 0;
    border: 0;
    color: var(--text-primary, #1f2937);
    font-size: 0.85rem;
}
.sig-ink legend {
    float: left;
    padding: 0;
    margin-right: 4px;
    color: var(--text-secondary, #64748b);
}
.sig-ink label {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    cursor: pointer;
}
.sig-error {
    margin: 0;
    color: #b91c1c;
    font-size: 0.85rem;
}
.sig-link,
.sig-link-danger {
    justify-self: start;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 0.85rem;
    text-decoration: underline;
    cursor: pointer;
}
.sig-link {
    color: var(--primary-600, #173863);
}
.sig-link-danger {
    color: #b91c1c;
}
.sig-doc-preview {
    display: grid;
    gap: 2px;
    max-width: 340px;
    padding: 14px 18px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    color: #1a1a1a;
    font-family: Arial, Helvetica, sans-serif;
}
.sig-doc-caption {
    color: #555;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.sig-doc-ink {
    height: 64px;
    display: flex;
    align-items: flex-end;
}
.sig-doc-ink img {
    max-width: 260px;
    max-height: 60px;
    object-fit: contain;
    margin-bottom: -6px;
}
.sig-doc-empty {
    color: #94a3b8;
    font-size: 0.8rem;
}
.sig-doc-line {
    display: block;
    margin-bottom: 4px;
    border-top: 1px solid #1a1a1a;
}
.sig-doc-preview b {
    color: #1a1a1a;
    font-size: 0.86rem;
}
.sig-doc-preview > span:not(.sig-doc-caption) {
    color: #555;
    font-size: 0.76rem;
}
[data-theme="dark"] .doc-signed-badge {
    background: rgba(74, 222, 128, 0.16);
    color: #86efac;
}
[data-theme="dark"] .doc-signoff-panel.is-signed {
    border-color: rgba(74, 222, 128, 0.35);
    background: rgba(74, 222, 128, 0.08);
}
[data-theme="dark"] .sig-error,
[data-theme="dark"] .sig-link-danger {
    color: #fca5a5;
}
[data-theme="dark"] .sig-tab.is-active {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
@media (max-width: 560px) {
    .sig-compare {
        grid-template-columns: minmax(0, 1fr);
    }
    .sig-pad-wrap {
        height: 170px;
    }
    .doc-signoff-panel {
        flex-direction: column;
        align-items: flex-start;
    }
}
.document-preview-footer {
    display: grid;
    gap: 3px;
    margin-top: 18px;
    padding-top: 10px;
    border-top: 1px solid #d9dee7;
    color: #64748b;
    text-align: center;
    line-height: 1.35;
}

.document-preview-footer strong {
    color: var(--preview-accent, #1f2937);
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.payment-reminder-template-group {
    grid-column: 1 / -1;
}
.payment-reminder-template-group textarea {
    min-height: 190px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}
.payment-reminder-template-help {
    margin: 0;
    color: var(--text-secondary, #64748b);
    font-size: 12px;
    line-height: 1.6;
}
.payment-reminder-template-help code {
    display: inline-block;
    margin: 2px 3px 2px 0;
    padding: 2px 5px;
    border-radius: 5px;
    background: var(--neutral-100, #f1f5f9);
    color: var(--text-primary, #1f2937);
    font-size: 11px;
}
.document-settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}
.document-settings-footer {
    display: grid;
    gap: 12px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color, #d9dee7);
}

.document-profile-heading {
    margin-top: 10px;
}

.document-business-profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.document-business-profile-grid label {
    display: grid;
    gap: 5px;
    color: var(--text-secondary, #64748b);
    font-size: 0.78rem;
}

.document-business-profile-grid input,
.document-business-profile-grid textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 9px;
    border: 1px solid var(--border-color, #d9dee7);
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text-primary, #1f2937);
    font: inherit;
}

.document-business-profile-grid textarea {
    resize: vertical;
}

.document-profile-visibility {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--border-color, #d9dee7);
    border-radius: 8px;
    background: var(--surface-muted, rgba(148, 163, 184, 0.08));
}

.document-profile-control-label,
.document-profile-visibility label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary, #64748b);
    font-size: 0.76rem;
}

.document-profile-control-label {
    width: 100%;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
}

.document-profile-order-heading {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
    color: var(--text-primary, #1f2937);
    font-size: 0.8rem;
}

.document-profile-order-heading span {
    color: var(--text-secondary, #64748b);
    font-weight: 400;
}

.document-business-profile-order {
    display: grid;
    gap: 5px;
    margin-top: 7px;
}

.document-business-profile-order-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid var(--border-color, #d9dee7);
    border-radius: 7px;
    background: var(--surface, #fff);
    color: var(--text-secondary, #64748b);
    font-size: 0.76rem;
}

.document-business-profile-order-actions {
    display: inline-flex;
    gap: 4px;
}

.document-business-profile-order-actions button {
    min-width: 28px;
    min-height: 26px;
    padding: 2px 6px;
}

.document-settings-footer-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.document-settings-footer-fields label {
    display: grid;
    gap: 5px;
    color: var(--text-secondary, #64748b);
}

.document-settings-footer-fields input,
.document-settings-footer-fields textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    border: 1px solid var(--border-color, #d9dee7);
    border-radius: 7px;
    background: var(--surface, #fff);
    color: var(--text-primary, #1f2937);
    font: inherit;
}

.document-settings-footer-fields textarea {
    resize: vertical;
}

.document-settings-footer-fields input:focus,
.document-settings-footer-fields textarea:focus {
    border-color: var(--primary-color, #2563eb);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color, #2563eb) 16%, transparent);
    outline: none;
}


.sale-payment-schedule-panel,
.document-settings-panel {
    transition: opacity 160ms ease, transform 160ms ease;
}

@media (max-width: 720px) {
    .payment-schedule-row,
    .document-settings-grid,
    .document-preview-meta,
    .document-preview-bottom-grid,
    .document-preview-payment-methods {
        grid-template-columns: 1fr;
    }

    .document-preview-table-head,
    .document-preview-table > div {
        grid-template-columns: minmax(0, 1fr) 34px 72px 82px;
        gap: 6px;
        padding-left: 7px;
        padding-right: 7px;
        font-size: 0.66rem;
    }

    .document-settings-inline-fields {
        grid-template-columns: 1fr;
    }
    .document-asset-toolbar {
        grid-template-columns: 1fr;
    }
    .document-asset-grid {
        grid-template-columns: 1fr;
    }
    .document-settings-footer-fields {
        grid-template-columns: 1fr;
    }
    .document-business-profile-grid {
        grid-template-columns: 1fr;
    }

    .document-payment-method-row {
        grid-template-columns: 1fr;
    }

    .document-payment-method-remove {
        width: 100%;
    }

    .document-settings-heading,
    .document-preview-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .payment-reminder-template-group {
    grid-column: 1 / -1;
}
.payment-reminder-template-group textarea {
    min-height: 190px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}
.payment-reminder-template-help {
    margin: 0;
    color: var(--text-secondary, #64748b);
    font-size: 12px;
    line-height: 1.6;
}
.payment-reminder-template-help code {
    display: inline-block;
    margin: 2px 3px 2px 0;
    padding: 2px 5px;
    border-radius: 5px;
    background: var(--neutral-100, #f1f5f9);
    color: var(--text-primary, #1f2937);
    font-size: 11px;
}
.document-settings-actions {
        flex-direction: column-reverse;
    }

    .document-settings-actions button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sale-payment-schedule-panel,
    .document-settings-panel,
    .payment-schedule-row input,
    .document-settings-group input,
    .document-settings-group textarea {
        transition: none;
    }
}

/* Business Plus attachment workspace */
.documents-workspace {
    display: grid;
    gap: 18px;
}
.documents-header {
    align-items: flex-start;
    margin-bottom: 0;
}
.eyebrow-label {
    display: inline-block;
    color: var(--primary-600);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    margin-bottom: 5px;
}
.documents-header h2 {
    margin: 0;
}
.documents-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 190px auto;
    gap: 10px;
    align-items: center;
}
.documents-table-container {
    min-height: 180px;
}
.documents-table .table-subtext {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 3px;
}
.inline-status {
    min-height: 20px;
    color: var(--text-secondary);
    font-size: 13px;
}
.inline-status.is-loading {
    color: var(--text-secondary);
}
.inline-status.is-success {
    color: var(--success-700, #16794b);
}
.inline-status.is-warning {
    color: var(--warning-700, #9a5b00);
}
.inline-status.is-error {
    color: var(--error-600, #b42318);
}
.attachment-manager-modal-content {
    width: min(760px, 96vw);
    max-height: min(900px, 92vh);
    overflow-y: auto;
}
.attachment-target-fields,
.attachment-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.attachment-target-fields {
    background: var(--surface-subtle, #f7f8fa);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 10px;
    padding: 12px;
    margin: 12px 0 16px;
}
.attachment-drop-zone {
    display: grid;
    gap: 5px;
    justify-items: center;
    border: 1px dashed var(--border-strong, #b8bec8);
    border-radius: 12px;
    padding: 22px 16px;
    margin-top: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    transition: border-color .18s ease, background-color .18s ease, transform .18s ease;
}
.attachment-drop-zone strong {
    color: var(--text-primary);
}
.attachment-drop-zone:hover,
.attachment-drop-zone:focus-visible,
.attachment-drop-zone.is-dragging {
    border-color: var(--primary-500);
    background: var(--primary-50, #f5f8ff);
    outline: none;
}
.attachment-drop-zone.is-dragging {
    transform: translateY(-1px);
}
.attachment-upload-queue,
.attachment-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}
.attachment-queue-item,
.attachment-list-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--surface, #fff);
}
.attachment-queue-item span,
.attachment-list-main > div:last-child {
    display: grid;
    gap: 3px;
    min-width: 0;
}
.attachment-queue-item small,
.attachment-list-main span,
.attachment-list-main small {
    color: var(--text-secondary);
    font-size: 12px;
}
.attachment-list-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.attachment-list-main strong,
.attachment-list-main span,
.attachment-list-main small {
    overflow: hidden;
    text-overflow: ellipsis;
}
.attachment-file-icon {
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--primary-50, #f5f8ff);
    color: var(--primary-700, #204bb5);
    font-size: 10px;
    font-weight: 800;
}
.attachment-list-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}
.attachment-confidential-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    margin: 6px 0 14px;
}
.attachment-confidential-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: var(--warning-100, #fff4d6);
    color: var(--warning-700, #8a5200);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    margin-left: 4px;
}
.attachment-list-section {
    border-top: 1px solid var(--border-light, #e5e7eb);
    margin-top: 18px;
    padding-top: 16px;
}
.attachment-list-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.attachment-list-heading h3 {
    margin: 0;
}
.muted-count {
    color: var(--text-secondary);
    font-size: 13px;
}
.field-optional {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 400;
}
.business-plus-nav-btn .nav-icon {
    color: var(--primary-500);
}
@media (max-width: 720px) {
    .documents-toolbar,
    .attachment-target-fields,
    .attachment-form-grid {
        grid-template-columns: 1fr;
    }
    .documents-header {
        display: grid;
        gap: 12px;
    }
    .documents-header .btn-primary {
        width: 100%;
    }
    .attachment-manager-modal-content {
        width: min(100vw - 20px, 760px);
        padding: 18px;
    }
    .attachment-list-item {
        align-items: flex-start;
        flex-direction: column;
    }
    .attachment-list-actions {
        justify-content: flex-start;
        width: 100%;
    }
}
@media (prefers-reduced-motion: reduce) {
    .attachment-drop-zone {
        transition: none;
    }
}
.finance-command-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 18px 0 22px;
}
.finance-command-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 126px;
    padding: 18px;
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--primary-500);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.finance-command-card--receivables { border-left-color: #2563eb; }
.finance-command-card--payables { border-left-color: #d97706; }
.finance-command-card--profit { border-left-color: #059669; }
.finance-command-card--activity { border-left-color: #7c3aed; }
.finance-command-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.finance-command-card strong {
    color: var(--text-primary);
    font-size: clamp(20px, 2vw, 28px);
    line-height: 1.1;
}
.finance-command-card > span:last-child {
    color: var(--text-tertiary);
    font-size: 12px;
    line-height: 1.35;
}
.finance-status {
    min-height: 20px;
    margin: -8px 0 18px;
    color: var(--text-secondary);
    font-size: 12px;
}
.finance-panel .cashflow-toolbar {
    align-items: flex-end;
    flex-wrap: wrap;
}
.finance-panel .cashflow-toolbar .form-group {
    min-width: 150px;
}
.finance-report-summary {
    margin: 18px 0;
}
.finance-balanced { color: #047857 !important; }
.finance-unbalanced { color: #b91c1c !important; }
.finance-only { transition: opacity .16s ease, transform .16s ease; }
@media (max-width: 1050px) {
    .finance-command-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .finance-command-grid { grid-template-columns: 1fr; gap: 10px; }
    .finance-command-card { min-height: 108px; padding: 15px; }
    .finance-panel .cashflow-toolbar .form-group,
    .finance-panel .cashflow-toolbar button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .finance-only { transition: none; }
}

.finance-panel-intro {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.finance-panel-intro h3 { margin: 0 0 4px; color: var(--text-primary); }
.finance-panel-intro p { margin: 0; color: var(--text-secondary); font-size: 13px; }
.finance-admin-form {
    margin: 0 0 18px;
    padding: 16px;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 92%, var(--primary-500));
}
.finance-admin-form h4 { margin: 0 0 12px; color: var(--text-primary); }
.finance-admin-form .form-row { align-items: flex-end; }
.finance-admin-form .form-group { min-width: 150px; flex: 1 1 150px; }
.finance-admin-only[hidden] { display: none !important; }
.finance-tax-summary { margin-top: 14px; }
.finance-tax-summary .finance-command-card strong { font-size: clamp(19px, 1.8vw, 25px); }
.finance-panel .table-container h4 { margin: 18px 0 10px; color: var(--text-primary); }
.finance-withholding {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}
.finance-withholding .finance-tax-summary { margin: 0 0 18px; }

/* Withholding tax on the record-payment form */
.payment-withholding { margin-bottom: 15px; }
.payment-withholding-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92em;
    color: var(--text-primary);
    cursor: pointer;
}
.payment-withholding-fields {
    display: grid;
    gap: 10px;
    margin: 10px 0 0;
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
}
.payment-withholding-fields[hidden] { display: none; }
.payment-withholding-row { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }
.payment-withholding-fields label {
    display: grid;
    gap: 4px;
    font-size: 0.85em;
    color: var(--text-secondary);
}
.payment-withholding-fields input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
}
.payment-withholding-optional { font-weight: 400; }
.payment-withholding-note { margin: 0; font-size: 0.85em; line-height: 1.45; color: var(--text-secondary); }
.payment-withholding-history { color: var(--text-secondary); }
/* On desktop the purchase form keeps its item list tall between a fixed header and
   footer, so its withholding sits on one row to leave the buttons in view. */
#addPurchaseModal .payment-withholding { flex-shrink: 0; margin: 10px 0 0; }
#addPurchaseModal .payment-withholding-fields { gap: 6px; margin-top: 8px; padding: 10px 12px; }
#addPurchaseModal .payment-withholding-row { grid-template-columns: minmax(70px, 0.5fr) 1fr 1.5fr; }
#addPurchaseModal .payment-withholding-fields input { background: var(--surface); color: var(--text-primary); }
[data-theme="dark"] #addPurchaseModal .payment-withholding-fields input { background: var(--background); }
@media (max-width: 768px) {
    #addPurchaseModal .payment-withholding-row { grid-template-columns: 1fr 1fr; }
    #addPurchaseModal .payment-withholding-row label:last-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .finance-panel-intro { flex-direction: column; }
    .finance-panel-intro button { width: 100%; }
    .finance-admin-form { padding: 13px; }
}


.finance-report-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}
.finance-statement-card {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    background: var(--surface);
}
.finance-statement-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}
.finance-statement-heading h3 {
    margin: 3px 0 4px;
    color: var(--text-primary);
}
.finance-statement-heading p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}
.finance-eyebrow {
    color: var(--primary-600, var(--primary-500));
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.finance-report-meta {
    flex: 0 0 auto;
    color: var(--text-tertiary);
    font-size: 12px;
    white-space: nowrap;
}
.finance-statement-summary,
.finance-cash-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 14px 0;
}
.finance-statement-summary > div,
.finance-cash-summary > div {
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--neutral-50);
}
.finance-statement-summary span,
.finance-cash-summary span {
    display: block;
    color: var(--text-tertiary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.finance-statement-summary strong,
.finance-cash-summary strong {
    display: block;
    margin-top: 4px;
    color: var(--text-primary);
    font-size: 14px;
}
.finance-report-status {
    min-height: 18px;
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 12px;
}
.finance-report-status.is-success { color: var(--success-600, #047857); }
.finance-report-status.is-warning { color: var(--error-600, #b91c1c); }
.finance-section-row td {
    padding-top: 14px !important;
    background: var(--neutral-50);
    color: var(--text-primary);
    font-weight: 700;
}
.finance-detail-row td:first-child { padding-left: 28px; color: var(--text-secondary); }
.finance-total-row td {
    border-top: 1px solid var(--border);
    font-weight: 700;
}
@media (max-width: 900px) {
    .finance-report-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .finance-statement-card { padding: 14px; }
    .finance-statement-heading { flex-direction: column; }
    .finance-report-meta { white-space: normal; }
    .finance-statement-summary,
    .finance-cash-summary { grid-template-columns: 1fr; }
}

.cashflow-overview-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 24px 0 12px;
}
.cashflow-overview-heading:first-child { margin-top: 0; }
.cashflow-overview-heading--compact { margin-top: 26px; }
.cashflow-overview-heading h3 {
    margin: 3px 0 4px;
    color: var(--text-primary);
    font-size: 1.05rem;
}
.cashflow-overview-kicker {
    color: var(--primary-600, var(--primary-500));
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.cashflow-overview-helper {
    color: var(--text-tertiary);
    font-size: 12px;
    text-align: right;
}
#cashflowAssetsPanel > .table-container:first-of-type .data-table {
    min-width: 1480px;
}
#cashflowAssetsPanel > .table-container:first-of-type th,
#cashflowAssetsPanel > .table-container:first-of-type td {
    white-space: nowrap;
}
.cashflow-loan-summary,
.cashflow-loan-detail-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin: 16px 0;
}
.cashflow-loan-summary-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--surface);
}
.cashflow-loan-summary-item span {
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.cashflow-loan-summary-item strong {
    color: var(--text-primary);
    font-size: 15px;
}
.cashflow-loan-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 260px;
}
.cashflow-loan-actions button {
    white-space: nowrap;
}
.cashflow-loan-edit-notice {
    margin: 0 0 16px;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--primary-500) 35%, var(--border-light));
    border-radius: 10px;
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--primary-500) 8%, var(--surface));
    font-size: 13px;
    line-height: 1.45;
}
.cashflow-asset-edit-notice {
    margin: 0 0 16px;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--primary-500) 35%, var(--border-light));
    border-radius: 10px;
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--primary-500) 8%, var(--surface));
    font-size: 13px;
    line-height: 1.45;
}
.cashflow-asset-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 280px;
}
.cashflow-asset-actions button {
    white-space: nowrap;
}
#cashflowLoanForm input:disabled,
#cashflowLoanForm select:disabled {
    color: var(--text-tertiary);
    cursor: not-allowed;
    opacity: .72;
}
.modal-content-wide {
    width: min(900px, 95vw);
    max-width: 95vw;
}
.modal-content-wide .data-table {
    min-width: 620px;
}
.cashflow-account-card {
    position: relative;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
    cursor: default;
}
.cashflow-account-card-main {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: left;
    background: transparent;
    cursor: pointer;
}
.cashflow-account-card-main:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary-500) 45%, transparent);
    outline-offset: 4px;
    border-radius: 8px;
}
.cashflow-account-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(20, 32, 74, 0.1);
}
.cashflow-account-card.is-selected {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-500) 14%, transparent), 0 12px 26px rgba(20, 32, 74, 0.1);
}
.cashflow-account-card-action {
    display: block;
    margin-top: 12px;
    color: var(--primary-600, var(--primary-500));
    font-size: 12px;
    font-weight: 800;
}
.cashflow-account-card-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}
.cashflow-account-edit {
    padding: 8px 12px;
    font-size: 12px;
}

/* Cashflow accounts use the dashboard KPI card language as their shared base. */
.cashflow-account-card.metric-card {
    justify-content: space-between;
    min-height: 160px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.cashflow-account-card.metric-card:hover {
    transform: translateY(-4px);
    border-color: var(--border);
    box-shadow: var(--shadow-lg);
}
.cashflow-account-card .cashflow-account-card-main {
    flex: 1 1 auto;
}
.cashflow-account-card .cashflow-account-type {
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .05em;
    line-height: 1.2;
}
.cashflow-account-card h3 {
    margin: 0 0 10px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
}
.cashflow-account-card .cashflow-account-balance.metric-value {
    margin-top: 2px;
    font-size: clamp(26px, 2.3vw, 36px);
    line-height: 1.12;
}
.cashflow-account-card .cashflow-account-card-action {
    margin-top: 10px;
    color: var(--primary-600, var(--primary-500));
    font-size: 12px;
    font-weight: 800;
}
.cashflow-account-card.is-selected {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-500) 14%, transparent), var(--shadow-lg);
}
@media (max-width: 640px) {
    .cashflow-account-card.metric-card {
        min-height: 140px;
        padding: 18px;
    }
    .cashflow-account-card .cashflow-account-balance.metric-value {
        font-size: clamp(24px, 8vw, 32px);
    }
}
/* Cash & bank: the account list sits beside the open statement on wide screens;
   below 1024px the list and the statement take turns. */
.cashflow-accounts-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}
.cashflow-account-list-pane,
.cashflow-statement-pane {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.cashflow-account-list-pane { padding: 8px; }
.cashflow-statement-pane { padding: 20px 20px 8px; }
.cashflow-statement-pane[hidden] { display: none; }
.cashflow-account-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    padding: 8px 10px 12px;
    border-bottom: 1px solid var(--border);
}
.cashflow-account-list-head h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 15px;
}
.cashflow-account-list-total {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}
.cashflow-account-list-total span {
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.cashflow-account-list-total strong {
    color: var(--text-primary);
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}
.cashflow-account-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cashflow-account-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 10px 12px 10px 14px;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.cashflow-account-row:hover { background: color-mix(in srgb, var(--primary-500) 6%, transparent); }
.cashflow-account-row:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 1px;
}
.cashflow-account-row.is-selected { background: color-mix(in srgb, var(--primary-500) 12%, transparent); }
.cashflow-account-row.is-selected::before {
    content: '';
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 0;
    width: 3px;
    border-radius: 3px;
    background: var(--primary-600);
}
.cashflow-account-row-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.cashflow-account-row-name strong {
    overflow: hidden;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cashflow-account-row-name small {
    color: var(--text-tertiary);
    font-size: 12px;
}
.cashflow-account-row-balance {
    flex: 0 0 auto;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.cashflow-account-row-balance.is-negative,
.cashflow-statement-balance.is-negative,
.cashflow-running-balance.is-negative { color: var(--error-600); }
.cashflow-statement-back {
    display: none;
    gap: 6px;
}
.cashflow-statement-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.cashflow-statement-identity { min-width: 0; }
.cashflow-statement-identity h3 {
    margin: 4px 0 2px;
    color: var(--text-primary);
    font-size: 18px;
}
.cashflow-statement-identity h3:focus { outline: none; }
.cashflow-statement-balance {
    color: var(--text-primary);
    font-size: clamp(24px, 2.4vw, 30px);
    font-weight: 800;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
.cashflow-statement-balance-label {
    display: block;
    margin-top: 6px;
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 600;
}
.cashflow-statement-today {
    display: block;
    margin-top: 2px;
    color: var(--text-secondary);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.cashflow-statement-today[hidden] { display: none; }
.cashflow-statement-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 14px 0 4px;
}
.cashflow-statement-filter .form-group {
    margin: 0;
    min-width: 160px;
}
.cashflow-statement-clear {
    min-height: 40px;
    padding: 0 6px;
    border: 0;
    background: none;
    color: var(--primary-600);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.cashflow-statement-clear[hidden] { display: none; }
.cashflow-statement-clear:hover { text-decoration: underline; }
.cashflow-statement-clear:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}
.cashflow-statement-summary {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.cashflow-statement-summary[hidden] { display: none; }
.cashflow-statement-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.cashflow-statement-actions .btn-secondary {
    padding: 8px 12px;
    font-size: 13px;
}
.cashflow-statement-pane .table-container.cashflow-statement-table {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
.cashflow-statement-table th,
.cashflow-statement-table td { text-align: left; }
.cashflow-statement-table th:last-child,
.cashflow-statement-table td:last-child { text-align: right; }
.cashflow-statement-table .cashflow-amount-col {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.cashflow-running-balance { font-weight: 700; }
.cashflow-movement-detail { display: block; }
.cashflow-movement-description {
    display: block;
    color: var(--text-primary);
}
.cashflow-movement-type {
    display: block;
    margin-top: 2px;
    color: var(--text-tertiary);
    font-size: 12px;
}
.cashflow-reverse-btn {
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--primary-600);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.cashflow-reverse-btn:hover { border-color: var(--border); }
.cashflow-reverse-btn:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 1px;
}
.cashflow-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
@media (min-width: 1024px) {
    .cashflow-accounts-layout { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); }
    .cashflow-account-list-pane {
        position: sticky;
        top: 16px;
        max-height: calc(100vh - 32px);
        overflow-y: auto;
    }
}
@media (max-width: 1023px) {
    .cashflow-accounts-layout.is-statement-open .cashflow-account-list-pane,
    .cashflow-accounts-layout:not(.is-statement-open) .cashflow-statement-pane { display: none; }
    .cashflow-statement-back { display: inline-flex; }
}
@media (max-width: 768px) {
    .cashflow-statement-pane {
        padding: 0;
        border: 0;
        background: transparent;
        box-shadow: none;
    }
    .cashflow-statement-head { margin-bottom: 12px; }
    .cashflow-statement-filter {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding-top: 0;
    }
    .cashflow-statement-filter .form-group { min-width: 0; }
    .cashflow-statement-clear { grid-column: 1 / -1; justify-self: start; }
    .cashflow-statement-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }
    .cashflow-statement-actions .btn-secondary { min-height: 44px; }
    /* Outranks the shared phone-card rules for the Actions cell. */
    .cashflow-statement-table .data-table td.cashflow-amount-col:empty,
    .cashflow-statement-table .data-table td[data-label="Actions"]:empty { display: none !important; }
    .cashflow-movement-detail { text-align: right; }
    .cashflow-statement-table .data-table .cashflow-reverse-btn {
        border-color: var(--border);
        border-radius: var(--radius-md);
        font-size: 14px;
    }
}
.finance-report-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0 2px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}
.finance-report-tab {
    padding: 9px 13px;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.finance-report-tab:hover { border-color: var(--primary-300, #93c5fd); color: var(--text-primary); }
.finance-report-tab.active {
    border-color: var(--primary-500);
    background: var(--primary-50, #eff6ff);
    color: var(--primary-700, #1d4ed8);
}
.finance-report-view { margin-top: 18px; }
.finance-statement-heading--standalone { margin-bottom: 2px; }
.finance-panel .table-container { overflow-x: auto; }
.finance-panel .data-table { min-width: 640px; }
.finance-statement-card .data-table { min-width: 460px; }
.finance-journal-table { min-width: 760px; }
.finance-journal-detail td { padding: 0 !important; background: var(--neutral-50); }
.finance-journal-detail[hidden] { display: none; }
.finance-journal-detail-wrap { padding: 14px 16px 16px 32px; border-bottom: 1px solid var(--border-light); }
.finance-journal-detail-table { width: 100%; border-collapse: collapse; }
.finance-journal-detail-table th,
.finance-journal-detail-table td { padding: 7px 8px; border-bottom: 1px solid var(--border-light); text-align: left; }
.finance-journal-detail-table th { color: var(--text-tertiary); font-size: 11px; text-transform: uppercase; }
.finance-journal-toggle {
    padding: 5px 8px;
    border: 1px solid var(--border-light);
    border-radius: 7px;
    background: var(--surface);
    color: var(--primary-600, var(--primary-500));
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
@media (max-width: 640px) {
    .cashflow-overview-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
    .cashflow-overview-helper { text-align: left; }
    .finance-report-switcher { overflow-x: auto; flex-wrap: nowrap; }
    .finance-report-tab { flex: 0 0 auto; }
    .finance-journal-detail-wrap { padding-left: 14px; }
}
/* Folder-first Business Plus document library */
.documents-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.documents-folder-strip {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 14px;
    background: var(--surface, #fff);
}
.documents-folder-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.documents-folder-heading h3 {
    margin: 0;
}
.document-folders {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
}
.document-folder-card {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 4px;
    min-width: 0;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 11px;
    background: var(--surface-subtle, #f7f8fa);
    transition: border-color .18s ease, background-color .18s ease, transform .18s ease;
}
.document-folder-card:hover,
.document-folder-card.is-selected {
    border-color: var(--primary-500);
    background: var(--primary-50, #f5f8ff);
    transform: translateY(-1px);
}
.document-folder-select {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 1;
    min-width: 0;
    padding: 12px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.document-folder-select span:last-child {
    display: grid;
    gap: 3px;
    min-width: 0;
}
.document-folder-select strong,
.document-folder-select small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.document-folder-select small {
    color: var(--text-secondary);
    font-size: 12px;
}
.document-folder-up {
    display: flex;
    align-items: center;
    gap: 10px;
    grid-column: 1 / -1;
    padding: 0 0 4px;
}
.document-folder-up button {
    padding: 6px 10px;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 7px;
    background: var(--surface, #fff);
    color: var(--primary-700);
    cursor: pointer;
}
.document-folder-up button:hover { background: var(--primary-50, #f5f8ff); }
.document-folder-up small { color: var(--text-secondary); }
.document-folder-icon {
    position: relative;
    flex: 0 0 30px;
    width: 30px;
    height: 26px;
    border-radius: 7px;
    background: var(--primary-100, #e7efff);
    color: var(--primary-700, #204bb5);
}
.document-folder-icon::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 8px;
    width: 18px;
    height: 12px;
    border-radius: 2px;
    background: var(--primary-600, #315dcc);
}
.document-folder-icon::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 6px;
    width: 9px;
    height: 4px;
    border-radius: 2px 2px 0 0;
    background: var(--primary-600, #315dcc);
}
.document-folder-actions {
    display: flex;
    align-items: center;
    padding-right: 5px;
}
.attachment-folder-picker {
    display: flex;
    align-items: end;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 11px;
    background: var(--surface-subtle, #f7f8fa);
}
.attachment-folder-picker .form-group {
    flex: 1;
    margin: 0;
}
.document-row-folder {
    min-width: 145px;
    max-width: 210px;
}
@media (max-width: 720px) {
    .documents-header-actions,
    .attachment-folder-picker {
        display: grid;
        grid-template-columns: 1fr;
    }
    .documents-header-actions button,
    .attachment-folder-picker button {
        width: 100%;
    }
    .document-row-folder {
        max-width: none;
        width: 100%;
    }
}
@media (prefers-reduced-motion: reduce) {
    .document-folder-card {
        transition: none;
    }
}

.document-preview-business {
    font-family: "Times New Roman", Times, serif;
    color: #111827;
    border-color: #9ca3af;
    border-radius: 0;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
}
.document-preview-business .document-preview-header {
    padding-bottom: 14px;
    border-bottom: 2px solid var(--preview-accent, #1f2937);
}
.document-preview-business .document-preview-title {
    font-size: 1.05rem;
    letter-spacing: 0;
}
.document-preview-business .document-preview-rule {
    height: 1px;
    margin: 12px 0;
    background: #9ca3af;
}
.document-preview-business .document-preview-business-profile {
    display: grid;
    gap: 4px;
    margin: 12px 0;
    padding: 10px 12px;
    border: 1px solid #9ca3af;
    background: #f9fafb;
    line-height: 1.35;
}
.document-preview-business .document-preview-business-profile b {
    color: #374151;
    font-size: 0.62rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.document-preview-business .document-preview-business-profile span {
    white-space: pre-line;
}

/* Drive-inspired document workspace, matched to StockMaster's blue and neutral tokens. */
#documents .documents-drive-main { width: 100%; }
#documents .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#documents input[type="search"], #documents select, #documentShareModal select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-md); background: var(--surface); color: var(--text-primary); font: inherit; font-size: 13px;
}
#documents .btn-primary { background: var(--primary-600); color: white; }
#documents .document-folders { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
#documents .document-folder-actions .btn-icon { font-size: 11px; padding: 4px; }
.document-actions summary { cursor: pointer; padding: 6px 10px; color: var(--primary-700); }
.document-actions > div { position: fixed; display: grid; gap: 6px; width: 180px; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); overflow-y: auto; padding: 8px; background: var(--surface); box-shadow: var(--shadow-md); border-radius: 8px; z-index: 50; }
.document-actions[open] { position: relative; z-index: 2; }
.documents-drive-shell button:focus-visible, .document-actions summary:focus-visible { outline: 2px solid var(--primary-400); outline-offset: 2px; }
#documentsBulk { padding: 10px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#documentsBulk[hidden] { display: none; }
.documents-grid .document-file-cell { min-width: 0; }
.documents-drive-shell .eyebrow-label { display: none; }
.documents-drive-main .documents-header h2 { color: var(--text-primary); }
@media (max-width: 720px) {
    .documents-table { min-width: 0 !important; width: 100%; }
    .documents-table thead { display: none; }
    .documents-table tbody, .documents-table tr { display: block; }
    .documents-table tr { padding: 12px 0; border-bottom: 1px solid var(--border); }
    .documents-table td { display: inline-block; border: 0; padding: 5px; max-width: 100%; }
    .documents-table td:nth-child(1) { display: none; }
    .documents-table td:nth-child(2) { width: calc(100% - 42px); }
    .documents-table td:nth-child(3),
    .documents-table td:nth-child(4),
    .documents-table td:nth-child(5),
    .documents-table td:nth-child(6) { display: none; }
    .documents-table td:last-child { width: 38px; vertical-align: middle; text-align: right; }
    .documents-table .document-file-cell { min-width: 0; }
    .documents-local-nav { grid-template-columns: 1fr !important; }
    .document-share-row { grid-template-columns: 1fr !important; }
}
.documents-drive-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}
.documents-local-nav {
    display: grid;
    min-width: 0;
    gap: 18px;
    position: sticky;
    top: 20px;
}
.documents-new-button {
    width: max-content;
    min-width: 112px;
    border-radius: 12px;
    min-height: 44px;
    box-shadow: var(--shadow-sm);
}
.documents-view-nav {
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 16px;
    gap: 4px;
}
.documents-view-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: max-content;
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.documents-view-link span {
    width: 18px;
    color: var(--primary-600);
    font-size: 16px;
    text-align: center;
}
.documents-view-link:hover,
.documents-view-link:focus-visible,
.documents-view-link.is-active {
    background: var(--primary-50);
    color: var(--primary-700);
    outline: none;
}
.documents-nav-summary {
    display: grid;
    gap: 3px;
    padding: 15px 12px;
    border-top: 1px solid var(--border-light);
    color: var(--text-secondary);
}
.documents-nav-summary strong { color: var(--text-primary); font-size: 13px; }
.documents-nav-summary small { font-size: 11px; }
.documents-drive-main { min-width: 0; }
.documents-breadcrumb {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
    color: var(--text-tertiary);
    font-size: 12px;
}
.documents-breadcrumb strong { color: var(--primary-700); }
.documents-breadcrumb { overflow-wrap: anywhere; }
.documents-breadcrumb button { border: 0; background: transparent; color: var(--primary-700); font: inherit; cursor: pointer; padding: 8px 0; }
.document-move-modal-content { width: min(560px, calc(100vw - 24px)); }
.document-preview-modal-content { width: min(1060px, calc(100vw - 24px)); }
.document-move-modal-content, .document-preview-modal-content { background: var(--surface); }
.document-move-modal-content .modal-header, .document-preview-modal-content .modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.document-move-modal-content .modal-header h2, .document-preview-modal-content .modal-header h2 { margin-bottom: 8px; overflow-wrap: anywhere; }
.document-preview-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 24px; }
#documentPreviewContent { min-width: 0; background: var(--neutral-100); padding: 12px; overflow-wrap: anywhere; }
#documentPreviewContent iframe { width: 100%; height: 55vh; border: 0; }
#documentPreviewContent img { width: 100%; max-height: 55vh; object-fit: contain; }
#documentPreviewDetails { min-width: 0; overflow-wrap: anywhere; }
#documentPreviewDetails dt { font-size: 12px; color: var(--text-secondary); margin-top: 16px; }
#documentPreviewDetails dt:first-child { margin-top: 0; }
#documentPreviewDetails dd { margin: 4px 0 0; font-size: 13px; white-space: pre-wrap; }
@media (max-width: 720px) { .document-preview-layout { grid-template-columns: 1fr; gap: 16px; } }
#documentMoveDestination { width: 100%; min-height: 44px; color: var(--text-primary); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px; }
.documents-drive-toolbar {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(120px, 160px) auto;
    gap: 10px;
    align-items: center;
    margin: 6px 0 14px;
}
.documents-drive-toolbar input[type="search"] {
    min-height: 42px;
    border-radius: 21px;
    padding-left: 18px;
    background: var(--surface);
}
.documents-toolbar-actions { display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
.documents-view-toggle { border-radius: 7px; color: var(--text-tertiary); }
.documents-view-toggle.is-active { background: var(--primary-100); color: var(--primary-700); opacity: 1; }
.documents-content-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    margin: 22px 0 9px;
}
.documents-content-heading h3 { margin: 0; font-size: 17px; }
.documents-table-container { overflow-x: auto; }
.documents-table { min-width: 760px; }
.documents-table th,
.documents-table td { vertical-align: middle; }
.documents-select-column { width: 38px; }
.documents-table input[type="checkbox"] { accent-color: var(--primary-600); }
.document-file-cell { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.document-file-cell > div:last-child { min-width: 0; }
.document-file-title { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: transparent; border: 0; font: inherit; font-weight: 600; color: var(--text-primary); cursor: pointer; padding: 6px 0; text-align: left; }
.document-file-title:hover { color: var(--primary-700); text-decoration: underline; text-underline-offset: 3px; }
.document-file-cell strong,
.document-file-cell small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-file-cell small { color: var(--text-tertiary); font-size: 11px; }
.document-type-icon {
    display: grid;
    place-items: center;
    flex: 0 0 30px;
    width: 30px;
    height: 34px;
    border-radius: 6px;
    background: var(--primary-50);
    color: var(--primary-700);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .04em;
}
.document-type-icon.is-pdf { background: var(--error-50); color: var(--error-700); }
.document-type-icon.is-image { background: var(--success-50); color: var(--success-700); }
.document-star-button { color: var(--warning-600); }
.document-row-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; white-space: nowrap; }
.document-row-actions .btn-icon { font-size: 16px; }
.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
}
.documents-grid[hidden] { display: none; }
.document-grid-card {
    display: grid;
    gap: 11px;
    min-height: 136px;
    padding: 15px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.document-grid-card:hover { border-color: var(--primary-300); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.document-grid-card-header,
.document-grid-card-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.document-grid-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.document-grid-card-meta { color: var(--text-tertiary); font-size: 11px; }
.document-share-modal-content { width: min(700px, 96vw); }
.document-share-add-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px auto; gap: 8px; }
.document-share-list-heading { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 8px; }
.document-share-list-heading h3 { margin: 0; font-size: 15px; }
.document-share-list { display: grid; gap: 8px; }
.document-share-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px auto; gap: 8px; align-items: center; padding: 9px 10px; border: 1px solid var(--border-light); border-radius: 8px; }
.document-share-person { display: grid; gap: 2px; min-width: 0; }
.document-share-person strong,
.document-share-person small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-share-person small { color: var(--text-tertiary); font-size: 11px; }
.document-share-remove { color: var(--error-700); }
@media (max-width: 900px) {
    .documents-drive-shell { grid-template-columns: 1fr; gap: 12px; }
    .documents-local-nav { position: static; grid-template-columns: 1fr; align-items: start; gap: 12px; }
    .documents-view-nav { display: flex; gap: 4px; overflow-x: auto; }
    .documents-view-link { width: max-content; white-space: nowrap; flex: 0 0 auto; }
    .documents-nav-summary { display: none; }
}
@media (max-width: 720px) {
    .documents-drive-toolbar { grid-template-columns: 1fr; }
    .documents-toolbar-actions { justify-content: space-between; }
    .documents-header { display: grid; gap: 12px; }
    .documents-header-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .documents-header-actions button { width: 100%; }
    .document-share-add-row { grid-template-columns: 1fr; }
    .document-share-row { grid-template-columns: minmax(0, 1fr) 100px auto; }
}
@media (prefers-reduced-motion: reduce) {
    .document-grid-card { transition: none; }
}

/* Keep folder cards calm; put management actions behind one predictable control.
   File rows reuse the same kebab markup, so default to in-flow layout. Absolute
   overlay is only for legacy standalone folder cards (not table/grid rows). */
.document-folder-card { position: relative; overflow: visible; }
.document-folder-select { padding-right: 48px; }
.document-folder-actions {
    position: static;
    display: inline-flex;
    align-items: center;
    padding: 0;
}
.document-folder-card:not(tr):not(.document-grid-card) > .document-folder-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: block;
}
.document-folder-menu { position: relative; }
.document-folder-menu summary { list-style: none; }
.document-folder-menu summary::-webkit-details-marker { display: none; }
.document-folder-menu-trigger {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--text-secondary);
    cursor: pointer;
}
.document-folder-menu-trigger:hover,
.document-folder-menu[open] .document-folder-menu-trigger,
.document-folder-menu-trigger:focus-visible {
    border-color: var(--border-light, #e5e7eb);
    background: var(--surface, #fff);
    color: var(--primary-700);
    outline: none;
}
.document-folder-menu-icon { display: grid; gap: 3px; }
.document-folder-menu-icon i {
    display: block;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
}
.document-folder-menu-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 20;
    display: grid;
    min-width: 132px;
    gap: 2px;
    padding: 5px;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 10px;
    background: var(--surface, #fff);
    box-shadow: var(--shadow-md, 0 8px 24px rgba(16, 24, 40, .14));
}
.document-folder-menu-panel button {
    width: 100%;
    padding: 8px 9px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
}
.document-folder-menu-panel button:hover,
.document-folder-menu-panel button:focus-visible {
    background: var(--primary-50, #f5f8ff);
    color: var(--primary-700);
    outline: none;
}
.document-folder-menu-panel button.is-danger { color: var(--error-700, #b42318); }
.document-folder-menu-panel button.is-danger:hover,
.document-folder-menu-panel button.is-danger:focus-visible {
    background: var(--error-50, #fff1f0);
    color: var(--error-700, #b42318);
}

/* Compact 3-dot row actions used across data tables */
.table-actions-menu {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
}

.table-actions-cluster {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

td.table-actions,
td.action-buttons {
    width: 52px;
    min-width: 52px;
    max-width: 120px;
    white-space: nowrap;
    text-align: right;
    vertical-align: middle;
}

/* Folder-card kebabs are absolutely pinned; table cells must reset that
   or the trigger paints outside the Actions column (and gets clipped). */
td.table-actions .document-folder-actions,
td.action-buttons .document-folder-actions,
.table-actions-menu .document-folder-actions {
    position: static;
    top: auto;
    right: auto;
    transform: none;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0;
}

@media (max-width: 768px) {
    .data-table.mobile-cards td[data-label="Actions"],
    .data-table.mobile-cards td[data-label="Action"],
    table.mobile-cards td[data-label="Actions"],
    table.mobile-cards td[data-label="Action"] {
        display: flex !important;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
        grid-template-columns: none;
        max-width: none;
        width: 100%;
        text-align: right;
    }

    .data-table.mobile-cards td[data-label="Actions"]::before,
    .data-table.mobile-cards td[data-label="Action"]::before,
    table.mobile-cards td[data-label="Actions"]::before,
    table.mobile-cards td[data-label="Action"]::before {
        margin-right: auto;
        grid-column: auto;
    }

    .data-table.mobile-cards td[data-label="Actions"] .table-actions-menu,
    table.mobile-cards td[data-label="Actions"] .table-actions-menu,
    .data-table.mobile-cards td[data-label="Actions"] .table-actions-cluster,
    table.mobile-cards td[data-label="Actions"] .table-actions-cluster {
        width: auto;
        justify-content: flex-end;
    }
}

/* Drive-inspired upload flow: destination first, files second, metadata on demand. */
.attachment-manager-modal-content {
    width: min(720px, calc(100vw - 28px));
    padding: 24px;
}
.attachment-upload-intro {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--primary-50, #f5f8ff);
    color: var(--text-secondary);
}
.attachment-upload-intro div {
    display: grid;
    gap: 3px;
    min-width: 0;
}
.attachment-upload-intro strong { color: var(--text-primary); font-size: 13px; }
.attachment-upload-intro span:not(.attachment-upload-intro-icon) { overflow-wrap: anywhere; font-size: 12px; }
.attachment-upload-intro-icon {
    position: relative;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--primary-100, #e7efff);
}
.attachment-upload-intro-icon::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 8px;
    width: 4px;
    height: 13px;
    border-radius: 2px;
    background: var(--primary-600, #315dcc);
}
.attachment-upload-intro-icon::after {
    content: '';
    position: absolute;
    left: 11px;
    top: 18px;
    width: 12px;
    height: 7px;
    border-bottom: 3px solid var(--primary-600, #315dcc);
    border-left: 3px solid var(--primary-600, #315dcc);
    transform: rotate(-45deg);
}
.attachment-folder-picker {
    align-items: end;
    margin-bottom: 22px;
    padding: 0;
    border: 0;
    background: transparent;
}
.attachment-upload-step {
    display: grid;
    gap: 10px;
}
.attachment-step-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
}
.attachment-step-heading div { display: grid; gap: 3px; }
.attachment-step-heading h3 { margin: 0; font-size: 16px; }
.attachment-step-heading span { color: var(--text-secondary); font-size: 12px; }
.attachment-drop-zone {
    min-height: 164px;
    align-content: center;
    gap: 7px;
    margin-top: 0;
    padding: 24px 16px;
    border-color: var(--primary-300, #b8caff);
    background: var(--neutral-100);
}
.attachment-drop-zone strong { font-size: 14px; }
.attachment-drop-zone > span:not(.attachment-drop-icon) { font-size: 12px; }
.attachment-drop-zone > span b { color: var(--primary-700); }
.attachment-drop-zone small { color: var(--text-secondary); font-size: 11px; }
.attachment-drop-icon {
    position: relative;
    width: 30px;
    height: 36px;
    margin-bottom: 2px;
    border: 2px solid var(--primary-500, #4b6fe8);
    border-radius: 5px;
    background: var(--surface, #fff);
}
.attachment-drop-icon::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 7px;
    width: 4px;
    height: 14px;
    border-radius: 2px;
    background: var(--primary-600, #315dcc);
}
.attachment-drop-icon::after {
    content: '';
    position: absolute;
    left: 8px;
    top: 16px;
    width: 11px;
    height: 8px;
    border-bottom: 3px solid var(--primary-600, #315dcc);
    border-left: 3px solid var(--primary-600, #315dcc);
    transform: rotate(-45deg);
}
.attachment-upload-queue { margin-top: 2px; }
.attachment-queue-item { padding: 11px 12px; }
.attachment-queue-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-queue-item small { color: var(--text-secondary); }
.attachment-advanced {
    margin-top: 18px;
    border-top: 1px solid var(--border-light, #e5e7eb);
    border-bottom: 1px solid var(--border-light, #e5e7eb);
}
.attachment-advanced summary,
.attachment-existing-files summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 0;
    color: var(--text-primary);
    cursor: pointer;
    list-style-position: inside;
}
.attachment-advanced summary small { color: var(--text-secondary); font-size: 11px; }
.attachment-advanced .attachment-form-grid { padding: 0 0 14px; }
.attachment-detail-wide { grid-column: 1 / -1; }
.attachment-existing-files summary { padding: 0 0 12px; }
.attachment-list-section { margin-top: 18px; padding-top: 16px; }
.attachment-existing-files .attachment-list { margin-top: 0; }
.attachment-manager-modal-content .modal-actions { margin-top: 20px; }
@media (max-width: 720px) {
    .attachment-manager-modal-content { width: min(100vw - 16px, 720px); padding: 18px; }
    .attachment-folder-picker { grid-template-columns: 1fr; }
    .attachment-folder-picker button { width: 100%; }
    .attachment-step-heading { align-items: start; flex-direction: column; }
    .attachment-detail-wide { grid-column: auto; }
}

/* Full-width file browser: the application already owns the sidebar. */
#documents .documents-titlebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
#documents .documents-titlebar .documents-view-nav { margin: 0; flex: 1 1 auto; min-width: 0; }
#documents .documents-folder-heading h2 { margin: 0; font-size: 20px; font-weight: 700; color: var(--text-primary); }
#documents .documents-folder-heading { margin: 8px 0 10px; }
#documents .documents-header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#documents .documents-header { margin: 0; padding: 0; border: 0; }
#documents .documents-breadcrumb { font-size: 14px; }
#documents .documents-folder-strip { background: transparent; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
#documents .documents-folder-heading { margin: 20px 0 8px; }
#documents .documents-folder-heading h3, #documents .documents-content-heading h3 { font-size: 14px; font-weight: 600; }
#documents .documents-table-container { border-radius: 0; box-shadow: none; border: 0; }
#documents .documents-table th { text-transform: none; letter-spacing: normal; font-weight: 500; }
#documents .documents-table td { padding-top: 10px; padding-bottom: 10px; }
#documents .document-folder-select { font: inherit; font-size: 14px; color: var(--text-primary); }
#documents .document-folder-select span:last-child { flex: 1; }
#documents .document-folder-select strong { font-weight: 500; }
#documents .document-folder-select:hover { background: transparent; color: var(--text-primary); }
#documents .documents-view-link:hover,
#documents .documents-table tbody tr:hover,
#documents .document-grid-card:hover,
#documents .document-folder-menu-panel button:hover,
#documents .document-actions button:hover { background: var(--neutral-100); color: var(--text-primary); }
#documents .documents-view-link.is-active,
#documents .documents-view-toggle.is-active { background: var(--primary-100); color: var(--primary-800); }
#documents button:focus-visible, #documents summary:focus-visible { outline: 2px solid var(--primary-600); outline-offset: 2px; }
#documents input::placeholder { color: var(--text-secondary); opacity: 1; }
[data-theme="dark"] #documents .btn-primary { color: var(--background); border-color: var(--primary-600); }
[data-theme="dark"] #documents .document-folder-card:hover,
[data-theme="dark"] #documents .documents-table tbody tr:hover,
[data-theme="dark"] #documents .document-grid-card:hover,
[data-theme="dark"] #documents .document-folder-menu-panel button:hover,
[data-theme="dark"] #documents .document-actions button:hover { background: var(--neutral-200); color: var(--text-primary); }
@media (max-width: 720px) {
    #documents .documents-titlebar { align-items: flex-start; flex-direction: column; gap: 12px; }
    #documents .documents-view-link { min-height: 44px; }
    #documents .document-folder-menu-panel {
        position: absolute !important;
        left: auto !important;
        right: 12px !important;
        top: calc(100% + 6px) !important;
        max-width: calc(100vw - 24px);
    }
}

/* Keep return navigation and the active folder heading in one compact hierarchy. */
#documents .documents-location {
    margin: 0 0 20px;
}
#documents .documents-location-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    min-height: 44px;
}
#documents .documents-folder-up {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
}
#documents .documents-folder-up[hidden] { display: none; }
#documents .documents-folder-up button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
#documents .documents-folder-up button:hover {
    background: var(--surface-subtle, #f7f8fa);
    color: var(--primary-700);
}
#documents .documents-folder-up small {
    color: var(--text-secondary);
    font-size: 12px;
}
#documents .documents-back-icon {
    font-size: 20px;
    line-height: 1;
}
#documents .documents-breadcrumb {
    min-height: 44px;
    margin: 0;
    gap: 8px;
    font-size: 14px;
}
#documents .documents-breadcrumb button {
    min-height: 44px;
    padding: 8px 0;
}
#documents .documents-breadcrumb button:hover {
    color: var(--primary-700);
    text-decoration: underline;
    text-underline-offset: 3px;
}
#documents .documents-folder-heading {
    display: block;
    margin: 14px 0 0;
}
#documents .documents-folder-heading h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
}
#documents .documents-folder-summary {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 14px;
}
@media (max-width: 720px) {
    #documents .documents-location-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }
    #documents .documents-breadcrumb {
        min-height: 40px;
        flex-wrap: wrap;
    }
}

/* Folder navigation is a list, not a card grid. Contents appear after opening a row. */
#documents .document-folders {
    grid-template-columns: 1fr;
    gap: 0;
}
#documents .document-folder-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 56px;
    border: 0;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
    border-radius: 0;
    background: transparent;
    transform: none;
}
#documents .document-folder-card:first-of-type { border-top: 1px solid var(--border-light, #e5e7eb); }
#documents .document-folder-card:hover,
#documents .document-folder-card.is-selected {
    border-color: var(--border-light, #e5e7eb);
    background: var(--surface-subtle, #f7f8fa);
    transform: none;
}
#documents .document-folder-card.is-selected { background: var(--primary-50, #f5f8ff); }
#documents .document-folder-select {
    padding: 12px 48px 12px 8px;
}
#documents .document-folder-select span:last-child {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
}
#documents .document-folder-select small {
    text-align: right;
}
@media (max-width: 720px) {
    #documents .document-folder-select span:last-child { grid-template-columns: 1fr; gap: 2px; }
    #documents .document-folder-select small { text-align: left; }
}

/* Folders and files share one Drive-style collection. Folder rows use the
   same table/grid surface as files; only the leading icon and action affordance differ. */
#documents .document-folder-row {
    display: table-row;
    border: 0;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
    background: transparent;
    transform: none;
}
#documents .document-folder-row:hover,
#documents .document-folder-row.is-selected {
    background: var(--surface-subtle, #f7f8fa);
}
#documents .document-folder-row td {
    padding-top: 10px;
    padding-bottom: 10px;
}
#documents .document-folder-row .document-folder-select {
    display: flex;
    width: 100%;
    min-width: 0;
    padding: 6px 0;
    color: var(--text-primary);
    font: inherit;
}
#documents .document-folder-row .document-folder-actions,
#documents .documents-table td:last-child .document-folder-actions,
#documents .document-grid-card .document-folder-actions {
    position: static;
    display: inline-flex;
    align-items: center;
    padding: 0;
    transform: none;
}
#documents .documents-table td:last-child {
    width: 44px;
    min-width: 44px;
    text-align: right;
    white-space: nowrap;
}
#documents .document-folder-up-row td { padding: 8px 0; }
#documents .document-folder-up { padding: 0; }
#documents .document-grid-card--folder .document-folder-select {
    width: 100%;
    padding: 6px 0;
    color: var(--text-primary);
}
.document-grid-kind {
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
}
@media (max-width: 720px) {
    #documents .document-folder-row { display: block; padding: 12px 0; }
    #documents .document-folder-row td { display: inline-block; border: 0; padding: 5px; max-width: 100%; }
    #documents .document-folder-row td:nth-child(1) { display: none; }
    #documents .document-folder-row td:nth-child(2) { width: calc(100% - 42px); }
    #documents .document-folder-row td:nth-child(3),
    #documents .document-folder-row td:nth-child(4),
    #documents .document-folder-row td:nth-child(5),
    #documents .document-folder-row td:nth-child(6) { display: none; }
    #documents .document-folder-row td:last-child { width: 38px; vertical-align: middle; }
    #documents .document-folder-row .document-folder-select { padding: 0; }
    #documents .document-folder-up-row { padding: 8px 0; }
    #documents .document-folder-up-row td { display: block; width: 100%; }
}


/* library-redesign */
#documents .documents-status-line {
  margin: 8px 0 6px;
  color: var(--text-secondary, #8b9bb8);
  font-size: 13px;
}
#documents .documents-bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 12px;
  margin: 0 0 10px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--primary, #4f8cff) 28%, transparent);
  background: color-mix(in srgb, var(--primary, #4f8cff) 14%, transparent);
}
#documents .documents-bulk-bar[hidden] { display: none !important; }
#documents .documents-bulk-spacer { flex: 1; }
#documents .documents-bulk-count { font-size: 13px; }
#documents .document-unfiled-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #92400e;
  background: rgba(240, 180, 80, 0.12);
}
#documents .documents-table tr.is-selected td {
  background: color-mix(in srgb, var(--primary, #4f8cff) 8%, transparent);
}
#documents .document-menu-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--border-color, rgba(255,255,255,0.08));
}
#documents .document-row-menu .document-folder-menu-panel {
  z-index: 40;
}
#documents .documents-table td.muted {
  color: var(--text-secondary, #8b9bb8);
}
#documents .documents-content-heading .muted-count { opacity: 0.7; }
#documents .documents-folder-summary:empty { display: none; }


/* library-location-context */
#documents .documents-table-container.documents-hide-location th:nth-child(3),
#documents .documents-table-container.documents-hide-location td:nth-child(3) {
  display: none !important;
}


/* modal-close-standardize */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-header > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
}

/* Keep deployed theme colors (light/dark via CSS variables) */
.modal-close,
.modal-header .close,
span.close {
    appearance: none;
    box-sizing: border-box;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.modal-close:hover,
.modal-header .close:hover,
span.close:hover {
    color: var(--text-primary);
    border-color: var(--primary-300);
    background: var(--primary-50);
}

.modal-close svg,
.modal-header .close svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}


/* Library declutter: secondary Documents heading removed */
#documents .documents-content-heading { display: none !important; }
#documents .documents-toolbar-actions { display: none !important; }
#documents .documents-grid { display: none !important; }


/* system-wide actions layout */
@media (max-width: 768px) {
  table.mobile-cards td[data-label="Actions"],
  table.mobile-cards td[data-label="Action"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: stretch;
  }
  table.mobile-cards td[data-label="Actions"]::before,
  table.mobile-cards td[data-label="Action"]::before {
    grid-column: 1 / -1;
    margin: 0 0 2px;
  }
  table.mobile-cards td[data-label="Actions"] > .action-buttons,
  table.mobile-cards td[data-label="Actions"] > .table-actions,
  table.mobile-cards td[data-label="Actions"] > .table-actions-inner,
  table.mobile-cards td[data-label="Actions"] > .btn-group {
    display: contents;
  }
  table.mobile-cards td[data-label="Actions"] button,
  table.mobile-cards td[data-label="Actions"] a,
  table.mobile-cards td[data-label="Action"] button,
  table.mobile-cards td[data-label="Action"] a {
    width: 100%;
    min-width: 0 !important;
    flex: none !important;
    margin: 0 !important;
  }
}

/* Select affordances are single icons, never tiled backgrounds. */
select {
    background-repeat: no-repeat !important;
}

/* Status classes used by invoices, cash entries and other ledgers. */
.status-badge.status-completed {
    background: var(--success-100);
    color: var(--success-700);
}

.status-badge.status-pending {
    background: var(--warning-100);
    color: var(--warning-700);
}

.status-badge.overdue,
.status-badge.status-cancelled {
    background: var(--error-100);
    color: var(--error-700);
}

.status-badge.status-info {
    background: var(--primary-100);
    color: var(--primary-700);
}

/* Stock Control on phones: header buttons wrap under the title instead of
   running off-screen, and full-width message rows (no search matches, empty
   shop) are not squeezed into a fixed 48px card cell. */
@media (max-width: 768px) {
    #inventory .tab-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    #inventory .tab-header h2 {
        margin: 0;
        font-size: 22px;
        line-height: 1.25;
    }

    #inventory .tab-header .header-actions {
        flex-wrap: wrap;
        gap: 8px !important;
        width: 100%;
    }

    #inventory .tab-header .header-actions > * {
        flex: 1 1 auto;
        min-width: 0;
        margin: 0;
    }

    #inventoryTable.mobile-cards tbody td[colspan] {
        display: block;
        height: auto;
        padding: 0;
        border: 0;
        text-align: center;
    }

    #inventoryTable.mobile-cards tbody td[colspan]::before {
        display: none;
    }
}

/* Card-only shortcut for the main row action; desktop keeps the 3-dot menu. */
.debt-quick-action {
    display: none !important;
}

/* Accounts hub on phones (Sales Analysis, Receivables, Invoices, Payables,
   Cash at Hand, Expenses). Header actions wrap instead of running off-screen,
   totals sit in a 2x2 grid, and each row becomes one compact card. */
@media (max-width: 768px) {
    #profitAnalysis .tab-header,
    #receivables .tab-header,
    #invoices .tab-header,
    #payables .tab-header,
    #cashbook .tab-header,
    #expenses .tab-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 14px;
    }

    #profitAnalysis .tab-header h2,
    #receivables .tab-header h2,
    #invoices .tab-header h2,
    #payables .tab-header h2,
    #cashbook .tab-header h2,
    #expenses .tab-header h2 {
        margin: 0;
        font-size: 22px;
        line-height: 1.25;
    }

    #profitAnalysis .header-actions,
    #receivables .header-actions,
    #invoices .header-actions,
    #payables .header-actions,
    #cashbook .header-actions,
    #expenses .header-actions {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    #profitAnalysis .header-actions > *,
    #receivables .header-actions > *,
    #invoices .header-actions > *,
    #payables .header-actions > *,
    #cashbook .header-actions > *,
    #expenses .header-actions > * {
        flex: 1 1 auto;
        min-width: 0;
        margin: 0;
    }

    #cashbook .header-actions > .btn-primary,
    #expenses .header-actions > .btn-primary {
        flex-basis: 100%;
        order: -1;
    }

    #cashbook .header-actions > select {
        flex-basis: 100%;
    }

    #customDateRangeStats,
    #cashbookCustomDateRange,
    #expenseCustomDateRange {
        flex-basis: 100%;
        gap: 8px;
    }

    #customDateRangeStats input[type="date"],
    #cashbookCustomDateRange input[type="date"],
    #expenseCustomDateRange input[type="date"] {
        width: calc(50% - 16px);
        min-width: 0;
    }

    #expenses .filter-section {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    #expenses .filter-section > select,
    #expenses .filter-section > button {
        width: 100%;
        min-width: 0;
        margin: 0;
    }

    #expenses .filter-section > #expenseCustomDateRange,
    #expenses .filter-section > button {
        grid-column: 1 / -1;
    }

    /* Totals: 2x2 tiles instead of four full-width cards */
    #profitAnalysis .profit-summary-grid,
    #receivables .profit-summary-grid,
    #payables .profit-summary-grid,
    #cashbook .profit-summary-grid,
    #expenses .profit-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 16px;
    }

    #profitAnalysis .profit-card,
    #receivables .profit-card,
    #payables .profit-card,
    #cashbook .profit-card,
    #expenses .profit-card {
        align-items: stretch;
        min-width: 0;
        padding: 12px;
    }

    #profitAnalysis .profit-card:hover,
    #receivables .profit-card:hover,
    #payables .profit-card:hover,
    #cashbook .profit-card:hover,
    #expenses .profit-card:hover {
        transform: none;
    }

    /* Label on top, value pinned to the bottom so a row's values line up */
    #profitAnalysis .profit-content,
    #receivables .profit-content,
    #payables .profit-content,
    #cashbook .profit-content,
    #expenses .profit-content {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        min-width: 0;
    }

    #profitAnalysis .profit-content h3,
    #receivables .profit-content h3,
    #payables .profit-content h3,
    #cashbook .profit-content h3,
    #expenses .profit-content h3 {
        margin-bottom: 4px;
        font-size: 10.5px;
        line-height: 1.3;
        letter-spacing: 0.4px;
    }

    #profitAnalysis .profit-value,
    #receivables .profit-value,
    #payables .profit-value,
    #cashbook .profit-value,
    #expenses .profit-value {
        margin: 0;
        font-size: 18px;
        line-height: 1.2;
        overflow-wrap: anywhere;
    }

    #profitAnalysis .profit-subtitle,
    #receivables .profit-subtitle,
    #payables .profit-subtitle,
    #cashbook .profit-subtitle,
    #expenses .profit-subtitle {
        display: none;
    }

    .profit-currency {
        font-size: 0.62em;
        font-weight: 600;
        color: var(--text-secondary);
        letter-spacing: 0.3px;
    }

    #profitAnalysis .sub-tabs {
        gap: 4px;
        margin-bottom: 14px;
    }

    #profitAnalysis .sub-tab-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 10px 4px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* Rows become cards: drop the table panel so cards sit on the page */
    #profitAnalysis .table-container,
    #receivables .table-container,
    #invoices .table-container,
    #payables .table-container,
    #cashbook .table-container,
    #expenses .table-container {
        margin: 0;
        padding: 0;
        overflow: visible;
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    #receivablesTableBody > tr,
    #payablesTableBody > tr,
    #invoicesTableBody > tr,
    #cashbookTableBody > tr,
    #expensesTableBody > tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        padding: 14px;
        border-radius: 14px;
    }

    #receivablesTableBody > tr > td,
    #payablesTableBody > tr > td,
    #invoicesTableBody > tr > td,
    #cashbookTableBody > tr > td,
    #expensesTableBody > tr > td {
        display: block;
        min-width: 0;
        height: auto;
        padding: 0;
        border: 0;
        margin: 0;
        font-size: 13px;
        font-weight: 500;
        line-height: 1.35;
        text-align: left;
        color: var(--text-primary);
        overflow-wrap: anywhere;
    }

    #receivablesTableBody > tr > td::before,
    #payablesTableBody > tr > td::before,
    #invoicesTableBody > tr > td::before,
    #cashbookTableBody > tr > td::before,
    #expensesTableBody > tr > td::before {
        display: block;
        margin: 0 0 2px;
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: 0.4px;
        color: var(--text-tertiary);
    }

    #receivablesTableBody > tr > td:only-child,
    #payablesTableBody > tr > td:only-child,
    #invoicesTableBody > tr > td:only-child,
    #cashbookTableBody > tr > td:only-child,
    #expensesTableBody > tr > td:only-child {
        grid-column: 1 / -1;
        text-align: center;
    }

    #receivablesTableBody > tr > td:only-child::before,
    #payablesTableBody > tr > td:only-child::before,
    #invoicesTableBody > tr > td:only-child::before,
    #cashbookTableBody > tr > td:only-child::before,
    #expensesTableBody > tr > td:only-child::before {
        display: none;
    }

    /* Receivables, payables and invoices: who, how much is left, then detail */
    #receivablesTableBody > tr > td:first-child:not(:only-child),
    #payablesTableBody > tr > td:first-child:not(:only-child),
    #invoicesTableBody > tr > td:first-child:not(:only-child) {
        grid-column: 1 / -1;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--border);
    }

    #receivablesTableBody .debt-primary-cell,
    #payablesTableBody .debt-primary-cell,
    #invoicesTableBody .debt-primary-cell {
        gap: 2px;
    }

    #receivablesTableBody .debt-primary-subtitle,
    #payablesTableBody .debt-primary-subtitle,
    #invoicesTableBody .debt-primary-subtitle {
        order: -1;
        font-size: 16px;
        font-weight: 700;
        line-height: 1.3;
        color: var(--text-primary);
    }

    #receivablesTableBody .debt-primary-ref,
    #payablesTableBody .debt-primary-ref,
    #invoicesTableBody .debt-primary-ref {
        font-size: 12px;
        font-weight: 600;
        color: var(--text-secondary);
    }

    /* The party name already heads the card */
    #receivablesTableBody > tr > td:nth-child(2):not(:only-child),
    #payablesTableBody > tr > td:nth-child(2):not(:only-child),
    #invoicesTableBody > tr > td:nth-child(3) {
        display: none;
    }

    #receivablesTableBody > tr > td:first-child::before,
    #payablesTableBody > tr > td:first-child::before,
    #invoicesTableBody > tr > td:first-child::before {
        display: none;
    }

    /* Amount spans the row; the status badge sits over its right end */
    #receivablesTableBody > tr > td:nth-child(6),
    #payablesTableBody > tr > td:nth-child(6),
    #invoicesTableBody > tr > td:nth-child(7) {
        grid-row: 2;
        grid-column: 1 / -1;
    }

    #receivablesTableBody > tr > td:nth-child(8),
    #payablesTableBody > tr > td:nth-child(8),
    #invoicesTableBody > tr > td:nth-child(8) {
        grid-row: 2;
        grid-column: 2;
        align-self: end;
        justify-self: end;
    }

    #receivablesTableBody > tr > td:nth-child(8)::before,
    #payablesTableBody > tr > td:nth-child(8)::before,
    #invoicesTableBody > tr > td:nth-child(8)::before {
        display: none;
    }

    #receivablesTableBody .debt-balance,
    #payablesTableBody .debt-balance,
    #invoicesTableBody .debt-balance {
        display: block;
        min-width: 0;
        padding: 0;
        border-radius: 0;
        background: none;
        font-size: 21px;
        font-weight: 800;
        line-height: 1.2;
    }

    /* Meta pairs: total | paid, then sold | due */
    #receivablesTableBody > tr > td:nth-child(4),
    #payablesTableBody > tr > td:nth-child(4),
    #invoicesTableBody > tr > td:nth-child(6) {
        grid-row: 3;
        grid-column: 1;
    }

    #receivablesTableBody > tr > td:nth-child(5),
    #payablesTableBody > tr > td:nth-child(5),
    #invoicesTableBody > tr > td:nth-child(2) {
        grid-row: 3;
        grid-column: 2;
    }

    #receivablesTableBody > tr > td:nth-child(3):not(:only-child),
    #payablesTableBody > tr > td:nth-child(3),
    #invoicesTableBody > tr > td:nth-child(4) {
        grid-row: 4;
        grid-column: 1;
    }

    #receivablesTableBody > tr > td:nth-child(7),
    #payablesTableBody > tr > td:nth-child(7),
    #invoicesTableBody > tr > td:nth-child(5) {
        grid-row: 4;
        grid-column: 2;
    }

    #receivablesTableBody .debt-date,
    #payablesTableBody .debt-date {
        font-size: 13px;
        color: var(--text-primary);
    }

    /* Action bar: main action as a full button, the rest behind the 3 dots.
       Tab id prefix outranks the per-table `display: grid !important` rules. */
    #receivables #receivablesTableBody > tr > td:nth-child(9),
    #payables #payablesTableBody > tr > td:nth-child(9),
    #invoices #invoicesTableBody > tr > td:nth-child(9),
    #cashbook #cashbookTableBody > tr > td:nth-child(9),
    #expenses #expensesTableBody > tr > td:nth-child(9) {
        grid-row: 5;
        grid-column: 1 / -1;
        display: flex !important;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-end;
        gap: 8px !important;
        width: auto;
        max-width: none;
        padding-top: 12px;
        border-top: 1px solid var(--border);
    }

    #receivablesTableBody > tr > td:nth-child(9)::before,
    #payablesTableBody > tr > td:nth-child(9)::before,
    #invoicesTableBody > tr > td:nth-child(9)::before,
    #cashbookTableBody > tr > td:nth-child(9)::before,
    #expensesTableBody > tr > td:nth-child(9)::before {
        display: none;
    }

    #receivablesTableBody .debt-quick-action,
    #payablesTableBody .debt-quick-action,
    #invoicesTableBody .debt-quick-action {
        display: inline-flex !important;
        flex: 1 1 auto !important;
        width: auto !important;
        min-height: 42px !important;
        padding: 10px 14px !important;
        border-radius: 10px !important;
        font-size: 14px !important;
    }

    #receivablesTableBody .table-actions-menu,
    #payablesTableBody .table-actions-menu,
    #invoicesTableBody .table-actions-menu,
    #cashbookTableBody .table-actions-menu,
    #expensesTableBody .table-actions-menu {
        flex: 0 0 auto;
        width: auto;
    }

    .document-folder-menu-panel button {
        justify-content: flex-start;
    }

    /* Cash at Hand and Expenses: what it was for, the amount, then detail */
    #cashbookTableBody > tr > td:nth-child(4),
    #expensesTableBody > tr > td:nth-child(4) {
        grid-row: 1;
        grid-column: 1 / -1;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--border);
        font-size: 15px;
        font-weight: 700;
        line-height: 1.35;
    }

    #cashbookTableBody > tr > td:nth-child(4)::before,
    #expensesTableBody > tr > td:nth-child(4)::before,
    #cashbookTableBody > tr > td:nth-child(2)::before,
    #cashbookTableBody > tr > td:nth-child(5)::before,
    #expensesTableBody > tr > td:nth-child(5)::before,
    #expensesTableBody > tr > td:nth-child(8)::before {
        display: none;
    }

    #cashbookTableBody > tr > td:nth-child(5),
    #expensesTableBody > tr > td:nth-child(5) {
        grid-row: 2;
        grid-column: 1 / -1;
        font-size: 19px;
        font-weight: 800;
        line-height: 1.2;
        white-space: nowrap;
    }

    #cashbookTableBody > tr > td:nth-child(2),
    #expensesTableBody > tr > td:nth-child(8) {
        grid-row: 2;
        grid-column: 2;
        align-self: center;
        justify-self: end;
    }

    #cashbookTableBody > tr > td:nth-child(3),
    #expensesTableBody > tr > td:nth-child(3) {
        grid-row: 3;
        grid-column: 1;
    }

    #cashbookTableBody > tr > td:first-child:not(:only-child),
    #expensesTableBody > tr > td:nth-child(2) {
        grid-row: 3;
        grid-column: 2;
    }

    #cashbookTableBody > tr > td:nth-child(6),
    #expensesTableBody > tr > td:nth-child(6) {
        grid-row: 4;
        grid-column: 1;
    }

    #cashbookTableBody > tr > td:nth-child(6) {
        font-weight: 700 !important;
    }

    #cashbookTableBody > tr > td:nth-child(7),
    #expensesTableBody > tr > td:nth-child(7) {
        grid-row: 4;
        grid-column: 2;
    }

    #cashbookTableBody > tr > td:nth-child(8) {
        grid-row: 5;
        grid-column: 1 / -1;
    }

    #cashbookTableBody > tr > td.cashbook-notes-empty {
        display: none;
    }

    #cashbook #cashbookTableBody > tr > td:nth-child(9) {
        grid-row: 6;
    }

    #cashbookTableBody > tr > td:nth-child(9) > .btn-small {
        flex: 1 1 auto;
        min-height: 42px;
        border-radius: 10px;
    }

    #expensesTableBody > tr > td:first-child:not(:only-child) {
        grid-row: 5;
        grid-column: 1;
        align-self: center;
        font-size: 12px;
        font-weight: 600;
        color: var(--text-secondary);
    }

    #expensesTableBody > tr > td:first-child::before {
        display: none;
    }

    #expenses #expensesTableBody > tr > td:nth-child(9) {
        grid-column: 2;
        padding-top: 0;
        border-top: 0;
    }

    /* Sales Analysis rankings: rank, product and margin on top, figures below */
    #profitAnalysis .profit-rank-table.mobile-cards,
    #profitAnalysis .profit-rank-table.mobile-cards tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    #profitAnalysis .profit-rank-table.mobile-cards thead {
        display: none;
    }

    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr {
        display: grid;
        grid-template-columns: 34px repeat(3, minmax(0, 1fr));
        gap: 8px 10px;
        padding: 12px 14px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 14px;
        box-shadow: var(--shadow-sm);
    }

    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr > td {
        display: block;
        min-width: 0;
        height: auto;
        padding: 0;
        border: 0;
        font-size: 13px;
        line-height: 1.35;
        text-align: left;
        color: var(--text-primary);
        overflow-wrap: anywhere;
    }

    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr > td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: 0.4px;
        text-transform: uppercase;
        color: var(--text-tertiary);
    }

    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr > td:only-child {
        grid-column: 1 / -1;
        text-align: center;
    }

    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr > td:first-child:not(:only-child) {
        grid-row: 1 / 3;
        grid-column: 1;
        align-self: center;
        font-size: 14px;
        color: var(--text-secondary);
    }

    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr > td:first-child::before,
    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr > td:nth-child(2)::before,
    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr > td:nth-child(6)::before {
        display: none;
    }

    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr > td:nth-child(2) {
        grid-row: 1;
        grid-column: 2 / 4;
        font-size: 14px;
        font-weight: 700;
    }

    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr > td:nth-child(6) {
        grid-row: 1;
        grid-column: 4;
        justify-self: end;
    }

    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr > td:nth-child(3) {
        grid-row: 2;
        grid-column: 2;
    }

    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr > td:nth-child(4) {
        grid-row: 2;
        grid-column: 3;
    }

    #profitAnalysis .profit-rank-table.mobile-cards tbody > tr > td:nth-child(5) {
        grid-row: 2;
        grid-column: 4;
    }
}

/* Editable dropdown lists: the "Manage list" window and Settings > Dropdown lists */
.option-list-description {
    margin: 0 0 12px;
    color: var(--text-secondary);
}

.option-list-add {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.option-list-add input {
    flex: 1;
    min-width: 0;
}

.option-list-rows,
.option-list-settings-rows {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.option-list-row,
.option-list-settings-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.option-list-row:last-child,
.option-list-settings-row:last-child {
    border-bottom: none;
}

.option-list-label {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.option-list-note {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.option-list-restore,
.option-list-footnote {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.option-list-settings-copy {
    display: grid;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.option-list-settings-copy span {
    font-size: 13px;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

@media (max-width: 480px) {
    .option-list-row {
        flex-wrap: wrap;
    }

    .option-list-note {
        white-space: normal;
    }
}

/* Customer form. Other plans keep the short single-column form; Business Plus
   lays the full record out in four titled sections of two columns. */
.customer-form-grid {
    display: block;
}

.customer-required {
    color: var(--error-600);
}

.customer-form-intro {
    margin: 0 0 14px;
    color: var(--text-secondary);
    font-size: 14px;
}

#customerModal.customer-modal--detailed .modal-content {
    width: min(880px, 94vw);
    max-width: 880px;
}

.customer-modal--detailed .customer-form-section {
    margin-bottom: 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.customer-modal--detailed .customer-form-heading {
    margin: 0;
    padding: 9px 14px;
    background: rgba(26, 56, 98, 0.06);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
}

[data-theme="dark"] .customer-modal--detailed .customer-form-heading {
    background: var(--neutral-200);
}

.customer-modal--detailed .customer-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 20px;
    padding: 12px 14px 2px;
}

.customer-modal--detailed .customer-form-grid .form-group {
    margin-bottom: 12px;
}

.customer-modal--detailed .customer-form-wide {
    grid-column: 1 / -1;
}

.customer-modal--detailed #customerCode {
    background: var(--neutral-100);
    color: var(--text-secondary);
    cursor: default;
}

.customer-modal--detailed textarea {
    font-family: inherit;
    resize: vertical;
}

@media (max-width: 640px) {
    .customer-modal--detailed .customer-form-grid {
        grid-template-columns: 1fr;
    }
}

/* Business Plus purchase order form: titled sections like the customer form, a line
   table that stacks into cards on phones, and a summary beside the notes. */
.po-form-intro {
    margin: 0 0 14px;
    color: var(--text-secondary);
    font-size: 14px;
}

.po-form-required {
    color: var(--error-600);
}

.po-form-section {
    margin-bottom: 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.po-form-heading {
    margin: 0;
    padding: 9px 14px;
    background: rgba(26, 56, 98, 0.06);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
}

[data-theme="dark"] .po-form-heading {
    background: var(--neutral-200);
}

.po-form-grid {
    display: grid;
    gap: 0 20px;
    padding: 12px 14px 2px;
}

.po-form-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.po-form-grid--delivery {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.6fr);
}

.po-form .form-group {
    margin-bottom: 12px;
}

.po-form textarea {
    font-family: inherit;
    resize: vertical;
}

#poNumberPreview {
    background: var(--neutral-100);
    cursor: default;
}

.po-lines {
    padding: 12px 14px 0;
}

.po-line {
    display: grid;
    grid-template-columns: minmax(180px, 2.6fr) minmax(64px, 0.8fr) minmax(90px, 1.1fr) minmax(90px, 1.2fr) minmax(80px, 1fr) minmax(60px, 0.7fr) minmax(90px, 1.1fr) 40px;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.po-line--head {
    padding: 8px 10px;
    margin: 0 -10px;
    border-radius: var(--radius-sm);
    background: rgba(26, 56, 98, 0.04);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    border-bottom: none;
}

.po-line input,
.po-line select {
    width: 100%;
    min-width: 0;
}

.po-form .po-line .po-cell {
    position: relative;
    min-width: 0;
    margin: 0;
}

.po-line .po-cell input,
.po-line .po-cell select {
    padding: 9px 10px;
}

.po-cell-label {
    display: none;
}

.po-line-total {
    display: block;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    background: var(--neutral-100);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.po-line-remove {
    width: 36px;
    height: 36px;
    border: 1px solid var(--error-100);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--error-600);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.po-line-remove:hover {
    background: var(--error-50);
}

.po-add-line {
    margin: 12px 14px 14px;
}

.po-summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr);
    gap: 20px;
    padding: 12px 14px 14px;
}

.po-totals {
    margin: 0;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: rgba(26, 56, 98, 0.04);
}

.po-totals > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
}

.po-totals dt {
    color: var(--text-secondary);
    font-size: 14px;
}

.po-totals dd {
    margin: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.po-totals input {
    width: 140px;
    padding: 7px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 14px;
    text-align: right;
}

.po-totals .po-totals-grand {
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.po-totals .po-totals-grand dt,
.po-totals .po-totals-grand dd {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 700;
}

.po-totals--view {
    max-width: 380px;
    margin: 14px 0 0 auto;
}

.po-view-details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 20px;
    margin: 0 0 14px;
}

.po-view-details dt {
    color: var(--text-secondary);
    font-size: 12px;
}

.po-view-details dd {
    margin: 2px 0 0;
    color: var(--text-primary);
}

.po-view-table {
    width: 100%;
    font-size: 13px;
}

.po-view-table th,
.po-view-table td {
    text-align: left;
}

.po-view-table .po-view-num {
    text-align: right;
    white-space: nowrap;
}

.po-view-note {
    margin: 10px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

@media (max-width: 900px) {
    .po-form-grid--three,
    .po-form-grid--delivery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .po-form-grid--delivery .form-group:last-child {
        grid-column: 1 / -1;
    }

    .po-line--head {
        display: none;
    }

    .po-line {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        padding: 12px 0;
    }

    .po-line .po-cell:first-child {
        grid-column: 1 / -1;
    }

    .po-cell-label {
        display: block;
        margin-bottom: 4px;
        color: var(--text-secondary);
        font-size: 12px;
    }

    .po-line-remove {
        grid-column: 1 / -1;
        justify-self: end;
    }

    .po-summary-grid,
    .po-view-details {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .po-form-grid--three,
    .po-form-grid--delivery,
    .po-line {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ===== Sectioned party form (Business Plus supplier record) =====
   Without .is-plus the form is the short one-column form other plans have. */
.party-form-modal .modal-header {
    align-items: flex-start;
    margin-bottom: 16px;
}
.party-form-modal .modal-header h2 {
    margin-bottom: 4px;
}
.party-form-intro {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}
.party-form-required {
    color: var(--error-600);
    font-weight: 600;
}
.party-form [hidden],
.party-form-modal [hidden] {
    display: none !important;
}
.party-form-modal--plus {
    width: min(1000px, 96vw);
    max-width: 96vw;
}
.party-form.is-plus .party-form-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    margin-bottom: 14px;
    overflow: hidden;
}
.party-form-section-title {
    margin: 0;
    padding: 9px 16px;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-700);
    background: var(--primary-50);
    border-bottom: 1px solid var(--border-light);
}
.party-form.is-plus .party-form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px 20px;
    padding: 14px 16px 6px;
}
.party-form.is-plus .form-group {
    margin-bottom: 10px;
}
.party-form.is-plus .form-group label,
.party-form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}
.party-form-wide {
    grid-column: 1 / -1;
}
.party-form input[readonly] {
    background: var(--primary-50);
    color: var(--text-secondary);
    cursor: default;
}
.party-form textarea {
    resize: vertical;
    min-height: 64px;
    font-family: inherit;
}
.party-form-upload {
    width: 100%;
    justify-content: center;
}
.party-form.is-plus .modal-actions {
    margin-top: 6px;
}
[data-theme="dark"] .party-form-section-title {
    color: #e2e8f0;
}
@media (max-width: 900px) {
    .party-form.is-plus .party-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 600px) {
    .party-form.is-plus .party-form-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
    .party-form-section-title {
        font-size: 15px;
    }
}

/* Accounts on this device: profile menu, Settings and the sign-in screen */
.account-switcher-menu {
    padding: 4px 0 0;
    border-bottom: 1px solid #f1f5f9;
}

.account-switcher-label {
    padding: 10px 6px 4px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}

.account-switcher-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.account-switcher-open {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    min-height: 48px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: #334155;
    text-align: left;
    justify-content: flex-start;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.account-switcher-open:hover,
.account-switcher-open:focus-visible {
    background: #f8fafc;
}

.account-switcher-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    font-size: 12px;
}

.account-switcher-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.account-switcher-name,
.account-switcher-shop {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-switcher-name {
    font-size: 14px;
    font-weight: 600;
}

.account-switcher-shop {
    font-size: 12.5px;
    color: #64748b;
}

.account-switcher-remove {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
}

.account-switcher-remove:hover,
.account-switcher-remove:focus-visible {
    background: #fef2f2;
    color: #b91c1c;
}

.account-switcher-menu .account-switcher-add {
    margin: 2px 0 8px;
}

.settings-account-switcher {
    margin-top: 40px;
    padding-top: 28px;
    border-top: 1px solid var(--border-light);
    max-width: 520px;
}

.account-switcher-heading {
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--neutral-900);
}

.account-switcher-menu .account-switcher-add,
.settings-account-switcher .account-switcher-add {
    justify-content: flex-start;
}

.settings-account-switcher .account-switcher-add {
    margin-top: 4px;
    padding-left: 6px;
}

#loginScreen .account-switcher-login {
    margin-bottom: 20px;
}

#loginScreen .account-switcher-login .account-switcher-row {
    margin-top: 6px;
    border: 1px solid rgba(13, 33, 55, 0.12);
    border-radius: 12px;
}

#loginScreen .account-switcher-login .account-switcher-open {
    color: #0d2137;
}

#loginScreen .account-switcher-login .account-switcher-open:hover {
    background: #f4f7fa;
}

.account-pin-dialog {
    width: min(420px, calc(100vw - 32px));
    max-width: none;
}

.account-pin-who {
    margin-bottom: 14px;
    color: var(--neutral-700);
    overflow-wrap: anywhere;
}

.account-pin-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.account-pin-input {
    width: 100%;
    font-size: 16px;
}

.account-pin-dialog .form-group {
    margin-bottom: 0;
}

.account-pin-error {
    min-height: 1.4em;
    margin-top: 8px;
    color: #dc2626;
    font-size: 13.5px;
}

/* Quick sign in ("Who is recording?"): the team as cards on the sign-in screen */
#loginScreen .enterprise-login-form-card.quick-signin-active > .enterprise-login-form-header,
#loginScreen .enterprise-login-form-card.quick-signin-active > .enterprise-login-divider,
#loginScreen .enterprise-login-form-card.quick-signin-active > .enterprise-login-mode-switch,
#loginScreen .enterprise-login-form-card.quick-signin-active > #loginForm {
    display: none;
}

/* The card widens to the team: --quick-signin-columns cards per row, fewer on a narrow screen. */
#loginScreen .enterprise-login-form-card.quick-signin-active {
    max-width: calc(var(--quick-signin-columns, 2) * 148px + (var(--quick-signin-columns, 2) - 1) * 12px + 60px);
}

/* While the team shows, the side panel gives the cards more of the screen. */
@media (min-width: 901px) {
    #loginScreen.quick-signin-on .enterprise-login-layout {
        grid-template-columns: minmax(300px, 0.55fr) minmax(0, 1fr);
    }
}

#loginScreen .quick-signin {
    margin-bottom: 20px;
}

#loginScreen .quick-signin-shop {
    margin-top: 4px;
    font-size: 13px;
    font-weight: 600;
    color: #0d2137;
    overflow-wrap: anywhere;
}

#loginScreen .quick-signin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
    gap: 12px;
    margin-top: 18px;
    max-height: min(420px, 52vh);
    overflow-y: auto;
    padding: 2px;
}

#loginScreen .quick-signin-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 18px 10px 16px;
    border: 1px solid rgba(13, 33, 55, 0.12);
    border-radius: 14px;
    background: #ffffff;
    color: #0d2137;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#loginScreen .quick-signin-card:hover,
#loginScreen .quick-signin-card:focus-visible {
    border-color: #1a3862;
    box-shadow: 0 6px 16px rgba(13, 33, 55, 0.08);
}

#loginScreen .quick-signin-avatar {
    width: 56px;
    height: 56px;
    margin-bottom: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #1a3862;
    color: #ffffff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

#loginScreen .quick-signin-name {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
}

#loginScreen .quick-signin-status:empty {
    display: none;
}

#loginScreen .quick-signin-status {
    margin-top: 12px;
    font-size: 13px;
    color: #5a7080;
}

#loginScreen .quick-signin-footer {
    margin-top: 18px;
}

#loginScreen .quick-signin-link {
    padding: 6px 0;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: #1a6b7c;
    cursor: pointer;
    text-align: left;
}

#loginScreen .quick-signin-link:hover,
#loginScreen .quick-signin-link:focus-visible {
    color: #0d2137;
    text-decoration: underline;
}

#loginScreen .quick-signin-back {
    display: block;
    margin-bottom: 14px;
}

#loginScreen .quick-signin-back[hidden] {
    display: none;
}

/* The PIN pad: one person, four dots, number keys. */
#loginScreen .enterprise-login-form-card.quick-signin-pin-active {
    max-width: 460px;
}

#loginScreen .enterprise-login-form-card.quick-signin-pin-active > #loginRememberedAccounts,
#loginScreen .enterprise-login-form-card.quick-signin-pin-active > .enterprise-login-links {
    display: none;
}

#loginScreen .quick-signin-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

#loginScreen .quick-signin-pin[hidden] {
    display: none;
}

#loginScreen .quick-signin-notme {
    align-self: flex-start;
    margin-bottom: 14px;
    font-size: 15px;
    color: #0d2137;
}

#loginScreen .quick-signin-pin-avatar {
    width: 72px;
    height: 72px;
    margin-bottom: 14px;
    font-size: 22px;
}

#loginScreen .quick-signin-pin-title {
    margin-bottom: 6px;
    overflow-wrap: anywhere;
}

/* Focused only so screen readers announce who is signing in; it is not a control. */
#loginScreen .quick-signin-pin-title:focus {
    outline: none;
}

#loginScreen .quick-signin-dots {
    display: flex;
    gap: 16px;
    margin: 20px 0 6px;
    transition: opacity 0.2s ease;
}

#loginScreen .quick-signin-dots span {
    width: 18px;
    height: 18px;
    border: 2px solid #1a3862;
    border-radius: 50%;
    transition: background-color 0.12s ease;
}

#loginScreen .quick-signin-dots span.is-filled {
    background: #1a3862;
}

#loginScreen .quick-signin-dots.is-checking {
    opacity: 0.45;
}

#loginScreen .quick-signin-dots.is-wrong {
    animation: quick-signin-shake 0.36s ease;
}

@keyframes quick-signin-shake {
    20%, 60% { transform: translateX(-7px); }
    40%, 80% { transform: translateX(7px); }
}

@media (prefers-reduced-motion: reduce) {
    #loginScreen .quick-signin-dots.is-wrong {
        animation: none;
    }
}

#loginScreen .quick-signin-pin-error {
    min-height: 1.5em;
    margin-bottom: 10px;
    font-size: 13.5px;
    color: #dc2626;
}

#loginScreen .quick-signin-keypad {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
}

#loginScreen .quick-signin-keypad button {
    height: 64px;
    border: 1px solid rgba(13, 33, 55, 0.14);
    border-radius: 14px;
    background: #ffffff;
    color: #0d2137;
    font-size: 26px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

#loginScreen .quick-signin-keypad button:hover,
#loginScreen .quick-signin-keypad button:focus-visible {
    border-color: #1a3862;
}

#loginScreen .quick-signin-keypad button:active {
    background: #eef2f7;
}

#loginScreen .quick-signin-keypad .quick-signin-key-word {
    font-size: 16px;
    font-weight: 600;
    color: #5a7080;
}

#loginScreen .quick-signin-keypad [data-key="delete"] {
    color: #5a7080;
}

/* Phones: smaller cards, two across; a slightly shorter pad. */
@media (max-width: 480px) {
    #loginScreen .quick-signin-grid {
        grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
        gap: 10px;
    }

    #loginScreen .quick-signin-card {
        padding: 14px 8px 12px;
    }

    #loginScreen .quick-signin-card .quick-signin-avatar {
        width: 46px;
        height: 46px;
        font-size: 16px;
    }

    #loginScreen .quick-signin-name {
        font-size: 14px;
    }

    #loginScreen .quick-signin-keypad {
        gap: 10px;
    }

    #loginScreen .quick-signin-keypad button {
        height: 58px;
    }
}

/* Readable placeholders by default; specific fields may set their own. */
input::placeholder,
textarea::placeholder {
    color: #64748b;
    opacity: 1;
}

/* Restaurant and cafe screens on phones.
   - Quick Service / Kitchen Order: the summary panel scrolls, the items in the
     order come first, and the total with its Complete Sale / Send to Kitchen
     button stays pinned at the bottom (it used to sit below the screen and the
     item list was squashed to nothing).
   - Menu cards show two per row and keep their category line.
   - Orders, Kitchen Queue, Menu and Bulk Orders headers stack their buttons.
   - The workspace drawer backdrop covers the screen (touch-button rules had
     shrunk it to a 44px square).
   - Open tables and the menu list are not trapped in small scroll boxes. */
.hospitality-pos-card > * {
    flex-shrink: 0;
}

@media (max-width: 980px) {
    .hospitality-pos-summary {
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0 !important;
    }

    .hospitality-pos-summary > h3 {
        order: 0;
    }

    .hospitality-pos-summary > .hospitality-pos-order-list {
        order: 1;
        flex: 0 0 auto;
        min-height: auto;
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .hospitality-pos-summary > .hospitality-pos-field,
    .hospitality-pos-summary > .hospitality-pos-fields {
        order: 2;
        flex-shrink: 0;
    }

    .hospitality-pos-summary > .hospitality-pos-summary-footer {
        order: 3;
        position: sticky;
        bottom: 0;
        z-index: 1;
        flex-shrink: 0;
        margin-top: auto;
        padding: 12px 0 14px;
        background: var(--surface);
        border-top: 1px solid var(--border);
    }
}

@media (max-width: 640px) {
    .hospitality-pos-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: max-content;
        gap: 8px;
    }

    .hospitality-pos-card {
        min-height: 0;
        padding: 12px;
        gap: 6px;
        text-align: left;
        align-items: stretch;
        justify-content: flex-start;
    }

    .hospitality-pos-card-name {
        font-size: 14px;
    }

    .hospitality-pos-card-footer {
        flex-wrap: wrap;
        gap: 2px 8px;
    }
}

@media (max-width: 768px) {
    #orders .tab-header,
    #kitchenQueue .tab-header,
    #menuItems .tab-header,
    #bulkOrders > .tab-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    #orders .tab-header .header-actions,
    #kitchenQueue .tab-header .header-actions,
    #menuItems .tab-header .header-actions,
    #bulkOrders > .tab-header .header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px !important;
        width: 100%;
    }

    #orders .tab-header .header-actions > *,
    #kitchenQueue .tab-header .header-actions > *,
    #menuItems .tab-header .header-actions > *,
    #bulkOrders > .tab-header .header-actions > * {
        flex: 1 1 140px;
        min-width: 0;
        margin: 0;
    }

    #bulkOrders .search-bar select {
        display: block;
        width: 100%;
        min-height: 42px;
        margin-top: 8px;
        padding: 0 36px 0 12px;
        border-radius: 5px;
        font-size: 14px;
    }

    .restaurant-mobile-workflow-nav .restaurant-mobile-workflow-backdrop {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;
        border-radius: 0;
    }

    #restaurantOrdersList {
        max-height: none;
        overflow: visible;
    }

    /* Bottom bar: buttons take their label's width and share what is left, so
       seven fit on a 375px phone; longer lists still scroll sideways. */
    .bottom-nav-btn {
        flex: 1 1 auto;
        min-width: 44px;
        padding-left: 4px;
        padding-right: 4px;
    }

    #menuItemsTable.mobile-cards,
    #bulkOrdersTable.mobile-cards {
        display: block;
    }

    #menuItemsTable.mobile-cards thead,
    #bulkOrdersTable.mobile-cards thead {
        display: none;
    }

    #menuItemsTable.mobile-cards tbody,
    #bulkOrdersTable.mobile-cards tbody {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    #menuItemsTable.mobile-cards tr,
    #bulkOrdersTable.mobile-cards tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 16px;
        box-shadow: var(--shadow-sm);
    }

    #menuItemsTable.mobile-cards td,
    #bulkOrdersTable.mobile-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 1px solid var(--border-light);
        font-size: 14px;
        text-align: right;
        height: auto;
        min-height: 44px;
    }

    #menuItemsTable.mobile-cards td:last-child,
    #bulkOrdersTable.mobile-cards td:last-child {
        border-bottom: none;
        padding-top: 12px;
    }

    #menuItemsTable.mobile-cards td::before,
    #bulkOrdersTable.mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        flex-shrink: 0;
        text-align: left;
    }

    #menuItemsTable.mobile-cards tbody td:first-child {
        justify-content: flex-start;
        text-align: left;
        font-size: 16px;
        font-weight: 700;
        padding-top: 0;
    }

    #menuItemsTable.mobile-cards tbody td:first-child::before,
    #menuItemsTable.mobile-cards tbody td.menu-cell-empty {
        display: none;
    }

    #menuItemsTable.mobile-cards tbody td[data-label="Actions"] {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding-top: 8px;
    }

    #menuItemsTable.mobile-cards tbody td[colspan],
    #bulkOrdersTable.mobile-cards tbody td[colspan],
    #salesTable.mobile-cards tbody td[colspan] {
        display: block;
        height: auto;
        padding: 0;
        border: 0;
        text-align: center;
    }

    #menuItemsTable.mobile-cards tbody td[colspan]::before,
    #bulkOrdersTable.mobile-cards tbody td[colspan]::before,
    #salesTable.mobile-cards tbody td[colspan]::before {
        display: none;
    }
}
