/* ============================================================
   ANPR v2 — Main Stylesheet
   Dark-mode security operations dashboard
   ============================================================ */

/* --- UK Number Plate Font --- */
@font-face {
    font-family: 'Charles Wright';
    src: url('/assets/fonts/CharlesWright-Bold.woff2') format('woff2'),
         url('/assets/fonts/CharlesWright-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* --- CSS Variables --- */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #21242f;
    --bg-input: #2a2d3a;
    --bg-hover: #2e3140;
    --border-color: #333748;
    --border-light: #3d4155;

    --text-primary: #e8eaed;
    --text-secondary: #9aa0b0;
    --text-muted: #6b7280;

    --accent: #4f8ff7;
    --accent-hover: #3a7de8;
    --accent-subtle: rgba(79, 143, 247, 0.1);

    --green: #34d399;
    --green-bg: rgba(52, 211, 153, 0.1);
    --amber: #fbbf24;
    --amber-bg: rgba(251, 191, 36, 0.1);
    --red: #f87171;
    --red-bg: rgba(248, 113, 113, 0.1);

    --plate-bg: #f7d616;
    --plate-text: #1a1a1a;

    --sidebar-width: 240px;
    --header-height: 56px;

    --radius: 6px;
    --radius-lg: 10px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, monospace;
}

/* --- Light Theme --- */
[data-theme="light"] {
    --bg-primary: #f0f1f5;
    --bg-secondary: #e4e5eb;
    --bg-card: #ffffff;
    --bg-input: #f0f1f5;
    --bg-hover: #e8e9ef;
    --border-color: #d1d5db;
    --border-light: #e5e7eb;

    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-subtle: rgba(37, 99, 235, 0.08);

    --green: #059669;
    --green-bg: rgba(5, 150, 105, 0.08);
    --amber: #d97706;
    --amber-bg: rgba(217, 119, 6, 0.08);
    --red: #dc2626;
    --red-bg: rgba(220, 38, 38, 0.08);

    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* --- Theme Toggle --- */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.theme-toggle-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.theme-switch {
    position: relative;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.theme-switch-track {
    position: absolute;
    inset: 0;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.25s, border-color 0.25s;
}

.theme-switch-track::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.25s, background 0.25s;
}

.theme-switch input:checked + .theme-switch-track {
    background: var(--accent-subtle);
    border-color: var(--accent);
}

.theme-switch input:checked + .theme-switch-track::before {
    transform: translateX(24px);
    background: var(--accent);
}

.theme-switch-icons {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: absolute;
    inset: 0;
    padding: 0 6px;
    pointer-events: none;
    font-size: 13px;
    line-height: 28px;
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

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

a:hover {
    color: var(--accent-hover);
}

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

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

/* --- Auth Page --- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 1.5rem;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-form .form-group {
    margin-bottom: 1.25rem;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
}

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

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.btn-success {
    background: var(--green);
    color: #0f1117;
}

.btn-success:hover {
    background: #4ade80;
    color: #0f1117;
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-danger:hover {
    background: #ef4444;
    color: #fff;
}

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

.btn-full {
    width: 100%;
}

/* --- Alerts / Flash Messages --- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.alert-success {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.alert-warning {
    background: var(--amber-bg);
    color: var(--amber);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.alert-info {
    background: var(--accent-subtle);
    color: var(--accent);
    border: 1px solid rgba(79, 143, 247, 0.2);
}

/* --- App Layout --- */
.app-page {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--accent);
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
}

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

.nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-right: 3px solid var(--accent);
}

.nav-icon {
    font-size: 0.5rem;
    opacity: 0.5;
}

.nav-group {
    margin-top: 0.5rem;
}

.nav-group-label {
    display: block;
    padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.logout-link {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.logout-link:hover {
    color: var(--red);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.top-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.25rem;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-user {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.content-area {
    padding: 1.5rem;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Tables --- */
.data-table {
    width: 100%;
}

.data-table th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    color: var(--text-primary);
}

/* --- Number Plate Badge --- */
.plate-badge {
    display: inline-block;
    background: var(--plate-bg);
    color: var(--plate-text);
    font-family: 'Charles Wright', var(--font-mono);
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.plate-badge-sm {
    font-size: 0.8rem;
    padding: 0.15rem 0.35rem;
}

/* --- Status Badges --- */
.status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-valid {
    background: var(--green-bg);
    color: var(--green);
}

.status-expired {
    background: var(--red-bg);
    color: var(--red);
}

.status-warning {
    background: var(--amber-bg);
    color: var(--amber);
}

.status-pending {
    background: var(--accent-subtle);
    color: var(--accent);
}

/* --- Camera Status Dots --- */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot-green {
    background: var(--green);
    box-shadow: 0 0 4px var(--green);
}

.status-dot-amber {
    background: var(--amber);
    box-shadow: 0 0 4px var(--amber);
}

.status-dot-red {
    background: var(--red);
    box-shadow: 0 0 4px var(--red);
}

/* --- Grid Helpers --- */
.grid {
    display: grid;
    gap: 1rem;
}

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

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
    justify-content: center;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
}

.pagination a {
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.pagination a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.pagination .active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.pagination .disabled {
    color: var(--text-muted);
    pointer-events: none;
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filter-pills {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filter-pill {
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
}

.filter-pill:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.filter-pill.active {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

/* --- Dashboard --- */
.camera-status-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.camera-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    min-width: 140px;
}

.camera-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.camera-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.camera-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow);
}

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

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

.stat-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.budget-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.budget-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 50px;
}

.budget-bar-wrap {
    flex: 1;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.budget-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
}

.budget-bar-green {
    background: var(--green);
}

.budget-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 100px;
    text-align: right;
}

/* --- Dashboard Admin Cards --- */

/* Card section divider */
.card-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0.875rem 0;
}

/* Section label within cards */
.card-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* Costs card — spend ticker row */
.spend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.spend-item {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.625rem 0.75rem;
    position: relative;
    overflow: hidden;
}

.spend-item-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.spend-item-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
    line-height: 1.2;
}

.spend-item-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.spend-item-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.4s ease;
}

.spend-item-bar--green { background: var(--green); }
.spend-item-bar--amber { background: var(--amber); }
.spend-item-bar--red { background: var(--red); }

/* Service cost rows */
.service-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.375rem 0;
    font-size: 0.85rem;
}

.service-row + .service-row {
    border-top: 1px solid rgba(51, 55, 72, 0.5);
}

.service-name {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.service-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.service-value {
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.service-value--muted {
    color: var(--text-muted);
    font-weight: 400;
}

/* Pipeline card — completion gauge */
.pipeline-gauge {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.25rem;
}

.gauge-ring {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.gauge-ring svg {
    transform: rotate(-90deg);
    width: 64px;
    height: 64px;
}

.gauge-ring-track {
    fill: none;
    stroke: var(--bg-input);
    stroke-width: 5;
}

.gauge-ring-fill {
    fill: none;
    stroke: var(--green);
    stroke-width: 5;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s ease;
}

.gauge-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.gauge-details {
    flex: 1;
    min-width: 0;
}

.gauge-detail-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    padding: 0.15rem 0;
}

.gauge-detail-dot {
    width: 7px;
    height: 7px;
    border-radius: 2px;
    flex-shrink: 0;
}

.gauge-detail-label {
    color: var(--text-secondary);
    flex: 1;
}

.gauge-detail-value {
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

/* Queue pills */
.queue-pills {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.queue-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.queue-pill-count {
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-weight: 700;
}

.queue-pill--immediate {
    border-color: rgba(248, 113, 113, 0.3);
    color: var(--red);
}

.queue-pill--soon {
    border-color: rgba(251, 191, 36, 0.3);
    color: var(--amber);
}

.queue-pill--routine {
    border-color: rgba(79, 143, 247, 0.2);
    color: var(--accent);
}

.queue-pill--deferred {
    color: var(--text-muted);
}

/* System health pulses */
.health-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.health-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--bg-input);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.health-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.health-time {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.health-pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 4px var(--green);
    animation: pulse-glow 2s ease-in-out infinite;
}

.health-pulse--stale {
    background: var(--amber);
    box-shadow: 0 0 4px var(--amber);
    animation: none;
}

.health-pulse--dead {
    background: var(--red);
    box-shadow: 0 0 4px var(--red);
    animation: none;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Corrections stat */
.corrections-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.corrections-saved {
    font-size: 0.75rem;
    color: var(--green);
    font-weight: 600;
}

/* --- Processing Chain (Sighting Detail) --- */
.processing-chain {
    display: flex;
    align-items: stretch;
    gap: 0;
    margin-bottom: 1rem;
}

.chain-step {
    flex: 1;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    position: relative;
}

.chain-step-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.chain-step-name {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.chain-step-status {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.chain-step-detail {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.chain-connector {
    width: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chain-connector::before {
    content: '';
    width: 100%;
    height: 2px;
    background: var(--border-color);
}

.chain-connector::after {
    content: '›';
    position: absolute;
    right: -1px;
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1;
}

/* Chain step states */
.chain-success {
    border-color: rgba(52, 211, 153, 0.3);
    background: rgba(52, 211, 153, 0.06);
}
.chain-success .chain-step-status { color: var(--green); }

.chain-fail {
    border-color: rgba(248, 113, 113, 0.3);
    background: rgba(248, 113, 113, 0.06);
}
.chain-fail .chain-step-status { color: var(--red); }

.chain-warn {
    border-color: rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.06);
}
.chain-warn .chain-step-status { color: var(--amber); }

.chain-pending {
    border-color: rgba(79, 143, 247, 0.3);
    background: rgba(79, 143, 247, 0.06);
}
.chain-pending .chain-step-status { color: var(--accent); }

.chain-skip .chain-step-status { color: var(--text-muted); }

.chain-inactive {
    opacity: 0.4;
}
.chain-inactive .chain-step-status { color: var(--text-muted); }

/* --- Review Queue --- */
.review-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.review-count {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--red);
    font-family: var(--font-mono);
    line-height: 1;
}

.review-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.review-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.review-card {
    display: flex;
    gap: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    animation: review-fade-in 0.3s ease both;
    transition: border-color 0.15s;
}

.review-card:hover {
    border-color: var(--border-light);
}

@keyframes review-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.review-image-link {
    position: relative;
    flex-shrink: 0;
    width: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    overflow: hidden;
}

.review-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: 160px;
    object-fit: contain;
}

.review-image-zoom {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0;
    transition: opacity 0.15s;
}

.review-image-link:hover .review-image-zoom {
    opacity: 1;
}

.review-body {
    flex: 1;
    min-width: 0;
    padding: 0.875rem 1rem 0.875rem 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
}

.review-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.review-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.review-chain {
    display: flex;
    align-items: center;
    gap: 0;
}

.review-chain-step {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-family: var(--font-mono);
}

.review-chain-fail {
    color: var(--red);
    background: var(--red-bg);
}

.review-chain-skip {
    color: var(--text-muted);
    background: var(--bg-input);
}

.review-chain-sep {
    width: 12px;
    height: 1px;
    background: var(--border-color);
    flex-shrink: 0;
}

.review-fix-form,
.sighting-fix-form {
    display: flex;
    gap: 0.375rem;
    max-width: 320px;
}

.review-fix-input {
    flex: 1;
    min-width: 0;
    padding: 0.375rem 0.5rem;
    font-size: 0.9rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .review-card {
        flex-direction: column;
    }

    .review-image-link {
        width: 100%;
    }

    .review-image {
        max-height: 200px;
    }

    .review-body {
        padding: 0.75rem;
    }

    .review-fix-form {
        max-width: 100%;
    }
}

/* --- AI Line Up match panel --- */
.review-card-matched {
    border-color: rgba(52, 211, 153, 0.3);
}

.lineup-match {
    margin-top: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: rgba(52, 211, 153, 0.06);
    border: 1px solid rgba(52, 211, 153, 0.2);
    border-radius: var(--radius);
}

.lineup-match-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.lineup-match-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--green);
}

.lineup-match-confidence {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.375rem;
    border-radius: 3px;
}

.confidence-high {
    background: rgba(52, 211, 153, 0.15);
    color: var(--green);
}

.confidence-med {
    background: rgba(251, 191, 36, 0.15);
    color: var(--amber);
}

.confidence-low {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
}

.lineup-match-suggestion {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.lineup-match-vehicle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.lineup-match-actions {
    display: flex;
    gap: 0.375rem;
}

/* --- Visit Frequency Badges --- */
.freq-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

.freq-daily {
    background: rgba(52, 211, 153, 0.15);
    color: var(--green);
}

.freq-regular {
    background: rgba(79, 143, 247, 0.15);
    color: var(--accent);
}

.freq-occasional {
    background: rgba(251, 191, 36, 0.15);
    color: var(--amber);
}

.freq-one-off {
    background: var(--bg-input);
    color: var(--text-muted);
}

.freq-infrequent {
    background: var(--bg-input);
    color: var(--text-secondary);
}

/* --- Input: Time (dark mode fix) --- */
input[type="time"] {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color-scheme: dark;
}

/* --- Input: Date (dark mode fix) --- */
input[type="date"] {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color-scheme: dark;
}

/* --- Checkbox styling --- */
input[type="checkbox"] {
    accent-color: var(--accent);
}

/* --- Analytics --- */
.analytics-range-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.range-presets {
    display: flex;
    gap: 0.375rem;
}

.range-btn {
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-sans);
}

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

.range-btn.active {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

.range-custom {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-input {
    width: 140px;
    padding: 0.375rem 0.5rem;
    font-size: 0.85rem;
}

.analytics-summary {
    margin-bottom: 1.25rem;
}

.analytics-card {
    margin-bottom: 1.25rem;
}

.chart-wrap {
    position: relative;
    height: 280px;
}

.chart-wrap-heatmap {
    height: auto;
    overflow-x: auto;
}

/* Heatmap grid */
.heatmap-grid {
    display: grid;
    grid-template-columns: 40px repeat(24, 1fr);
    gap: 2px;
    min-width: 500px;
}

.heatmap-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    padding-right: 0.25rem;
}

.heatmap-hour-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-align: center;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 2px;
    min-height: 18px;
    cursor: default;
    transition: opacity 0.15s;
}

.heatmap-cell:hover {
    opacity: 0.8;
    outline: 1px solid var(--accent);
}

.analytics-table-wrap {
    max-height: 400px;
    overflow-y: auto;
}

/* --- Placeholder text --- */
.placeholder-text {
    color: var(--text-muted);
    text-align: center;
    padding: 3rem 1rem;
    font-size: 0.95rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

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

    .sidebar-close {
        display: block;
    }

    .hamburger {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

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

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

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

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

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

    .corrections-row {
        flex-direction: column;
        gap: 0.25rem;
        align-items: flex-start;
    }

    .processing-chain {
        flex-direction: column;
    }

    .chain-connector {
        width: auto;
        height: 16px;
    }

    .chain-connector::before {
        width: 2px;
        height: 100%;
    }

    .chain-connector::after {
        content: '›';
        transform: rotate(90deg);
        right: auto;
        bottom: -2px;
    }

    /* Tables as cards on mobile */
    .data-table:not(.detail-table) thead {
        display: none;
    }

    .data-table:not(.detail-table) tr {
        display: block;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        margin-bottom: 0.5rem;
        padding: 0.75rem;
    }

    .data-table:not(.detail-table) td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.25rem 0;
        border: none;
    }

    .data-table:not(.detail-table) td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.75rem;
        text-transform: uppercase;
    }

    /* Detail tables (key-value pairs) keep standard layout on mobile */
    .detail-table tr {
        display: flex;
        border-bottom: 1px solid var(--border-color);
    }

    .detail-table td {
        display: block;
        padding: 0.375rem 0;
    }

    .detail-table tr td:first-child {
        min-width: 110px;
        flex-shrink: 0;
    }

    .detail-table tr td:last-child {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .content-area {
        padding: 1rem;
    }

    .auth-card {
        padding: 1.5rem;
    }

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

    .stat-value {
        font-size: 1.5rem;
    }

    .camera-status-bar {
        flex-direction: column;
    }
}
