/* ═══════════════════════════════════════════════════════════
   GaugeVision-AI — Enterprise Design System
   ═══════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─────────────────────────────────────── */
:root {
    /* Surface colors */
    --bg-base: #0a0c10;
    --bg-surface: #12141c;
    --bg-elevated: #1a1d28;
    --bg-card: #1e2130;
    --bg-hover: #252940;
    --bg-active: #2d3250;

    /* Brand / Accent */
    --accent-50: #e0f4ff;
    --accent-100: #b8e6ff;
    --accent-200: #7dd3fc;
    --accent-300: #38bdf8;
    --accent-400: #0ea5e9;
    --accent-500: #0284c7;
    --accent-600: #0369a1;
    --accent-700: #075985;

    /* Text */
    --text-primary: #f0f2f5;
    --text-secondary: #8891a5;
    --text-tertiary: #5c6478;
    --text-inverse: #0a0c10;

    /* Semantic */
    --success-bg: #0d2818;
    --success: #34d399;
    --success-text: #6ee7b7;
    --error-bg: #2d0f0f;
    --error: #f87171;
    --error-text: #fca5a5;
    --warning-bg: #2d1f0f;
    --warning: #fbbf24;
    --warning-text: #fde68a;
    --info-bg: #0c1929;
    --info: #60a5fa;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.16);
    --border-accent: var(--accent-500);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.15);
    --shadow-glow-strong: 0 0 40px rgba(14, 165, 233, 0.25);

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Layout */
    --topbar-height: 56px;
    --sidebar-width: 240px;
    --sidebar-collapsed: 0px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    overflow: hidden;
    height: 100vh;
}

a { color: var(--accent-300); text-decoration: none; }
a:hover { color: var(--accent-200); }

img { max-width: 100%; height: auto; }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

/* ─── Top Bar ───────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-5);
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

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

.sidebar-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--duration-fast) ease;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.brand-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-500), var(--accent-700));
    border-radius: var(--radius-sm);
    color: white;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.brand-tagline {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 400;
    letter-spacing: 0.2px;
}

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

.topbar-status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ─── App Layout ────────────────────────────────────────── */
.app-layout {
    display: flex;
    height: calc(100vh - var(--topbar-height));
    margin-top: var(--topbar-height);
}

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    transition: all var(--duration-normal) var(--ease-out);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
    min-width: var(--sidebar-collapsed);
}

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

.nav-section {
    margin-bottom: var(--space-6);
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-tertiary);
    padding: 0 var(--space-3);
    margin-bottom: var(--space-2);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--duration-fast) ease;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(14, 165, 233, 0.12);
    color: var(--accent-300);
}

.nav-item.active svg {
    color: var(--accent-400);
}

.nav-item svg {
    flex-shrink: 0;
}

/* Sidebar Stats */
.sidebar-stats {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: 0 var(--space-3);
}

.stat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) 0;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-300);
}

.stat-label {
    font-size: 12px;
    color: var(--text-tertiary);
}

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

.sidebar-version {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* ─── Main Content ──────────────────────────────────────── */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.content-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-5) var(--space-6) var(--space-8);
}

/* ─── Section Headers ───────────────────────────────────── */
.section {
    margin-bottom: var(--space-5);
}

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

.section-title-group h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    letter-spacing: -0.3px;
}

.section-title-group h2 svg {
    color: var(--accent-400);
    flex-shrink: 0;
}

.section-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

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

.count-badge {
    font-size: 11px;
    font-weight: 600;
    background: var(--accent-600);
    color: white;
    padding: 1px 8px;
    border-radius: var(--radius-full);
    margin-left: var(--space-1);
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--duration-fast) ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-500);
    color: white;
    box-shadow: 0 1px 3px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover {
    background: var(--accent-400);
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.4);
    transform: translateY(-1px);
}

.btn-ghost {
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* ─── View Toggle ───────────────────────────────────────── */
.view-toggle {
    display: flex;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}

.view-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: all var(--duration-fast) ease;
}

.view-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.view-btn.active {
    color: var(--accent-300);
    background: var(--bg-active);
}

/* ─── Search Box ────────────────────────────────────────── */
.search-box {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0 var(--space-3);
    transition: all var(--duration-fast) ease;
}

.search-box:focus-within {
    border-color: var(--accent-500);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.search-box svg {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    padding: var(--space-2) 0;
    width: 180px;
    font-family: var(--font-sans);
}

.search-box input::placeholder {
    color: var(--text-tertiary);
}

/* ─── Drop Zone ─────────────────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-6) var(--space-8);
    text-align: center;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    background: var(--bg-surface);
    position: relative;
    overflow: hidden;
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(14, 165, 233, 0.03) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--duration-normal) ease;
}

.drop-zone:hover {
    border-color: var(--accent-500);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-glow);
}

.drop-zone:hover::before {
    opacity: 1;
}

.drop-zone.drag-over {
    border-color: var(--accent-400);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-glow-strong);
    transform: scale(1.005);
}

.drop-zone.drag-over::before {
    opacity: 1;
}

.drop-zone-content {
    pointer-events: none;
    position: relative;
    z-index: 1;
}

.drop-zone-icon {
    color: var(--accent-400);
    margin-bottom: var(--space-2);
    opacity: 0.8;
}

.drop-zone-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.drop-zone-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.drop-zone-formats {
    display: flex;
    justify-content: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.format-tag {
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    letter-spacing: 0.5px;
}

.drop-zone-limit {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ─── Upload Preview ────────────────────────────────────── */
.upload-preview {
    margin-top: var(--space-4);
}

.preview-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    animation: slideUp var(--duration-normal) var(--ease-out);
}

.preview-card img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.preview-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.preview-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-size {
    font-size: 12px;
    color: var(--text-secondary);
}

.preview-actions {
    display: flex;
    gap: var(--space-2);
}

/* ─── Gallery ───────────────────────────────────────────── */
.gallery-scroll {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    background: var(--bg-surface);
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: var(--space-3);
}

.gallery.list-view {
    grid-template-columns: 1fr;
    gap: var(--space-2);
}

.gallery-empty {
    color: var(--text-secondary);
    text-align: center;
    padding: var(--space-8);
    grid-column: 1 / -1;
    font-size: 14px;
}

.gallery-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
}

.gallery-card:hover {
    border-color: var(--accent-500);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.gallery-card.selected {
    border-color: var(--accent-400);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.25), var(--shadow-glow);
}

.gallery-card.processing {
    opacity: 0.5;
    pointer-events: none;
}

.gallery-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
    transition: transform var(--duration-slow) var(--ease-out);
}

.gallery-card:hover img {
    transform: scale(1.04);
}

/* Gallery overlay */
.gallery-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 120px;
    background: linear-gradient(to bottom, rgba(2, 132, 199, 0.85), rgba(7, 89, 133, 0.9));
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    opacity: 0;
    transition: opacity var(--duration-normal) ease;
}

.gallery-card:hover .gallery-card-overlay {
    opacity: 1;
}

.gallery-card-overlay svg {
    opacity: 0.9;
}

.overlay-text {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

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

.gallery-card-info .filename {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.gallery-card-info .dimensions {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* List view card overrides */
.gallery.list-view .gallery-card {
    display: flex;
    align-items: center;
}

.gallery.list-view .gallery-card img {
    width: 80px;
    height: 56px;
    border-radius: 0;
}

.gallery.list-view .gallery-card-overlay {
    width: 80px;
    height: 56px;
}

.gallery.list-view .gallery-card-info {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ─── Skeleton Loading ──────────────────────────────────── */
.gallery-card.skeleton {
    cursor: default;
    pointer-events: none;
}

.gallery-card.skeleton:hover {
    transform: none;
    border-color: var(--border-subtle);
    box-shadow: none;
}

.skeleton-img {
    width: 100%;
    height: 120px;
    background: linear-gradient(110deg, var(--bg-card) 30%, var(--bg-hover) 50%, var(--bg-card) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton-text {
    margin: var(--space-3) var(--space-3) 0;
    height: 10px;
    border-radius: var(--radius-full);
    background: linear-gradient(110deg, var(--bg-card) 30%, var(--bg-hover) 50%, var(--bg-card) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton-text:last-child {
    margin-bottom: var(--space-3);
}

.skeleton-text.short {
    width: 50%;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Cards ─────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.card-header h3 svg {
    color: var(--text-tertiary);
}

.reading-count {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* ─── Processing Status ─────────────────────────────────── */
.status-card {
    background: var(--bg-surface);
    border: 1px solid var(--accent-600);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-glow);
    animation: slideUp var(--duration-normal) var(--ease-out);
}

.status-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.status-spinner {
    flex-shrink: 0;
    color: var(--accent-400);
    animation: spin 1s linear infinite;
}

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

.status-text {
    flex: 1;
    min-width: 0;
}

.status-text h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.status-filename {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 2px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

.status-timer-group {
    text-align: right;
    flex-shrink: 0;
}

.status-timer-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-tertiary);
    margin-bottom: 2px;
}

.status-timer {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-300);
    letter-spacing: 1px;
}

/* Pipeline Steps */
.status-pipeline {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: var(--space-5);
    padding: 0 var(--space-2);
}

.pipeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    flex-shrink: 0;
    position: relative;
}

.pipeline-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-default);
    color: var(--text-tertiary);
    transition: all var(--duration-normal) var(--ease-out);
}

.pipeline-step.active .pipeline-icon {
    background: rgba(14, 165, 233, 0.15);
    border-color: var(--accent-400);
    color: var(--accent-300);
    box-shadow: 0 0 12px rgba(14, 165, 233, 0.2);
}

.pipeline-step.done .pipeline-icon {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
}

.pipeline-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color var(--duration-fast) ease;
}

.pipeline-step.active .pipeline-label {
    color: var(--accent-300);
}

.pipeline-step.done .pipeline-label {
    color: var(--success-text);
}

.pipeline-connector {
    flex: 1;
    height: 2px;
    background: var(--border-default);
    margin: 0 var(--space-1);
    margin-bottom: 18px;
    transition: background var(--duration-normal) ease;
}

.pipeline-connector.done {
    background: var(--success);
}

/* Progress Bar */
.status-progress {
    height: 4px;
    background: var(--bg-card);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-500), var(--accent-300));
    border-radius: var(--radius-full);
    width: 0%;
    transition: width var(--duration-slow) var(--ease-out);
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    animation: progress-shine 2s linear infinite;
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ─── Primary Reading Card ──────────────────────────────── */
.primary-reading-card {
    background: linear-gradient(135deg, var(--bg-elevated), var(--bg-card));
    border: 1px solid var(--accent-600);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-6);
    text-align: center;
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-glow);
    animation: fadeIn var(--duration-slow) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.primary-reading-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.06) 0%, transparent 60%);
    pointer-events: none;
}

.primary-reading-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-400);
    margin-bottom: var(--space-2);
}

.primary-reading-value {
    font-family: var(--font-mono);
    font-size: 36px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 2px;
    line-height: 1.1;
    margin-bottom: var(--space-2);
}

.primary-reading-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
}

.primary-reading-type {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    background: var(--accent-600);
    color: white;
    letter-spacing: 0.5px;
}

.primary-reading-conf {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ─── Results Grid Layout ───────────────────────────────── */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    align-items: start;
}

.results-grid > .card {
    margin-bottom: 0;
}

.results-grid-full {
    grid-column: 1 / -1;
}

/* ─── Reading Cards ─────────────────────────────────────── */
.result-values {
    margin-bottom: var(--space-3);
}

.values-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
}

.reading-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    transition: all var(--duration-fast) ease;
    animation: fadeIn var(--duration-normal) var(--ease-out);
}

.reading-card:hover {
    border-color: var(--border-strong);
    background: var(--bg-hover);
}

.reading-card.reading-primary {
    border-left: 3px solid var(--success);
    background: rgba(52, 211, 153, 0.05);
}

.reading-card.reading-primary:hover {
    background: rgba(52, 211, 153, 0.08);
}

.primary-badge,
.primary-badge-sm {
    background: var(--success);
    color: var(--bg-base);
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.primary-badge-sm {
    font-size: 8px;
    padding: 1px 5px;
    margin-left: var(--space-2);
    vertical-align: middle;
}

.primary-row td {
    background: rgba(52, 211, 153, 0.04);
}

.reading-value {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    letter-spacing: 1px;
    line-height: 1.2;
}

.reading-unit {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
    font-family: var(--font-sans);
}

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

.reading-type {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.reading-conf {
    font-size: 12px;
    color: var(--text-secondary);
}

.reading-details {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ─── Type Badges ───────────────────────────────────────── */
.type-badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.type-digital {
    background: rgba(14, 165, 233, 0.12);
    color: var(--accent-300);
    border: 1px solid rgba(14, 165, 233, 0.25);
}

.type-analog {
    background: rgba(251, 191, 36, 0.12);
    color: var(--warning-text);
    border: 1px solid rgba(251, 191, 36, 0.25);
}

.type-value {
    background: rgba(52, 211, 153, 0.12);
    color: var(--success-text);
    border: 1px solid rgba(52, 211, 153, 0.25);
}

.type-unit {
    background: rgba(14, 165, 233, 0.12);
    color: var(--accent-300);
    border: 1px solid rgba(14, 165, 233, 0.25);
}

.type-label {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.type-ocr {
    background: rgba(192, 132, 252, 0.12);
    color: #d8b4fe;
    border: 1px solid rgba(192, 132, 252, 0.25);
}

.type-unknown {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.type-light {
    background: rgba(250, 204, 21, 0.12);
    color: #fde047;
    border: 1px solid rgba(250, 204, 21, 0.25);
}

/* ─── Color Badges ─────────────────────────────────────── */
.color-badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.color-green {
    background: rgba(52, 211, 153, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.color-red {
    background: rgba(248, 113, 113, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.color-yellow {
    background: rgba(251, 191, 36, 0.15);
    color: #fde68a;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.color-orange {
    background: rgba(251, 146, 60, 0.15);
    color: #fdba74;
    border: 1px solid rgba(251, 146, 60, 0.3);
}

.color-blue {
    background: rgba(96, 165, 250, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(96, 165, 250, 0.3);
}

.color-white {
    background: rgba(255, 255, 255, 0.1);
    color: #e5e7eb;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ─── Image Comparison ──────────────────────────────────── */
.comparison-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.comp-tab {
    font-size: 12px;
    font-weight: 500;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    transition: all var(--duration-fast) ease;
}

.comp-tab:hover {
    color: var(--text-primary);
}

.comp-tab.active {
    background: var(--bg-active);
    color: var(--text-primary);
}

.image-comparison {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
    padding: var(--space-3);
}

.image-comparison.single-view {
    grid-template-columns: 1fr;
}

.comparison-panel {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
}

.comparison-panel.hidden-panel {
    display: none;
}

.comparison-label {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius-sm);
    color: white;
    z-index: 1;
}

.comparison-img-wrap {
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
}

.comparison-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform var(--duration-slow) var(--ease-out);
    cursor: zoom-in;
}

.comparison-img-wrap img:hover {
    transform: scale(1.02);
}

/* ─── Details Table ─────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
}

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

thead {
    background: var(--bg-elevated);
}

th {
    padding: var(--space-3) var(--space-5);
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}

td {
    padding: var(--space-3) var(--space-5);
    font-size: 13px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

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

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

.conf-value {
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 12px;
}

.conf-bar {
    display: inline-block;
    height: 5px;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--accent-500), var(--accent-300));
    margin-left: var(--space-2);
    vertical-align: middle;
}

.details-cell {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ─── Info Grid ─────────────────────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1px;
    background: var(--border-subtle);
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface);
}

.info-item-wide {
    grid-column: 1 / -1;
}

.info-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-tertiary);
}

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

.step-tag {
    display: inline-block;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 1px 10px;
    font-size: 11px;
    font-weight: 500;
    margin: 2px;
    color: var(--text-secondary);
}

/* ─── Empty State ───────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: var(--space-6) var(--space-4);
    color: var(--text-secondary);
}

.empty-state.compact {
    padding: var(--space-4);
}

.empty-state svg {
    margin-bottom: var(--space-3);
    color: var(--text-tertiary);
}

.empty-state p {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.empty-state span {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ─── Toast Notifications ───────────────────────────────── */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-height) + var(--space-4));
    right: var(--space-4);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}

.toast {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    max-width: 420px;
    pointer-events: auto;
    animation: toastIn var(--duration-normal) var(--ease-out);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-lg);
}

.toast.removing {
    animation: toastOut var(--duration-fast) ease forwards;
}

.toast-success {
    background: rgba(13, 40, 24, 0.95);
    border: 1px solid rgba(52, 211, 153, 0.3);
    color: var(--success-text);
}

.toast-error {
    background: rgba(45, 15, 15, 0.95);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--error-text);
}

.toast-icon {
    flex-shrink: 0;
}

.toast-close {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    opacity: 0.5;
    transition: opacity var(--duration-fast) ease;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes toastIn {
    from {
        transform: translateX(100%) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    to {
        transform: translateX(100%) scale(0.95);
        opacity: 0;
    }
}

/* ─── Animations ────────────────────────────────────────── */
.fade-in {
    animation: fadeIn var(--duration-slow) var(--ease-out);
}

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

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

/* Staggered children animation */
.stagger-in > * {
    animation: fadeIn var(--duration-normal) var(--ease-out) backwards;
}

.stagger-in > *:nth-child(1) { animation-delay: 0ms; }
.stagger-in > *:nth-child(2) { animation-delay: 50ms; }
.stagger-in > *:nth-child(3) { animation-delay: 100ms; }
.stagger-in > *:nth-child(4) { animation-delay: 150ms; }
.stagger-in > *:nth-child(5) { animation-delay: 200ms; }
.stagger-in > *:nth-child(6) { animation-delay: 250ms; }
.stagger-in > *:nth-child(7) { animation-delay: 300ms; }
.stagger-in > *:nth-child(8) { animation-delay: 350ms; }

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* ─── Image Lightbox ────────────────────────────────────── */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    animation: fadeIn var(--duration-fast) ease;
}

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        bottom: 0;
        z-index: 90;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

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

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        top: var(--topbar-height);
        background: rgba(0, 0, 0, 0.5);
        z-index: 89;
        animation: fadeIn var(--duration-fast) ease;
    }

    .content-wrapper {
        padding: var(--space-5);
    }

    .image-comparison {
        grid-template-columns: 1fr !important;
    }

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

@media (max-width: 768px) {
    .content-wrapper {
        padding: var(--space-4);
    }

    .section-header {
        flex-direction: column;
        gap: var(--space-3);
    }

    .section-actions {
        width: 100%;
    }

    .search-box {
        flex: 1;
    }

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

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
        gap: var(--space-3);
    }

    .drop-zone {
        padding: var(--space-8) var(--space-4);
    }

    .status-pipeline {
        flex-wrap: wrap;
        gap: var(--space-1);
        justify-content: center;
    }

    .pipeline-connector {
        display: none;
    }

    .primary-reading-value {
        font-size: 36px;
    }

    .values-display {
        grid-template-columns: 1fr;
    }

    .toast {
        max-width: calc(100vw - var(--space-8));
    }

    .topbar-status .status-label {
        display: none;
    }

    .comparison-tabs {
        width: 100%;
        overflow-x: auto;
    }

    .preview-card {
        flex-direction: column;
        text-align: center;
    }

    .preview-actions {
        width: 100%;
        justify-content: center;
    }

    .brand-tagline {
        display: none;
    }

    .info-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .brand-name {
        font-size: 13px;
    }
}
