/* ==========================================================================
   1. CSS RESET, NORMALIZE & VARIABLES
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; font-size: 16px; -webkit-tap-highlight-color: transparent; }

/* Base Light Theme */
:root {
    --color-primary: #1976d2;
    --color-primary-hover: #1565c0;
    --color-success: #2e7d32;
    --color-warning: #f57f17;
    --color-danger: #d32f2f;
    --color-bg-body: #F9F7F2;
    --color-bg-surface: #FCFBF7;
    --color-text-main: #3F3E3A;
    --color-text-muted: #6A6560;
    --color-border: #E0DED9;
    --radius-md: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05);
    --min-touch-target: 44px;
}

/* Native Dark Theme Override */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg-body: #121212;
        --color-bg-surface: #1e1e1e;
        --color-text-main: #e0e0e0;
        --color-text-muted: #a0a0a0;
        --color-border: #333;
        --color-primary: #90caf9;
        --color-primary-hover: #64b5f6;
        --color-success: #81c784;
        --color-warning: #ffb74d;
        --color-danger: #e57373;
    }
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--color-bg-body);
    color: var(--color-text-main);
    line-height: 1.5;
    padding: 20px;
    overflow-x: hidden; 
}

/* ==========================================================================
   2. GLOBAL UTILITY CLASSES
   ========================================================================== */
/* Layout & Dimensions */
.container { max-width: 1200px; margin: 0 auto; }
.w-100 { width: 100%; }
.w-auto { width: auto !important; }
.h-100 { height: 100%; }
.min-w-120 { min-width: 120px; }
.min-w-150 { min-width: 150px; }
.min-w-250 { min-width: 250px; }
.max-w-120 { max-width: 120px; }

/* Flexbox & Grid */
.flex-row { display: flex; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.flex-grow { flex-grow: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.align-start { align-items: flex-start; }
.align-end { align-items: flex-end; }
.inline-flex { display: inline-flex; }
.block { display: block; }
.d-none { display: none; }

/* Spacing (Margins & Padding) */
.m-0 { margin: 0 !important; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-sm { margin-top: 5px; }
.mb-sm { margin-bottom: 8px; }
.mt-15 { margin-top: 15px; }
.mb-15 { margin-bottom: 15px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.mb-25 { margin-bottom: 25px; }
.mt-30 { margin-top: 30px; }
.mt-40 { margin-top: 40px; }
.mb-10 { margin-bottom: 10px; }
.ml-10 { margin-left: 10px; }
.mx-5 { margin-left: 5px; margin-right: 5px; }

.p-10 { padding: 10px; }
.p-15 { padding: 15px; }
.p-20 { padding: 20px; }
.p-30 { padding: 30px; }
.p-40 { padding: 40px; }
.pt-0 { padding-top: 0 !important; }
.pb-10 { padding-bottom: 10px; }
.pb-15 { padding-bottom: 15px; }
.px-15 { padding-left: 15px; padding-right: 15px; }
.py-10 { padding-top: 10px; padding-bottom: 10px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 15px; }
.gap-lg { gap: 20px; }

/* Typography & Colors */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-main { color: var(--color-text-main); }
.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-border { color: var(--color-border); }
.bg-body { background-color: var(--color-bg-body); }

.bold { font-weight: bold; }
.italic { font-style: italic; }
.small { font-size: 0.85rem; }
.text-md { font-size: 0.95rem; }
.text-lg { font-size: 1.1rem; }
.capitalize { text-transform: capitalize; }
.line-height-md { line-height: 1.4; }
.line-height-lg { line-height: 1.5; }

/* Borders & Shadows */
.border-none { border: none !important; }
.border-solid { border: 1px solid var(--color-border); }
.border-dashed { border: 1px dashed var(--color-border) !important; }
.border-bottom { border-bottom: 1px solid var(--color-border); }
.border-primary { border-bottom-color: var(--color-primary) !important; }
.border-success { border-bottom-color: var(--color-success) !important; }
.border-danger { border-bottom-color: var(--color-danger) !important; }
.border-left-primary { border-left: 4px solid var(--color-primary); }
.border-left-success { border-left: 4px solid var(--color-success); }
.border-left-danger { border-left: 4px solid var(--color-danger); }
.rounded { border-radius: 4px; }
.shadow-none { box-shadow: none !important; }

/* Icons & Interactive */
.icon-xs { width: 12px; height: 12px; vertical-align: middle; }
.icon-sm { width: 14px; height: 14px; vertical-align: middle; }
.icon-md { width: 18px; height: 18px; vertical-align: middle; }
.icon-xl { width: 48px; height: 48px; }
i[data-lucide] { width: 16px; height: 16px; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }

/* ==========================================================================
   3. TOUCH-FRIENDLY FORMS & BUTTONS
   ========================================================================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; padding: 8px 16px; border-radius: 6px; font-weight: 600;
    text-decoration: none; border: none; cursor: pointer; transition: all 0.2s;
    min-height: var(--min-touch-target); font-size: 1rem;
    touch-action: manipulation; 
    white-space: nowrap; 
    flex-shrink: 0;      
}
.btn-sm { font-size: 0.9rem; padding: 6px 12px; }
.btn-lg { min-height: 48px; font-size: 1.05rem; }
.btn-icon-only { padding: 0; width: 44px; flex-shrink: 0; }

.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: color-mix(in srgb, var(--color-text-main) 10%, transparent); color: var(--color-text-main); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text-main) 20%, transparent); }
.btn-success { background: var(--color-success); color: white; }
.btn-warning { background: var(--color-warning); color: white; }
.btn-danger { background: var(--color-danger); color: white; }
.btn-danger:hover { background: color-mix(in srgb, var(--color-danger) 85%, black); }
.btn-outline-danger { background: transparent; color: var(--color-danger); border: 1px solid var(--color-danger); }
.btn-outline-danger:hover { background: var(--color-danger); color: white; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: bold; margin-bottom: 8px; color: var(--color-text-main); }
.input-grid { display: flex; flex-wrap: wrap; gap: 15px; }

/* Reintegrated input[type="datetime-local"] into the global reset */
input[type="text"], input[type="number"], input[type="email"], 
input[type="password"], input[type="date"], input[type="datetime-local"], input[type="file"],
select, textarea {
    width: 100%; min-height: var(--min-touch-target); padding: 10px 12px;
    border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background-color: var(--color-bg-surface); color: var(--color-text-main);
    font-family: inherit; font-size: 1rem; box-sizing: border-box;
    -webkit-appearance: none; appearance: none;
}
textarea { resize: vertical; } 
.textarea-tall { width: 100%; min-height: 100px; padding: 10px; }

input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

select {
    background-image: url('data:image/svg+xml;utf8,<svg fill="%236A6560" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat; background-position: right 10px center; padding-right: 35px;
}

input[type="file"] { padding: 6px 10px; line-height: 28px; cursor: pointer; }
input[type="file"]::file-selector-button {
    font-family: inherit; font-size: 0.9rem; font-weight: 600;
    background-color: color-mix(in srgb, var(--color-text-main) 10%, transparent); color: var(--color-text-main);
    border: none; border-radius: 4px; padding: 6px 16px; margin-right: 15px; cursor: pointer; transition: background-color 0.2s;
}
input[type="file"]::file-selector-button:hover { background-color: color-mix(in srgb, var(--color-text-main) 20%, transparent); }

.locked-input { pointer-events: none; background-color: var(--color-bg-body); color: var(--color-text-muted); cursor: not-allowed; }
.locked-warning { color: var(--color-danger); font-size: 0.8rem; }
.checkbox-lg { width: 20px; height: 20px; flex-shrink: 0; margin: 0; cursor: pointer; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-tag { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    padding: 10px 15px; 
    background: var(--color-bg-body); 
    border: 1px solid var(--color-border); 
    border-radius: 6px; 
    cursor: pointer; 
    transition: all 0.2s; 
    user-select: none; 
    /* NEW: Enforces the 44px mobile-first touch area */
    min-height: var(--min-touch-target); 
}
.checkbox-tag input { margin: 0; width: auto; }
.checkbox-tag:has(input:checked) { background: color-mix(in srgb, var(--color-primary) 10%, transparent); border-color: var(--color-primary); color: var(--color-primary); font-weight: bold; }

/* ==========================================================================
   4. CUSTOM UI COMPONENTS
   ========================================================================== */
/* Cards & Containers */
.card {
    background: var(--color-bg-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-md); padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 20px;
}
.card-paused { opacity: 0.7; border-style: dashed; background: var(--color-bg-body); transition: opacity 0.2s ease; }
.card-paused:hover { opacity: 1; }
.section-title {
    display: flex; align-items: center; gap: 10px; border-bottom: 2px solid var(--color-border);
    padding-bottom: 10px; margin-bottom: 20px; color: var(--color-text-main); font-size: 1.5rem; font-weight: bold;
}
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 15px; align-items: flex-end;
    background: var(--color-bg-body); padding: 15px; border-radius: var(--radius-md); border: 1px solid var(--color-border);
}
.filter-label { font-weight: bold; color: var(--color-text-main); display: block; margin-bottom: 5px; font-size: 0.9rem; }
.divider { border: none; border-top: 1px solid var(--color-border); margin: 20px 0; }
.testing-banner { background: var(--color-danger); color: white; text-align: center; padding: 10px; font-weight: bold; width: 100%; border-radius: 4px; margin-bottom: 20px; }

/* Badges & System Status */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 50px; font-weight: bold; font-size: 0.85rem; border: 1px solid transparent; }
.status-submitted { background: #fff3e0; color: #e65100; border-color: #ffb74d; }
.status-assigned { background: #fff9c4; color: #f57f17; border-color: #fbc02d; }
.status-in-progress { background: #e3f2fd; color: #1565c0; border-color: #64b5f6; }
.status-completed { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }

.priority-emergency { color: #dc2626; font-weight: bold; display: inline-flex; align-items: center; gap: 5px; }
.priority-high { color: #ea580c; font-weight: bold; display: inline-flex; align-items: center; gap: 5px; }
.priority-medium { color: #ca8a04; font-weight: bold; display: inline-flex; align-items: center; gap: 5px; }
.priority-low { color: #0284c7; font-weight: bold; display: inline-flex; align-items: center; gap: 5px; }

.badge-role { background: var(--color-bg-body); border: 1px solid var(--color-border); color: var(--color-text-main); }
.system-locked-badge {
    display: inline-flex; align-items: center; gap: 5px; color: var(--color-text-muted); font-size: 0.85rem; 
    font-style: italic; font-weight: 600; padding: 8px 12px; background: var(--color-bg-body); 
    border-radius: 6px; border: 1px dashed var(--color-border);
}

/* Feedback, Alerts & Comments */
.alert { padding: 15px; border-radius: 6px; margin-bottom: 20px; font-weight: bold; display: flex; align-items: center; gap: 8px; }
.alert.success { background: #e8f5e9; color: #2e7d32; }
.alert.error { background: #fef2f2; color: #dc2626; }

.comment-section { margin-top: 20px; padding-top: 15px; border-top: 1px dashed var(--color-border); }
.comment-bubble { background: var(--color-bg-body); padding: 10px 15px; border-radius: 6px; border: 1px solid var(--color-border); font-size: 0.9rem; margin-bottom: 12px; }
.comment-meta { color: var(--color-text-muted); font-size: 0.8rem; margin-bottom: 4px; display: flex; justify-content: space-between; }
.comment-text { color: var(--color-text-main); }

/* Voice & Interactive Controls */

.dictate-btn { background: var(--color-bg-surface); color: var(--color-text-main); }
.is-recording { background-color: var(--color-danger) !important; color: white !important; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* Login & Branding */
.brand-logo { font-weight: 800; font-size: 1.2rem; color: var(--color-success); }
.brand-icon { width: 32px; height: 32px; }
.brand-title { font-size: 1.6rem; }
.login-wrapper {
    display: flex; justify-content: center; align-items: center; min-height: 100dvh; 
    margin: 0; background-color: var(--color-bg-body); padding: 20px; box-sizing: border-box;
}
.login-card { max-width: 400px; width: 100%; padding: 30px 25px; }

/* Links & Media */
.profile-link { color: var(--color-primary); font-weight: bold; text-decoration: none; transition: color 0.2s; }
.profile-link:hover { color: var(--color-primary-hover); text-decoration: underline; }
.ref-link { font-size: 1.1rem; color: var(--color-primary); font-weight: bold; text-decoration: none; }
.search-wrapper { position: relative; width: 100%; max-width: 350px; }
.search-wrapper .search-icon { position: absolute; left: 12px; top: 12px; color: var(--color-text-muted); width: 20px; height: 20px; }
.search-wrapper input { padding-left: 40px !important; background: var(--color-bg-body); }
.search-highlight { background-color: color-mix(in srgb, var(--color-warning) 20%, transparent); color: var(--color-text-main); font-weight: bold; border-radius: 3px; padding: 0 4px; }

/* ==========================================================================
   5. DOMAIN SPECIFIC COMPONENTS
   ========================================================================== */
/* Profile & Avatars */
.profile-layout { display: grid; grid-template-columns: 1fr; gap: 20px; }
.role-tag { display: inline-flex; align-items: center; gap: 8px; background: var(--color-bg-body); border: 1px solid var(--color-border); padding: 4px 12px; border-radius: 50px; font-size: 0.75rem; font-weight: bold; text-transform: uppercase; color: var(--color-text-main); }
.avatar-wrapper { position: relative; display: inline-block; }
.avatar-img { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 4px solid var(--color-bg-body); box-shadow: var(--shadow-sm); }
.avatar-placeholder { width: 120px; height: 120px; background: var(--color-bg-body); border-radius: 50%; margin: 0 auto; font-size: 3rem; color: var(--color-text-muted); border: 4px solid var(--color-border); box-shadow: var(--shadow-sm); display: flex; align-items: center; justify-content: center; }
.avatar-sm { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; margin: 0 auto 10px auto; display: block; border: 2px solid var(--color-border); }
.avatar-placeholder-sm { display: flex; align-items: center; justify-content: center; width: 60px; height: 60px; background: var(--color-bg-body); border-radius: 50%; margin: 0 auto 10px auto; font-size: 1.5rem; color: var(--color-text-muted); font-weight: bold; border: 2px solid var(--color-border); }
.avatar-upload-btn { cursor: pointer; margin: 0 auto; display: inline-flex; }

/* Scoreboard, Timelines & Teams */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 20px; }
.stat-label { color: var(--color-text-muted); font-size: 0.8rem; text-transform: uppercase; margin: 0 0 5px 0; }
.stat-value { font-size: 1.8rem; font-weight: bold; color: var(--color-text-main); margin: 0; }
.stat-value-lg { font-size: 2rem; font-weight: bold; }
.timeline-item { padding-bottom: 15px; border-bottom: 1px solid var(--color-border); margin-bottom: 15px; }
.timeline-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; margin-top: 20px; }
.team-link { text-decoration: none; color: inherit; display: block; }
.team-card { transition: transform 0.2s, box-shadow 0.2s; }
.team-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.team-role { font-size: 0.75rem; text-transform: uppercase; color: var(--color-text-muted); font-weight: bold; }

/* Dashboard & Admin */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.chart-container-sm { position: relative; max-width: 320px; margin: 0 auto; }
.chart-container-wide { position: relative; height: 300px; width: 100%; }

.tab-nav { display: flex; gap: 10px; margin-bottom: 25px; border-bottom: 2px solid var(--color-border); padding-bottom: 10px; overflow-x: auto; }
.tab-btn { background: none; border: none; padding: 10px 20px; font-size: 1rem; font-weight: bold; color: var(--color-text-muted); cursor: pointer; border-radius: 6px; transition: all 0.2s; white-space: nowrap; }
.tab-btn:hover { background: var(--color-bg-body); color: var(--color-text-main); }
.tab-btn.active { background: var(--color-primary); color: white; box-shadow: var(--shadow-sm); }
.tab-pane { display: none; animation: fadeIn 0.3s ease; }
.tab-pane.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Fleet */
.fleet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.details-summary { cursor: pointer; font-weight: bold; color: var(--color-primary); padding: 10px 0; border-top: 1px solid var(--color-border); margin-top: 15px; display: flex; align-items: center; gap: 8px; user-select: none; }
.details-summary:hover { color: var(--color-primary-hover); }
.details-content { margin-top: 10px; padding-bottom: 10px; }
.metric-box { padding: 10px; background: var(--color-bg-body); border-radius: 6px; border: 1px solid var(--color-border); font-weight: bold; font-size: 1rem; color: var(--color-primary); }
.log-notes { color: var(--color-text-muted); font-style: italic; border-left: 2px solid var(--color-border); padding-left: 8px; }

/* Inspections */
.category-header { margin-top: 0; color: var(--color-text-main); border-bottom: 1px solid var(--color-border); padding-bottom: 15px; margin-bottom: 15px; display: flex; align-items: center; gap: 10px; }
.inspection-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 20px; }
.check-item { margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px dashed var(--color-border); }
.check-item:last-of-type { border-bottom: none; margin-bottom: 10px; padding-bottom: 0; }
.question-text { display: block; font-weight: bold; color: var(--color-text-main); font-size: 0.95rem; line-height: 1.4; }

.toggle-group { display: flex; gap: 10px; margin-top: 10px; }
.toggle-group input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-btn { flex: 1; text-align: center; padding: 10px 5px; border: 2px solid var(--color-border); border-radius: 6px; font-weight: 600; color: var(--color-text-muted); cursor: pointer; transition: all 0.2s ease; background-color: var(--color-bg-body); font-size: 0.85rem; user-select: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.toggle-group label:hover .toggle-btn { border-color: var(--color-text-main); background-color: var(--color-bg-surface); }
input[value="Pass"]:checked + .toggle-btn { background-color: color-mix(in srgb, var(--color-success) 12%, transparent); border-color: var(--color-success); color: var(--color-success); }
input[value="Action"]:checked + .toggle-btn { background-color: color-mix(in srgb, var(--color-danger) 12%, transparent); border-color: var(--color-danger); color: var(--color-danger); }
input[value="N/A"]:checked + .toggle-btn { background-color: color-mix(in srgb, var(--color-primary) 12%, transparent); border-color: var(--color-primary); color: var(--color-primary); }

.photo-dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 20px; border: 2px dashed var(--color-border); border-radius: var(--radius-md); cursor: pointer; background-color: var(--color-bg-body); transition: all 0.2s ease; text-align: center; }
.photo-dropzone:hover { border-color: var(--color-primary); background-color: var(--color-bg-surface); }
.dropzone-icon { width: 36px !important; height: 36px !important; color: var(--color-primary); }
.dropzone-title { font-weight: bold; color: var(--color-text-main); font-size: 1.05rem; }
.dropzone-subtext { font-size: 0.85rem; color: var(--color-text-muted); margin-top: 6px; }
.photo-dropzone.dropzone-active { border-style: solid; border-color: var(--color-primary); background-color: var(--color-bg-surface); }
.photo-dropzone.dropzone-active .dropzone-title { color: var(--color-primary); }

/* Work Orders */
.ticket-header { display: flex; flex-direction: column; gap: 20px; }
.ticket-media img { max-width: 100%; height: auto; border-radius: var(--radius-md); border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); }
.meta-item { display: flex; align-items: center; gap: 5px; margin-bottom: 6px; font-size: 0.9rem; }
.badge-priority { padding: 4px 10px; border-radius: 4px; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 5px; }
.issue-text { margin: 8px 0; color: var(--color-text-main); }
.locked-status { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--color-border); color: var(--color-text-muted); font-size: 0.85rem; }
.wo-thumbnail { max-width: 120px; border-radius: 6px; border: 1px solid var(--color-border); margin-top: 10px; }

/* Milestone & Star Elements (Fall Theme) */
.milestone-box { 
    background-color: #fff3e0; 
    border: 2px dashed #e65100; 
    border-radius: var(--radius-md); 
    padding: 15px; 
    text-align: center; 
    margin: 15px 0; 
}
.milestone-title { 
    margin: 8px 0 5px 0; 
    color: #d84315; 
    font-size: 1.1rem; 
}
.milestone-text { 
    margin: 0; 
    color: var(--color-text-main); 
    font-size: 0.95rem; 
}
.milestone-icon { 
    font-size: 1.8rem; 
}

/* Leave the warning/danger star milestone CSS below this alone */

.alert-star { background: color-mix(in srgb, var(--color-warning) 15%, transparent); color: var(--color-warning); border: 1px solid color-mix(in srgb, var(--color-warning) 40%, transparent); }
.star-card { background: color-mix(in srgb, var(--color-warning) 5%, transparent); border-color: color-mix(in srgb, var(--color-warning) 30%, transparent); }
.star-title { color: var(--color-warning); font-size: 1.1rem; margin-top: 0; }
.star-box { background: var(--color-bg-surface); padding: 10px; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--color-warning) 30%, transparent); margin-bottom: 15px; }
.star-summary { cursor: pointer; color: var(--color-warning); font-weight: bold; user-select: none; }
.star-input { border-color: color-mix(in srgb, var(--color-warning) 40%, transparent) !important; }
.star-history-container { margin-top: 15px; border-top: 1px dashed color-mix(in srgb, var(--color-warning) 40%, transparent); padding-top: 15px; }
.star-history-item { margin-bottom: 12px; font-size: 0.9rem; color: var(--color-text-main); line-height: 1.4; border-left: 3px solid var(--color-warning); padding-left: 10px; }
.star-reason { color: var(--color-text-muted); font-style: italic; margin-top: 4px; }

/* ==========================================================================
   6. DATA TABLES
   ========================================================================== */
table { width: 100%; border-collapse: separate; border-spacing: 0 12px; background: transparent; }
th, td { padding: 15px; text-align: left; }
thead th { color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; font-size: 0.85rem; padding-bottom: 0; }

tbody tr { background: var(--color-bg-surface); box-shadow: var(--shadow-sm); transition: box-shadow 0.2s; }
tbody tr:hover { box-shadow: var(--shadow-md); }
tbody td { border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); }
tbody td:first-child { border-left: 1px solid var(--color-border); border-top-left-radius: var(--radius-md); border-bottom-left-radius: var(--radius-md); }
tbody td:last-child { border-right: 1px solid var(--color-border); border-top-right-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); }

tbody tr.separator-row, tbody tr.separator-row:hover { background: transparent; box-shadow: none; border: none; transform: none; }
tbody tr.separator-row td { border: none; padding: 30px 0 0 0; }
.action-cell { min-width: 200px; vertical-align: top; }
.row-inactive { opacity: 0.6; background-color: var(--color-bg-body) !important; border-style: dashed; }

/* ==========================================================================
   7. RESPONSIVE BREAKPOINTS & MOBILE OVERRIDES
   ========================================================================== */
@media (min-width: 769px) {
    .profile-layout { grid-template-columns: 300px 1fr; }
    .ticket-header { flex-direction: row; justify-content: space-between; align-items: flex-start; }
    .ticket-header-right { text-align: right; }
    .meta-item { justify-content: flex-end; }
    .offline-badge-container { display: none !important; }
}

@media (max-width: 768px) {
    table, thead, tbody, th, td, tr { display: block; }
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    table { border-spacing: 0; } 
    tbody tr { margin-bottom: 15px; border-radius: var(--radius-md); border: 1px solid var(--color-border); }
    tbody td, tbody td:first-child, tbody td:last-child { border: none; border-radius: 0; border-bottom: 1px solid var(--color-border); position: relative; padding: 15px; }
    tbody td:last-child { border-bottom: none; }
    td::before { content: attr(data-label); display: block; font-weight: bold; color: var(--color-text-muted); text-transform: uppercase; font-size: 0.75rem; margin-bottom: 5px; }

    /* Action Column Horizontal Lock */
    .action-cell .flex-col { gap: 10px !important; }
    .action-cell form { display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; align-items: center !important; gap: 5px !important; }
    .action-cell form select { flex-grow: 1; width: auto !important; padding: 8px 12px; }
    .action-cell form button { flex-shrink: 0; width: auto !important; padding-left: 12px; padding-right: 12px; }
}

/* Handles form submission visual blocking */
.btn-processing {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

/* Hardware-accelerated alert dismissal */
.fade-out {
    animation: slideOutUp 0.4s ease-out forwards;
}

@keyframes slideOutUp {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* ==============================================================================
   8. OFFLINE SYNCHRONIZATION & PWA STYLES
   ============================================================================== */
.offline-badge-container {
    display: inline-flex;
    align-items: center;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f0f0f0;
    color: #333;
}

.badge-status.status-online {
    background: #e8f5e9;
    color: #2e7d32;
    border-color: #c8e6c9;
}

.badge-status.status-offline {
    background: #ffebee;
    color: #c62828;
    border-color: #ffcdd2;
}

.badge-status.status-pending {
    background: #fff8e1;
    color: #f57f17;
    border-color: #ffe082;
    animation: pulseGlow 2s infinite ease-in-out;
}

.badge-status.status-syncing {
    background: #e1f5fe;
    color: #0277bd;
    border-color: #b3e5fc;
}

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

/* Outbox Modal */
.outbox-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 16px;
    backdrop-filter: blur(3px);
}

.outbox-modal-card {
    background: #ffffff;
    border-radius: 12px;
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: modalPop 0.25s ease-out;
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.outbox-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.outbox-modal-header h3 {
    margin: 0;
    font-size: 1.15rem;
    color: #2e7d32;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #888;
    padding: 4px 8px;
}

.outbox-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.outbox-items-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.outbox-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: #f8faf8;
    border: 1px solid #e8ede8;
    border-radius: 8px;
}

.outbox-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.outbox-item-sub {
    font-size: 0.78rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
}

.photo-badge {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.badge-pending {
    font-size: 0.75rem;
    font-weight: 600;
    background: #fff3e0;
    color: #e65100;
    padding: 4px 8px;
    border-radius: 6px;
}

.outbox-modal-footer {
    padding: 14px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
}

/* Offline Toast Notifications */
.offline-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    max-width: 380px;
    padding: 14px 18px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    font-size: 0.9rem;
    animation: slideInUp 0.3s ease-out;
}

.toast-success {
    background: #2e7d32;
    color: #ffffff;
}

.toast-warning {
    background: #f57f17;
    color: #ffffff;
}

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

/* ==============================================================================
   8. IMAGE LIGHTBOX & PHOTO VIEWER (PWA & Mobile-First)
   ============================================================================== */
.app-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.93);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

.app-lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.app-lightbox-close {
    position: fixed;
    top: max(16px, env(safe-area-inset-top, 16px));
    right: max(16px, env(safe-area-inset-right, 16px));
    background: rgba(30, 41, 59, 0.9);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 9999px;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    z-index: 100005;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
    touch-action: manipulation;
    transition: all 0.2s ease;
    text-decoration: none;
}

.app-lightbox-close:hover,
.app-lightbox-close:active {
    background: #dc2626;
    border-color: #f87171;
    transform: scale(1.04);
}

.app-lightbox-close-icon {
    font-size: 1.3rem;
    line-height: 1;
    font-weight: bold;
}

.app-lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
    cursor: pointer;
}

.app-lightbox-img-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 95vw;
    max-height: 82vh;
}

.app-lightbox-img {
    max-width: 100%;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.85);
    transition: transform 0.2s ease-out;
    cursor: default;
}

.app-lightbox-caption {
    color: #e2e8f0;
    font-size: 0.88rem;
    font-weight: 500;
    margin-top: 12px;
    text-align: center;
    max-width: 90vw;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.app-lightbox-hint {
    color: #94a3b8;
    font-size: 0.75rem;
    margin-top: 6px;
    text-align: center;
}

body.lightbox-open {
    overflow: hidden !important;
    touch-action: none;
}

/* ==============================================================================
   9. LOAD MORE BUTTON & SPINNER
   ============================================================================== */
.load-more-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 0 16px 0;
}

.spin {
    animation: spinRotate 1s linear infinite;
    display: inline-block;
}

@keyframes spinRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}