/* ===================================================
   Adelaide Dataset Viewer — Polished Dashboard Theme
   =================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Sidebar palette — slate tones */
    --sidebar-bg: #1e1e2e;
    --sidebar-bg-hover: #262639;
    --sidebar-bg-active: #2a2a40;
    --sidebar-border: #33334a;
    --sidebar-text: #c9cdd6;
    --sidebar-text-muted: #8b8fa3;
    --sidebar-text-bright: #e8eaf0;

    /* Accent */
    --accent: #6c8cff;
    --accent-hover: #839dff;
    --accent-muted: rgba(108, 140, 255, 0.15);
    --accent-strong: rgba(108, 140, 255, 0.25);

    /* Right panel */
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --bg: #f3f4f8;
    --border: #e4e6ec;
    --text: #1a1d26;
    --text-secondary: #5f6577;
    --text-muted: #8b8fa3;

    /* Semantic */
    --green: #10b981;
    --green-bg: #ecfdf5;
    --green-text: #065f46;
    --red: #ef4444;
    --red-bg: #fef2f2;
    --red-text: #991b1b;
    --orange: #f59e0b;
    --orange-hover: #d97706;
    --orange-bg: rgba(245, 158, 11, 0.15);
    --orange-text: #92400e;

    /* Spacing & radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* Transitions */
    --ease: 0.2s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    height: 100vh;
}

/* ========================
   Left Panel — Dark sidebar
   ======================== */
#left-panel {
    width: 380px;
    min-width: 380px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

#panel-header {
    padding: 20px 18px 14px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.panel-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

#panel-header h2 {
    font-weight: 600;
    color: var(--sidebar-text-bright);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-size: 11px;
    opacity: 0.7;
    margin: 0;
}

.filters-active-hint {
    font-size: 10px;
    color: var(--accent);
    flex: 1;
    text-align: right;
    margin-right: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filters-toggle-btn {
    background: none;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 12px;
    transition: all var(--ease);
}

.filters-toggle-btn:hover {
    color: var(--sidebar-text);
    border-color: var(--accent);
}

/* ---- Dataset toggle ---- */
.customer-picker {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.customer-picker-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--sidebar-text-muted);
}
.customer-picker-select {
    padding: 7px 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
}
.customer-picker-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.source-picker-empty {
    padding: 10px;
    font-size: 12px;
    color: var(--sidebar-text-muted);
    text-align: center;
    border: 1px dashed var(--sidebar-border);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
}

.dataset-toggle button.source-live {
    font-weight: 600;
    letter-spacing: 0.5px;
}
.dataset-toggle button.source-live.active {
    background: var(--green);
}

.dataset-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 14px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--sidebar-border);
    background: rgba(0, 0, 0, 0.2);
}

.dataset-toggle button {
    flex: 1;
    padding: 9px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--sidebar-text-muted);
    transition: all var(--ease);
    position: relative;
}

.dataset-toggle button.active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 1px 6px rgba(108, 140, 255, 0.35);
}

.dataset-toggle button:hover:not(.active) {
    background: rgba(255, 255, 255, 0.06);
    color: var(--sidebar-text);
}

/* ---- Filters ---- */
/* ---- Search field with icon ---- */

.search-field {
    position: relative;
    margin-bottom: 10px;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sidebar-text-muted);
    font-size: 14px;
    pointer-events: none;
}

.filter-search-input {
    width: 100%;
    padding: 8px 10px 8px 30px;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--sidebar-text);
    transition: all var(--ease);
    box-sizing: border-box;
}

.filter-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.filter-search-input::placeholder {
    color: var(--sidebar-text-muted);
    opacity: 0.7;
}

/* ---- Segmented control (Review Status) ---- */

.segment-section {
    margin-bottom: 10px;
}

.date-range-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--sidebar-text-muted);
}
.date-range-input {
    flex: 1;
    min-width: 0;
    padding: 5px 7px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 11px;
    font-family: inherit;
}
.date-range-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}
.date-range-input::-webkit-calendar-picker-indicator { filter: invert(0.6); cursor: pointer; }
.date-range-clear {
    background: transparent;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text-muted);
    cursor: pointer;
    padding: 3px 8px;
    font-size: 12px;
    line-height: 1;
}
.date-range-clear:hover { color: var(--red); border-color: var(--red); }

.segment-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--sidebar-text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.segment-bar {
    display: flex;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.segment-btn {
    flex: 1;
    padding: 6px 0;
    border: none;
    background: rgba(0, 0, 0, 0.15);
    color: var(--sidebar-text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--ease);
}

.segment-btn:not(:last-child) {
    border-right: 1px solid var(--sidebar-border);
}

.segment-btn:hover {
    background: rgba(0, 0, 0, 0.25);
    color: var(--sidebar-text);
}

.segment-btn.active {
    background: var(--accent);
    color: white;
}

/* ---- Facet groups (toggle-item design) ---- */

.facet-group {
    margin-bottom: 4px;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.facet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 10px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.15);
    user-select: none;
    transition: background var(--ease);
}

.facet-header:hover {
    background: rgba(0, 0, 0, 0.25);
}

.facet-header-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.facet-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.facet-selected-badge {
    font-size: 10px;
    font-weight: 700;
    background: var(--accent);
    color: white;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 14px;
    text-align: center;
}

.facet-excluded-badge {
    font-size: 10px;
    font-weight: 700;
    background: var(--red);
    color: white;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 14px;
    text-align: center;
}

.facet-clear-btn {
    background: none;
    border: none;
    color: var(--sidebar-text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.facet-clear-btn:hover {
    color: var(--red);
}

.facet-items {
    display: none;
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid var(--sidebar-border);
    background: rgba(0, 0, 0, 0.08);
}

.facet-group.expanded .facet-items {
    display: block;
}

.facet-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
    color: var(--sidebar-text-muted);
    transition: all 0.1s;
}

.facet-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--sidebar-text);
}

.facet-item.facet-item-active {
    background: rgba(108, 140, 255, 0.1);
    color: var(--accent);
}

.facet-item.facet-item-excluded {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
}

.facet-item.facet-item-excluded .facet-item-label {
    text-decoration: line-through;
    opacity: 0.7;
}

.facet-item-indicator {
    font-size: 10px;
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

.facet-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.facet-item-hidden {
    display: none;
}

.facet-show-more {
    padding: 5px 10px;
    font-size: 11px;
    color: var(--accent);
    cursor: pointer;
    text-align: center;
}

.facet-show-more:hover {
    text-decoration: underline;
}

/* ---- Alert list ---- */
#alert-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
}

.alert-card {
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    margin-bottom: 4px;
    cursor: pointer;
    transition: all var(--ease);
    background: rgba(255, 255, 255, 0.04);
}

.alert-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.alert-card.reviewed {
    border-left: 2px solid var(--accent);
}

.alert-card.selected {
    background: var(--accent-muted);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), 0 2px 8px rgba(108, 140, 255, 0.15);
}

.alert-card .card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.alert-card .plate {
    font-weight: 700;
    font-size: 14px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    letter-spacing: 1.5px;
    color: var(--sidebar-text-bright);
}

.alert-card .badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge.infringement {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
}

.badge.officer-rejected {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.badge.pending {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}

.alert-card .card-detail {
    font-size: 11px;
    color: var(--sidebar-text-muted);
    display: flex;
    justify-content: space-between;
}

.alert-card .offence-type {
    font-size: 11px;
    color: var(--sidebar-text-muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* ---- Pagination ---- */
#pagination {
    padding: 10px 18px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--sidebar-text-muted);
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.1);
}

#pagination button {
    padding: 5px 14px;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    color: var(--sidebar-text);
    transition: all var(--ease);
}

#pagination button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent);
    color: var(--accent);
}

#pagination button:disabled {
    opacity: 0.25;
    cursor: default;
}

/* ========================
   Right Panel — Light
   ======================== */
#right-panel {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    background: var(--bg);
}

/* ---- Summary cards ---- */
.summary-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: box-shadow var(--ease);
}

.summary-section:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.summary-ai {
    border-left: 3px solid var(--accent);
}

.summary-ai h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 20px 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-muted {
    color: var(--text-muted);
    font-size: 13px;
}

.ai-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.ai-stats-col {
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.ai-stats-col h4 {
    margin-top: 0;
}

.summary-table.compact td {
    padding: 4px 8px;
    font-size: 12px;
}

.stat-sub {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 400;
}

.summary-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    letter-spacing: -0.01em;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    margin-bottom: 4px;
}

.stat-box {
    text-align: center;
    padding: 18px 16px;
    background: var(--bg);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent);
    transition: transform var(--ease), box-shadow var(--ease);
    position: relative;
}

.stat-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.stat-box.clickable {
    cursor: pointer;
}

.stat-box.clickable:hover {
    border-left-color: var(--accent-hover);
    background: var(--surface);
}

.clickable-row {
    cursor: pointer;
    transition: background 0.1s;
}

.clickable-row:hover {
    background: var(--accent-muted) !important;
}

.stat-box .number {
    font-size: 30px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.stat-box .label {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 500;
}

/* ---- Summary tables ---- */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.summary-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #f0f2f5;
    color: var(--text-secondary);
    transition: background var(--ease);
}

.summary-table tr:hover td {
    background: #f8f9fb;
}

.summary-table .bar-cell {
    width: 50%;
}

.mini-bar {
    height: 7px;
    background: #e8ecf2;
    border-radius: 4px;
    overflow: hidden;
}

.mini-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.4s ease;
}

/* ========================
   Detail View
   ======================== */

/* Back button */
.topbar-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    min-width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    transition: all var(--ease);
    align-self: center;
}

.topbar-back-btn:hover {
    background: var(--bg);
    border-color: var(--accent);
    color: var(--accent);
}

/* Keep old class for backwards compat */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    transition: all var(--ease);
    font-weight: 500;
}

.back-btn:hover {
    background: var(--bg);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateX(-2px);
}

/* Detail topbar — alert + plate + zone + decision in one row */
.detail-topbar {
    display: flex;
    gap: 16px;
    align-items: stretch;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.topbar-alert,
.topbar-plate,
.topbar-zone {
    padding-right: 16px;
    border-right: 1px solid var(--border);
}

.topbar-alert {
    min-width: 160px;
    flex-shrink: 0;
}

.topbar-plate {
    min-width: 130px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.topbar-zone {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-zone-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.topbar-decision {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.detail-topbar .alert-id {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.detail-topbar .event-ids {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.detail-topbar .detected-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.tz-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    opacity: 0.6;
    margin-left: 2px;
}

.detail-topbar .plate-display {
    font-size: 22px;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    letter-spacing: 3px;
    color: var(--text);
    line-height: 1.2;
}

.detail-topbar .plate-secondary {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
    margin-top: 2px;
}

.detail-topbar .vehicle-info {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.detail-topbar .zone-name {
    font-size: 13px;
    color: var(--text);
    font-weight: 600;
    line-height: 1.3;
}

.detail-topbar .offence-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 3px;
    line-height: 1.35;
}

/* Decision badge */
.decision-badge {
    display: flex;
    flex-direction: column;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    text-align: center;
    transition: all var(--ease);
}

.decision-primary {
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.01em;
    white-space: nowrap;
    line-height: 1.3;
}

.decision-raw {
    font-size: 11px;
    margin-top: 3px;
    opacity: 0.7;
    font-style: italic;
    white-space: normal;
    line-height: 1.3;
    max-width: 260px;
}

.decision-badge.accepted {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    color: var(--green-text);
    border: 1px solid #a7f3d0;
}

.decision-badge.rejected {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    color: var(--red-text);
    border: 1px solid #fecaca;
}

.decision-badge.pending {
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    color: #475569;
    border: 1px solid #cbd5e1;
}

/* ---- Image gallery ---- */
.image-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.image-viewer-layout {
    display: flex;
    gap: 0;
}

.image-viewer-main {
    flex: 1;
    min-width: 0;
}

.hero-width-handle {
    width: 12px;
    flex-shrink: 0;
    cursor: ew-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.hero-width-handle::before {
    content: '';
    display: block;
    width: 4px;
    height: 40px;
    border-left: 1px dotted var(--border);
    border-right: 1px dotted var(--border);
}

.hero-width-handle:hover {
    background: var(--accent-muted);
}

.hero-width-handle:hover::before {
    border-color: var(--accent);
}

.hero-image-container {
    width: 100%;
    height: 520px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0a0a12;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    overflow: hidden;
    margin-bottom: 0;
    position: relative;
    outline: none;
}

.hero-image-container img {
    max-width: 100%;
    max-height: 520px;
    object-fit: contain;
    transition: opacity 0.3s ease;
    cursor: zoom-in;
}

/* ---- Fullscreen image overlay ---- */
.image-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    cursor: grab;
}

.image-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-overlay.dragging {
    cursor: grabbing;
}

.overlay-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-image-wrapper img {
    max-width: none;
    max-height: none;
    transform-origin: center center;
    transition: transform 0.15s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.image-overlay.dragging .overlay-image-wrapper img {
    transition: none;
}

.overlay-controls {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    gap: 8px;
    align-items: center;
}

.overlay-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
}

.overlay-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.overlay-zoom-level {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', monospace;
    min-width: 48px;
    text-align: center;
}

.overlay-nav {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    gap: 8px;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 6px 14px;
}

.overlay-nav .overlay-btn {
    width: 30px;
    height: 30px;
    font-size: 16px;
    background: transparent;
    border: none;
}

.overlay-counter {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    font-weight: 500;
    min-width: 60px;
    text-align: center;
}

/* Navigation arrows */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    width: 40px;
    height: 60px;
    font-size: 28px;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ease);
    opacity: 0.6;
    border-radius: 4px;
}

.nav-arrow:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.7);
}

.nav-prev { left: 8px; }
.nav-next { right: 8px; }

/* Image counter */
.image-counter {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
    z-index: 2;
}

/* Side-by-side event comparison (multi-event alerts) */
.hero-compare-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: background var(--ease);
}
.hero-compare-btn:hover {
    background: rgba(0, 0, 0, 0.85);
}

.compare-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(10, 12, 16, 0.96);
    flex-direction: column;
}
.compare-overlay.active {
    display: flex;
}

.compare-topbar {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 10px 16px;
    color: #e6e8ee;
}
.compare-title {
    font-size: 13px;
    font-weight: 600;
    margin-right: auto;
}
.compare-sync-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #c2c6d0;
    cursor: pointer;
    user-select: none;
}

.compare-panes {
    flex: 1;
    display: flex;
    gap: 10px;
    padding: 0 12px 12px;
    min-height: 0;
}

.compare-pane {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid color-mix(in srgb, var(--evt-color) 55%, transparent);
    border-top: 3px solid var(--evt-color);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

.compare-pane-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    color: #e6e8ee;
    font-size: 13px;
}
.compare-pane-header .cph-time {
    font-weight: 700;
    color: var(--evt-color);
}
.compare-pane-header .cph-event {
    color: #8a8f9c;
    font-size: 11px;
}

.compare-pane-img {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.compare-pane-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.compare-pane-caption {
    text-align: center;
    padding: 6px 0 10px;
    font-size: 12px;
    font-weight: 500;
    color: #c2c6d0;
    letter-spacing: 0.3px;
}

/* Event accents — distinguish the capture groups of multi-event alerts
   (e.g. Logan overstay entry/exit pairs). 3-colour cycle. */
:root {
    --evt-1: #0e9f9d;   /* teal */
    --evt-2: #e08a00;   /* amber */
    --evt-3: #9d5bd2;   /* purple */
}
.evt-c1 { --evt-color: var(--evt-1); }
.evt-c2 { --evt-color: var(--evt-2); }
.evt-c3 { --evt-color: var(--evt-3); }

.evt-tag {
    display: inline-block;
    padding: 0 5px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: var(--evt-color);
}

.hero-event-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--evt-color);
    color: #fff;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    z-index: 2;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.thumb-event-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex-shrink: 0;
    align-self: stretch;
    padding: 4px 7px;
    margin: 0 2px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--evt-color) 12%, transparent);
    border-left: 3px solid var(--evt-color);
}
.thumb-event-divider .ted-tag {
    font-size: 11px;
    font-weight: 700;
    color: var(--evt-color);
}
.thumb-event-divider .ted-time {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Tint thumbnail captions with their event colour */
.thumb-wrapper.thumb-evt-c1 .thumbnail-label,
.thumb-wrapper.thumb-evt-c2 .thumbnail-label,
.thumb-wrapper.thumb-evt-c3 .thumbnail-label {
    color: var(--evt-color);
    font-weight: 600;
}
.thumb-wrapper.thumb-evt-c1 { --evt-color: var(--evt-1); }
.thumb-wrapper.thumb-evt-c2 { --evt-color: var(--evt-2); }
.thumb-wrapper.thumb-evt-c3 { --evt-color: var(--evt-3); }

.sidebar-thumb-label.evt-c1,
.sidebar-thumb-label.evt-c2,
.sidebar-thumb-label.evt-c3 {
    color: var(--evt-color);
    font-weight: 600;
}

/* Thumbnail filmstrip (navigable: source + context frames) */
.thumbnail-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 4px;
    background: #f8f9fb;
    border-radius: var(--radius-sm);
    margin: 0 -4px;
}

.thumb-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    transition: transform var(--ease);
}

.thumb-wrapper:hover {
    transform: translateY(-2px);
}

.thumbnail {
    width: 80px;
    height: 60px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.55;
    transition: all var(--ease);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.thumbnail:hover {
    opacity: 0.85;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.thumbnail.active {
    border-color: var(--accent);
    opacity: 1;
    box-shadow: 0 0 0 2px var(--accent-muted), 0 2px 6px rgba(108, 140, 255, 0.2);
}

.thumbnail-label {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* Sidebar thumbnails (plate, crop-wheel, context-sign) */
.image-sidebar {
    flex: 1;
    min-width: 100px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-left: 8px;
    background: #f0f1f4;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: 8px;
}

.sidebar-thumb-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sidebar-thumbnail {
    width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    cursor: pointer;
    border: 2px solid var(--border);
    transition: all var(--ease);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    background: white;
}

.sidebar-thumbnail:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(108, 140, 255, 0.2);
}

.sidebar-thumb-label {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Properties + Review side-by-side ---- */
.props-review-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.props-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* ---- Zone schedule ---- */
.zone-header {
    margin-bottom: 0.5rem;
}
.zone-header .zone-id {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 0.85rem;
    color: var(--text-muted, #888);
}
.zone-header .zone-pk {
    opacity: 0.6;
}
.zone-header .zone-desc {
    font-weight: 500;
    margin-top: 0.15rem;
    word-break: break-word;
}
.zone-active {
    background: rgba(255, 193, 7, 0.10);
    border-left: 3px solid #f0a020;
    padding: 0.4rem 0.6rem;
    margin: 0.3rem 0 0.6rem;
    border-radius: 3px;
    font-size: 0.9rem;
    line-height: 1.45;
}
.zone-active .zone-window {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}
.zone-active .zone-no-match {
    color: var(--text-muted, #888);
    font-style: italic;
}
.zone-schedule-table th {
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted, #888);
    padding: 0.2rem 0.4rem;
    border-bottom: 1px solid var(--border, #e0e0e0);
}
.zone-schedule-table td {
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
}
.zone-schedule-table td:nth-child(3) {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    white-space: nowrap;
}
.zone-schedule-table tr.zone-active-row > td {
    background: rgba(255, 193, 7, 0.18);
    font-weight: 600;
}
.zone-check {
    color: #d97706;
    font-weight: 700;
    margin-left: 0.25rem;
}
.zone-empty {
    padding: 0.5rem 0.6rem;
    color: var(--text-muted, #888);
    font-size: 0.85rem;
    line-height: 1.45;
    font-style: italic;
}
.zone-source-tag {
    margin-left: 0.5rem;
    padding: 0.05rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
    border-radius: 3px;
    vertical-align: middle;
    cursor: help;
}

.review-col {
    flex: 2;
    min-width: 0;
}

/* ---- Review panel ---- */
.review-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: background 400ms ease-out, box-shadow 400ms ease-out;
}

/* External-edit flash — pulses accent when Claude (or another session)
   mutates the current alert's tags/notes. Class set by review-panel.js. */
.review-panel.external-update {
    animation: review-external-flash 800ms ease-out 1;
}
@keyframes review-external-flash {
    0%   { background: var(--accent-muted); box-shadow: 0 0 0 3px var(--accent-muted); }
    100% { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04); }
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.review-title {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 600;
}

.review-save-status {
    font-size: 11px;
    color: var(--accent);
    font-weight: 500;
}

.review-tags-section {
    margin-bottom: 10px;
}

.review-tags-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: var(--accent);
    color: #fff;
    line-height: 1.4;
}

.tag-chip-remove {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
}

.tag-chip-remove:hover {
    color: #fff;
}

.review-tag-input-wrapper {
    position: relative;
}

.review-tag-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}

.review-tag-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.review-tag-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    margin-top: 2px;
}

.tag-suggestion {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
}

.tag-suggestion:hover {
    background: var(--accent-muted);
}

.tag-suggestion-create {
    color: var(--accent);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}

.review-note {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    box-sizing: border-box;
    min-height: 36px;
}

.review-note:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.review-note::placeholder {
    color: var(--text-muted);
}

/* Review tags on alert cards */
.card-review-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.card-tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.2px;
    background: var(--accent-muted);
    color: var(--accent-hover);
    border: 1px solid rgba(108, 140, 255, 0.2);
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* AI mark/queue states on alert cards */
.alert-card.ai-marked {
    border-left: 3px solid #8b5cf6;
}

.alert-card.ai-running {
    border-left: 3px solid var(--accent);
}

.alert-card.ai-queued {
    border-left: 3px solid var(--sidebar-text-muted);
}

.card-ai-status {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.card-ai-marked {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.card-ai-running {
    background: rgba(108, 140, 255, 0.15);
    color: var(--accent);
    border: 1px solid rgba(108, 140, 255, 0.3);
    animation: pulse-waiting 1.5s ease-in-out infinite;
}

.card-ai-queued {
    background: rgba(255, 255, 255, 0.06);
    color: var(--sidebar-text-muted);
    border: 1px solid var(--sidebar-border);
}

#ai-batch-bar {
    flex-shrink: 0;
    padding: 0 12px;
}

/* Batch send bar */
.ai-batch-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-sm);
    gap: 8px;
    margin-bottom: 4px;
}

.ai-batch-info {
    font-size: 11px;
    color: #8b5cf6;
    font-weight: 500;
}

.ai-batch-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.ai-batch-btn {
    padding: 4px 10px;
    background: none;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: #8b5cf6;
    cursor: pointer;
    white-space: nowrap;
}

.ai-batch-btn:hover {
    background: rgba(139, 92, 246, 0.1);
}

.ai-batch-btn.ai-batch-clear {
    color: var(--sidebar-text-muted);
    border-color: var(--sidebar-border);
}

.ai-batch-btn.ai-batch-clear:hover {
    color: var(--red);
    border-color: var(--red);
    background: rgba(239, 68, 68, 0.08);
}

.ai-batch-send-btn {
    padding: 4px 12px;
    background: #8b5cf6;
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.ai-batch-send-btn:hover {
    background: #7c3aed;
}

.card-tag.card-tag-agrees {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
    border-color: rgba(16, 185, 129, 0.3);
}

.card-tag.card-tag-disagrees {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
    border-color: rgba(239, 68, 68, 0.3);
}

.card-note-indicator {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 500;
    font-style: italic;
    background: rgba(253, 230, 138, 0.15);
    color: #fde68a;
    border: 1px solid rgba(253, 230, 138, 0.25);
}

/* ---- Info panels (used by properties) ---- */
.info-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: box-shadow var(--ease);
}

.info-panel:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.info-panel h4 {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 600;
}

/* Properties table */
.props-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}

.props-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f2f5;
    transition: background var(--ease);
}

.props-table tr:hover td {
    background: #f8f9fb;
}

.props-table td:first-child {
    font-weight: 500;
    color: var(--text-muted);
    width: 40%;
    font-size: 12px;
}

.props-table td:last-child {
    color: var(--text);
}

/* Vehicle info */
.vehicle-info {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.vehicle-info span {
    text-transform: capitalize;
}

/* ---- Map section ---- */
.map-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.map-section h4 {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 600;
}

.map-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.map-panel {
    height: 350px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

/* ========================
   Scrollbars — slim & subtle
   ======================== */
#alert-list::-webkit-scrollbar,
.thumbnail-strip::-webkit-scrollbar,
.facet-items::-webkit-scrollbar,
#right-panel::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

#alert-list::-webkit-scrollbar-track,
.facet-items::-webkit-scrollbar-track {
    background: transparent;
}

#alert-list::-webkit-scrollbar-thumb,
.facet-items::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

#alert-list::-webkit-scrollbar-thumb:hover,
.facet-items::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.thumbnail-strip::-webkit-scrollbar-thumb,
#right-panel::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.thumbnail-strip::-webkit-scrollbar-thumb:hover,
#right-panel::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ========================
   Loading state
   ======================== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

/* Loading inside dark sidebar */
#alert-list .loading {
    color: var(--sidebar-text-muted);
}

/* ========================
   Keyboard help badge
   ======================== */
.kbd-help {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

.kbd-help-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--sidebar-bg);
    color: var(--sidebar-text-muted);
    font-size: 14px;
    font-weight: 700;
    cursor: default;
    border: 1px solid var(--sidebar-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all var(--ease);
}

.kbd-help:hover .kbd-help-icon {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.kbd-help-panel {
    display: none;
    position: absolute;
    bottom: 42px;
    right: 0;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    min-width: 260px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.kbd-help:hover .kbd-help-panel {
    display: block;
}

.kbd-help-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--sidebar-text-muted);
    font-weight: 600;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--sidebar-border);
}

.kbd-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 12.5px;
    color: var(--sidebar-text);
}

.kbd-row span {
    margin-left: auto;
    color: var(--sidebar-text-muted);
    font-size: 12px;
}

kbd {
    display: inline-block;
    padding: 2px 7px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--sidebar-border);
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
    color: var(--sidebar-text-bright);
    line-height: 1.4;
    min-width: 24px;
    text-align: center;
}

/* ---- Review/AI Review Tabs ---- */

.review-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.review-tab {
    padding: 8px 16px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}

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

.review-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ---- AI Review Panel ---- */

.ai-review-panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
}

.ai-review-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.ai-mark-btn {
    padding: 6px 14px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.ai-mark-btn:hover {
    border-color: #8b5cf6;
    color: #8b5cf6;
}

.ai-mark-btn.marked {
    background: rgba(139, 92, 246, 0.1);
    border-color: #8b5cf6;
    color: #8b5cf6;
    font-weight: 600;
}

.ai-review-send-btn {
    padding: 8px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-review-send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.ai-review-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-review-send-btn.waiting {
    background: var(--text-muted);
    opacity: 1;
    animation: pulse-waiting 1.5s ease-in-out infinite;
}

@keyframes pulse-waiting {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.ai-review-status {
    font-size: 12px;
    font-weight: 500;
}

.ai-review-status.ai-approve { color: var(--green); }
.ai-review-status.ai-reject { color: var(--red); }
.ai-review-status.ai-error { color: var(--red); }
.ai-review-status.ai-waiting { color: var(--text-muted); font-family: 'SF Mono', monospace; }

.ai-review-empty {
    color: var(--text-muted);
    font-size: 13px;
    padding: 12px 0;
}

.ai-review-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 10px;
    background: var(--bg);
}

.ai-review-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.ai-review-decision {
    font-weight: 700;
    font-size: 13px;
    padding: 2px 10px;
    border-radius: 12px;
}

.ai-review-decision.ai-approve {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.ai-review-decision.ai-reject {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.ai-review-model {
    font-size: 10px;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', monospace;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(108, 140, 255, 0.1);
    color: var(--accent);
}

.ai-review-mode-chip {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(139, 143, 163, 0.1);
    color: var(--text-muted);
}

.ai-agreement-chip {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
}

.ai-agreement-chip.ai-agrees {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.ai-agreement-chip.ai-disagrees {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.ai-review-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'SF Mono', monospace;
}

.ai-review-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}

.ai-review-reason {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.ai-review-events {
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 8px;
}

.ai-event-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 2px 0;
}

.ai-event-plate {
    font-family: 'SF Mono', monospace;
    font-weight: 600;
}

.ai-ocr-mismatch {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
}

.ai-event-state {
    background: var(--accent-muted);
    color: var(--accent);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
}

.ai-event-vehicle {
    color: var(--text-muted);
}

.ai-review-tokens {
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'SF Mono', monospace;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}
.ai-review-tokens strong {
    font-weight: 700;
    color: var(--text-secondary);
}
.ai-review-sep {
    color: var(--text-muted);
    margin: 0 4px;
}
.ai-review-requested {
    color: var(--text-muted);
    font-style: italic;
    font-weight: normal;
}

/* Queue status */

.ai-queue-status {
    margin-bottom: 12px;
}

.ai-queue-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
}

.ai-queue-item.ai-queue-running {
    background: rgba(108, 140, 255, 0.08);
    color: var(--accent);
}

.ai-queue-item.ai-queue-queued {
    background: var(--bg);
    color: var(--text-muted);
}

.ai-queue-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ai-queue-dot.running {
    background: var(--accent);
    animation: pulse-waiting 1.5s ease-in-out infinite;
}

.ai-queue-dot.queued {
    background: var(--text-muted);
}

/* Queue chips — collapsible per-status groups */
.ai-queue-status {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.ai-chip-group {
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    flex: 1;
    min-width: 0;
}

.ai-chip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    user-select: none;
    transition: background 0.1s;
}

.ai-chip-header:hover {
    filter: brightness(0.95);
}

.ai-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ai-chip-summary {
    flex: 1;
}

.ai-chip-chevron {
    font-size: 10px;
    color: inherit;
    opacity: 0.5;
}

.ai-chip-alerts {
    padding: 2px 10px 6px 26px;
    font-size: 11px;
    font-family: 'SF Mono', monospace;
    max-height: 150px;
    overflow-y: auto;
}

.ai-chip-alert {
    padding: 2px 0;
}

.ai-chip-elapsed {
    color: inherit;
    opacity: 0.6;
    margin-left: 4px;
}

.ai-chip-config {
    font-size: 10px;
    opacity: 0.7;
    padding-left: 12px;
}

/* Running — blue */
.ai-chip-running { background: rgba(108, 140, 255, 0.08); }
.ai-chip-running .ai-chip-header { color: var(--accent); }
.ai-chip-running .ai-chip-dot { background: var(--accent); animation: pulse-waiting 1.5s ease-in-out infinite; }
.ai-chip-running .ai-chip-alerts { color: var(--accent); }

/* Pending — grey */
.ai-chip-pending { background: rgba(0, 0, 0, 0.03); }
.ai-chip-pending .ai-chip-header { color: var(--text-muted); }
.ai-chip-pending .ai-chip-dot { background: var(--text-muted); }
.ai-chip-pending .ai-chip-alerts { color: var(--text-secondary); }

/* Done — green */
.ai-chip-done { background: rgba(16, 185, 129, 0.06); }
.ai-chip-done .ai-chip-header { color: #059669; }
.ai-chip-done .ai-chip-dot { background: #10b981; }
.ai-chip-done .ai-chip-alerts { color: #059669; }

/* Error — red */
.ai-chip-error { background: rgba(239, 68, 68, 0.06); }
.ai-chip-error .ai-chip-header { color: #dc2626; }
.ai-chip-error .ai-chip-dot { background: #ef4444; }
.ai-chip-error .ai-chip-alerts { color: #dc2626; }

#ai-review-history {
    max-height: 500px;
    overflow-y: auto;
}

.ai-review-maximize-btn {
    margin-left: auto;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 8px;
    line-height: 1;
    transition: all var(--ease);
}
.ai-review-maximize-btn:hover { color: var(--accent); border-color: var(--accent); }

.ai-review-maximized {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    border-radius: 0;
    padding: 20px 28px;
    overflow-y: auto;
}
.ai-review-maximized #ai-review-history {
    max-height: none;
    overflow-y: visible;
}

/* ========================
   Settings Page
   ======================== */

.settings-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 10px;
    line-height: 1;
    transition: all var(--ease);
}
.settings-btn:hover { color: var(--accent); border-color: var(--accent); }
.settings-btn.active { color: var(--accent); background: var(--accent-muted); border-color: var(--accent); }

.settings-page {
    padding: 28px 32px;
}
.settings-page > :not([data-tab-content="prompts"]):not(.settings-header) {
    max-width: 900px;
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.settings-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.settings-tabs {
    display: flex;
    gap: 2px;
    margin-left: auto;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.settings-tab {
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 5px;
    transition: all var(--ease);
}
.settings-tab:hover { color: var(--text); background: var(--surface); }
.settings-tab.active {
    color: var(--accent);
    background: var(--surface);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    font-weight: 600;
}

.settings-tab-content { display: none; }
.settings-tab-content.active { display: block; }

.settings-section {
    margin-bottom: 24px;
}
.settings-section h3 {
    margin-bottom: 16px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

/* Config list */
.settings-configs-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
}
.settings-configs-header h3 { margin-bottom: 0; }
.settings-configs-hint {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}
.settings-configs-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}

/* Each config is a card */
#config-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: opacity var(--ease), box-shadow var(--ease);
}
.config-row:hover {
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
/* When followed by an API key row, connect them visually */
.config-row:has(+ .config-api-key-row) {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
}
.config-row-disabled { opacity: 0.4; }

/* Toggle switch */
.config-toggle {
    position: relative;
    width: 34px;
    height: 19px;
    flex-shrink: 0;
    cursor: pointer;
}
.config-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.config-toggle-slider {
    position: absolute;
    inset: 0;
    background: #d0d3dc;
    border-radius: 10px;
    transition: background var(--ease);
}
.config-toggle-slider::before {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    left: 2px;
    top: 2px;
    background: white;
    border-radius: 50%;
    transition: transform var(--ease);
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.config-toggle input:checked + .config-toggle-slider {
    background: var(--accent);
}
.config-toggle input:checked + .config-toggle-slider::before {
    transform: translateX(15px);
}

.config-mode, .config-model, .config-effort {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    transition: border-color var(--ease);
}
.config-mode { min-width: 140px; }
.config-model { min-width: 150px; }
.config-effort { min-width: 70px; }
.config-mode:focus, .config-model:focus, .config-effort:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.config-alias {
    width: 90px;
    padding: 6px 8px !important;
    font-size: 12px !important;
    /* Same reasoning as .config-api-key: avoid SF Mono descender clip +
       Fira Code underscore ligatures. */
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-variant-ligatures: none;
    font-feature-settings: "liga" 0, "calt" 0;
    line-height: 1.5;
}
.config-alias-spacer { width: 90px; flex-shrink: 0; }

.config-api-key-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 10px 52px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    margin-bottom: 0;
}
.config-api-key-row .config-key-alias {
    width: 110px;
    flex-shrink: 0;
    font-size: 12px;
    font-style: italic;
}
.config-api-key-row .config-api-key {
    flex: 1;
    font-size: 12px;
    /* ui-monospace first so SF Mono's low-descender `_` doesn't clip; drop
       Fira Code from the stack because its underscore ligatures can render
       invisibly thin at 12px. Keep ligatures off regardless as defence. */
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-variant-ligatures: none;
    font-feature-settings: "liga" 0, "calt" 0;
    line-height: 1.5;
}
.config-api-key-row .settings-reveal-btn {
    position: static;
    transform: none;
    flex-shrink: 0;
}

.config-delete {
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 3px 7px;
    line-height: 1;
    transition: all var(--ease);
    flex-shrink: 0;
    margin-left: auto;
}
.config-delete:hover { color: var(--red); border-color: var(--red); background: var(--red-bg); }

/* Add buttons */
.settings-add-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 16px 0;
}
.settings-add-config-btn {
    background: none;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--accent);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    padding: 6px 14px;
    transition: all var(--ease);
}
.settings-add-config-btn:hover { border-color: var(--accent); background: var(--accent-muted); }

/* Help details */
.settings-help {
    margin: 12px 0 4px;
    font-size: 12px;
    color: var(--text-muted);
}
.settings-help summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 500;
    user-select: none;
}
.settings-help summary:hover { text-decoration: underline; }
.settings-help-body {
    margin-top: 8px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    line-height: 1.6;
}
.settings-help-body p { margin: 0 0 8px; }
.settings-help-body p:last-child { margin-bottom: 0; }
.settings-help-body code {
    background: rgba(108, 140, 255, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.settings-help-body pre {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
    margin: 8px 0;
}

/* Form elements */
.settings-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}
.settings-row .settings-field { flex: 1; }

.settings-field {
    margin-bottom: 10px;
}

.settings-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    display: block;
}

.settings-input, .settings-select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    transition: border-color var(--ease);
}
.settings-input:focus, .settings-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.settings-input-wrap {
    position: relative;
    display: flex;
}
.settings-input-wrap .settings-input {
    padding-right: 36px;
}
.settings-reveal-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    opacity: 0.5;
    transition: opacity var(--ease);
}
.settings-reveal-btn:hover { opacity: 1; }

.settings-env-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 20px;
}

.settings-budgets-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 8px 0;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.settings-budget-field { display: flex; flex-direction: column; gap: 4px; }
.settings-budget-field .settings-label { font-size: 10px; letter-spacing: 0.8px; }
.settings-budget-input { width: 100%; text-align: right; }

/* Aliases */
.settings-alias-section {
    margin-bottom: 8px;
}
.settings-alias-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    align-items: center;
}
.settings-alias-row .settings-input { flex: 1; }
.settings-alias-name { max-width: 160px; }
.settings-alias-remove {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 5px 8px;
    transition: all var(--ease);
}
.settings-alias-remove:hover { color: var(--red); border-color: var(--red); }

.settings-alias-add {
    background: none;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--accent);
    cursor: pointer;
    font-size: 12px;
    padding: 6px 14px;
    transition: all var(--ease);
}
.settings-alias-add:hover { border-color: var(--accent); background: var(--accent-muted); }

/* Actions row */
.settings-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.settings-save-btn {
    padding: 8px 22px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ease);
    box-shadow: 0 1px 3px rgba(108, 140, 255, 0.25);
}
.settings-save-btn:hover { background: var(--accent-hover); box-shadow: 0 2px 6px rgba(108, 140, 255, 0.35); }

.settings-danger-btn {
    background: transparent;
    color: var(--red);
    border: 1px solid var(--red);
    box-shadow: none;
}
.settings-danger-btn:hover { background: rgba(239, 68, 68, 0.1); box-shadow: none; }

.settings-cancel-btn {
    padding: 8px 18px;
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--ease);
}
.settings-cancel-btn:hover { border-color: var(--text-muted); color: var(--text); }

.settings-preview-btn {
    padding: 8px 18px;
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--ease);
}
.settings-preview-btn:hover:not(:disabled) { background: var(--accent-muted); }
.settings-preview-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Rendered-markdown preview modal (prompt editors) ---- */
.md-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(20, 22, 30, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    backdrop-filter: blur(2px);
}

.md-modal {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: min(860px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.md-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.md-modal-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.md-modal-close {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--ease);
}
.md-modal-close:hover { background: var(--border); color: var(--text); }

.md-modal-body {
    padding: 22px 26px;
    overflow-y: auto;
}

.md-modal-empty { color: var(--text-muted); font-style: italic; }

/* Rendered markdown typography — scoped so it can't leak into the app chrome. */
.markdown-body { font-size: 14px; line-height: 1.65; color: var(--text); }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    margin: 1.4em 0 0.5em;
    font-weight: 650;
    line-height: 1.3;
    color: var(--text);
}
.markdown-body h1 { font-size: 1.55em; }
.markdown-body h2 { font-size: 1.3em; padding-bottom: 0.25em; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.12em; }
.markdown-body h4 { font-size: 1em; }
.markdown-body p { margin: 0.6em 0; }
.markdown-body ul, .markdown-body ol { margin: 0.6em 0; padding-left: 1.6em; }
.markdown-body li { margin: 0.25em 0; }
.markdown-body li > ul, .markdown-body li > ol { margin: 0.25em 0; }
.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body strong { font-weight: 650; color: var(--text); }
.markdown-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.88em;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1em 0.35em;
}
.markdown-body pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    overflow-x: auto;
    margin: 0.8em 0;
}
.markdown-body pre code { background: none; border: none; padding: 0; font-size: 0.85em; }
.markdown-body blockquote {
    margin: 0.8em 0;
    padding: 0.2em 1em;
    border-left: 3px solid var(--accent);
    color: var(--text-secondary);
}
.markdown-body table {
    border-collapse: collapse;
    margin: 0.8em 0;
    font-size: 0.92em;
}
.markdown-body th, .markdown-body td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
}
.markdown-body th { background: var(--bg); font-weight: 600; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.markdown-body img { max-width: 100%; }

.settings-status {
    font-size: 12px;
    transition: opacity 0.3s;
}
.settings-status-success { color: var(--green); }
.settings-status-error { color: var(--red); }
.settings-status-info { color: var(--accent); }

/* Live-connection tab inline status */
.settings-status-ok  { color: var(--green); }
.settings-status-err { color: var(--red); }
.live-status-line { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.live-status-sep { color: var(--text-muted); opacity: 0.5; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.live-dot-up      { background: var(--green); box-shadow: 0 0 4px rgba(16, 185, 129, 0.6); }
.live-dot-down    { background: var(--red); }
.live-dot-stale   { background: var(--amber, #f59e0b); box-shadow: 0 0 4px rgba(245, 158, 11, 0.6); }
.live-dot-unknown { background: var(--text-muted); }

/* Left-panel live sync bar (shown only for live sources) */
.live-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    margin: 6px 0;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.live-bar-stale {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.4);
}
.live-bar-text { flex: 1; min-width: 0; }
.live-bar-flag { color: var(--amber, #f59e0b); font-weight: 700; }
.live-bar-sep { opacity: 0.5; margin: 0 2px; }
.live-bar-btn {
    flex-shrink: 0;
    padding: 4px 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ease);
}
.live-bar-btn:hover:not(:disabled) { background: var(--accent-hover); }
.live-bar-btn:disabled { opacity: 0.6; cursor: default; }

/* Prompt textareas */
.settings-prompt-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 4px;
}
.settings-prompt-header h3 { margin-bottom: 0; font-size: 14px; }

.settings-prompt-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 10px 0;
    line-height: 1.5;
}

.settings-prompt-textarea {
    width: 100%;
    min-height: 220px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 12px;
    line-height: 1.7;
    resize: vertical;
    tab-size: 4;
    transition: border-color var(--ease), box-shadow var(--ease);
}
.settings-prompt-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

/* Sidebar-footer toggle button (used by CTX next to Settings) */
.sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 10px;
    line-height: 1;
    transition: all var(--ease);
    letter-spacing: 0.5px;
}
.sidebar-toggle-btn:hover { color: var(--accent); border-color: var(--accent); }
.sidebar-toggle-btn.active { color: var(--accent); background: var(--accent-muted); border-color: var(--accent); }

/* "Add to AR" button in AI review panel */
.ai-ar-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 4px 10px;
    cursor: pointer;
    transition: all var(--ease);
}
.ai-ar-btn:hover { color: var(--orange); border-color: var(--orange); }
.ai-ar-btn.in-ar {
    color: var(--orange);
    border-color: var(--orange);
    background: var(--orange-bg);
    font-weight: 600;
}

/* AR view layout */
/* ===================================================
   Logging Styles
   =================================================== */

.settings-logging-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}
.settings-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}
.settings-toggle-label input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

.settings-log-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
    font-size: 12px;
}
.settings-log-filters label {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

.settings-log-entries {
    max-height: 600px;
    overflow-y: auto;
}

.settings-log-entry {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
}
.settings-log-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}
.settings-log-summary:hover { background: var(--bg); }
.settings-log-time { color: var(--text-muted); min-width: 140px; }
.settings-log-pk { font-family: monospace; font-weight: 600; min-width: 60px; }
.settings-log-dataset { color: var(--text-muted); }
.settings-log-source {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--bg);
    color: var(--text-secondary);
}
.settings-log-model { font-weight: 600; color: var(--text); }
.settings-log-effort { color: var(--text-muted); }
.settings-log-agree { color: var(--text-secondary); font-size: 11px; }
.settings-log-elapsed { color: var(--text-muted); }

.settings-log-detail {
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    line-height: 1.7;
}
.settings-log-detail > div { margin-bottom: 4px; }
.settings-log-reason { color: var(--text-secondary); }

.settings-log-raw summary {
    color: var(--accent);
    cursor: pointer;
    font-size: 11px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
}
.settings-log-raw summary::-webkit-details-marker { display: none; }
.settings-log-raw summary::before {
    content: '';
    flex: 0 0 auto;
    width: 0;
    height: 0;
    border-left: 4px solid currentColor;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    transition: transform 0.12s ease;
}
.settings-log-raw[open] > summary::before {
    transform: rotate(90deg);
}
.settings-log-raw summary .log-summary-text {
    flex: 1 1 auto;
    min-width: 0;
}
.log-copy-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 0;
}
.log-copy-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--bg);
}
.log-copy-btn.log-copy-ok {
    color: #10b981;
    border-color: #10b981;
}
.log-copy-btn.log-copy-fail {
    color: #ef4444;
    border-color: #ef4444;
}
.settings-log-json {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    font-size: 10px;
    line-height: 1.5;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ---- Context-image panel (per-alert add/edit/summary) ---- */
.ctx-panel {
    padding: 10px 12px;
    font-size: 13px;
}
.ctx-summary-head,
.ctx-editor-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 8px;
}
.ctx-tag-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    background: #5b21b6;
    color: white;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.ctx-actions {
    display: flex;
    gap: 6px;
}
.ctx-btn {
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    cursor: pointer;
}
.ctx-btn:hover { background: #f3f4f6; }
.ctx-btn-primary {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}
.ctx-btn-primary:hover { background: #1d4ed8; }
.ctx-btn-danger {
    color: #b91c1c;
    border-color: #fca5a5;
}
.ctx-btn-danger:hover { background: #fee2e2; }
.ctx-btn-secondary { }

.ctx-caption {
    padding: 8px 10px;
    background: #f9fafb;
    border-left: 3px solid #8b5cf6;
    margin-bottom: 10px;
    line-height: 1.4;
}
.ctx-caption-empty { color: #9ca3af; font-style: italic; }

.ctx-frame-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}
.ctx-frame-card {
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    background: #f9fafb;
}
.ctx-frame-card img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; }
.ctx-frame-missing {
    padding: 24px; text-align: center; color: #9ca3af; background: #f3f4f6;
}
.ctx-frame-name {
    font-size: 10px;
    padding: 3px 6px;
    color: #6b7280;
    background: white;
    border-top: 1px solid #e5e7eb;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ctx-meta { color: #9ca3af; font-size: 11px; }

.ctx-label {
    display: block;
    margin: 10px 0 4px;
    font-weight: 600;
    font-size: 12px;
    color: #374151;
}
.ctx-hint { font-weight: 400; color: #9ca3af; font-size: 11px; }
.ctx-category-row { display: flex; gap: 6px; align-items: center; }
.ctx-select, .ctx-input, .ctx-textarea {
    padding: 5px 8px;
    font-size: 13px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-family: inherit;
}
.ctx-select { flex: 0 0 auto; }
.ctx-input { flex: 1; }
.ctx-textarea { width: 100%; box-sizing: border-box; resize: vertical; }

.ctx-frame-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #f9fafb;
}
.ctx-frame-pick {
    position: relative;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    background: white;
    display: flex;
    flex-direction: column;
}
.ctx-frame-pick:has(input:checked) {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px #2563eb;
}
.ctx-frame-pick img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; }
.ctx-frame-pick input[type="checkbox"] {
    position: absolute;
    top: 4px; left: 4px;
    width: 16px; height: 16px;
    cursor: pointer;
}
.ctx-frame-pick .ctx-frame-name {
    padding: 2px 5px;
    font-size: 10px;
    border-top: 1px solid #e5e7eb;
}

.ctx-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    gap: 10px;
}
.ctx-status { color: #6b7280; font-size: 12px; }

/* ---- Context-images gallery view (sidebar toggle) ---- */
.ctx-view-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid #e5e7eb;
}
.ctx-view-header h2 { margin: 0; font-size: 18px; }
.ctx-view-hint {
    padding: 8px 18px; color: #6b7280; font-size: 12px;
    background: #f9fafb; border-bottom: 1px solid #e5e7eb;
}
.ctx-view-body {
    padding: 12px 18px 24px; overflow-y: auto; max-height: calc(100vh - 130px);
}
.ctx-view-summary {
    padding: 10px 12px; background: #eff6ff; border: 1px solid #bfdbfe;
    border-radius: 4px; margin-bottom: 16px; font-size: 13px;
}
.ctx-view-cats { color: #374151; font-size: 11px; margin-top: 4px; }
.ctx-view-shared-badge {
    display: inline-block; margin-left: 6px; padding: 1px 8px;
    background: #6c8cff; color: #fff; border-radius: 10px;
    font-size: 11px; font-weight: 600; vertical-align: middle;
}
.ctx-view-empty { padding: 30px; text-align: center; color: #9ca3af; }

.ctx-view-category { margin-bottom: 22px; }
.ctx-view-cat-head {
    display: flex; justify-content: space-between; align-items: center;
    margin: 0 0 8px; padding: 0; font-size: 14px; font-weight: 600;
}
.ctx-view-cat-count { color: #9ca3af; font-size: 11px; font-weight: 400; }
.ctx-view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}
.ctx-view-card {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    background: white;
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.ctx-view-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-color: #9ca3af;
}
.ctx-view-card-thumbs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: #e5e7eb;
    position: relative;
}
.ctx-view-card-thumbs img {
    width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: #f9fafb;
}
.ctx-view-more {
    position: absolute;
    right: 4px; bottom: 4px;
    background: rgba(0,0,0,0.6); color: white;
    padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: 600;
}
.ctx-view-card-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 10px 2px; font-size: 12px;
}
.ctx-view-pk { font-weight: 600; color: #111827; }
.ctx-view-split { color: #9ca3af; text-transform: uppercase; font-size: 10px; }
.ctx-view-caption {
    padding: 4px 10px; color: #374151; font-size: 12px; line-height: 1.4;
    max-height: 3.5em; overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.ctx-view-meta { padding: 4px 10px 8px; color: #9ca3af; font-size: 10px; }

.config-prompt-variant {
    flex: 0 0 auto;
    font-size: 11px;
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #f9fafb;
    color: #374151;
    max-width: 200px;
}

/* ---- Workflow-impact overlay on the summary page ---- */
.workflow-impact-section {
    margin: 18px 0 22px;
}
.workflow-impact-heading {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 10px;
}
.workflow-impact-heading h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    color: #111827;
}
.workflow-impact-sub {
    font-size: 11px;
    color: #6b7280;
}

.workflow-impact {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: start;
}
.impact-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

/* Accent-left border for kinship with .stat-box elsewhere in the viewer. */
.impact-tile {
    padding: 12px 14px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    border-left-width: 3px;
    background: var(--surface);
}
/* Operationally-meaningful thresholds only: loss rate (green/amber/red) and
   the "insufficient data" muted state. Other tiles use a steady neutral
   palette so there's no implicit "good/bad" signal when thresholds aren't
   disclosed. */
.impact-tile.impact-info  { background: #f9fafb; border-left-color: #6b7280; }
.impact-tile.impact-good  { background: #ecfdf5; border-left-color: #10b981; }
.impact-tile.impact-warn  { background: #fffbeb; border-left-color: #f59e0b; }
.impact-tile.impact-bad   { background: #fef2f2; border-left-color: #dc2626; }
.impact-tile.impact-muted { background: #f9fafb; border-left-color: #9ca3af; color: #6b7280; }

.impact-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: #111827;
}
.impact-tile.impact-info  .impact-value { color: #374151; }
.impact-tile.impact-good  .impact-value { color: #047857; }
.impact-tile.impact-warn  .impact-value { color: #b45309; }
.impact-tile.impact-bad   .impact-value { color: #b91c1c; }
.impact-tile.impact-muted .impact-value { color: #9ca3af; }

.impact-label {
    margin-top: 2px;
    font-size: 13px;
    font-weight: 600;
    color: #111827;
}
.impact-sub {
    margin-top: 2px;
    font-size: 11px;
    color: #6b7280;
    line-height: 1.35;
}
.impact-detail {
    margin-top: 6px;
    font-size: 11px;
    color: #374151;
    font-variant-numeric: tabular-nums;
}

/* Confusion matrix — real <table>, smaller counts than the tiles so it reads
   as subordinate supporting detail rather than competing headline numbers. */
.impact-matrix {
    border-collapse: separate;
    border-spacing: 4px;
    font-size: 12px;
    align-self: center;
}
.impact-matrix th {
    font-weight: 600;
    color: #374151;
    padding: 2px 8px;
    background: transparent;
}
.impact-matrix .matrix-corner {
    padding: 0;
    background: transparent;
    border: 0;
}
.impact-matrix .matrix-gt-head {
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-bottom: 2px;
}
.impact-matrix thead tr:last-child th {
    font-size: 11px;
    padding-bottom: 4px;
}
.matrix-n { margin-left: 4px; color: #9ca3af; font-weight: 400; }

.matrix-row-head {
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    color: #111827;
    padding: 6px 8px 6px 0;
    vertical-align: middle;
}
.matrix-row-sub { font-weight: 400; color: #6b7280; font-size: 10px; }

.matrix-cell {
    padding: 8px 12px;
    border-radius: 4px;
    min-width: 86px;
    text-align: center;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.matrix-cell:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.matrix-cell:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.matrix-cell .cell-count {
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.matrix-cell .cell-code {
    margin-top: 2px;
    font-size: 10px;
    color: #6b7280;
    letter-spacing: 0.02em;
}

/* TP = real infringement caught (green = "correct work").
   TN = non-violation filtered (blue = "work avoided") — kept visually
        distinct from TP so the matrix reads as diagnostic, not just
        "green = good".
   FP = wasted officer review (amber = noted but not urgent).
   FN = lost infringement (red = unrecoverable). */
.cell-tp { background: #ecfdf5; border-color: #a7f3d0; }
.cell-tp .cell-count { color: #047857; }
.cell-tn { background: #eff6ff; border-color: #bfdbfe; }
.cell-tn .cell-count { color: #1d4ed8; }
.cell-fp { background: #fffbeb; border-color: #fcd34d; }
.cell-fp .cell-count { color: #b45309; }
.cell-fn { background: #fef2f2; border-color: #fecaca; }
.cell-fn .cell-count { color: #b91c1c; }

/* Alarm state on FN > 0 combines a glow AND an explicit "LOST" text label
   (set in JS) so the warning isn't colour-only. */
.cell-alarm {
    box-shadow: 0 0 0 2px #f87171, 0 0 8px rgba(248, 113, 113, 0.4);
}
.cell-alarm .cell-code {
    color: #991b1b;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.workflow-impact-caption {
    margin-top: 10px;
    font-size: 11px;
    color: #6b7280;
    line-height: 1.5;
}
.workflow-impact-caption strong { color: #111827; font-weight: 600; }

/* Stack below ~1100px so the matrix doesn't squish the tiles */
@media (max-width: 1100px) {
    .workflow-impact { grid-template-columns: 1fr; }
    .impact-matrix { align-self: stretch; justify-self: start; }
}

/* ---- CTX gallery: export button + status banner ---- */
.ctx-view-header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.ctx-view-status {
    margin: 8px 18px 0;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
    border: 1px solid transparent;
}
.ctx-view-status-pending {
    background: #eff6ff; color: #1e40af; border-color: #bfdbfe;
}
.ctx-view-status-success {
    background: #ecfdf5; color: #065f46; border-color: #a7f3d0;
}
.ctx-view-status-error {
    background: #fef2f2; color: #991b1b; border-color: #fecaca;
}
.ctx-view-status code {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 11px;
    background: rgba(0,0,0,0.05);
    padding: 1px 4px;
    border-radius: 3px;
}
.ctx-view-status-cats {
    margin-top: 4px;
    font-size: 11px;
    color: #374151;
    font-variant-numeric: tabular-nums;
}
.ctx-btn[disabled] { opacity: 0.55; cursor: progress; }

/* ---- Floating panel layout (alert detail view) ---- */

.float-canvas {
    position: relative;
    width: 100%;
}

.float-win {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.float-win.dragging {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}

.float-win__bar {
    height: 26px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 0 12px;
    cursor: grab;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    user-select: none;
}

.float-win.dragging .float-win__bar {
    cursor: grabbing;
}

.float-win__body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    position: relative;
}

/* Resize handles */
.float-win__rs {
    position: absolute;
    z-index: 5;
}
.float-win__rs--e {
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
}
.float-win__rs--s {
    left: 0;
    bottom: 0;
    height: 6px;
    width: 100%;
    cursor: ns-resize;
}
.float-win__rs--se {
    right: 0;
    bottom: 0;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
}

/* Maps and other embeds must not swallow mousemove mid-drag */
.float-canvas.float-dragging .float-win__body {
    pointer-events: none;
}

/* Snap guide line at canvas left / center / right */
.float-snap-guide {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--accent);
    pointer-events: none;
    z-index: 9999;
}

/* Reset-layout button in the detail topbar */
.topbar-reset-btn {
    align-self: center;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--ease);
}

.topbar-reset-btn:hover {
    background: var(--bg);
    border-color: var(--accent);
    color: var(--accent);
}

/* ---- Floated panel chrome overrides ----
   The .float-win provides border/background/title; inner panels drop their
   own so we don't get double chrome. Inner h4 headings duplicate the window
   title bar, so hide them (roughly offsets the bar's added height too). */

.float-win .info-panel,
.float-win .image-section {
    border: none;
    box-shadow: none;
    border-radius: 0;
    margin-bottom: 0;
}

/* Keep h4s carrying extra info (e.g. the zone "GPS-resolved" tag) */
.float-win .info-panel > h4:not(:has(.zone-source-tag)) {
    display: none;
}

/* Image window: hero flexes to fill whatever height the window has */
.float-win .image-section {
    height: 100%;
    padding: 12px;
    display: flex;
    flex-direction: column;
}
.float-win .image-viewer-layout {
    flex: 1;
    min-height: 0;
}
.float-win .image-viewer-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.float-win .hero-image-container {
    height: auto;
    flex: 1;
    min-height: 0;
    border-radius: var(--radius-md);
}
.float-win .hero-image-container img {
    max-height: 100%;
}
.float-win .thumbnail-strip {
    flex-shrink: 0;
}
.float-win .image-sidebar {
    overflow-y: auto;
}

/* Map windows: fill the window body exactly */
.float-win .map-panel {
    height: 100%;
    border-radius: 0;
}

/* Zone group keeps spacing between multiple zone panels */
.float-win .zone-group .info-panel + .info-panel {
    border-top: 1px solid var(--border);
}

/* ---- Remote AI review panel (on-server agent results) ---- */

.ai-agreement-chip.ai-no-gt {
    background: rgba(148, 163, 184, 0.15);
    color: #64748b;
}

.remote-ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.remote-ai-title {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 600;
}

.remote-ai-count {
    font-size: 11px;
    color: var(--text-muted);
}

.remote-ai-usage {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.remote-ai-raw {
    margin-top: 8px;
    padding: 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 11px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 240px;
    overflow: auto;
}

.cell-officer-split {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

/* Tag chips with a colour from the tags table (e.g. R-Approved/R-Rejected) */
.card-tag-colored {
    color: #fff;
}

.cell-pct {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

/* ---- Load-error panel (components/load-error.js) ---- */
/* Shown in place of the summary/detail when an API load fails — notably the
   tunnel_down 503 from a live source whose SSH tunnel isn't up. */
.load-error {
    max-width: 620px;
    margin: 48px auto;
    padding: 24px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
}

.load-error h2 {
    margin: 0 0 12px;
    font-size: 18px;
}

.load-error h3 {
    margin: 18px 0 8px;
    font-size: 14px;
}

.load-error p {
    margin: 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.load-error ol {
    margin: 8px 0;
    padding-left: 22px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.load-error pre {
    margin: 6px 0;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 12px;
}

.load-error code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

.load-error-detail {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px !important;
    color: var(--red-text) !important;
    background: var(--red-bg);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    word-break: break-word;
}

.load-error-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.load-error-actions button {
    padding: 7px 16px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: background var(--ease), border-color var(--ease);
}

.load-error-actions button:hover {
    border-color: var(--accent);
}

.load-error-actions button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.load-error-actions button.primary:hover {
    background: var(--accent-hover);
}

.load-error-actions button:disabled {
    opacity: 0.6;
    cursor: default;
}

.load-error-note {
    margin-top: 14px !important;
    font-size: 12px !important;
    color: var(--text-muted) !important;
}
