/* ============================================
   CSS VARIABLES & RESET
   ============================================ */
:root {
    /* Primary Colors - Deep Indigo Theme */
    --primary: #4338ca;
    /* Indigo 700 */
    --primary-dark: #3730a3;
    /* Indigo 800 */
    --primary-light: #6366f1;
    /* Indigo 500 */
    --primary-subtle: #e0e7ff;
    /* Indigo 100 */

    /* Semantic Colors */
    --success: #059669;
    /* Emerald 600 */
    --success-light: #d1fae5;
    --success-dark: #047857;

    --warning: #d97706;
    /* Amber 600 */
    --warning-light: #fef3c7;
    --warning-dark: #b45309;

    --danger: #dc2626;
    /* Red 600 */
    --danger-light: #fee2e2;
    --danger-dark: #b91c1c;

    --info: #2563eb;
    /* Blue 600 */
    --info-light: #dbeafe;
    --info-dark: #1d4ed8;

    /* Neutral Colors - Slate */
    --background: #f1f5f9;
    /* Slate 100 */
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    /* Slate 50 */

    --text-main: #0f172a;
    /* Slate 900 */
    --text-secondary: #475569;
    /* Slate 600 */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --text-inverse: #ffffff;

    --border: #e2e8f0;
    /* Slate 200 */
    --border-light: #f1f5f9;
    /* Slate 100 */

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

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

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    /* Sidebar Width */
    --sidebar-width: 280px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Extended aliases — match the hex values used in inline styles */
    --success-border:  #10b981;
    --success-text:    #065f46;
    --danger-text:     #991b1b;
    --warning-text:    #78350f;
    --info-text:       #1e40af;
}

/* ============================================
   DARK THEME
   ============================================ */
[data-theme="dark"] {
    --primary:         #6366f1;
    --primary-dark:    #818cf8;
    --primary-light:   #a5b4fc;
    --primary-subtle:  #1e1b4b;

    --success:         #10b981;
    --success-light:   #022c22;
    --success-dark:    #34d399;
    --success-border:  #34d399;
    --success-text:    #a7f3d0;

    --warning:         #f59e0b;
    --warning-light:   #1c1408;
    --warning-dark:    #fbbf24;
    --warning-text:    #fde68a;

    --danger:          #f87171;
    --danger-light:    #2d0404;
    --danger-dark:     #fca5a5;
    --danger-text:     #fecaca;

    --info:            #60a5fa;
    --info-light:      #0c1f3d;
    --info-dark:       #93c5fd;
    --info-text:       #bfdbfe;

    --background:      #0f172a;
    --surface:         #1e293b;
    --surface-hover:   #273549;

    --text-main:       #f1f5f9;
    --text-secondary:  #94a3b8;
    --text-muted:      #64748b;
    --text-inverse:    #0f172a;

    --border:          #334155;
    --border-light:    #1e293b;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
    --shadow:    0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.6), 0 4px 6px -4px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.6), 0 8px 10px -6px rgb(0 0 0 / 0.5);
}

/* Dark overrides for elements with hardcoded values in the stylesheet */
[data-theme="dark"] .btn-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-secondary);
}
[data-theme="dark"] .btn-secondary:hover {
    background: var(--surface-hover);
}
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card {
    border-color: var(--border);
}
[data-theme="dark"] .card-header {
    border-bottom-color: var(--border);
}
[data-theme="dark"] th {
    background: var(--surface-hover);
    border-bottom-color: var(--border);
    color: var(--text-secondary);
}
[data-theme="dark"] td {
    color: var(--text-secondary);
}
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] textarea {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text-main);
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}
[data-theme="dark"] .input-group-text {
    background: var(--surface-hover);
    border-color: var(--border);
    color: var(--text-muted);
}
[data-theme="dark"] select option {
    background: var(--surface);
    color: var(--text-main);
}
[data-theme="dark"] input[readonly] {
    background-color: var(--surface-hover);
}

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    height: 100%;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    /* For sidebar layout */
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-main);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 {
    font-size: 2.25rem;
}

h2 {
    font-size: 1.875rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

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

a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

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

/* ============================================
   LAYOUT STRUCTURE (SIDEBAR)
   ============================================ */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

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

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 var(--space-6);
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 1.25rem;
    font-weight: 800;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.logo-mark {
    width: 1.75rem;
    height: 1.75rem;
    flex: 0 0 auto;
}

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

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.nav-links a:hover {
    background: var(--surface-hover);
    color: var(--text-main);
}

.nav-links a.active {
    background: var(--primary-subtle);
    color: var(--primary);
}

.nav-links a i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.nav-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    padding: var(--space-5) var(--space-4) var(--space-2) var(--space-4);
    margin-top: var(--space-2);
    border-top: 1px solid var(--border);
    list-style: none;
}

/* Collapsible sidebar groups */
.nav-group {
    list-style: none;
}

.nav-group-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-weight: 500;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-group-toggle:hover {
    background: var(--surface-hover);
    color: var(--text-main);
}

.nav-group.child-active > .nav-group-toggle {
    color: var(--primary);
    font-weight: 600;
}

.nav-group-toggle i:first-child {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.nav-group-toggle .chev {
    margin-left: auto;
    font-size: 0.62rem;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.nav-group.open > .nav-group-toggle .chev {
    transform: rotate(90deg);
}

.nav-sublist {
    display: none;
    list-style: none;
    margin: 0;
    padding: 0 0 0 var(--space-6);
}

.nav-group.open > .nav-sublist {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding-top: var(--space-1);
}

.nav-sublist a {
    padding: var(--space-2) var(--space-3);
    font-size: 0.85rem;
}

.nav-sublist a i {
    width: 18px;
    font-size: 0.9rem;
}

.sidebar-footer {
    padding: var(--space-4);
    border-top: 1px solid var(--border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius);
    background: var(--surface-hover);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary-subtle);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

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

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-credit {
    text-align: center;
    padding-top: var(--space-3);
    margin-top: var(--space-3);
    border-top: 1px solid var(--border);
}

.sidebar-credit small {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-8) var(--space-10);
    width: calc(100% - var(--sidebar-width));
}

/* ============================================
   COMPONENTS
   ============================================ */

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

/* Breadcrumbs */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumb-link:hover {
    color: var(--primary);
}

.breadcrumb-sep {
    color: var(--border);
    font-size: 0.65rem;
    display: inline-flex;
    align-items: center;
}

.breadcrumb-current {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Clickable table rows — the whole row navigates; action links/buttons inside
   still work (handled in layout.ejs). */
.table tbody tr.row-link {
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.table tbody tr.row-link:hover {
    background: var(--surface-hover);
}

/* Related-records strip on detail pages (quote ↔ job ↔ invoice) */
.record-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
}

.record-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.record-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

.record-link .record-link-label {
    color: var(--text-muted);
    font-weight: 500;
}

/* Flash toasts — action feedback that survives redirects (see middleware/flash.js) */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: min(380px, calc(100vw - 2 * var(--space-4)));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--surface);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-left: 4px solid var(--info);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toast-in 0.28s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.toast.toast-hide {
    animation: toast-out 0.3s ease-in forwards;
}

.toast-icon {
    font-size: 1.1rem;
    margin-top: 0.1rem;
    flex-shrink: 0;
}

.toast-msg {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: var(--text-main);
}

.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-danger  { border-left-color: var(--danger); }
.toast-danger .toast-icon  { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    { border-left-color: var(--info); }
.toast-info .toast-icon    { color: var(--info); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(24px); }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'Plus Jakarta Sans', sans-serif;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1.25;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: none;
    border: 1px solid var(--primary);
}

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

.btn-secondary {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    box-shadow: none;
}

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

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--success-dark);
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: var(--warning-dark);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-icon {
    padding: 0.5rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

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

/* Destructive icon buttons stay solid red, including on hover */
.btn-danger.btn-icon {
    color: white;
}

.btn-danger.btn-icon:hover {
    background: var(--danger-dark);
    color: white;
}

/* Search box above a list table */
.table-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: var(--space-4) var(--space-5) 0;
}

.table-search {
    max-width: 320px;
}

/* Table row action group — keeps icon buttons on one horizontal line */
.table-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

td.text-right .table-actions {
    justify-content: flex-end;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: none;
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: var(--space-5);
    transition: all var(--transition-fast);
}

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

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

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

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

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

th {
    padding: var(--space-4) var(--space-6);
    background: var(--surface-hover);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

tr:hover td {
    background: var(--surface-hover);
}

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

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

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

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

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

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

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

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.875rem;
}

.form-control,
.form-select,
textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-main);
    font-size: 0.875rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    transition: all var(--transition-fast);
}

.form-control:focus,
.form-select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-lg {
    max-width: 700px;
}

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

.modal-header .modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.modal-header .close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.25rem;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius);
    line-height: 1;
    transition: all var(--transition-fast);
}

.modal-header .close:hover {
    background: var(--surface-hover);
    color: var(--text-main);
}

.modal-body {
    padding: var(--space-6) var(--space-8);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-8) var(--space-6);
    border-top: 1px solid var(--border-light);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.25rem;
    padding: var(--space-2);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--surface-hover);
    color: var(--text-main);
}

@keyframes modalSlide {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

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

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #1e1b4b 100%);
    padding: var(--space-4);
}

.auth-card {
    background: var(--surface);
    padding: var(--space-10);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
}

.auth-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.auth-header h1 {
    font-size: 1.75rem;
    margin-bottom: var(--space-2);
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-6);
    font-size: 0.875rem;
}

/* Quote Form Enhancements */
.quote-container {
    max-width: 1200px;
    margin: 0 auto;
}

.totals-card {
    background: var(--surface-hover);
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.total-row.grand-total {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 2px dashed var(--border);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
}

.form-section-title {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.form-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-light);
}

/* Input enhancements */
.form-control:focus {
    box-shadow: 0 0 0 3px var(--primary-subtle);
    border-color: var(--primary);
}

input[readonly] {
    background-color: var(--surface-hover);
    cursor: not-allowed;
    color: var(--text-muted);
}

/* Table enhancements */
.table-card {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.table th {
    background: var(--surface-hover);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: var(--space-3) var(--space-4);
}

.table td {
    padding: var(--space-3) var(--space-4);
    vertical-align: middle;
}

.remove-row {
    color: var(--danger);
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: transparent;
    border: none;
    cursor: pointer;
}

.remove-row:hover {
    background: var(--danger-light);
    color: var(--danger-dark);
}

/* ============================================
   CONSOLIDATED COMPONENTS FROM STYLES.CSS
   ============================================ */

/* Table Empty State */
.table-empty {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--text-muted);
}

.table-empty i {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    color: var(--border);
}

.table-empty i.icon-success {
    color: var(--success);
}

.table-empty-cta {
    margin-top: var(--space-4);
}

/* Secondary Badge */
.badge-secondary {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

/* Form Helper Classes */
/* Required-field marker. Templates use `class="form-label required"`, so match
   that as well as the older `.form-label-required`. */
.form-label-required::after,
.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

/* Inline client-side validation (see the validation block in layout.ejs) */
.form-control.is-invalid,
.form-select.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: var(--danger);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent);
}

.field-error {
    display: block;
    color: var(--danger);
    font-size: 0.78rem;
    font-weight: 500;
    margin-top: var(--space-1);
}

.field-error::before {
    content: '\f06a'; /* fa exclamation-circle */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-right: 0.35rem;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* Session expiry warning banner */
/* The class sets display:flex which would override the hidden attribute's
   UA display:none — this rule keeps [hidden] winning. */
.session-banner[hidden] {
    display: none;
}

.session-banner {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: var(--warning-light);
    border: 1px solid var(--warning);
    color: var(--warning-text);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: 0.9rem;
    max-width: calc(100vw - 2rem);
}

.session-banner i {
    color: var(--warning);
}

/* Audit trail page */
.audit-filter-card {
    margin-bottom: 1.5rem;
}

.audit-filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.audit-filter-form .form-group {
    margin-bottom: 0;
    min-width: 140px;
}

.audit-filter-actions {
    display: flex;
    gap: 0.5rem;
}

.audit-when {
    white-space: nowrap;
    font-size: 0.85rem;
}

.audit-record {
    font-family: monospace;
    font-size: 0.85rem;
}

.audit-changes {
    font-size: 0.82rem;
}

.audit-change-row {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex-wrap: wrap;
    padding: 0.1rem 0;
}

.audit-field {
    font-weight: 600;
    color: var(--text-secondary);
}

.audit-field::after {
    content: ':';
}

.audit-old {
    color: var(--danger);
    text-decoration: line-through;
    word-break: break-word;
}

.audit-new {
    color: var(--success);
    word-break: break-word;
}

.audit-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.audit-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
}

/* Inventory page tabs (All / Soft Furnishings / Assemblies) */
.inv-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: 1.5rem;
}

.inv-tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
}

.inv-tab i {
    margin-right: 0.4rem;
}

.inv-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Stock adjustment modal — live delta preview */
.adjust-delta-preview {
    font-weight: 600;
    font-size: 0.875rem;
    margin: var(--space-2) 0;
}

.adjust-delta-preview.delta-pos { color: var(--success); }
.adjust-delta-preview.delta-neg { color: var(--danger); }
.adjust-delta-preview.delta-zero { color: var(--text-muted); font-weight: 400; }

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: var(--space-1);
}

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

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

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

.input-group .form-control:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
    border-right: 1px solid var(--border);
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-right: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.input-group .form-control {
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* Alerts */
.alert-error {
    background: var(--danger-light);
    color: var(--danger-dark);
    border: 1px solid var(--danger-light);
}

/* Bulk import */
.import-note {
    background: var(--surface-hover);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.55;
}
.import-note ul { margin: 0.5rem 0 0; padding-left: 1.1rem; }
.import-note li { margin-bottom: 0.25rem; }

.import-summary {
    display: flex;
    gap: var(--space-6);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
    font-size: 0.9rem;
}
.import-summary strong { font-size: 1.05rem; }

.import-errors td { vertical-align: top; }
.import-errors ul { margin: 0; padding-left: 1.1rem; }

.import-file-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: var(--space-6);
    text-align: center;
    color: var(--text-muted);
}
.import-file-drop input[type="file"] { margin-top: var(--space-3); }

/* Stats & Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-8);
}

.stat-card {
    background: var(--surface);
    padding: var(--space-6);
    border-radius: var(--radius-md);
    box-shadow: none;
    border: 1px solid var(--border);
    transition: all var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: var(--space-4);
}

.stat-icon.blue {
    background: var(--info-light);
    color: var(--info-dark);
}

.stat-icon.green {
    background: var(--success-light);
    color: var(--success-dark);
}

.stat-icon.yellow {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.stat-icon.red {
    background: var(--danger-light);
    color: var(--danger-dark);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: var(--space-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Inventory Specific */
.stock-level {
    font-weight: 600;
}

.stock-level.low-stock {
    color: var(--danger);
}

.sku {
    font-family: monospace;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface-hover);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
}

/* Utility Classes */
.grid {
    display: grid;
    gap: var(--space-6);
}

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

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

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.w-full {
    width: 100%;
}

/* Full-width buttons keep their content centred */
.btn.w-full {
    justify-content: center;
}

/* Page-header action row — flex + gap comes from here, never inline */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* Record-page actions are arranged by intent instead of presented as one
   undifferentiated button row. */
.record-page-header {
    align-items: flex-start;
}

.record-page-header .header-actions {
    justify-content: flex-end;
}

.record-quick-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin: calc(-1 * var(--space-2)) 0 var(--space-6);
    padding: var(--space-3) var(--space-4);
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.record-action-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.record-action-list {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.record-action-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    margin-top: var(--space-6);
    padding: var(--space-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.record-action-copy strong,
.record-danger-copy strong {
    display: block;
    color: var(--text-main);
    font-size: 0.9rem;
}

.record-action-copy span,
.record-danger-copy span {
    display: block;
    margin-top: var(--space-1);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.record-danger-zone {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    margin-top: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: color-mix(in srgb, var(--danger-light) 52%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--danger) 22%, var(--border));
    border-radius: var(--radius-md);
}

@media (max-width: 768px) {
    .record-page-header,
    .record-quick-actions,
    .record-action-panel,
    .record-danger-zone {
        align-items: stretch;
        flex-direction: column;
    }

    .record-page-header .header-actions,
    .record-action-list {
        justify-content: flex-start;
    }

    .record-quick-actions .btn,
    .record-action-panel .btn,
    .record-danger-zone .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

/* Standard form footer: Cancel + one primary action, right-aligned */
.form-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border-light);
}

.mt-2 {
    margin-top: var(--space-2);
}

.mt-4 {
    margin-top: var(--space-4);
}

.mt-6 {
    margin-top: var(--space-6);
}

/* Line-item rows on credit/debit note forms (EJS rows + addLine() JS template) */
.line-item {
    display: grid;
    grid-template-columns: 1fr 80px 100px 100px 36px;
    gap: var(--space-2);
    align-items: start;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-light);
}

.line-item .form-label {
    font-size: 0.8rem;
}

.line-item-remove-cell {
    /* Clear the label row so the action lines up with the form controls. */
    padding-top: 1.55rem;
}

.line-item-remove {
    color: var(--danger);
    background: none;
    border: none;
    padding: var(--space-2);
}

/* Shared inventory browser used by document lines and production forms. */
.inventory-browser-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-2);
    align-items: stretch;
}

.inventory-browser-trigger {
    white-space: nowrap;
    padding-inline: var(--space-3);
}

.inventory-browser-trigger i {
    margin-right: var(--space-1);
}

body.inventory-browser-open {
    overflow: hidden;
}

.inventory-browser-modal {
    padding: var(--space-4);
    z-index: 1200;
}

.inventory-browser-panel {
    max-width: 820px;
    height: min(720px, calc(100vh - 2rem));
    overflow: hidden;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
}

.inventory-browser-header {
    padding-block: var(--space-5);
}

.inventory-browser-kicker {
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.inventory-browser-search-wrap {
    position: relative;
    padding: var(--space-5) var(--space-8) var(--space-3);
}

.inventory-browser-search-wrap > i {
    position: absolute;
    left: calc(var(--space-8) + 0.9rem);
    top: calc(var(--space-5) + 0.9rem);
    color: var(--text-muted);
    pointer-events: none;
}

.inventory-browser-search-wrap input {
    padding-left: 2.6rem;
    padding-right: 3.6rem;
    font-size: 1rem;
}

.inventory-browser-search-wrap kbd {
    position: absolute;
    right: calc(var(--space-8) + 0.7rem);
    top: calc(var(--space-5) + 0.7rem);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--surface-hover);
    color: var(--text-muted);
    font: 600 0.68rem/1 sans-serif;
    padding: 0.35rem 0.45rem;
}

.inventory-browser-summary {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 0 var(--space-8) var(--space-3);
    color: var(--text-muted);
    font-size: 0.76rem;
}

.inventory-browser-summary span:first-child {
    color: var(--text-main);
    font-weight: 700;
}

.inventory-browser-list {
    overflow-y: auto;
    border-top: 1px solid var(--border-light);
    padding: var(--space-2) var(--space-4) var(--space-5);
}

.inventory-browser-item {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: 1px solid transparent;
    border-bottom-color: var(--border-light);
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
    font: inherit;
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.inventory-browser-item[hidden] {
    display: none;
}

.inventory-browser-item:hover,
.inventory-browser-item:focus-visible {
    outline: none;
    background: var(--primary-light);
    border-color: color-mix(in srgb, var(--primary) 28%, transparent);
    border-radius: var(--radius);
    transform: translateX(2px);
}

.inventory-browser-item-main,
.inventory-browser-item-meta {
    display: flex;
    align-items: center;
    min-width: 0;
}

.inventory-browser-item-main {
    gap: var(--space-3);
}

.inventory-browser-sku {
    min-width: 90px;
    color: var(--primary);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.inventory-browser-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 650;
}

.inventory-browser-category {
    border-radius: var(--radius-full);
    background: var(--surface-hover);
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    white-space: nowrap;
}

.inventory-browser-item-meta {
    justify-content: flex-end;
    gap: var(--space-4);
    color: var(--text-muted);
    font-size: 0.76rem;
}

.inventory-browser-stock.is-low {
    color: var(--danger);
    font-weight: 700;
}

.inventory-browser-price {
    min-width: 82px;
    color: var(--text-main);
    font-weight: 750;
    text-align: right;
}

.inventory-browser-empty {
    display: grid;
    justify-items: center;
    gap: var(--space-2);
    color: var(--text-muted);
    padding: var(--space-8);
    text-align: center;
}

.inventory-browser-empty[hidden] {
    display: none;
}

.inventory-browser-empty i {
    color: var(--primary);
    font-size: 2rem;
    opacity: 0.55;
}

/* Password recovery follows the login card, with a real three-step lifecycle. */
.password-reset-shell {
    position: relative;
}

.password-reset-card {
    max-width: 460px;
}

.password-reset-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
}

.password-reset-back:hover {
    color: var(--primary);
}

.password-reset-mark {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    margin: 0 auto var(--space-4);
    border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
    border-radius: 16px 16px 16px 5px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 1.25rem;
    transform: rotate(-2deg);
}

.password-reset-mark i {
    transform: rotate(2deg);
}

.password-reset-steps {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr auto;
    align-items: start;
    margin: var(--space-6) 0;
}

.password-reset-steps > span {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
}

.password-reset-steps > span.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.password-reset-steps > span span {
    position: absolute;
    top: 33px;
    left: 50%;
    color: var(--text-muted);
    font-size: 0.66rem;
    font-weight: 650;
    transform: translateX(-50%);
}

.password-reset-steps > i {
    height: 1px;
    margin-top: 14px;
    background: var(--border);
}

.password-reset-steps > span.active + i {
    background: var(--primary);
}

.password-reset-note {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin: var(--space-5) 0;
    padding: var(--space-4);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface-hover);
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.password-reset-note > i {
    margin-top: 0.15rem;
    color: var(--primary);
}

.password-reset-note strong {
    color: var(--text-main);
}

.password-reset-note.is-warning > i {
    color: var(--warning);
}

@media (max-width: 680px) {
    .inventory-browser-trigger span { display: none; }
    .inventory-browser-trigger i { margin-right: 0; }
    .inventory-browser-header,
    .inventory-browser-search-wrap { padding-inline: var(--space-4); }
    .inventory-browser-search-wrap > i { left: calc(var(--space-4) + 0.9rem); }
    .inventory-browser-search-wrap kbd { display: none; }
    .inventory-browser-summary { padding-inline: var(--space-4); }
    .inventory-browser-summary span:last-child { display: none; }
    .inventory-browser-item { grid-template-columns: 1fr; gap: var(--space-2); }
    .inventory-browser-item-main { flex-wrap: wrap; gap: var(--space-2); }
    .inventory-browser-sku { min-width: 0; }
    .inventory-browser-name { order: 3; flex-basis: 100%; }
    .inventory-browser-item-meta { justify-content: space-between; }
}

/* PO document upload row (Documents card on the purchase order view) */
.attachment-upload-form {
    display: grid;
    grid-template-columns: 220px 1fr auto;
    gap: var(--space-4);
    align-items: end;
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-light);
}

.attachment-upload-form .form-group {
    margin-bottom: 0;
}

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

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

.text-right {
    text-align: right;
}

/* Dashboard Specific */
.dashboard-greeting {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: var(--space-2);
    margin-bottom: 0;
}

.dashboard-date {
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

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

/* Stat card accent border */
.stat-card-accent {
    border-top: 3px solid transparent;
    position: relative;
}

.stat-card-accent.accent-green { border-top-color: var(--success); }
.stat-card-accent.accent-yellow { border-top-color: var(--warning); }
.stat-card-accent.accent-blue { border-top-color: var(--info); }
.stat-card-accent.accent-indigo { border-top-color: var(--primary); }

/* Client portal access — deliberately separate from internal staff settings. */
.client-access-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 0.7fr)) minmax(300px, 1.4fr);
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.client-access-stat,
.client-access-limit {
    min-height: 132px;
    padding: var(--space-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.client-access-stat {
    position: relative;
    overflow: hidden;
}

.client-access-stat::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--access-color);
}

.client-access-stat.is-active { --access-color: var(--success); }
.client-access-stat.is-pending { --access-color: var(--warning); }
.client-access-stat.is-inactive { --access-color: var(--text-muted); }

.client-access-stat__label {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.client-access-stat strong {
    display: block;
    color: var(--text-main);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    line-height: 1;
}

.client-access-stat > span:last-child {
    display: block;
    margin-top: var(--space-2);
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.client-access-limit {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    background: linear-gradient(135deg, var(--surface), var(--surface-hover));
}

.client-access-limit p {
    margin: 0;
    color: var(--text-main);
    font-weight: 700;
}

.client-access-limit form {
    display: grid;
    grid-template-columns: 110px auto;
    gap: var(--space-2);
}

.client-access-alert {
    margin-bottom: var(--space-5);
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--warning);
    border-left-width: 4px;
    border-radius: var(--radius);
    background: var(--warning-light);
    color: var(--warning-text);
}

.client-account-card { border-top: 3px solid var(--primary); }

.client-account-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.client-account-heading h2 {
    margin: 0 0 var(--space-1);
    font-size: 1.15rem;
}

.client-account-heading p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.client-account-table-wrap { margin: 0; }
.client-account-table td { vertical-align: middle; }

.client-account-row--pending td:first-child { box-shadow: inset 3px 0 0 var(--warning); }

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

.account-identity__mark {
    display: inline-flex;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 800;
}

.account-identity span:last-child,
.client-account-email {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.access-state {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.55rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.access-state--active { background: var(--success-light); color: var(--success-dark); }
.access-state--pending { background: var(--warning-light); color: var(--warning-text); }
.access-state--inactive { background: var(--surface-hover); color: var(--text-muted); }

.client-account-actions,
.client-approval-form {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
}

.client-approval-form label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    white-space: nowrap;
}

.client-approval-form .form-control {
    width: 64px;
    padding: 0.4rem 0.5rem;
}

.client-account-empty {
    padding: var(--space-10) var(--space-5);
    text-align: center;
    color: var(--text-muted);
}

.client-account-empty > i {
    margin-bottom: var(--space-4);
    color: var(--primary);
    font-size: 2rem;
    opacity: 0.65;
}

.client-account-empty h3 { margin-bottom: var(--space-2); color: var(--text-main); }
.client-account-empty p { margin: 0; }

/* Client portal delivery receipts on quotes and invoices. */
.document-view-receipt {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--border);
    border-left: 4px solid var(--receipt-color);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.document-view-receipt--viewed { --receipt-color: var(--success); }
.document-view-receipt--unviewed { --receipt-color: var(--text-muted); }

.document-view-receipt__icon {
    display: flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface-hover);
    color: var(--receipt-color);
    font-size: 1rem;
}

.document-view-receipt--viewed .document-view-receipt__icon { background: var(--success-light); }

.document-view-receipt__copy strong,
.document-view-receipt__copy span { display: block; }

.document-view-receipt__copy > strong {
    margin-bottom: 0.2rem;
    color: var(--text-main);
    font-size: 0.9rem;
}

.document-view-receipt__copy span,
.document-view-receipt__meta {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.document-view-receipt__copy span strong { display: inline; color: var(--text-secondary); }

.document-view-receipt__meta {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 0.2rem;
    white-space: nowrap;
}

.document-view-history {
    margin: calc(var(--space-4) * -1) 0 var(--space-4);
    padding: var(--space-3) var(--space-5);
    border: 1px solid var(--border);
    border-top: 0;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    background: var(--surface-hover);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.document-view-history summary { cursor: pointer; font-weight: 700; }
.document-view-history ul { margin: var(--space-3) 0 0; padding: 0; list-style: none; }
.document-view-history li { display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-2) 0; }
.document-view-history li + li { border-top: 1px solid var(--border); }
.document-view-history li span { color: var(--text-muted); }

.portal-view-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.55rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.portal-view-badge--viewed { background: var(--success-light); color: var(--success-dark); }
.portal-view-badge--unviewed { background: var(--surface-hover); color: var(--text-muted); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1100px) {
    .client-access-summary { grid-template-columns: repeat(3, 1fr); }
    .client-access-limit { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
    .client-access-summary { grid-template-columns: 1fr; }
    .client-access-limit { grid-column: auto; align-items: flex-start; flex-direction: column; }
    .client-account-actions,
    .client-approval-form { align-items: flex-end; flex-direction: column; }
    .document-view-receipt { grid-template-columns: auto 1fr; }
    .document-view-receipt__meta { grid-column: 2; align-items: flex-start; }
    .document-view-history li { align-items: flex-start; flex-direction: column; gap: 0.15rem; }
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-3);
}

.stat-trend {
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.stat-trend.trend-up {
    color: var(--success-dark);
    background: var(--success-light);
}

.stat-trend.trend-alert {
    color: var(--warning-dark);
    background: var(--warning-light);
}

.stat-detail {
    margin-top: var(--space-2);
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.stat-detail .text-success { color: var(--success); font-weight: 500; }
.stat-detail .text-danger { color: var(--danger); font-weight: 500; }

/* Mini stat cards */
.stat-mini {
    padding: var(--space-4) var(--space-5);
}

.stat-mini-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.stat-icon-sm {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.stat-icon-sm.blue { background: var(--info-light); color: var(--info-dark); }
.stat-icon-sm.green { background: var(--success-light); color: var(--success-dark); }
.stat-icon-sm.yellow { background: var(--warning-light); color: var(--warning-dark); }
.stat-icon-sm.red { background: var(--danger-light); color: var(--danger-dark); }

.stat-value-sm {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.stat-label-sm {
    font-size: 0.78rem;
    color: var(--text-muted);
}

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

.dash-col-main, .dash-col-side {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Pipeline Bar */
.pipeline-bar {
    display: flex;
    height: 40px;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: var(--space-4);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
}

.pipeline-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 36px;
    transition: all var(--transition);
}

.pipeline-pending { background: var(--text-muted); }
.pipeline-progress { background: var(--info); }
.pipeline-qc { background: var(--warning); }
.pipeline-done { background: var(--success); }
.pipeline-empty { background: var(--border); color: var(--text-muted); font-weight: 500; font-size: 0.8rem; }

.pipeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    font-size: 0.78rem;
    color: var(--text-secondary);
}

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

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.legend-pending { background: var(--text-muted); }
.legend-progress { background: var(--info); }
.legend-qc { background: var(--warning); }
.legend-done { background: var(--success); }

/* Quick Actions — Vertical List */
.quick-actions-vertical {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.quick-action-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    text-decoration: none;
    border: 1px solid transparent;
}

.quick-action-row:hover {
    background: var(--surface-hover);
    border-color: var(--border);
    color: var(--text-main);
}

.quick-action-row .qa-arrow {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.7rem;
    transition: transform var(--transition-fast);
}

.quick-action-row:hover .qa-arrow {
    transform: translateX(3px);
    color: var(--primary);
}

.quick-action-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.quick-action-icon.blue { background: var(--info-light); color: var(--info-dark); }
.quick-action-icon.green { background: var(--success-light); color: var(--success-dark); }
.quick-action-icon.yellow { background: var(--warning-light); color: var(--warning-dark); }
.quick-action-icon.red { background: var(--danger-light); color: var(--danger-dark); }

/* Dashboard List Items */
.dash-list {
    display: flex;
    flex-direction: column;
}

.dash-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border-light);
    text-decoration: none;
    color: inherit;
    transition: background var(--transition-fast);
}

.dash-list-item:hover {
    background: var(--surface-hover);
}

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

.dash-list-alert {
    cursor: default;
}

.dash-list-main {
    flex: 1;
    min-width: 0;
}

.dash-list-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-main);
}

.dash-list-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.dash-list-right {
    text-align: right;
    flex-shrink: 0;
    margin-left: var(--space-3);
}

.dash-list-amount {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-main);
}

/* Text helpers */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-muted { color: var(--text-muted); }

/* ============================================
   SCAN STATION
   ============================================ */
.scan-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
    gap: var(--space-6);
    align-items: start;
}

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

.scan-input-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.scan-input-icon {
    font-size: 1.5rem;
    color: var(--text-muted);
}

.scan-input {
    font-size: 1.25rem;
    font-family: 'Space Grotesk', monospace;
    letter-spacing: 0.05em;
}

.scan-hint {
    margin-top: var(--space-3);
    font-size: 0.8125rem;
}

.scan-item-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.scan-item-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: var(--space-2);
}

.scan-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.scan-qty-display {
    text-align: right;
    flex-shrink: 0;
}

.scan-qty-number {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.scan-qty-label {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.scan-low-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    margin-top: var(--space-2);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--warning-light);
    color: var(--warning-dark);
    font-size: 0.75rem;
    font-weight: 600;
}

.scan-actions {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.scan-qty-input-group {
    width: 110px;
}

.scan-error {
    margin-top: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--danger-light);
    color: var(--danger-dark);
    font-size: 0.875rem;
}

.scan-notfound-actions {
    text-align: center;
    margin-top: var(--space-3);
}

.scan-log {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 420px;
    overflow-y: auto;
}

.scan-log li {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
    font-family: 'Space Grotesk', monospace;
}

.scan-log-in { color: var(--success-dark); }
.scan-log-out { color: var(--warning-dark); }

@media (max-width: 900px) {
    .scan-layout {
        grid-template-columns: 1fr;
    }
}

/* Badge info */
.badge-primary {
    background: var(--primary-subtle);
    color: var(--primary-dark);
}

/* Settings: staff creation is split into identity and credential bands so
   password feedback never pulls the other fields off their shared baseline. */
.staff-user-form {
    display: grid;
    gap: 1rem;
}

.staff-user-form .form-group {
    margin-bottom: 0;
}

.staff-user-identity-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(180px, 0.7fr);
    gap: 1rem;
    align-items: end;
}

.staff-user-password-row {
    display: grid;
    grid-template-columns: minmax(240px, 0.85fr) minmax(520px, 1.8fr) auto;
    gap: 1rem;
    align-items: end;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.staff-password-panel-label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.staff-password-requirements {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.4rem;
}

.staff-password-requirements span {
    display: flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 0.38rem;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--surface-hover);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.staff-password-requirements span i {
    flex: 0 0 auto;
    font-size: 0.42rem;
}

.staff-password-requirements span[data-met="true"] {
    border-color: color-mix(in srgb, var(--success) 42%, var(--border));
    background: var(--success-light);
    color: var(--success-dark);
}

.staff-password-requirements span[data-met="true"] i {
    font-size: 0.78rem;
}

.staff-user-submit {
    min-width: 112px;
    min-height: 42px;
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .staff-user-password-row {
        grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.5fr);
    }

    .staff-user-submit {
        grid-column: 1 / -1;
        justify-self: end;
    }

    .staff-password-requirements {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .staff-user-identity-grid,
    .staff-user-password-row {
        grid-template-columns: 1fr;
    }

    .staff-user-submit {
        grid-column: auto;
        width: 100%;
    }

    .staff-password-requirements {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .staff-password-requirements span {
        transition: none;
    }
}

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

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

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

    .stats-grid-4 {
        grid-template-columns: 1fr;
    }

    .grid-cols-2,
    .grid-cols-3 {
        grid-template-columns: 1fr;
    }

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

    .pipeline-legend {
        flex-direction: column;
        gap: var(--space-2);
    }
}
/* ============================================
   TECHNICIAN JOBS (MES) PAGE
   ============================================ */
/* Scoped under .tech-jobs — large touch targets for shop-floor tablets */
.tech-jobs .job-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.tech-jobs .job-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border: 2px solid transparent;
    transition: all var(--transition);
}

.tech-jobs .job-card.active-timer {
    border-color: var(--danger);
    box-shadow: var(--shadow-lg), 0 0 0 1px color-mix(in srgb, var(--danger) 10%, transparent);
}

.tech-jobs .job-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.tech-jobs .job-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.tech-jobs .job-details {
    color: var(--text-muted);
    font-size: 1.05rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.tech-jobs .job-details i {
    width: 1.5rem;
    color: var(--text-muted);
    text-align: center;
}

.tech-jobs .job-notes {
    margin-top: 0.5rem;
    font-size: 0.95rem;
    background: var(--surface-hover);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.tech-jobs .timer-display {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--danger-light);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    border-radius: var(--radius);
}

.tech-jobs .timer-display.visible {
    display: flex;
}

.tech-jobs .timer-dot {
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 50%;
    animation: tech-blink 1s infinite;
}

@keyframes tech-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.tech-jobs .timer-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--danger);
}

.tech-jobs .timer-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.tech-jobs .job-actions {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.tech-jobs .btn-start,
.tech-jobs .btn-stop {
    display: block;
    width: 100%;
    padding: 1rem;
    border-radius: var(--radius);
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.tech-jobs .btn-start:active,
.tech-jobs .btn-stop:active {
    transform: scale(0.98);
}

.tech-jobs .btn-start {
    background-color: var(--success);
    color: var(--text-inverse);
    box-shadow: 0 4px 6px -1px color-mix(in srgb, var(--success) 40%, transparent);
}

.tech-jobs .btn-start:hover { background-color: var(--success-dark); }

.tech-jobs .btn-stop {
    background-color: var(--danger);
    color: var(--text-inverse);
    box-shadow: 0 4px 6px -1px color-mix(in srgb, var(--danger) 40%, transparent);
    animation: tech-pulse 2s infinite;
}

.tech-jobs .btn-stop:hover { background-color: var(--danger-dark); }

@keyframes tech-pulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 40%, transparent); }
    70% { box-shadow: 0 0 0 10px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.tech-jobs .notes-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    margin-bottom: 0.75rem;
    background: var(--surface-hover);
    color: var(--text-main);
    font-family: inherit;
}

.tech-jobs .notes-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent);
    background: var(--surface);
}

.tech-jobs .empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    background: var(--surface);
    border-radius: var(--radius-md);
    color: var(--text-muted);
}

.tech-jobs .empty-state i {
    font-size: 4rem;
    color: var(--border);
    margin-bottom: 1rem;
}

.tech-jobs .loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: color-mix(in srgb, var(--background) 70%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.tech-jobs .loading-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.tech-jobs .loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: tech-spin 0.8s linear infinite;
}

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

@media (max-width: 480px) {
    .tech-jobs .job-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   TECHNICIAN WORKBENCH — IPAD-FIRST SHELL
   ============================================ */
.technician-shell {
    display: block;
    min-height: 100vh;
    background: var(--background);
}

.technician-shell > .sidebar {
    display: none;
}

.tech-shell-header {
    position: sticky;
    top: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    padding: 0 var(--space-6);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
}

.tech-shell-brand,
.tech-shell-user,
.tech-shell-brand span {
    display: flex;
    align-items: center;
}

.tech-shell-brand {
    gap: var(--space-3);
    color: var(--text-main);
}

.tech-shell-brand span {
    align-items: flex-start;
    flex-direction: column;
    line-height: 1.05;
}

.tech-shell-brand small {
    margin-top: 0.2rem;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.tech-shell-user {
    gap: var(--space-4);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

.tech-shell-user a {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    color: var(--text-secondary);
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.technician-shell .tech-main-wrapper {
    width: 100%;
    max-width: none;
    margin-left: 0;
    padding: var(--space-6) var(--space-6) 108px;
}

.tech-workbench {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
}

.tech-workbench-intro,
.tech-section-heading,
.tech-active-actions,
.tech-job-meta,
.tech-workbench .job-header,
.tech-workbench .job-actions {
    display: flex;
    align-items: center;
}

.tech-workbench-intro {
    justify-content: space-between;
    margin-bottom: var(--space-6);
}

.tech-workbench-intro h1 {
    margin: 0.15rem 0 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(2rem, 4vw, 3rem);
    letter-spacing: -0.045em;
}

.tech-workbench-intro p {
    margin: var(--space-1) 0 0;
    color: var(--text-muted);
}

.tech-eyebrow {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.tech-sync-state {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.55rem 0.8rem;
    color: var(--success-dark);
    background: var(--success-light);
    border: 1px solid color-mix(in srgb, var(--success) 24%, transparent);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
}

.tech-sync-state span {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
}

.tech-active-section,
.tech-queue-section {
    margin-bottom: var(--space-8);
}

.tech-section-heading {
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.tech-section-heading h2 {
    margin: 0.15rem 0 0;
    font-size: 1.35rem;
}

.tech-active-job {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-5) var(--space-8);
    padding: var(--space-6);
    color: var(--text-main);
    background: linear-gradient(135deg, var(--surface) 0%, color-mix(in srgb, var(--success-light) 52%, var(--surface)) 100%);
    border: 2px solid color-mix(in srgb, var(--success) 38%, var(--border));
    border-left: 8px solid var(--success);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.tech-active-number,
.tech-workbench .job-number {
    color: var(--primary);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.86rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.tech-active-main h3 {
    margin: var(--space-1) 0;
    font-size: 1.55rem;
}

.tech-active-main > p {
    max-width: 66ch;
    margin: 0 0 var(--space-3);
    color: var(--text-secondary);
    font-size: 1rem;
}

.tech-job-meta {
    gap: var(--space-3);
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.tech-running-time {
    align-self: center;
    min-width: 190px;
    text-align: right;
}

.tech-running-label {
    display: block;
    color: var(--success-dark);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.tech-running-label i {
    margin-right: var(--space-1);
    font-size: 0.55rem;
}

.tech-running-time strong {
    display: block;
    margin-top: var(--space-1);
    font-family: 'Space Grotesk', monospace;
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
}

.tech-active-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: var(--space-3);
    padding-top: var(--space-4);
    border-top: 1px solid color-mix(in srgb, var(--success) 18%, var(--border));
}

.tech-active-actions form {
    margin: 0;
}

.tech-ready-state {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-5);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
}

.tech-ready-icon {
    display: grid;
    width: 50px;
    height: 50px;
    flex: 0 0 auto;
    place-items: center;
    color: var(--primary);
    background: var(--primary-subtle);
    border-radius: var(--radius-md);
}

.tech-ready-state strong,
.tech-ready-state span {
    display: block;
}

.tech-ready-state span {
    margin-top: var(--space-1);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.tech-queue-count {
    padding: 0.35rem 0.65rem;
    color: var(--text-secondary);
    background: var(--surface-hover);
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 700;
}

.tech-workbench .job-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
}

.tech-workbench .job-card {
    display: flex;
    min-width: 0;
    flex-direction: column;
    padding: var(--space-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.tech-workbench .job-header {
    justify-content: space-between;
    gap: var(--space-3);
}

.tech-workbench .job-customer {
    margin-top: var(--space-4);
    color: var(--text-main);
    font-size: 1.15rem;
    font-weight: 750;
}

.tech-workbench .job-description {
    display: -webkit-box;
    min-height: 3em;
    margin: var(--space-2) 0 var(--space-4);
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.tech-workbench .job-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    padding: var(--space-3);
    color: var(--text-muted);
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
}

.tech-workbench .job-details i {
    width: 1.15rem;
    color: var(--primary);
}

.tech-workbench .job-notes,
.tech-workbench .job-alert {
    margin-top: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    font-size: 0.84rem;
}

.tech-workbench .job-notes {
    color: var(--text-secondary);
    background: var(--surface-hover);
}

.tech-workbench .job-alert {
    color: var(--warning-dark);
    background: var(--warning-light);
    border-left: 4px solid var(--warning);
}

.tech-workbench .job-actions {
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: auto;
    padding-top: var(--space-5);
}

.tech-btn {
    display: inline-flex;
    min-height: 54px;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.75rem 1.15rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 750;
    cursor: pointer;
}

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

.tech-btn-start {
    color: var(--text-inverse);
    background: var(--success);
}

.tech-btn-stop {
    color: var(--text-inverse);
    background: var(--danger);
}

.tech-btn:focus-visible,
.tech-bottom-nav a:focus-visible,
.tech-bottom-nav button:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent);
    outline-offset: 2px;
}

.tech-empty-state {
    grid-column: 1 / -1;
    padding: var(--space-10) var(--space-6);
    text-align: center;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
}

.tech-empty-state > i {
    color: var(--success);
    font-size: 2.5rem;
}

.tech-empty-state h3 {
    margin: var(--space-3) 0 var(--space-1);
    color: var(--text-main);
}

.tech-workbench .loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    background: color-mix(in srgb, var(--background) 84%, transparent);
    backdrop-filter: blur(4px);
    transition: opacity 0.18s ease;
}

.tech-workbench .loading-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.tech-workbench .loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: tech-spin 0.8s linear infinite;
}

.tech-start-sheet {
    max-width: 620px;
}

.tech-start-context {
    margin: 0 0 var(--space-4);
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 700;
}

.tech-switch-warning {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    padding: var(--space-4);
    color: var(--warning-dark);
    background: var(--warning-light);
    border-radius: var(--radius-md);
}

.tech-bottom-nav {
    position: fixed;
    right: var(--space-5);
    bottom: var(--space-4);
    left: var(--space-5);
    z-index: 90;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    max-width: 620px;
    min-height: 68px;
    margin: 0 auto;
    padding: 0.35rem;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(16px);
}

.tech-bottom-nav a,
.tech-bottom-nav button,
.tech-bottom-nav .tech-nav-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    flex-direction: column;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
}

.tech-bottom-nav .tech-nav-status.is-disabled {
    color: var(--text-muted);
    opacity: 0.58;
    cursor: default;
}

.tech-bottom-nav i {
    font-size: 1.05rem;
}

.tech-bottom-nav a.active {
    color: var(--primary);
    background: var(--primary-subtle);
}

@media (max-width: 899px) {
    .tech-workbench .job-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .tech-shell-header,
    .technician-shell .tech-main-wrapper {
        padding-right: var(--space-4);
        padding-left: var(--space-4);
    }

    .tech-shell-user > span {
        display: none;
    }

    .tech-active-job {
        grid-template-columns: 1fr;
    }

    .tech-running-time {
        min-width: 0;
        text-align: left;
    }

    .tech-active-actions,
    .tech-workbench .job-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .tech-active-actions .tech-btn,
    .tech-active-actions form,
    .tech-active-actions form .tech-btn,
    .tech-workbench .job-actions .tech-btn {
        width: 100%;
    }

    .tech-workbench .job-details {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tech-workbench .loading-spinner {
        animation: none;
    }
}

/* Technician job ticket — the iPad work surface for one assigned job. */
.tech-job-workspace {
    width: 100%;
    max-width: 1360px;
    margin: 0 auto;
}

.tech-job-toolbar,
.tech-job-hero,
.tech-work-panel,
.tech-rework-alert {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.tech-job-toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
}

.tech-job-toolbar h1 {
    margin: 0.1rem 0 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.4rem, 3vw, 2rem);
    letter-spacing: -0.035em;
}

.tech-icon-link {
    display: grid;
    width: 50px;
    height: 50px;
    place-items: center;
    color: var(--text-secondary);
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.tech-job-rail {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    max-width: 680px;
    margin: var(--space-5) auto;
    padding: 0;
    list-style: none;
}

.tech-job-rail li {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    color: var(--text-muted);
    font-size: 0.78rem;
}

.tech-job-rail li:not(:last-child)::after {
    position: absolute;
    top: 21px;
    right: -28%;
    width: 56%;
    height: 2px;
    content: '';
    background: var(--border);
}

.tech-job-rail li > span {
    display: grid;
    width: 44px;
    height: 44px;
    z-index: 1;
    place-items: center;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 50%;
}

.tech-job-rail li.complete,
.tech-job-rail li.current {
    color: var(--text-main);
}

.tech-job-rail li.complete > span {
    color: var(--success-dark);
    background: var(--success-light);
    border-color: var(--success);
}

.tech-job-rail li.current > span {
    color: var(--text-inverse);
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 5px var(--primary-subtle);
}

.tech-rework-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    padding: var(--space-5);
    color: var(--warning-dark);
    background: var(--warning-light);
    border-color: color-mix(in srgb, var(--warning) 45%, var(--border));
    border-left: 7px solid var(--warning);
}

.tech-rework-alert > i {
    margin-top: 0.2rem;
    font-size: 1.5rem;
}

.tech-rework-alert h2 {
    margin: 0.15rem 0 var(--space-2);
    font-size: 1.15rem;
}

.tech-rework-alert p {
    margin: 0;
    white-space: pre-wrap;
}

.tech-job-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.tech-job-brief {
    padding: clamp(1.5rem, 4vw, 2.75rem);
}

.tech-job-brief h2 {
    margin: var(--space-1) 0 var(--space-3);
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    letter-spacing: -0.045em;
}

.tech-job-brief > p {
    max-width: 65ch;
    margin: 0;
    color: var(--text-secondary);
    font-size: clamp(1rem, 2vw, 1.18rem);
    line-height: 1.65;
    white-space: pre-wrap;
}

.tech-instruction-note {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-top: var(--space-5);
    padding: var(--space-4);
    color: var(--text-secondary);
    background: var(--surface-hover);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    white-space: pre-wrap;
}

.tech-job-clock {
    display: flex;
    min-width: 0;
    align-items: stretch;
    justify-content: center;
    flex-direction: column;
    padding: var(--space-6);
    color: var(--text-main);
    background: color-mix(in srgb, var(--primary-subtle) 62%, var(--surface));
    border-left: 1px solid var(--border);
}

.tech-job-clock.is-running {
    color: var(--text-inverse);
    background: linear-gradient(145deg, #087f5b, #046c4e);
    border-color: transparent;
}

.tech-clock-state {
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tech-job-clock.is-running .tech-clock-state {
    color: #b7f7de;
}

.tech-job-clock.is-running .tech-clock-state i {
    margin-right: var(--space-1);
    font-size: 0.55rem;
}

.tech-job-clock > strong {
    display: block;
    margin: var(--space-2) 0 var(--space-4);
    font-family: 'Space Grotesk', monospace;
    font-size: clamp(2.7rem, 6vw, 4.8rem);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.06em;
    line-height: 1;
}

.tech-job-clock > p {
    margin: 0;
    color: var(--text-muted);
}

.tech-job-clock form,
.tech-job-clock .tech-btn {
    width: 100%;
}

.tech-job-start-form label,
.tech-job-start-form label span {
    display: block;
}

.tech-job-start-form label {
    margin-bottom: var(--space-2);
    font-size: 0.8rem;
    font-weight: 750;
}

.tech-job-start-form label span {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
}

.tech-job-start-form input,
.tech-camera-form > input {
    width: 100%;
    min-height: 50px;
    margin-bottom: var(--space-3);
    padding: 0 var(--space-3);
    color: var(--text-main);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font: inherit;
}

.tech-job-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.7fr);
    gap: var(--space-5);
    margin-top: var(--space-5);
}

.tech-job-primary,
.tech-job-sidebar {
    display: grid;
    align-content: start;
    gap: var(--space-5);
}

.tech-job-sidebar {
    position: sticky;
    top: 90px;
}

.tech-work-panel {
    padding: var(--space-5);
}

.tech-work-panel > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.tech-work-panel h2,
.tech-work-panel header h2 {
    margin: 0.15rem 0 0;
    font-size: 1.25rem;
}

.tech-panel-count {
    display: grid;
    min-width: 34px;
    height: 34px;
    padding: 0 var(--space-2);
    place-items: center;
    color: var(--primary);
    background: var(--primary-subtle);
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 800;
}

.tech-repair-panel {
    border-left: 6px solid var(--warning);
}

.tech-repair-panel header > i {
    color: var(--warning);
    font-size: 1.35rem;
}

.tech-repair-panel > p {
    color: var(--text-secondary);
    line-height: 1.55;
}

.tech-panel-facts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}

.tech-panel-facts span,
.tech-panel-facts strong {
    display: block;
}

.tech-panel-facts span {
    padding: var(--space-3);
    color: var(--text-muted);
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
}

.tech-panel-facts strong {
    margin-top: var(--space-1);
    color: var(--text-main);
    font-size: 0.9rem;
    text-transform: capitalize;
}

.tech-material-list {
    display: grid;
    gap: var(--space-2);
}

.tech-material-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px 90px;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-hover);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
}

.tech-material-row.has-shortage {
    background: var(--danger-light);
    border-color: color-mix(in srgb, var(--danger) 28%, transparent);
}

.tech-material-row > div:first-child span,
.tech-material-row > div:first-child strong,
.tech-material-row > div:first-child small,
.tech-material-qty span,
.tech-material-qty strong,
.tech-material-stock span,
.tech-material-stock strong {
    display: block;
}

.tech-material-row > div:first-child span,
.tech-material-row > div:first-child small,
.tech-material-qty span,
.tech-material-stock span {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.tech-material-row > div:first-child strong {
    margin: 0.15rem 0;
    color: var(--text-main);
}

.tech-material-qty,
.tech-material-stock {
    text-align: right;
}

.tech-material-qty strong,
.tech-material-stock strong {
    margin-top: 0.2rem;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.15rem;
}

.tech-material-row.has-shortage .tech-material-stock strong {
    color: var(--danger);
}

.tech-camera-form {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto;
    align-items: end;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.tech-camera-input {
    display: flex;
    min-height: 68px;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: var(--primary);
    background: var(--primary-subtle);
    border: 1px dashed color-mix(in srgb, var(--primary) 45%, var(--border));
    border-radius: var(--radius-md);
    cursor: pointer;
}

.tech-camera-input input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.tech-camera-input > i {
    font-size: 1.4rem;
}

.tech-camera-input span,
.tech-camera-input strong,
.tech-camera-input small {
    display: block;
}

.tech-camera-input small {
    margin-top: 0.1rem;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 500;
}

.tech-camera-form > input {
    margin: 0;
}

.tech-photo-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
}

.tech-photo-card {
    overflow: hidden;
    color: var(--text-main);
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.tech-photo-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.tech-photo-card > span,
.tech-photo-card strong,
.tech-photo-card small {
    display: block;
}

.tech-photo-card > span {
    padding: var(--space-3);
}

.tech-photo-card small {
    margin-top: 0.15rem;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.tech-panel-empty {
    padding: var(--space-6);
    text-align: center;
    color: var(--text-muted);
    background: var(--surface-hover);
    border-radius: var(--radius-md);
}

.tech-panel-empty i {
    font-size: 1.5rem;
    opacity: 0.45;
}

.tech-panel-empty p {
    margin: var(--space-2) 0 0;
}

.tech-time-summary h2 {
    margin: var(--space-1) 0 var(--space-3);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.3rem;
}

.tech-time-summary p {
    margin: var(--space-2) 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.tech-progress-track {
    height: 8px;
    overflow: hidden;
    background: var(--surface-hover);
    border-radius: var(--radius-full);
}

.tech-progress-track span {
    display: block;
    height: 100%;
    background: var(--success);
    border-radius: inherit;
}

.tech-time-history {
    padding: 0;
}

.tech-time-history summary {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    cursor: pointer;
    list-style: none;
}

.tech-time-history summary::-webkit-details-marker {
    display: none;
}

.tech-time-history summary span span,
.tech-time-history summary strong {
    display: block;
}

.tech-time-history[open] summary > i {
    transform: rotate(180deg);
}

.tech-time-history > div {
    padding: 0 var(--space-5) var(--space-5);
}

.tech-time-history article {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-top: 1px solid var(--border-light);
}

.tech-time-history article > i {
    display: grid;
    width: 27px;
    height: 27px;
    flex: 0 0 auto;
    place-items: center;
    color: var(--success-dark);
    background: var(--success-light);
    border-radius: 50%;
    font-size: 0.65rem;
}

.tech-time-history article strong,
.tech-time-history article small {
    display: block;
}

.tech-time-history article small {
    margin-top: 0.2rem;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.tech-qc-handoff {
    color: var(--text-main);
    background: linear-gradient(150deg, var(--surface) 0%, color-mix(in srgb, var(--primary-subtle) 72%, var(--surface)) 100%);
    border-top: 5px solid var(--primary);
}

.tech-qc-handoff > i {
    margin-bottom: var(--space-4);
    color: var(--primary);
    font-size: 1.65rem;
}

.tech-qc-handoff > p {
    color: var(--text-muted);
    line-height: 1.5;
}

.tech-qc-handoff label {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin: var(--space-4) 0;
    font-size: 0.82rem;
    line-height: 1.4;
}

.tech-qc-handoff input[type='checkbox'] {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    accent-color: var(--primary);
}

.tech-btn-qc {
    width: 100%;
    color: var(--text-inverse);
    background: var(--primary);
}

.tech-job-workspace input:focus-visible,
.tech-job-workspace summary:focus-visible,
.tech-job-workspace .tech-icon-link:focus-visible,
.tech-camera-input:focus-within {
    outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent);
    outline-offset: 2px;
}

@media (max-width: 1050px) {
    .tech-job-grid {
        grid-template-columns: minmax(0, 1.45fr) minmax(270px, 0.7fr);
    }

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

    .tech-camera-form > input {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .tech-camera-form > button {
        grid-column: 2;
        grid-row: 1;
    }
}

@media (max-width: 820px) {
    .tech-job-hero,
    .tech-job-grid {
        grid-template-columns: 1fr;
    }

    .tech-job-clock {
        border-top: 1px solid var(--border);
        border-left: 0;
    }

    .tech-job-sidebar {
        position: static;
    }

    .tech-photo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .tech-job-toolbar {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .tech-job-toolbar > .badge {
        grid-column: 2;
        justify-self: start;
    }

    .tech-job-rail li {
        flex-direction: column;
    }

    .tech-job-rail li:not(:last-child)::after {
        right: -22%;
        width: 44%;
    }

    .tech-job-brief,
    .tech-job-clock,
    .tech-work-panel {
        padding: var(--space-4);
    }

    .tech-material-row {
        grid-template-columns: minmax(0, 1fr) 68px 68px;
        padding: var(--space-3);
    }

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

    .tech-camera-form > input,
    .tech-camera-form > button {
        grid-column: 1;
        grid-row: auto;
        width: 100%;
    }

    .tech-photo-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   TINTED BADGES & RISK CARDS
   ============================================ */
/* Tinted badge: text in --badge-color with a translucent tint of the
   same color for background/border. Set the tone with a .tone-* class,
   or pass a dynamic color inline via style="--badge-color: <value>". */
.tinted-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
    border-radius: 4px;
    color: var(--badge-color);
    background: color-mix(in srgb, var(--badge-color) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--badge-color) 25%, transparent);
}

.tinted-badge--pill {
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.tinted-badge--cap {
    text-transform: capitalize;
}

/* Tone modifiers — usable on .tinted-badge and .tone-text */
.tone-primary { --badge-color: var(--primary-light); }
.tone-success { --badge-color: var(--success); }
.tone-warning { --badge-color: var(--warning); }
.tone-danger  { --badge-color: var(--danger); }
.tone-info    { --badge-color: var(--info); }
.tone-muted   { --badge-color: var(--text-muted); }

/* Plain text colored by the active tone */
.tone-text { color: var(--badge-color); }

/* Risk prediction card (per-SKU analytics ML card) */
.risk-card {
    margin-bottom: 2rem;
    background: var(--risk-bg);
    border: 1px solid color-mix(in srgb, var(--risk-color) 25%, transparent);
}

.risk-card > .card-header {
    padding: 1.25rem 1.5rem;
    background: transparent;
    border-bottom: 1px solid color-mix(in srgb, var(--risk-color) 19%, transparent);
}

.risk-card--critical { --risk-color: var(--danger);  --risk-bg: var(--danger-light); }
.risk-card--warning  { --risk-color: var(--warning); --risk-bg: var(--warning-light); }
.risk-card--normal   { --risk-color: var(--success); --risk-bg: var(--success-light); }

.risk-text { color: var(--risk-color); }

/* ============================================
   PRINT / PDF STYLES - OPTIMIZED FOR SINGLE PAGE
   ============================================ */
@media print {
    /* Hide browser UI and non-document elements */
    .sidebar,
    .header-actions,
    .no-print,
    .d-print-none,
    .breadcrumb,
    .record-links,
    .record-quick-actions,
    .record-action-panel,
    .record-danger-zone,
    .btn-download-pdf,
    .modal,
    #sendToast,
    .alert,
    .page-header {
        display: none !important;
    }

    /* Clean print preview - remove margins and padding */
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
    }

    /* Full-width layout */
    .app-container {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .main-wrapper {
        margin: 0 !important;
        padding: 0.5rem !important;
        width: 100% !important;
    }

    /* Page setup - single page, no page numbers */
    @page {
        size: A4;
        margin: 10mm;
        color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    /* Remove default browser print headers/footers */
    @page {
        margin-top: 10mm;
        margin-bottom: 10mm;
        @bottom-left {
            content: "";
        }
        @bottom-center {
            content: "";
        }
        @bottom-right {
            content: "";
        }
        @top-left {
            content: "";
        }
        @top-center {
            content: "";
        }
        @top-right {
            content: "";
        }
    }

    /* Card optimization */
    .card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        page-break-inside: avoid;
        margin-bottom: 0.75rem !important;
    }

    .card-body {
        padding: 0.75rem !important;
    }

    .card-header {
        padding: 0.5rem 0.75rem !important;
    }

    /* Spacing optimization */
    h1, h2, h3, h4, h5, h6 {
        margin: 0.25rem 0 !important;
        padding: 0 !important;
    }

    p {
        margin: 0.25rem 0 !important;
    }

    table {
        font-size: 0.9rem;
        margin-bottom: 0.5rem !important;
    }

    tbody tr {
        page-break-inside: avoid;
        height: auto !important;
    }

    td, th {
        padding: 0.25rem 0.5rem !important;
    }

    /* Row styling */
    .row {
        margin-bottom: 0.5rem !important;
    }

    .mb-4 {
        margin-bottom: 0.75rem !important;
    }

    .mb-3 {
        margin-bottom: 0.5rem !important;
    }

    /* Print footer styling */
    .print-footer {
        display: block !important;
        margin-top: 0.75rem;
        padding-top: 0.5rem;
        padding-bottom: 0;
        border-top: 1px solid #ccc;
        font-size: 0.75rem;
    }

    .print-footer p {
        margin: 0.1rem 0 !important;
        padding: 0 !important;
    }

    /* Company header */
    .print-company-header {
        display: flex !important;
        justify-content: space-between;
        margin-bottom: 0.75rem;
        align-items: flex-start;
    }

    .print-company-header img {
        max-height: 50px !important;
        margin-bottom: 0.25rem !important;
    }

    .print-company-header h2 {
        font-size: 1.2rem !important;
    }

    /* Form optimization */
    .form-group {
        margin-bottom: 0.5rem !important;
    }

    .form-label {
        margin-bottom: 0.1rem !important;
        font-size: 0.85rem;
    }

    .form-control {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.9rem;
        margin-bottom: 0.25rem !important;
    }

    /* Grid spacing */
    .grid {
        gap: 0.5rem !important;
    }

    /* Badge and status styling */
    .badge {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    /* Progress bar sizing */
    .progress {
        height: 20px !important;
    }

    /* Quote container optimization */
    .quote-container {
        padding: 0 !important;
    }

    /* Hide page break helpers */
    .page-header {
        page-break-after: avoid;
    }

    /* Text optimization */
    body {
        font-size: 10pt;
        line-height: 1.2;
    }

    /* Currency and numbers */
    .text-right {
        text-align: right;
    }
}

/* ============================================
   KPI summary cards (reports)
   ============================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    border-left: 4px solid var(--kpi-color, var(--primary));
}

.kpi-card .kpi-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--kpi-color, var(--text-main));
    margin: var(--space-2) 0;
}

.kpi-card .kpi-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.kpi-primary { --kpi-color: var(--primary); }
.kpi-success { --kpi-color: var(--success); }
.kpi-warning { --kpi-color: var(--warning); }
.kpi-danger  { --kpi-color: var(--danger); }
.kpi-info    { --kpi-color: var(--info); }

/* ============================================
   Entity detail pages (label/value field grid)
   ============================================ */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-5) var(--space-6);
}

.detail-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.detail-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    overflow-wrap: anywhere;
}

.fabric-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border);
    vertical-align: -2px;
    margin-right: 0.35rem;
}

/* Signed stock-movement quantities */
.qty-in  { color: var(--success); font-weight: 700; }
.qty-out { color: var(--danger); font-weight: 700; }

/* ============================================
   Age analysis report
   ============================================ */
.aging-table td,
.aging-table th {
    white-space: nowrap;
}

.aging-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.aging-table td.num-zero {
    color: var(--text-muted);
}

.aging-table td.aging-warning {
    color: var(--warning-dark);
    background: var(--warning-light);
    font-weight: 600;
}

.aging-table td.aging-danger {
    color: var(--danger-dark);
    background: var(--danger-light);
    font-weight: 600;
}

.aging-table td.aging-credit {
    color: var(--success);
}

.aging-table .totals-row td {
    border-top: 2px solid var(--border);
    background: var(--surface-hover);
    font-weight: 700;
    color: var(--text-main);
}

.aging-table .row-total {
    font-weight: 700;
    color: var(--text-main);
}

/* ============================================
   Report notes / legend block
   ============================================ */
.report-note {
    margin-top: var(--space-8);
    padding: var(--space-5);
    background: var(--surface-hover);
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

.report-note .report-note-title {
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: var(--space-3);
}

.report-note ul {
    margin: 0;
    padding-left: var(--space-6);
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ============================================
   Reports menu cards
   ============================================ */
.report-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-6);
}

.report-menu-grid > a {
    text-decoration: none;
}

.report-card {
    cursor: pointer;
    height: 100%;
    margin-bottom: 0;
}

.report-menu-grid a:hover .report-card {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.report-card .card-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.report-card-head {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.report-card-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--report-color, var(--primary));
    background: color-mix(in srgb, var(--report-color, var(--primary)) 12%, transparent);
}

.report-card-head h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.report-card-head p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.report-card-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0;
    flex: 1;
}

.report-card-cta {
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--report-color, var(--primary));
    font-weight: 600;
}

.report-info    { --report-color: var(--info); }
.report-purple  { --report-color: #7c3aed; }
.report-success { --report-color: var(--success); }
.report-warning { --report-color: var(--warning); }
/* Graceful request failures */
.graceful-error-shell {
    width: 100%;
    min-height: 100vh;
    flex: 1;
    display: grid;
    place-items: center;
    padding: clamp(1rem, 4vw, 3rem);
}

.graceful-error-card {
    width: min(100%, 620px);
    padding: clamp(1.5rem, 5vw, 3rem);
    text-align: center;
    background: var(--surface, #fff);
    border: 1px solid var(--border-color, #dbe3ee);
    border-radius: 20px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

.graceful-error-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    display: grid;
    place-items: center;
    color: #b45309;
    background: #fff7ed;
    border-radius: 18px;
    font-size: 1.55rem;
}

.graceful-error-eyebrow {
    margin: 0 0 0.35rem;
    color: var(--text-secondary, #64748b);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.graceful-error-card h1 {
    margin: 0;
    font-size: clamp(1.5rem, 4vw, 2.15rem);
}

.graceful-error-message {
    max-width: 48ch;
    margin: 0.85rem auto 1.5rem;
    color: var(--text-secondary, #64748b);
    line-height: 1.65;
}

.graceful-error-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.graceful-error-reference {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-secondary, #64748b);
    font-size: 0.78rem;
}

.graceful-error-reference span,
.graceful-error-reference code {
    display: block;
}

.graceful-error-reference code {
    margin: 0.35rem auto;
    color: var(--text-primary, #0f172a);
    font-size: 0.72rem;
    overflow-wrap: anywhere;
}

.graceful-error-reference p {
    margin: 0.25rem 0;
}

@media (max-width: 560px) {
    .graceful-error-actions,
    .graceful-error-actions .btn {
        width: 100%;
    }
}
