/* ================================================
   Maintenance-Eye — Mobile-First PWA Styles
   Premium dark theme with cyan/blue accent gradient
   ================================================ */

:root {
    /* Colors — Premium Dark Theme */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-glass: rgba(15, 23, 42, 0.85);
    --bg-glass-light: rgba(30, 41, 59, 0.75);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-cyan: #06b6d4;
    --accent-blue: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #06b6d4, #3b82f6);
    --accent-glow: 0 0 20px rgba(6, 182, 212, 0.3);

    /* Priority Colors */
    --priority-p1: #ef4444;
    --priority-p2: #f97316;
    --priority-p3: #eab308;
    --priority-p4: #22c55e;
    --priority-p5: #64748b;

    /* Status */
    --status-online: #22c55e;
    --status-recording: #ef4444;
    --accent-green: #22c55e;

    /* Spacing */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

/* ==================== RESET ==================== */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== SCREENS ==================== */

.screen {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    z-index: 1;
}

.screen.active {
    display: flex;
}

/* ==================== SPLASH SCREEN ==================== */

#splash-screen {
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(6, 182, 212, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 50%);
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 80px;
    height: 80px;
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(6, 182, 212, 0.3)); }
    50% { filter: drop-shadow(0 0 20px rgba(6, 182, 212, 0.6)); }
}

.logo-text {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.logo-text .accent {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-tagline {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

/* ==================== BUTTONS ==================== */

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 280px;
    padding: 16px 32px;
    background: linear-gradient(135deg, #06b6d4, #3b82f6, #06b6d4);
    background-size: 200% auto;
    color: white;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--accent-glow);
    animation: gradient-shift 4s ease infinite;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(6, 182, 212, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-glass-light);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
}

/* ==================== SPLASH STATUS ==================== */

.splash-status {
    font-size: 14px;
    color: var(--accent-cyan);
    text-align: center;
    padding: 8px 16px;
}

.splash-status.error {
    color: var(--priority-p1);
}

/* ==================== STATUS BAR ==================== */

.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s ease;
}

.status-bar.connected .status-dot {
    background: var(--status-online);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.status-bar.reconnecting .status-dot {
    background: #f59e0b;
    animation: reconnect-pulse 1.2s ease-in-out infinite;
}

.status-bar.reconnecting {
    color: #f59e0b;
}

@keyframes reconnect-pulse {
    0%, 100% { box-shadow: 0 0 4px rgba(245, 158, 11, 0.4); opacity: 1; }
    50% { box-shadow: 0 0 12px rgba(245, 158, 11, 0.8); opacity: 0.6; }
}

/* ==================== CAMERA ==================== */

#camera-container {
    position: absolute;
    inset: 0;
    background: #000;
    z-index: 0;
}

#camera-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#camera-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border: 1px solid rgba(6, 182, 212, 0.15);
}

.scan-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(6, 182, 212, 0.8), transparent);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
    animation: scan 4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes scan {
    0%, 100% { top: 10%; opacity: 0; }
    15% { opacity: 1; }
    50% { top: 90%; opacity: 1; }
    65% { opacity: 0; }
}

/* ==================== TOP BAR ==================== */

#top-bar {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--safe-area-top) + 12px) 16px 12px;
    background: linear-gradient(to bottom, rgba(15, 23, 42, 0.9), transparent);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.session-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.session-asset {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.session-timer {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-cyan);
    font-variant-numeric: tabular-nums;
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    color: var(--status-recording);
    letter-spacing: 1px;
}

.rec-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--status-recording);
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ==================== AGENT PANEL ==================== */

#agent-panel {
    position: absolute;
    bottom: 80px;
    left: 0;
    right: 0;
    z-index: 10;
    max-height: 55%;
    display: flex;
    flex-direction: column;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transition: max-height 0.3s ease;
    overflow: hidden;
}

#agent-panel.collapsed {
    max-height: 60px;
}

#agent-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    flex-shrink: 0;
    cursor: pointer;
}

.agent-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

.agent-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.agent-name {
    font-size: 14px;
    font-weight: 600;
}

.agent-status {
    font-size: 12px;
    color: var(--accent-cyan);
}

.btn-expand {
    width: 32px;
    height: 32px;
    transition: transform 0.3s ease;
}

#agent-panel.collapsed .btn-expand {
    transform: rotate(180deg);
}

/* ==================== MESSAGES ==================== */

.agent-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.5;
    max-width: 90%;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.agent-message {
    background: var(--bg-secondary);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.user-message {
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid rgba(6, 182, 212, 0.2);
    color: var(--text-primary);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* ==================== FINDINGS ==================== */

.findings-container {
    padding: 0 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.finding-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid;
    animation: fadeInUp 0.3s ease;
}

.finding-card.severity-P1 { border-left-color: var(--priority-p1); }
.finding-card.severity-P2 { border-left-color: var(--priority-p2); }
.finding-card.severity-P3 { border-left-color: var(--priority-p3); }
.finding-card.severity-P4 { border-left-color: var(--priority-p4); }

.finding-severity {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.finding-severity.P1 { background: rgba(239, 68, 68, 0.15); color: var(--priority-p1); }
.finding-severity.P2 { background: rgba(249, 115, 22, 0.15); color: var(--priority-p2); }
.finding-severity.P3 { background: rgba(234, 179, 8, 0.15); color: var(--priority-p3); }
.finding-severity.P4 { background: rgba(34, 197, 94, 0.15); color: var(--priority-p4); }

.finding-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.finding-confidence {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ==================== BOTTOM CONTROLS ==================== */

#bottom-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 16px 24px calc(var(--safe-area-bottom) + 16px);
    background: linear-gradient(to top, rgba(15, 23, 42, 0.95), var(--bg-glass));
    backdrop-filter: blur(10px);
}

.btn-control {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-control:hover {
    transform: scale(1.08);
}

.btn-control:active {
    transform: scale(0.95);
}

.btn-mic.active {
    background: var(--accent-gradient);
    border-color: transparent;
    box-shadow: var(--accent-glow);
    animation: mic-pulse 2s ease-in-out infinite;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(6, 182, 212, 0.3); }
    50% { box-shadow: 0 0 25px rgba(6, 182, 212, 0.5); }
}

.btn-mic.muted {
    background: var(--bg-tertiary);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--priority-p1);
    animation: none;
}

.btn-capture {
    width: 64px;
    height: 64px;
    border-width: 3px;
}

.btn-capture:active {
    background: var(--accent-gradient);
    border-color: transparent;
}

/* ==================== SCROLLBAR ==================== */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 4px; }

/* ==================== HUD OVERLAY ==================== */

#hud-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

.hud-corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 2px solid rgba(6, 182, 212, 0.4);
    opacity: 0.6;
}

.hud-tl { top: 20px; left: 20px; border-right: 0; border-bottom: 0; }
.hud-tr { top: 20px; right: 20px; border-left: 0; border-bottom: 0; }
.hud-bl { bottom: 20px; left: 20px; border-right: 0; border-top: 0; }
.hud-br { bottom: 20px; right: 20px; border-left: 0; border-top: 0; }

.hud-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
    opacity: 0.4;
    animation: crosshair-pulse 3s ease-in-out infinite;
}

.hud-crosshair::before, .hud-crosshair::after {
    content: '';
    position: absolute;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
}

.hud-crosshair::before { left: 0; top: 19px; width: 100%; height: 1px; }
.hud-crosshair::after { left: 19px; top: 0; width: 1px; height: 100%; }

@keyframes crosshair-pulse {
    0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.1); }
}


.hud-data-left, .hud-data-right {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 20px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 10px;
    color: var(--accent-cyan);
    opacity: 0.6;
    letter-spacing: 1px;
}

.hud-data-left { left: 30px; align-items: flex-start; }
.hud-data-right { right: 30px; align-items: flex-end; }

.hud-v-line {
    width: 1px;
    height: 100px;
    background: linear-gradient(to bottom, transparent, var(--accent-cyan), transparent);
}

.hud-scanning-text {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 2px;
    animation: pulse 2s infinite;
    display: none;
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

#hud-overlay.active .hud-scanning-text {
    display: block;
}

/* ==================== INTERLEAVED MEDIA CARDS ==================== */

.media-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: fadeInUp 0.4s ease;
}

.media-card-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.media-card-content {
    padding: 12px;
}

.media-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-bottom: 4px;
}

.media-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.media-card-link {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 12px;
    background: var(--accent-gradient);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.media-card-link:hover {
    filter: brightness(1.1);
}

.media-card-details {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.media-card-detail {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
}

.detail-label {
    color: var(--text-muted, rgba(255,255,255,0.45));
    font-weight: 600;
    text-transform: uppercase;
    font-size: 9px;
    letter-spacing: 0.4px;
}

.detail-value {
    color: var(--accent-cyan, #06b6d4);
    font-weight: 600;
    padding: 1px 6px;
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.2);
    border-radius: 4px;
    font-size: 11px;
}

/* ==================== RESPONSIVE ==================== */

@media (min-width: 768px) {
    #agent-panel {
        max-width: 480px;
        left: auto;
        right: 16px;
        bottom: 96px;
        border-radius: var(--radius-lg);
    }

    #bottom-controls {
        max-width: 480px;
        left: auto;
        right: 16px;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

/* ==================== CONFIRMATION CARDS ==================== */

.confirmation-container {
    padding: 0 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.confirmation-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(51, 65, 85, 0.9));
    border: 1px solid rgba(6, 182, 212, 0.25);
    border-radius: var(--radius);
    padding: 14px;
    animation: fadeInUp 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.confirm-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.confirm-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 20px;
    color: var(--accent-cyan);
    letter-spacing: 0.3px;
}

.confirm-priority {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.confirm-priority.P1 { background: rgba(239, 68, 68, 0.15); color: var(--priority-p1); }
.confirm-priority.P2 { background: rgba(249, 115, 22, 0.15); color: var(--priority-p2); }
.confirm-priority.P3 { background: rgba(234, 179, 8, 0.15); color: var(--priority-p3); }
.confirm-priority.P4 { background: rgba(34, 197, 94, 0.15); color: var(--priority-p4); }
.confirm-priority.P5 { background: rgba(100, 116, 139, 0.15); color: var(--priority-p5); }

.confirm-confidence {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}

.confirm-description {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.confirm-codes {
    font-size: 11px;
    color: var(--accent-cyan);
    font-family: 'SF Mono', 'Fira Code', monospace;
    padding: 4px 8px;
    background: rgba(6, 182, 212, 0.06);
    border-radius: 4px;
    margin-bottom: 10px;
}

.confirm-actions {
    display: flex;
    gap: 8px;
}

.confirm-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.confirm-btn:hover {
    transform: translateY(-1px);
}

.confirm-yes:hover {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
    color: #4ade80;
}

.confirm-no:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.confirm-edit:hover {
    background: rgba(234, 179, 8, 0.2);
    border-color: rgba(234, 179, 8, 0.4);
    color: #fbbf24;
}

/* ==================== TRANSCRIPTS ==================== */

.transcript {
    font-size: 13px;
    padding: 8px 12px;
    max-width: 85%;
    line-height: 1.4;
    word-wrap: break-word;
}

.transcript-user {
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid rgba(6, 182, 212, 0.2);
    color: var(--text-primary);
    align-self: flex-end;
    text-align: right;
    border-radius: var(--radius-sm);
    border-bottom-right-radius: 4px;
}

.transcript-agent {
    background: var(--bg-secondary);
    color: var(--text-primary);
    align-self: flex-start;
    text-align: left;
    border-radius: var(--radius-sm);
    border-bottom-left-radius: 4px;
}

.transcript-speaker {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}

.transcript-user .transcript-speaker {
    color: var(--accent-cyan);
}

.transcript-agent .transcript-speaker {
    color: var(--accent-green, #22c55e);
}

.transcript-text {
    display: block;
}

.markdown-content p {
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

.markdown-content ul,
.markdown-content ol {
    margin: 0 0 8px 18px;
    padding: 0;
}

.markdown-content li {
    margin: 0 0 4px 0;
    line-height: 1.5;
}

.markdown-content li:last-child {
    margin-bottom: 0;
}

/* ==================== ANIMATIONS ==================== */

.fade-in {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-8px); }
}

/* ==================== SECONDARY BUTTON ==================== */

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 320px;
    padding: 14px 28px;
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: var(--radius);
    background: rgba(6, 182, 212, 0.08);
    color: var(--accent-cyan);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
}

.btn-secondary:hover {
    background: rgba(6, 182, 212, 0.15);
    border-color: rgba(6, 182, 212, 0.5);
    transform: translateY(-1px);
}

/* ==================== CHAT PANEL ==================== */

.chat-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 480px;
    height: 60vh;
    max-height: 600px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    overflow: hidden;
    animation: fadeInUp 0.3s ease;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.chat-image-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.chat-image-source-picker {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.chat-source-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(6, 182, 212, 0.35);
    background: rgba(6, 182, 212, 0.08);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.chat-source-btn:active {
    background: rgba(6, 182, 212, 0.2);
}

.chat-preview-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.chat-preview-remove {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-preview-remove:hover {
    background: var(--priority-p1);
    color: white;
}

.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.chat-text-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--bg-tertiary);
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    min-width: 0;
}

.chat-text-input:focus {
    border-color: rgba(6, 182, 212, 0.5);
}

.chat-text-input::placeholder {
    color: var(--text-muted);
}

.chat-input-bar .chat-send-btn {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
    flex-shrink: 0;
}

.chat-input-bar #btn-chat-voice.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
    animation: mic-pulse 2s ease-in-out infinite;
}

.chat-msg-img {
    max-width: 200px;
    max-height: 150px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

/* Chat panel confirmation cards spacing */
#chat-confirmation-container {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .chat-panel {
        max-width: 100%;
        height: 55vh;
        border-radius: var(--radius);
    }
}

/* ==================== DASHBOARD ==================== */

#dashboard-screen.active {
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* Top Bar */
#dash-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--bg-tertiary);
    flex-shrink: 0;
}

.dashboard-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.env-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 3px 10px;
    border-radius: 4px;
    background: rgba(6, 182, 212, 0.12);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.25);
}

/* Layout: sidebar + main */
#dash-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar */
#dash-sidebar {
    width: 200px;
    flex-shrink: 0;
    border-right: 1px solid var(--bg-tertiary);
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    text-align: left;
    width: 100%;
}

.nav-item:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: var(--accent-cyan);
    border-left-color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.06);
}

.nav-item svg { flex-shrink: 0; }

/* Main Content */
#dash-main {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px 24px;
    min-width: 0;
}

.dash-page { display: none; }
.dash-page.active { display: block; }

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.filter-search {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.filter-search:focus {
    border-color: rgba(6, 182, 212, 0.5);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

.filter-search::placeholder { color: var(--text-muted); }

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-select {
    padding: 7px 12px;
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 12px;
    outline: none;
    cursor: pointer;
    min-width: 130px;
    transition: border-color 0.2s ease;
}

.filter-select:focus {
    border-color: rgba(6, 182, 212, 0.5);
}

/* Data Table */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--bg-tertiary);
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.1s ease;
}

.data-table tbody tr:hover {
    background: rgba(6, 182, 212, 0.04);
}

.data-table td {
    padding: 10px 12px;
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table td.cell-mono {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.data-table td.cell-truncate {
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badges — priority */
.badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
}

.badge.priority-P1 { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge.priority-P2 { background: rgba(249, 115, 22, 0.15); color: #fb923c; }
.badge.priority-P3 { background: rgba(234, 179, 8, 0.15); color: #facc15; }
.badge.priority-P4 { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge.priority-P5 { background: rgba(100, 116, 139, 0.15); color: #94a3b8; }

/* Badges — status */
.badge.status-open { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge.status-in_progress { background: rgba(234, 179, 8, 0.15); color: #facc15; }
.badge.status-on_hold { background: rgba(249, 115, 22, 0.15); color: #fb923c; }
.badge.status-completed { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge.status-cancelled { background: rgba(100, 116, 139, 0.15); color: #94a3b8; }

/* Data Grid (cards) */
.data-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 600px) {
    .data-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
    .data-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.data-card {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    padding: 14px;
    transition: border-color 0.2s ease, transform 0.15s ease;
}

.data-card:hover {
    border-color: rgba(6, 182, 212, 0.25);
    transform: translateY(-1px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.card-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(6, 182, 212, 0.12);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.card-id {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'SF Mono', monospace;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.3;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}

.card-meta span {
    font-size: 11px;
    color: var(--text-muted);
}

.card-detail {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.card-content {
    line-height: 1.5;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.card-status {
    display: inline-block;
    margin-top: 6px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.status-active { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.status-inactive { background: rgba(100, 116, 139, 0.15); color: #94a3b8; }

/* Locations List */
.locations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zone-group {
    margin-bottom: 12px;
}

.zone-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.location-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    transition: border-color 0.15s ease;
}

.location-row:hover {
    border-color: rgba(6, 182, 212, 0.2);
}

.location-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.location-code {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'SF Mono', monospace;
    margin-left: 8px;
}

.location-count {
    font-size: 12px;
    color: var(--accent-cyan);
    font-weight: 600;
}

/* Loading & Empty */
.dash-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-muted);
    font-size: 13px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.dash-empty {
    display: flex;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

.dash-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    color: #f87171;
    font-size: 14px;
}

.retry-btn {
    padding: 8px 20px;
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: var(--radius-sm);
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-btn:hover {
    background: rgba(248, 113, 113, 0.2);
    border-color: rgba(248, 113, 113, 0.5);
}

.data-error {
    padding: 16px;
    color: #f87171;
    font-size: 13px;
    text-align: center;
}

/* Mobile Bottom Nav */
#dash-bottom-nav {
    display: none;
    border-top: 1px solid var(--bg-tertiary);
    background: var(--bg-secondary);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
    flex-shrink: 0;
}

.bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 10px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.bnav-item.active {
    color: var(--accent-cyan);
}

.bnav-item:hover {
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 767px) {
    #dash-sidebar { display: none; }
    #dash-bottom-nav { display: flex; }
    #dash-main { padding: 16px 12px 12px; }
    .page-title { font-size: 17px; margin-bottom: 12px; }
    .filter-select { min-width: 0; flex: 1; }
    .data-table { font-size: 12px; }
    .data-table td.cell-truncate { max-width: 160px; }
}

@media (min-width: 768px) {
    #dash-bottom-nav { display: none; }
    #dash-sidebar { display: flex; }
}

