/* ===== CSS Variables — Obviously Brand ===== */
:root {
    /* Brand Palette */
    --color-digital-green: #00FF50;
    --color-aluminium: #E0DAD6;
    --color-white: #FFFFFF;
    --color-black: #000000;
    --color-purple: #B996FF;
    --color-yellow: #FFE65A;
    --color-blue: #96E6FF;
    --color-pink: #FFB9B9;

    /* Primary — Digital Green */
    --primary: #00FF50;
    --primary-hover: #00e647;
    --primary-light: rgba(0, 255, 80, 0.08);
    --primary-50: rgba(0, 255, 80, 0.06);
    --primary-100: rgba(0, 255, 80, 0.12);
    --primary-border: rgba(0, 255, 80, 0.4);
    --primary-text: #0a6e2a;

    /* Semantic — Status Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --success-subtle: #f0fdf4;
    --success-border: #86efac;
    --success-text: #166534;
    --success-dark: #059669;

    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --warning-border: #fcd34d;
    --warning-text: #92400e;

    --danger: #ef4444;
    --danger-light: #fee2e2;
    --danger-subtle: #fef2f2;
    --danger-border: #fca5a5;
    --danger-text: #991b1b;
    --danger-hover: #dc2626;

    --info: #6366f1;
    --info-light: #e0e7ff;
    --info-border: #a5b4fc;
    --info-text: #3730a3;

    /* Secondary accents */
    --purple: #B996FF;
    --purple-hover: #a57ef5;
    --info-hover: #4f46e5;

    /* Neutrals */
    --bg: #FFFFFF;
    --bg-secondary: #f9f8f7;
    --bg-alternate: #f5f3f1;
    --surface: #FFFFFF;
    --surface-raised: #FFFFFF;
    --border: #E0DAD6;
    --border-light: #ece9e6;
    --border-medium: #c9c2bc;
    --text: #000000;
    --text-secondary: #333333;
    --text-muted: #666666;
    --text-faint: #999999;
    --text-on-dark: #E0DAD6;

    /* Header */
    --header-bg: #000000;
    --header-bg-light: #1a1a1a;
    --header-border: #333333;
    --header-input-border: #444444;

    /* Focus & overlay */
    --focus-ring: 0 0 0 3px rgba(0, 255, 80, 0.15);
    --primary-shadow: rgba(0, 255, 80, 0.3);
    --danger-shadow: rgba(239, 68, 68, 0.3);
    --overlay: rgba(0, 0, 0, 0.6);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

    /* Radius */
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Easing — natural deceleration curves */
    --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-out-snappy: cubic-bezier(0.22, 1, 0.36, 1);

    /* Transitions */
    --transition-fast: 0.15s var(--ease-out);
    --transition-base: 0.2s var(--ease-out);
    --transition-expand: 0.25s var(--ease-out-snappy);

    /* Compat aliases */
    --bg-primary: var(--surface);
    --bg-tertiary: var(--bg);
    --background: var(--bg-secondary);

    color-scheme: light;
}

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

body {
    font-family: 'Helvetica Neue LT Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-weight: 400;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    scroll-behavior: smooth;
}

::selection {
    background: rgba(0, 255, 80, 0.2);
    color: var(--text);
}

/* ===== Header ===== */
header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    padding: 0 var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    color: var(--color-white);
    letter-spacing: -0.01em;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 36px;
    height: 36px;
    background: transparent;
    border: 2px solid var(--color-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0;
    color: transparent;
    flex-shrink: 0;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
}

/* Switch device dot inside header logo */
.header-logo::after {
    content: '';
    width: 14px;
    height: 14px;
    background: var(--color-digital-green);
    border-radius: 50%;
}

.header-logo:hover {
    transform: scale(1.06);
    box-shadow: 0 0 0 2px rgba(0, 255, 80, 0.3);
}

.header-title-group {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.header-subtitle {
    font-size: 0.65rem;
    color: var(--color-aluminium);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Client selector in dark header */
.client-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.client-selector label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-faint);
}

.client-selector select {
    padding: 7px 14px;
    border: 1px solid var(--header-input-border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    min-width: 220px;
    background: var(--header-bg-light);
    color: var(--text-on-dark);
    transition: border-color var(--transition-fast);
}

.client-selector select:hover {
    border-color: var(--text-muted);
}

.client-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 255, 80, 0.2);
}

/* New Client button in header */
.client-selector .btn.btn-small {
    background: transparent;
    border: 1px solid var(--header-input-border);
    color: var(--text-faint);
    font-size: 0.75rem;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
}

.client-selector .btn.btn-small:hover {
    background: var(--header-border);
    color: var(--text-on-dark);
    border-color: var(--text-muted);
}

/* ===== App Layout (Sidebar + Content) ===== */
.app-layout {
    display: flex;
    min-height: calc(100vh - 64px);
}

/* ===== Sidebar ===== */
.sidebar {
    width: 200px;
    min-width: 200px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    z-index: 99;
    transition: width 0.2s var(--ease-out), min-width 0.2s var(--ease-out);
    overflow: hidden;
}

.sidebar.collapsed {
    width: 48px;
    min-width: 48px;
}

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

.sidebar-title {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-title {
    display: none;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), transform 0.2s var(--ease-out);
    flex-shrink: 0;
}

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

.sidebar.collapsed .sidebar-toggle {
    transform: rotate(180deg);
    margin: 0 auto;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    gap: 2px;
}

.sidebar-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: left;
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), font-weight var(--transition-fast);
    white-space: nowrap;
    border-left: 3px solid transparent;
}

.sidebar-tab:hover {
    color: var(--text);
    background: var(--bg);
    border-left-color: var(--border-medium);
}

.sidebar-tab.active {
    color: var(--primary);
    background: var(--primary-light);
    border-left-color: var(--primary);
    font-weight: 500;
}

.sidebar-icon {
    font-size: 0.875rem;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.sidebar-label {
    overflow: hidden;
}

.sidebar.collapsed .sidebar-label {
    display: none;
}

.sidebar.collapsed .sidebar-tab {
    justify-content: center;
    padding: 10px 0;
    border-left-color: transparent;
}

.sidebar.collapsed .sidebar-tab.active {
    background: var(--primary-light);
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 12px;
}

.sidebar.collapsed .sidebar-divider {
    margin: 4px 6px;
}

/* ===== Content Area ===== */
.content-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ===== Client Navigation (horizontal tabs) ===== */
.client-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 var(--space-lg);
    display: flex;
    gap: 2px;
    position: sticky;
    top: 64px;
    z-index: 98;
    box-shadow: var(--shadow-sm);
}

.tab {
    padding: 14px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
    position: relative;
    letter-spacing: 0.01em;
}

.tab:hover {
    color: var(--text);
    background: var(--bg);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 500;
}

/* ===== Main Content ===== */
main {
    padding: var(--space-lg);
    flex: 1;
}

/* ===== Mobile: collapse sidebar into horizontal nav ===== */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100% !important;
        min-width: 100% !important;
        height: auto;
        position: relative;
        top: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-direction: row;
        overflow-x: auto;
    }
    .sidebar.collapsed {
        width: 100% !important;
        min-width: 100% !important;
    }
    .sidebar-header {
        display: none;
    }
    .sidebar-nav {
        flex-direction: row;
        padding: 0;
        width: 100%;
    }
    .sidebar-tab {
        border-left: none;
        border-bottom: 2px solid transparent;
        padding: 12px 16px;
    }
    .sidebar-tab.active {
        border-left-color: transparent;
        border-bottom-color: var(--primary);
    }
    .sidebar-divider {
        width: 1px;
        height: auto;
        margin: 8px 4px;
    }
    .sidebar.collapsed .sidebar-label {
        display: inline;
    }
    .sidebar.collapsed .sidebar-tab {
        justify-content: flex-start;
        padding: 12px 16px;
    }
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.15s var(--ease-out);
}

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

.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-light);
}

.tab-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

/* ===== Buttons (capsule/pill shape per brand) ===== */
.btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
    white-space: nowrap;
    font-family: inherit;
}

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

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary);
    color: var(--color-black);
    border-color: var(--color-black);
    box-shadow: 0 1px 2px var(--primary-shadow);
    font-weight: 700;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--color-black);
    box-shadow: 0 4px 8px var(--primary-shadow);
    color: var(--color-black);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: var(--color-white);
    border-color: var(--danger);
    box-shadow: 0 1px 2px var(--danger-shadow);
}

.btn-danger:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
    box-shadow: 0 4px 8px var(--danger-shadow);
    transform: translateY(-1px);
}

.btn-small {
    padding: 5px 12px;
    font-size: 0.75rem;
    border-radius: var(--radius-full);
}

/* ===== Split button (main action + dropdown toggle) =====
 * Used for "Publish to CASE" and friends where the primary action has a
 * default mode but users can pick a variant (e.g. all-history) from a
 * menu without needing a second top-level button. The main + toggle are
 * two separate buttons visually joined — they keep their own focus rings
 * but share a capsule-pill silhouette so it reads as one control.
 */
.split-button {
    position: relative;
    display: inline-flex;
    align-items: stretch;
}
.split-button .split-button-main {
    /* Flatten the right side so it meets the toggle flush. */
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right-width: 0;
}
.split-button .split-button-toggle {
    /* Flatten the left side; narrow width since it's just a chevron. */
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding-left: 8px;
    padding-right: 8px;
}
.split-button .split-button-toggle[aria-expanded="true"] {
    /* Subtle pressed-state when the menu is open. */
    background: var(--header-border);
}
.split-button-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 260px;
    background: var(--color-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 6px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.split-button-menu.hidden {
    display: none;
}
.split-menu-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
    font-size: 0.8125rem;
}
.split-menu-item:hover,
.split-menu-item:focus-visible {
    background: var(--primary-light);
    outline: none;
}
.split-menu-item strong {
    font-weight: 500;
}
.split-menu-item-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    pointer-events: none;
}

.btn-primary:disabled {
    background: var(--success-border);
    border-color: var(--success-border);
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.7;
}

/* ===== Add Terms Section ===== */
.add-terms-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.add-single, .add-bulk {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base);
}

.add-single:hover, .add-bulk:hover {
    box-shadow: var(--shadow-md);
}

.add-single h3, .add-bulk h3 {
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text);
}

.add-single form {
    display: flex;
    gap: var(--space-sm);
}

.add-single input, .add-bulk textarea {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    color: var(--text);
    background: var(--surface);
}

.add-single input:hover, .add-bulk textarea:hover {
    border-color: var(--border-medium);
}

.add-single input:focus, .add-bulk textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.add-single input::placeholder, .add-bulk textarea::placeholder {
    color: var(--text-faint);
}

.add-single input {
    flex: 1;
}

.add-bulk textarea {
    resize: vertical;
    margin-bottom: 10px;
    min-height: 70px;
}

.add-bulk form {
    display: flex;
    flex-direction: column;
}

.add-bulk .btn {
    align-self: flex-end;
}

/* ===== Tables ===== */
.table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
    -webkit-overflow-scrolling: touch;
    position: relative;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

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

th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
}

td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border-light);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
}

td:last-child {
    max-width: none;
    overflow: visible;
    text-overflow: unset;
    white-space: nowrap;
}

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

tbody tr:nth-child(even) {
    background: var(--bg-alternate);
}

tbody tr {
    transition: background var(--transition-fast);
}

tr:hover:not(.empty-row) {
    background: var(--primary-50);
}

tr:hover:not(.empty-row) td:first-child {
    box-shadow: inset 3px 0 0 var(--primary);
}

.empty-row td {
    text-align: center;
    color: var(--text-faint);
    padding: 48px 16px;
    font-style: normal;
    font-size: 0.875rem;
}

/* ===== Status Badges ===== */
.status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-pending {
    background: var(--warning-light);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}
.status-pending::before { background: var(--warning); }

.status-running {
    background: var(--primary-100);
    color: var(--primary-text);
    border: 1px solid var(--primary-border);
}
.status-running::before { background: var(--primary); animation: pulse 1.5s ease-in-out infinite; }

.status-completed {
    background: var(--success-light);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}
.status-completed::before { background: var(--success); }

.status-failed {
    background: var(--danger-light);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}
.status-failed::before { background: var(--danger); }

.status-ingesting {
    background: var(--info-light);
    color: var(--info-text);
    border: 1px solid var(--info-border);
}
.status-ingesting::before { background: var(--info); animation: pulse 1.5s ease-in-out infinite; }

.status-ingested {
    background: var(--success-light);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}
.status-ingested::before { background: var(--success-dark); }

.status-ingestion_failed {
    background: var(--danger-light);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}
.status-ingestion_failed::before { background: var(--danger); }

.status-converting {
    background: var(--primary-100);
    color: var(--primary-text);
    border: 1px solid var(--primary-border);
}
.status-converting::before { background: var(--primary); animation: pulse 1.5s ease-in-out infinite; }

.status-converter_failed {
    background: var(--danger-light);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}
.status-converter_failed::before { background: var(--danger); }

.status-compacting {
    background: var(--info-light);
    color: var(--info-text);
    border: 1px solid var(--info-border);
}
.status-compacting::before { background: var(--info); animation: pulse 1.5s ease-in-out infinite; }

.status-compactor_failed {
    background: var(--danger-light);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}
.status-compactor_failed::before { background: var(--danger); }

.status-ingesting_data {
    background: var(--info-light);
    color: var(--info-text);
    border: 1px solid var(--info-border);
}
.status-ingesting_data::before { background: var(--info); animation: pulse 1.5s ease-in-out infinite; }

.status-searching {
    background: var(--primary-100);
    color: var(--primary-text);
    border: 1px solid var(--primary-border);
}
.status-searching::before { background: var(--primary); animation: pulse 1.5s ease-in-out infinite; }

.status-completing {
    background: var(--success-light);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}
.status-completing::before { background: var(--success); animation: pulse 1.5s ease-in-out infinite; }

.status-search_failed {
    background: var(--danger-light);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}
.status-search_failed::before { background: var(--danger); }

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

.enabled-true { color: var(--success); font-weight: 700; }
.enabled-false { color: var(--danger); font-weight: 700; opacity: 0.7; }

/* ===== Mode Badges ===== */
.mode-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mode-like {
    background: var(--primary-100);
    color: var(--primary-text);
    border: 1px solid var(--primary-border);
}

.mode-fuzzy {
    background: var(--warning-light);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}

.mode-similarity {
    background: var(--info-light);
    color: var(--info-text);
    border: 1px solid var(--info-border);
}

.config-view-btn {
    font-size: 0.75rem;
    padding: 3px 10px;
}

.config-legacy-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ===== Full Scan Toggle ===== */
.full-scan-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: all var(--transition-fast);
}

.full-scan-label:hover {
    border-color: var(--primary);
    color: var(--text);
}

.full-scan-label input[type="checkbox"] {
    cursor: pointer;
}

/* ===== Sent Status Toggle ===== */
.sent-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.sent-toggle input[type="checkbox"] {
    cursor: pointer;
}

.sent-label {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.sent-yes {
    background: var(--success-light);
    color: var(--success-text);
}

.sent-no {
    background: var(--warning-light);
    color: var(--warning-text);
}

/* ===== Search Term Chips ===== */
.term-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    max-width: 280px;
}

.term-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 500;
    background: var(--success-subtle);
    color: var(--success-text);
    border: 1px solid var(--success-border);
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.term-chips-overflow {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 500;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
}

.term-chips-overflow:hover {
    background: var(--bg-secondary);
}

.term-chips-tooltip {
    display: none;
    position: absolute;
    z-index: 100;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    box-shadow: var(--shadow-md);
    max-width: 300px;
}

.term-chips-overflow:hover + .term-chips-tooltip,
.term-chips-tooltip:hover {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* ===== Pagination ===== */
.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: var(--space-md);
    padding: 8px 0;
}

.pagination-controls span {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

#total-info, #domains-total-info, #history-total-info, #admin-total-info, #pipeline-total-info, #playground-total-info, #pg-results-total-info {
    font-size: 0.75rem;
    color: var(--text-faint);
    margin-left: 4px;
}

.pagination-controls .btn.btn-small {
    padding: 5px 14px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

.pagination-controls .btn.btn-small:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== Expandable Record ===== */
.record-toggle {
    cursor: pointer;
    color: var(--primary);
    font-size: 0.75rem;
    text-decoration: none;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--primary-50);
    transition: background var(--transition-fast);
    display: inline-block;
}

.record-toggle:hover {
    background: var(--primary-100);
}

.record-content {
    display: none;
    background: var(--header-bg);
    color: var(--text-on-dark);
    padding: 16px;
    border-radius: var(--radius);
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Cascadia Code', monospace;
    font-size: 0.7rem;
    max-height: 320px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin-top: 8px;
    border: 1px solid var(--header-bg-light);
    line-height: 1.6;
}

.record-content.open {
    display: block;
    animation: recordReveal 0.2s var(--ease-out-snappy);
}

@keyframes recordReveal {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.record-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.record-content::-webkit-scrollbar-track {
    background: var(--header-bg-light);
}

.record-content::-webkit-scrollbar-thumb {
    background: var(--header-input-border);
    border-radius: 3px;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modalOverlayIn 0.15s var(--ease-out);
}

@keyframes modalOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    min-width: min(420px, calc(100vw - 32px));
    max-width: 520px;
    width: 100%;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.05);
    animation: modalContentIn 0.25s var(--ease-out-snappy);
}

@keyframes modalContentIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-content h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: var(--space-lg);
    letter-spacing: -0.01em;
}

.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    color: var(--text);
    font-family: inherit;
    background: var(--surface);
}

.form-group input:hover,
.form-group select:hover {
    border-color: var(--border-medium);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.form-group input::placeholder {
    color: var(--text-faint);
}

.modal-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-light);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-white);
    z-index: 2000;
    transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastIn 0.35s var(--ease-out-snappy);
    overflow: hidden;
}

.toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: rgba(255, 255, 255, 0.4);
    animation: toastProgress 3s linear forwards;
}

.toast.hidden::after {
    animation: none;
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

.toast svg {
    flex-shrink: 0;
    opacity: 0.9;
}

.toast.success svg path {
    stroke-dasharray: 14;
    stroke-dashoffset: 14;
    animation: checkDraw 0.4s var(--ease-out) 0.15s forwards;
}

@keyframes checkDraw {
    to { stroke-dashoffset: 0; }
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

.toast.success {
    background: var(--success-dark);
}

.toast.error {
    background: var(--danger);
}

.toast.info {
    background: var(--color-black);
}

.toast.warning {
    background: var(--color-yellow);
    color: var(--color-black);
}
.toast.warning svg {
    color: var(--color-black);
}

/* Inline Undo button rendered inside toasts that surface a reversible
 * bulk action. Deliberately minimal — the toast itself is the affordance;
 * the button just needs to stand out a little so the user notices it
 * before the 7-second timeout.
 */
.toast-undo-btn {
    margin-left: 12px;
    background: transparent;
    color: inherit;
    border: 1px solid currentColor;
    border-radius: var(--radius-full);
    padding: 2px 10px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition-fast);
}
.toast-undo-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}
.toast.warning .toast-undo-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

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

/* ===== Domain History Modal ===== */
.modal-wide .modal-content {
    min-width: 800px;
    max-width: 1200px;
    width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.history-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.history-modal-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    line-height: 1;
}

.modal-close-btn:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border-medium);
}

.modal-close-btn:active {
    transform: scale(0.95);
}

.history-modal-body {
    overflow-y: auto;
    padding: var(--space-lg) var(--space-xl);
    flex: 1;
}

@media (max-width: 768px) {
    .modal-wide .modal-content {
        min-width: 0;
        width: calc(100% - 32px);
        max-height: 90vh;
    }
}

/* ===== Changed Field Tags ===== */
.changed-field-tag {
    display: inline-block;
    background: var(--primary-50);
    color: var(--primary-text);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 500;
    margin: 1px 2px;
    border: 1px solid var(--primary-100);
}

/* ===== Search Trigger Bar ===== */
.trigger-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: var(--space-md);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.trigger-bar label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

.trigger-bar select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    font-family: inherit;
}

.trigger-bar select:hover {
    border-color: var(--border-medium);
}

.trigger-bar select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.selected-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
    padding: 4px 10px;
    background: var(--bg);
    border-radius: var(--radius-full);
}

/* ===== Checkboxes ===== */
.checkbox-col {
    width: 40px;
    text-align: center;
}

.checkbox-col input[type="checkbox"],
td input[type="checkbox"].term-checkbox {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    border-radius: 3px;
}

/* ===== Admin Controls ===== */
.admin-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-controls label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

.admin-controls select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    font-family: inherit;
}

.admin-controls select:hover {
    border-color: var(--border-medium);
}

.admin-controls select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.auto-refresh-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    user-select: none;
    color: var(--text-muted);
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg);
    transition: all var(--transition-fast);
}

.auto-refresh-label:hover {
    background: var(--surface);
    border-color: var(--border-medium);
}

.auto-refresh-label input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--primary);
}

/* ===== Scrollbars ===== */
.table-container::-webkit-scrollbar {
    height: 6px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--bg);
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-faint);
}

/* Firefox scrollbar support */
.table-container {
    scrollbar-width: thin;
    scrollbar-color: var(--border-medium) var(--bg);
}

.record-content {
    scrollbar-width: thin;
    scrollbar-color: var(--header-input-border) var(--header-bg-light);
}

/* ===== Focus Ring ===== */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ===== Responsive: Tablet & below (768px) ===== */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        height: auto;
        padding: var(--space-md);
        gap: var(--space-sm);
    }

    .header-brand {
        width: 100%;
    }

    .header-auth {
        width: 100%;
        justify-content: flex-end;
    }

    .client-selector {
        width: 100%;
        flex-wrap: wrap;
    }

    .client-selector select {
        min-width: 0;
        flex: 1;
    }

    .add-terms-section {
        grid-template-columns: 1fr;
    }

    nav {
        overflow-x: auto;
        position: static;
        -webkit-overflow-scrolling: touch;
    }

    nav::-webkit-scrollbar {
        display: none;
    }

    .tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    main {
        padding: var(--space-md);
    }

    .tab-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .admin-controls {
        flex-wrap: wrap;
        gap: 8px;
    }

    .trigger-bar {
        flex-wrap: wrap;
    }

    .modal-content {
        min-width: 0;
        margin: var(--space-md);
        width: calc(100% - 32px);
    }

    /* Touch targets — 44px minimum on touch devices */
    .btn {
        min-height: 44px;
        padding: 10px 16px;
    }

    .btn-small {
        min-height: 40px;
        padding: 8px 14px;
    }

    .checkbox-col input[type="checkbox"],
    td input[type="checkbox"].term-checkbox {
        width: 20px;
        height: 20px;
    }

    /* Improve table readability */
    th {
        padding: 10px 12px;
    }

    td {
        padding: 10px 12px;
        max-width: 200px;
    }

    /* Pagination spacing */
    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Execution action buttons stack */
    .execution-actions {
        flex-direction: column;
        gap: 4px;
    }

    /* Config banner stacks vertically */
    .config-banner {
        flex-direction: column;
        text-align: center;
    }

    .config-banner-detail {
        max-width: 100%;
        text-align: center;
    }

    /* Filter banner stacks */
    .filter-banner {
        flex-direction: column;
        gap: var(--space-sm);
        text-align: center;
    }

    /* Guide modal fullscreen on mobile */
    .guide-modal .modal-content {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        max-width: none;
    }
}

/* ===== Responsive: Small phone (480px) ===== */
@media (max-width: 480px) {
    header {
        padding: var(--space-sm);
    }

    main {
        padding: var(--space-sm);
    }

    .tab-header h2 {
        font-size: 1.1rem;
    }

    .modal-content {
        padding: var(--space-md);
        border-radius: var(--radius);
    }

    /* Stack single-term form vertically */
    .add-single form {
        flex-direction: column;
    }

    .add-single form .btn {
        align-self: stretch;
    }

    /* Full-width action buttons */
    .admin-controls {
        width: 100%;
    }

    .admin-controls .btn {
        flex: 1;
        justify-content: center;
    }

    /* Wider history modal body padding */
    .history-modal-body {
        padding: var(--space-md);
    }

    .history-modal-header {
        padding: var(--space-sm) var(--space-md);
    }

    /* Playground search stacks fully */
    .playground-search-section {
        padding: var(--space-md);
    }

    /* Selection bar stacks */
    .selection-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }
}

/* ===== Search Config ===== */

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

.config-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--success-subtle), var(--success-light));
    border: 1px solid var(--success-border);
    border-radius: var(--radius-lg);
    padding: 14px var(--space-lg);
    margin-bottom: var(--space-lg);
    gap: var(--space-md);
    animation: bannerSlideIn 0.25s var(--ease-out-snappy);
}

.config-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--success-text);
}

.config-banner-icon {
    color: var(--success);
    font-size: 0.75rem;
}

.config-banner-detail {
    font-size: 0.75rem;
    color: var(--success-text);
    max-width: 60%;
    text-align: right;
}

.config-row-active {
    background: var(--success-subtle) !important;
}

.config-inactive {
    color: var(--text-faint);
    font-size: 0.8125rem;
}

.config-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.field-rule-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 500;
    white-space: nowrap;
    margin: 2px 2px;
}

.field-rule-chip small {
    font-size: 0.6rem;
    opacity: 0.7;
}

.config-detail-panel {
    margin-top: var(--space-lg);
    background: var(--surface);
    border: 1px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(0, 255, 80, 0.08);
}

.config-detail-panel.hidden {
    display: none;
}

.config-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-light);
}

.config-detail-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.01em;
}

.config-info-bar {
    display: flex;
    gap: var(--space-xl);
    margin-bottom: var(--space-lg);
    padding: 12px var(--space-md);
    background: var(--bg);
    border-radius: var(--radius);
    flex-wrap: wrap;
}

.config-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-info-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.config-info-value {
    font-size: 0.8125rem;
    color: var(--text);
}

.add-field-rule-section {
    margin-bottom: var(--space-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.add-field-rule-section h4 {
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text);
}

.field-rule-form {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    flex-wrap: wrap;
}

.field-rule-form select,
.field-rule-form input {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.field-rule-form select:hover,
.field-rule-form input:hover {
    border-color: var(--border-medium);
}

.field-rule-form select:focus,
.field-rule-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.field-rule-form select {
    min-width: 180px;
}

.field-rule-form input[type="number"] {
    width: 140px;
}

#table-field-rules code {
    background: var(--bg);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text);
    font-weight: 500;
}

/* Modal textarea */
.form-group textarea {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    color: var(--text);
    background: var(--surface);
    resize: vertical;
}

.form-group textarea:hover {
    border-color: var(--border-medium);
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.form-group textarea::placeholder {
    color: var(--text-faint);
}

/* ===== Search Mode Helper ===== */

.helper-panel {
    margin-bottom: var(--space-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.helper-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px var(--space-lg);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast);
}

.helper-toggle:hover {
    background: var(--bg);
}

.helper-toggle h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin: 0;
}

.helper-toggle-icon {
    font-size: 0.625rem;
    color: var(--text-muted);
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.helper-toggle-hint {
    font-size: 0.75rem;
    color: var(--text-faint);
    margin-left: auto;
}

.helper-content {
    border-top: 1px solid var(--border-light);
    padding: var(--space-lg);
    animation: fadeIn 0.15s var(--ease-out);
}

.helper-content.hidden {
    display: none;
}

/* Mode explanation cards */
.helper-modes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.helper-mode-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-md);
    transition: box-shadow var(--transition-base);
}

.helper-mode-card:hover {
    box-shadow: var(--shadow-md);
}

.helper-mode-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.helper-mode-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
}

.helper-mode-card p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 8px;
}

.helper-threshold-note {
    font-size: 0.7rem !important;
    color: var(--text-muted) !important;
    background: var(--surface);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.helper-threshold-note code {
    background: var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 500;
}

.helper-examples {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.helper-example {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.helper-example code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
    color: var(--text);
    font-size: 0.7rem;
}

.helper-example-label {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.helper-match {
    background: var(--success-subtle);
}

.helper-nomatch {
    background: var(--danger-subtle);
}

.helper-match-icon {
    color: var(--success);
    font-weight: 700;
    font-size: 0.75rem;
}

.helper-nomatch-icon {
    color: var(--danger);
    font-weight: 700;
    font-size: 0.75rem;
}

.helper-score {
    color: var(--text-faint);
    font-size: 0.65rem;
    margin-left: auto;
}

/* Playground */
.helper-playground {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.helper-playground h4 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.helper-playground-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.helper-playground-inputs {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.helper-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.helper-input-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.helper-input-group input,
.helper-input-group textarea {
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.helper-input-group input:focus,
.helper-input-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.helper-input-group textarea {
    resize: vertical;
    min-height: 100px;
}

.helper-playground-controls {
    display: flex;
    align-items: flex-end;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}

.helper-threshold-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.helper-threshold-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.helper-threshold-group input {
    width: 80px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: 'SF Mono', 'Menlo', monospace;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition-fast);
}

.helper-threshold-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.helper-default-note {
    font-size: 0.65rem;
    color: var(--text-faint);
    font-style: italic;
}

/* Results table cells */
.helper-results {
    animation: fadeIn 0.15s var(--ease-out);
}

.helper-cell-match {
    background: var(--success-subtle) !important;
}

.helper-cell-nomatch {
    background: var(--danger-subtle) !important;
}

.helper-result-icon {
    font-size: 0.875rem;
    font-weight: 700;
}

.helper-result-icon.match {
    color: var(--success);
}

.helper-result-icon.nomatch {
    color: var(--danger);
}

.helper-result-detail {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 6px;
}

.helper-result-threshold {
    font-size: 0.65rem;
    color: var(--text-faint);
    margin-left: 4px;
}

#table-helper-results code {
    background: var(--bg);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text);
    font-weight: 500;
}

#table-helper-results td {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .helper-modes {
        grid-template-columns: 1fr;
    }

    .helper-playground-inputs {
        grid-template-columns: 1fr;
    }

    .helper-playground-controls {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ===== Execution Actions ===== */
.execution-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.btn-download {
    background: var(--header-bg);
    color: var(--primary-border);
    border-color: var(--header-bg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-download:hover {
    background: var(--header-bg-light);
    border-color: var(--header-bg-light);
    color: var(--primary-100);
}

.download-icon {
    font-size: 0.875rem;
    line-height: 1;
}

/* ===== Filter Banner ===== */
.filter-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--success-subtle), var(--success-light));
    border: 1px solid var(--success-border);
    border-radius: var(--radius-lg);
    padding: 10px var(--space-lg);
    margin-bottom: var(--space-md);
    font-size: 0.8125rem;
    color: var(--success-text);
    animation: bannerSlideIn 0.25s var(--ease-out-snappy);
}

.filter-banner strong {
    color: var(--success-text);
}

/* ===== Accent Buttons ===== */
.btn-accent {
    background: var(--color-black);
    color: var(--color-white);
    border: 1px solid var(--color-black);
}

.btn-accent:hover {
    background: var(--header-border);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    color: var(--color-white);
    transform: translateY(-1px);
}

.btn-guide {
    margin-right: var(--space-sm);
}

/* ===== Modal Size Variants ===== */
.modal-content.modal-narrow {
    max-width: 420px;
}

.modal-content.modal-medium {
    max-width: 480px;
}

.modal-content.modal-ai {
    max-width: 500px;
}

/* ===== Terms Overflow Modal ===== */
.terms-modal-header {
    padding: 12px 20px;
}

.terms-modal-body {
    padding: 12px 20px;
}

.terms-modal-chips {
    max-width: none;
}

/* ===== AI Review Modal ===== */
.ai-review-meta {
    margin-bottom: var(--space-md);
}

.ai-review-header {
    display: flex;
    gap: var(--space-md);
    align-items: center;
    margin-bottom: var(--space-sm);
}

.ai-review-name {
    font-size: 1.1em;
}

.ai-review-description {
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.ai-review-details {
    margin-bottom: var(--space-sm);
}

.ai-review-details summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 500;
}

.ai-review-reasoning {
    margin-top: var(--space-xs);
    padding: var(--space-sm);
    background: var(--bg);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
}

.ai-review-section-title {
    margin-bottom: var(--space-sm);
}

.ai-review-actions {
    margin-top: var(--space-lg);
    display: flex;
    gap: var(--space-sm);
}

/* ===== Guide Modal ===== */
.guide-modal {
    z-index: 10000;
}

.guide-modal .modal-content {
    width: 95vw;
    max-width: 960px;
    height: 90vh;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.guide-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.guide-modal-header h3 {
    margin: 0;
    font-size: 1.1em;
}

.guide-modal-close {
    font-size: 1.5em;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
}

.guide-iframe {
    flex: 1;
    border: none;
    width: 100%;
}

/* ===== Section Titles ===== */
.section-title-spaced {
    margin: var(--space-lg) 0 var(--space-sm);
}

/* ===== Record Modal Override ===== */
.record-content.record-modal-body {
    display: block;
    max-height: none;
}

/* ===== Utility ===== */

.hidden {
    display: none !important;
}

/* ===== Login Screen ===== */

.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-white);
    position: relative;
    overflow: hidden;
}

/* Subtle dot grid suggesting data scale */
.login-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(0, 0, 0, 0.06) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, black 20%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, black 20%, transparent 70%);
}

.login-card {
    background: transparent;
    padding: 48px 40px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    margin: var(--space-md);
    position: relative;
    z-index: 1;
}

.login-card > * {
    animation: loginReveal 0.6s var(--ease-out) backwards;
}

.login-card > :nth-child(1) { animation-delay: 0.1s; }
.login-card > :nth-child(2) { animation-delay: 0.2s; }
.login-card > :nth-child(3) { animation-delay: 0.3s; }
.login-card > :nth-child(4) { animation-delay: 0.4s; }
.login-card > :nth-child(5) { animation-delay: 0.5s; }
.login-card > :nth-child(6) { animation-delay: 0.5s; }

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

.login-card h1 {
    font-size: 2rem;
    font-weight: 500;
    color: var(--color-black);
    margin: var(--space-lg) 0 6px;
    letter-spacing: -0.02em;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    margin-bottom: var(--space-md);
}

.login-descriptor {
    color: var(--text-muted);
    font-size: 0.8125rem;
    line-height: 1.5;
    margin-bottom: 36px;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

.login-logo {
    width: 72px;
    height: 72px;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0;
    color: transparent;
    margin: 0 auto;
    border: 3px solid var(--color-black);
    position: relative;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* Switch device inside login logo */
.login-logo::after {
    content: '';
    width: 28px;
    height: 28px;
    background: var(--color-digital-green);
    border-radius: 50%;
}

.btn-login {
    width: 100%;
    padding: 14px var(--space-lg);
    font-size: 0.9375rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    letter-spacing: 0.01em;
    background: var(--color-digital-green);
    color: var(--color-black);
    border: 2px solid var(--color-black);
    box-shadow: 0 4px 12px rgba(0, 255, 80, 0.2);
    transition: all var(--transition-base);
}

.btn-login:hover {
    box-shadow: 0 6px 20px rgba(0, 255, 80, 0.3);
    transform: translateY(-1px);
}

.btn-login:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(0, 255, 80, 0.2);
}

.login-error {
    color: var(--danger);
    font-size: 0.8125rem;
    margin-top: var(--space-md);
}

/* ===== Header Auth ===== */

.header-auth {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.user-email {
    color: var(--text-faint);
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Current JWT org_code pill shown next to the user email. Helps users
   understand which org context their token is currently scoped to — the
   backend resolves cross-org access via Kinde's Management API so this
   is purely informational. Hidden when the token has no org. */
.user-org {
    color: var(--text-faint);
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    white-space: nowrap;
}
.user-org:empty {
    display: none;
}

/* ===== Playground ===== */

.playground-search-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.playground-search-section h3 {
    font-size: 0.9375rem;
    font-weight: 700;
    margin-bottom: var(--space-md);
    color: var(--text);
}

.playground-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.playground-form textarea {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    color: var(--text);
    background: var(--surface);
    resize: vertical;
    min-height: 80px;
}

.playground-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.playground-form textarea::placeholder {
    color: var(--text-faint);
}

/* Legacy .playground-options kept for backward compat */

.playground-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border-light);
}

.playground-results-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.btn-transfer {
    background: var(--success-dark);
    color: var(--color-white);
    border-color: var(--success-dark);
    box-shadow: 0 1px 2px rgba(5, 150, 105, 0.3);
}

.btn-transfer:hover {
    background: var(--success-text);
    border-color: var(--success-text);
    color: var(--color-white);
}

.transfer-description {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
    line-height: 1.5;
}

.playground-method-toggle {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 1px solid var(--border);
}

.radio-label {
    flex: 1;
    text-align: center;
    padding: 8px 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.radio-label:hover {
    color: var(--text);
    background: var(--primary-light);
}

.radio-label input[type="radio"] {
    display: none;
}

.radio-label:has(input:checked) {
    background: var(--primary);
    color: var(--color-white);
    box-shadow: 0 1px 3px var(--primary-shadow);
}

.playground-method-panel {
    margin-bottom: var(--space-md);
}

.playground-method-panel .form-group label {
    font-size: 0.75rem;
}

.playground-method-panel select,
.playground-method-panel input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.playground-method-panel select:hover,
.playground-method-panel input:hover {
    border-color: var(--border-medium);
}

.playground-method-panel select:focus,
.playground-method-panel input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.playground-inline-rules {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    background: var(--background);
}

.playground-rule-form {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.playground-rule-form select,
.playground-rule-form input {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.playground-rule-form select:first-child {
    flex: 2;
    min-width: 200px;
}

.playground-rule-form select:nth-child(2) {
    flex: 1;
    min-width: 150px;
}

.playground-rule-form input[type="number"] {
    width: 120px;
}

.playground-rule-form select:focus,
.playground-rule-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.playground-options-row {
    margin-bottom: var(--space-sm);
}

.playground-options-row .form-group label {
    font-size: 0.75rem;
}

.playground-options-row input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.playground-options-row input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.btn-save-config {
    background: var(--purple);
    color: var(--color-black);
    border-color: var(--purple);
    box-shadow: 0 1px 2px rgba(185, 150, 255, 0.3);
}

.btn-save-config:hover {
    background: var(--purple-hover);
    border-color: var(--purple-hover);
    color: var(--color-black);
}

@media (max-width: 768px) {
    .playground-method-toggle {
        flex-direction: column;
    }
    .playground-rule-form {
        flex-direction: column;
        align-items: stretch;
    }
    .playground-rule-form select:first-child,
    .playground-rule-form select:nth-child(2),
    .playground-rule-form input[type="number"] {
        width: 100%;
        min-width: 0;
    }
}

/* ===== Result Selection Bar ===== */
.selection-bar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 8px var(--space-md);
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    margin-bottom: var(--space-sm);
    font-size: 0.9em;
    animation: bannerSlideIn 0.25s var(--ease-out-snappy);
}

.selection-bar span {
    font-weight: 500;
    color: var(--primary);
}

.checkbox-col {
    width: 36px;
    text-align: center;
}

.result-checkbox,
.pg-result-checkbox {
    cursor: pointer;
}

/* ===== Results Filter Bar ===== */
.results-filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-md);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-md);
}

.results-filter-bar .filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.results-filter-bar .filter-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.results-filter-bar .filter-group input,
.results-filter-bar .filter-group select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    background: var(--surface);
    color: var(--text);
    min-width: 180px;
}

.results-filter-bar .filter-group input:focus,
.results-filter-bar .filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-100);
}

@media (max-width: 768px) {
    .results-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .results-filter-bar .filter-group {
        flex-direction: column;
        align-items: stretch;
    }
    .results-filter-bar .filter-group input,
    .results-filter-bar .filter-group select {
        min-width: 0;
    }
}

/* ===== Record View Modal ===== */
#record-modal-body {
    margin: 0;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.7rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ===== Terms Overflow Modal ===== */
#terms-modal-chips {
    max-width: none;
    gap: 6px;
    flex-wrap: wrap;
    display: flex;
}

#terms-modal-chips .term-chip {
    max-width: none;
}

/* ===== Bulk Sessions ===== */
.bulk-session-queue-section {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
}

.queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.queue-header h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.text-danger {
    color: var(--danger);
    font-weight: 700;
}

/* ===== Term Config Badges ===== */
.config-assigned-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 500;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary-100);
}

.config-inherit-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 500;
    background: var(--border-light);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.term-config-inline-select {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    background: var(--surface);
    color: var(--text);
    max-width: 180px;
}

.term-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* ===== Chips (bulk session detail) ===== */
.chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary-100);
    margin: 1px 2px;
}

.chip-config {
    background: var(--border-light);
    color: var(--text);
    border-color: var(--border);
}

.chip-playground {
    background: var(--warning-light);
    color: var(--warning-text);
    border-color: var(--warning-border);
}

.bulk-session-detail-row td {
    padding: 0 !important;
}

.expandable-row:hover {
    background: var(--bg-secondary);
}

/* ===== Skip to Content ===== */
.skip-to-content {
    position: absolute;
    top: -100%;
    left: 0;
    z-index: 9999;
    padding: 12px 20px;
    background: var(--primary);
    color: var(--color-black);
    font-weight: 500;
    font-size: 0.875rem;
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-to-content:focus {
    top: 0;
}

/* ===== Screen Reader Only ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Loading Spinner ===== */
.loading-row td {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

/* ===== Touch Device Adaptation ===== */
@media (pointer: coarse) {
    /* Ensure 44px minimum touch targets */
    .btn {
        min-height: 44px;
    }

    .btn-small {
        min-height: 40px;
        padding: 8px 14px;
    }

    .checkbox-col input[type="checkbox"],
    td input[type="checkbox"].term-checkbox,
    .sent-toggle input[type="checkbox"],
    .auto-refresh-label input[type="checkbox"],
    .full-scan-label input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    /* Increase touch area on close buttons */
    .modal-close-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* Sidebar tabs — comfortable touch targets */
    .sidebar-tab {
        min-height: 44px;
    }

    /* Form selects and inputs */
    .trigger-bar select,
    .admin-controls select,
    .form-group select,
    .form-group input {
        min-height: 40px;
    }

    /* Status badge tap area */
    .sent-toggle {
        min-height: 36px;
        padding: 4px;
    }

    /* Pagination */
    .pagination-controls .btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ===== Table Scroll Hint ===== */
.table-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 24px;
    pointer-events: none;
    background: linear-gradient(to left, var(--surface), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.table-container.scrollable::after {
    opacity: 1;
}

/* ===== Skeleton Loaders ===== */
@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton-row td {
    padding: 12px 16px;
}

.skeleton-cell {
    height: 14px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
    background-size: 800px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-cell-sm { width: 40%; }
.skeleton-cell-md { width: 60%; }
.skeleton-cell-lg { width: 80%; }
.skeleton-cell-xl { width: 95%; }

/* ===== Status Timeline ===== */
.status-timeline {
    display: inline-flex;
    align-items: center;
    gap: 0;
    white-space: nowrap;
    vertical-align: middle;
}

.timeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.timeline-step-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
    border: 2px solid var(--border-medium);
    background: var(--surface);
    color: var(--text-faint);
    transition: all var(--transition-fast);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.timeline-step-label {
    font-size: 0.55rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-faint);
    margin-top: 3px;
    max-width: 64px;
    text-align: center;
    line-height: 1.15;
    white-space: normal;
}

.timeline-connector {
    width: 24px;
    height: 2px;
    background: var(--border-medium);
    flex-shrink: 0;
    transition: background var(--transition-fast);
}

.timeline-step-complete .timeline-step-dot {
    background: var(--success);
    border-color: var(--success);
    color: var(--color-white);
}

.timeline-step-complete .timeline-step-label { color: var(--success-text); }
.timeline-connector-complete { background: var(--success); }

.timeline-step-active .timeline-step-dot {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--color-white);
    animation: timeline-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 0 3px rgba(0, 255, 80, 0.2);
}

.timeline-step-active .timeline-step-label { color: var(--primary-text); font-weight: 700; }

.timeline-step-failed .timeline-step-dot {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--color-white);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.timeline-step-failed .timeline-step-label { color: var(--danger-text); font-weight: 700; }
.timeline-connector-failed { background: var(--danger); }

@keyframes timeline-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(0, 255, 80, 0.2); }
    50% { box-shadow: 0 0 0 6px rgba(0, 255, 80, 0.1); }
}

.status-timeline-compact .timeline-step-dot { width: 10px; height: 10px; font-size: 0; border-width: 1.5px; }
.status-timeline-compact .timeline-step-dot svg { display: none; }
.status-timeline-compact .timeline-step-label { display: none; }
.status-timeline-compact .timeline-connector { width: 10px; height: 1.5px; }
.status-timeline-compact .timeline-step-active .timeline-step-dot { box-shadow: 0 0 0 2px rgba(0, 255, 80, 0.2); }
.status-timeline-compact .timeline-step-failed .timeline-step-dot { box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15); }

.status-cell-with-timeline {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== Progress Bar ===== */
.progress-bar-container {
    display: none;
    margin-top: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.progress-bar-container.active { display: block; }

.progress-bar-track {
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.3s var(--ease-out);
    width: 0%;
}

.progress-bar-fill.indeterminate {
    width: 30%;
    animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
    0% { margin-left: 0%; }
    50% { margin-left: 70%; }
    100% { margin-left: 0%; }
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
}

.progress-bar-container.success .progress-bar-fill { background: var(--success); }
.progress-bar-container.error .progress-bar-fill { background: var(--danger); }

/* ===== Inline Edit ===== */
.editable-cell {
    cursor: pointer;
    position: relative;
    padding-right: 20px;
}

.editable-cell:hover { color: var(--primary); }
.editable-cell::after {
    content: '\270E';
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: opacity var(--transition-fast);
}
.editable-cell:hover::after { opacity: 1; }

.inline-edit-input {
    width: 100%;
    padding: 4px 8px;
    border: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    font-size: inherit;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ===== Dashboard ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.dashboard-card {
    background: var(--surface-raised);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
}

.dashboard-card-wide { grid-column: span 2; }

.dashboard-card h3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-light);
}

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

.stat-number-primary { color: var(--primary); }
.stat-number-success { color: var(--success); }
.stat-number-warning { color: var(--warning); }
.stat-number-danger { color: var(--danger); }

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.stat-row {
    display: flex;
    gap: var(--space-lg);
    margin-bottom: var(--space-sm);
}

.dashboard-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.875rem;
}

.dashboard-detail-row:last-child { border-bottom: none; }
.dashboard-detail-label { color: var(--text-muted); }
.dashboard-detail-value { color: var(--text); font-weight: 500; }

.dashboard-exec-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.dashboard-exec-table th { text-align: left; padding: 4px 8px; color: var(--text-muted); font-weight: 500; }
.dashboard-exec-table td { padding: 4px 8px; }

.dashboard-exec-row { cursor: pointer; transition: background var(--transition-fast); }
.dashboard-exec-row:hover { background: var(--primary-50); }
.dashboard-exec-row:focus-visible { outline: none; box-shadow: var(--focus-ring); }

@media (max-width: 1024px) { .dashboard-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .dashboard-grid { grid-template-columns: 1fr; } .dashboard-card-wide { grid-column: span 1; } }

/* ===== Dashboard — AI verdict donut (D2) =====
 * 160x160 SVG donut with a flex-laid-out legend. Per-slice colours pull
 * from the brand secondary palette (Pink / Yellow / Blue) for confidence
 * tiers, Aluminium for CLEAR, border-medium for "unanalysed" so the
 * residual reads as "work still to do".
 */
.donut-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 4px 0;
}
.donut-svg {
    flex-shrink: 0;
}
.donut-total {
    font-family: inherit;
    font-weight: 500;
    font-size: 1.25rem;
    fill: var(--text);
}
.donut-total-label {
    font-family: inherit;
    font-size: 0.7rem;
    fill: var(--text-muted);
}
.donut-legend {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    flex: 1;
    min-width: 0;
}
.donut-legend li {
    display: flex;
    align-items: center;
    gap: 8px;
}
.donut-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}
.donut-legend-label {
    flex: 1;
    color: var(--text-secondary);
}
.donut-legend-value {
    font-weight: 500;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* ===== Dashboard — executions timeline (D1) =====
 * Thirty proportional-height bars in a fixed-height track. Digital-green
 * because executions are a positive signal (brand primary usage); the
 * rail underneath is Aluminium so absent days still show a position.
 */
.timeline-summary {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0 10px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}
.timeline-axis {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.timeline-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 80px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-light);
}
.timeline-bar-wrap {
    flex: 1;
    display: flex;
    align-items: flex-end;
    height: 100%;
    min-height: 0;
    position: relative;
    cursor: default;
}
.timeline-bar-wrap::after {
    /* Rail so empty days still read as "nothing happened that day" rather
     * than a missing column. */
    content: '';
    position: absolute;
    inset: 0 0 0 0;
    background: var(--bg);
    z-index: 0;
}
.timeline-bar {
    position: relative;
    z-index: 1;
    width: 100%;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
    transition: background var(--transition-fast);
}
.timeline-bar-wrap:hover .timeline-bar {
    background: var(--primary-hover, var(--primary));
    filter: brightness(0.92);
}

/* ===== Dashboard — needs-attention (D3) ===== */
.needs-attention-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
}
.needs-attention-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 2px;
    border-bottom: 1px dashed var(--border-light);
}
.needs-attention-list li:last-child { border-bottom: none; }
.needs-attention-link {
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}
.needs-attention-link:hover { text-decoration: underline; }
.needs-attention-tags {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.needs-attention-more {
    display: inline-block;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-decoration: none;
}
.needs-attention-more:hover { text-decoration: underline; }

/* ===== Diff View ===== */
.diff-container {
    max-height: 600px;
    overflow-y: auto;
}

.diff-entry {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-md);
    overflow: hidden;
}

.diff-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.diff-toggle {
    font-size: 0.7rem;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
}

.diff-toggle:hover { background: var(--bg); }

.diff-field {
    display: grid;
    grid-template-columns: 160px 1fr 1fr;
    gap: 1px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8rem;
}

.diff-field:last-child { border-bottom: none; }

.diff-field-name {
    padding: 6px var(--space-sm);
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    word-break: break-all;
}

.diff-value-old, .diff-value-new {
    padding: 6px var(--space-sm);
    word-break: break-all;
    white-space: pre-wrap;
}

.diff-added .diff-value-new { background: var(--success-subtle); color: var(--success-text); }
.diff-changed .diff-value-old { background: var(--danger-subtle); color: var(--danger-text); text-decoration: line-through; }
.diff-changed .diff-value-new { background: var(--success-subtle); color: var(--success-text); }
.diff-unchanged { display: none; }
.diff-entry.show-all .diff-unchanged { display: grid; }
.diff-unchanged .diff-value-old, .diff-unchanged .diff-value-new { color: var(--text-faint); }

.diff-new-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 1px 6px;
    background: var(--success-light);
    color: var(--success-text);
    border-radius: var(--radius-full);
    margin-left: var(--space-sm);
}

/* ===== Filter Panel ===== */
.filter-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-md);
    background: var(--surface);
}

.filter-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    user-select: none;
}

.filter-panel-header:hover { background: var(--bg-secondary); }

.filter-toggle-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: none;
    border: none;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
}

.filter-toggle-icon {
    transition: transform var(--transition-fast);
    font-size: 0.7rem;
}

.filter-panel.collapsed .filter-toggle-icon { transform: rotate(-90deg); }

.filter-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--color-white);
    background: var(--primary);
    border-radius: var(--radius-full);
}

.filter-count-badge.hidden { display: none; }

.filter-panel-body {
    padding: var(--space-md);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
    align-items: end;
}

.filter-panel.collapsed .filter-panel-body { display: none; }

.filter-panel-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: end;
    grid-column: 1 / -1;
}

.preset-controls {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.preset-controls select {
    font-size: 0.8rem;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
}

/* ===== Domain Search Typeahead ===== */
.domain-search-wrapper {
    position: relative;
}

.domain-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 100;
    display: none;
}

.domain-suggestions.active { display: block; }

.domain-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-light);
}

.domain-suggestion:hover, .domain-suggestion.active { background: var(--primary-light); color: var(--primary-text); }
.domain-suggestion-create { font-style: italic; color: var(--primary); }

.link-domain-selected {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-sm);
    margin-top: var(--space-sm);
    font-size: 0.875rem;
}

/* ===== Queue Stats ===== */
.queue-stats {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.queue-stat-card {
    flex: 1;
    text-align: center;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.queue-stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.queue-stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }

.queue-header-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.queue-terms-preview {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.queue-terms-preview:hover { white-space: normal; word-break: break-all; }

/* ===== Theme Toggle ===== */
.theme-toggle {
    background: none;
    border: 1px solid var(--header-input-border);
    border-radius: var(--radius-sm);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-on-dark);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.theme-toggle:hover { border-color: var(--primary); background: var(--header-bg-light); }

html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition: background-color 0.3s, color 0.3s, border-color 0.3s, box-shadow 0.3s !important;
}

/* ===== SSE Status Indicator ===== */
.sse-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-faint);
    margin-left: 6px;
    vertical-align: middle;
}

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

.sse-status-dot.disconnected {
    background: var(--danger);
}

/* ===== Dark Mode ===== */
[data-theme="dark"] {
    --primary: #00FF50;
    --primary-hover: #00e647;
    --primary-light: rgba(0, 255, 80, 0.1);
    --primary-50: rgba(0, 255, 80, 0.08);
    --primary-100: rgba(0, 255, 80, 0.15);
    --primary-border: rgba(0, 255, 80, 0.4);
    --primary-text: #5cff8a;
    --success: #34d399;
    --success-light: rgba(16, 185, 129, 0.15);
    --success-subtle: rgba(16, 185, 129, 0.08);
    --success-border: #059669;
    --success-text: #6ee7b7;
    --success-dark: #10b981;
    --warning: #fbbf24;
    --warning-light: rgba(245, 158, 11, 0.15);
    --warning-border: #d97706;
    --warning-text: #fcd34d;
    --danger: #f87171;
    --danger-light: rgba(239, 68, 68, 0.15);
    --danger-subtle: rgba(239, 68, 68, 0.08);
    --danger-border: #dc2626;
    --danger-text: #fca5a5;
    --danger-hover: #ef4444;
    --info: #818cf8;
    --info-light: rgba(99, 102, 241, 0.15);
    --info-border: #6366f1;
    --info-text: #a5b4fc;
    --info-hover: #6366f1;
    --purple: #c4a8ff;
    --purple-hover: #B996FF;
    --bg: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-alternate: #141414;
    --surface: #1a1a1a;
    --surface-raised: #2a2a2a;
    --border: #333333;
    --border-light: #1a1a1a;
    --border-medium: #444444;
    --text: #E0DAD6;
    --text-secondary: #c9c2bc;
    --text-muted: #999999;
    --text-faint: #666666;
    --text-on-dark: #E0DAD6;
    --header-bg: #000000;
    --header-bg-light: #0a0a0a;
    --header-border: #1a1a1a;
    --header-input-border: #333333;
    --focus-ring: 0 0 0 3px rgba(0, 255, 80, 0.2);
    --primary-shadow: rgba(0, 255, 80, 0.3);
    --danger-shadow: rgba(248, 113, 113, 0.3);
    --overlay: rgba(0, 0, 0, 0.7);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --bg-primary: var(--surface);
    --bg-tertiary: var(--bg);
    --background: var(--bg-secondary);
    color-scheme: dark;
}

/* System preference: removed — light mode is always the default per brand guidelines.
   Dark mode is only activated via explicit user toggle (data-theme="dark"). */

/* ===== Advanced Domain Filters ===== */
.advanced-filter-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.filter-group select,
.filter-group input[type="date"] {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
}

.filter-group select:focus,
.filter-group input[type="date"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.filter-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: var(--color-black);
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 4px;
    vertical-align: middle;
}

.filter-badge.hidden {
    display: none;
}

/* AI verdict badges — inline on the Domains table. Colour-coded by
 * confidence level so triagers can spot high-risk rows at a glance
 * without flipping to the AI Analysis tab. Secondary brand palette
 * (Pink / Yellow / Blue) for confidence tiers; Aluminium for CLEAR
 * so it recedes visually. 'none' (unanalysed) renders invisible so
 * the column doesn't fill with placeholders. */
.ai-verdict-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 6px;
    border: 1px solid transparent;
    white-space: nowrap;
}
.ai-verdict-pending {
    /* Transitional state while the /verdicts batch-lookup is in flight.
     * Invisible but reserves space so we don't reflow when badges land. */
    min-width: 1px;
    background: transparent;
    color: transparent;
    border-color: transparent;
}
.ai-verdict-none {
    display: none;
}
.ai-verdict-high {
    /* HIGH confidence = most likely to be a brand-protection hit.
     * Use brand Pink against a darker text to stand out without
     * competing with the primary green. */
    background: var(--color-pink);
    color: #7a1e1e;
    border-color: #e57a7a;
}
.ai-verdict-medium {
    background: var(--color-yellow);
    color: #6b5300;
    border-color: #d9bf3a;
}
.ai-verdict-low {
    background: var(--color-blue);
    color: #155a73;
    border-color: #6cc4e0;
}
.ai-verdict-clear {
    /* Analysed + verdict 'CLEAR' — the AI thinks the domain is benign.
     * Aluminium pill so it reads as "no action needed". */
    background: var(--color-aluminium);
    color: var(--text-muted);
    border-color: var(--border-medium);
}

/* Field badges in the domains table */
.field-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary-text);
    font-size: 0.72rem;
    font-weight: 500;
    margin: 1px 2px;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-theme="dark"] .field-badge {
    background: rgba(0, 255, 80, 0.15);
    color: #5cff8a;
}

.domain-fields-cell {
    max-width: 200px;
}

.domain-terms-cell {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-center {
    text-align: center;
}

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

/* ===== AI Analysis Sub-tabs ===== */
.domain-subtabs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.domain-subtabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 3px;
}

.domain-subtab {
    padding: 6px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.domain-subtab:hover {
    color: var(--text);
    background: var(--surface);
}

.domain-subtab.active {
    background: var(--surface);
    color: var(--primary);
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.domain-subtab-actions {
    display: flex;
    gap: 8px;
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 4px;
    vertical-align: middle;
}

.ai-badge.hidden { display: none; }

/* Tag badges */
.ai-tag-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 500;
    margin: 1px 2px;
    white-space: nowrap;
}

/* Tag colours mapped to Obviously secondary palette */
.tag-typosquatting { background: rgba(185, 150, 255, 0.15); color: #6d28d9; }
.tag-phishing { background: rgba(255, 185, 185, 0.2); color: #b91c1c; }
.tag-counterfeit { background: rgba(255, 230, 90, 0.2); color: #92400e; }
.tag-impersonation { background: rgba(150, 230, 255, 0.15); color: #0e7490; }
.tag-affiliate { background: rgba(255, 230, 90, 0.12); color: #a16207; }
.tag-review { background: rgba(224, 218, 214, 0.3); color: #57534e; }

[data-theme="dark"] .tag-typosquatting { background: rgba(185, 150, 255, 0.2); color: var(--color-purple); }
[data-theme="dark"] .tag-phishing { background: rgba(255, 185, 185, 0.2); color: var(--color-pink); }
[data-theme="dark"] .tag-counterfeit { background: rgba(255, 230, 90, 0.15); color: var(--color-yellow); }
[data-theme="dark"] .tag-impersonation { background: rgba(150, 230, 255, 0.15); color: var(--color-blue); }
[data-theme="dark"] .tag-affiliate { background: rgba(255, 230, 90, 0.1); color: var(--color-yellow); }
[data-theme="dark"] .tag-review { background: rgba(224, 218, 214, 0.15); color: var(--color-aluminium); }

/* Confidence badges */
.confidence-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* Confidence badges — using brand semantic colours */
.confidence-high { background: var(--danger-light); color: var(--danger-text); }
.confidence-medium { background: var(--warning-light); color: var(--warning-text); }
.confidence-low { background: rgba(224, 218, 214, 0.3); color: #57534e; }

[data-theme="dark"] .confidence-high { background: var(--danger-light); color: var(--danger-text); }
[data-theme="dark"] .confidence-medium { background: var(--warning-light); color: var(--warning-text); }
[data-theme="dark"] .confidence-low { background: rgba(224, 218, 214, 0.15); color: var(--color-aluminium); }

/* Reasoning cell */
.reasoning-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.83rem;
    color: var(--text-muted);
}

/* ===== Column Picker ===== */

.column-picker-wrapper {
    position: relative;
    display: inline-block;
}

.column-picker-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.column-picker-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.column-picker-btn .col-icon {
    font-size: 0.9rem;
    line-height: 1;
}

.column-picker-btn .col-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--primary);
    color: var(--color-black);
    border-radius: var(--radius-full);
}

.column-picker-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1000;
    width: 340px;
    max-height: 480px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0;
    display: none;
}

.column-picker-dropdown.open {
    display: block;
}

.column-picker-search {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: var(--space-sm);
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
}

.column-picker-search input {
    width: 100%;
    padding: 6px 10px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text);
    outline: none;
}

.column-picker-search input:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.active-columns-section {
    padding: var(--space-sm);
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-secondary);
}
.column-picker-apply {
    position: sticky;
    bottom: 0;
    padding: var(--space-sm);
    background: var(--surface);
    border-top: 1px solid var(--border-light);
    text-align: right;
}
.column-picker-apply .btn-sm {
    padding: 4px 16px;
    font-size: 0.8rem;
}

.active-columns-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xs);
}

.active-columns-header span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.active-columns-header .clear-all-link {
    font-size: 0.75rem;
    color: var(--danger);
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    text-decoration: underline;
}

.active-columns-header .clear-all-link:hover {
    color: var(--danger-hover);
}

.active-columns-list {
    list-style: none;
    padding: 0;
    margin: 0;
    min-height: 4px;
}

.active-column-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    margin-bottom: 2px;
    font-size: 0.8rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: grab;
    transition: all var(--transition-fast);
}

.active-column-item:hover {
    border-color: var(--primary-border);
    background: var(--primary-light);
}

.active-column-item.dragging {
    opacity: 0.4;
    border-style: dashed;
}

.active-column-item .drag-handle {
    color: var(--text-faint);
    font-size: 0.8rem;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.active-column-item .col-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: monospace;
    font-size: 0.75rem;
}

.active-column-item .remove-col {
    color: var(--text-faint);
    cursor: pointer;
    border: none;
    background: none;
    padding: 0 2px;
    font-size: 0.85rem;
    line-height: 1;
    flex-shrink: 0;
}

.active-column-item .remove-col:hover {
    color: var(--danger);
}

.field-category {
    padding: 6px var(--space-sm) 2px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.column-picker-dropdown .field-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px var(--space-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.column-picker-dropdown .field-item:hover {
    background: var(--bg-secondary);
}

.column-picker-dropdown .field-item input[type="checkbox"] {
    flex-shrink: 0;
    margin: 0;
}

.column-picker-dropdown .field-item .field-label {
    flex: 1;
    font-family: monospace;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.column-picker-dropdown .field-item .field-desc {
    font-size: 0.7rem;
    color: var(--text-faint);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Field-Targeted Search ===== */

.field-search-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: var(--space-sm) 0;
}

.field-search-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-search-row .field-selector-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.field-search-row .field-selector-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.field-search-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.field-search-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.field-selector-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    width: 300px;
    max-height: 360px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: var(--space-xs) 0;
    display: none;
}

.field-selector-dropdown.open {
    display: block;
}

.field-selector-search {
    padding: var(--space-xs) var(--space-sm);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.field-selector-search input {
    width: 100%;
    padding: 5px 8px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text);
    outline: none;
}

.field-selector-search input:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.field-selector-dropdown .field-selector-category {
    padding: 6px var(--space-sm) 3px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.field-selector-dropdown .field-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 4px var(--space-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.field-selector-dropdown .field-option:hover {
    background: var(--bg-secondary);
}

.field-selector-dropdown .field-option.field-option-selected {
    background: var(--primary-light);
    color: var(--primary);
}

.field-option-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.field-option-check {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--primary);
}

/* Active search field rows */
.active-search-fields {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.search-field-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-field-label {
    flex-shrink: 0;
    width: 180px;
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 2px 0;
}

.search-field-input {
    flex: 1;
    padding: 5px 8px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    outline: none;
    min-width: 0;
}

.search-field-input:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.search-field-remove {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-muted);
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    transition: all var(--transition-fast);
}

.search-field-remove:hover {
    color: var(--danger);
    background: var(--danger-light, rgba(239, 68, 68, 0.1));
    border-color: var(--danger);
}

/* Custom fullRecord columns in tables */
.custom-col-header {
    font-family: monospace;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-col-value {
    font-size: 0.8rem;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

/* ===== Compound Search Configs ===== */

.compound-configs-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    gap: var(--space-sm);
}

.compound-configs-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.compound-config-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    transition: border-color var(--transition-fast);
}

.compound-config-card:hover {
    border-color: var(--border-medium);
}

.compound-config-card-info {
    flex: 1;
    min-width: 0;
}

.compound-config-card-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 2px;
}

.compound-config-card-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.compound-config-card-actions {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    flex-shrink: 0;
}

.compound-config-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--border-medium);
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--transition-fast);
    border: none;
    padding: 0;
}

.compound-config-toggle.active {
    background: var(--primary);
}

.compound-config-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--color-white);
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.compound-config-toggle.active::after {
    transform: translateX(16px);
}

/* Editor */

.compound-editor {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.compound-editor-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.compound-editor-header input {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    font-family: inherit;
    background: var(--surface);
}

.compound-editor-header input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.compound-groups {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.compound-group {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    background: var(--bg);
    position: relative;
}

.compound-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-light);
}

.compound-group-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.compound-group-header-left label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.compound-group-header-left .group-label {
    font-weight: 500;
    color: var(--text);
    font-size: 0.8125rem;
}

.compound-standalone-badge {
    font-size: 0.6875rem;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    background: var(--accent-bg, var(--warning-light));
    color: var(--accent-text, var(--warning-text));
    font-weight: 500;
}

[data-theme="dark"] .compound-standalone-badge {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.compound-rules {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.compound-rule-row {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-wrap: nowrap;
}

.compound-rule-row select,
.compound-rule-row input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--text);
    font-family: inherit;
    background: var(--surface);
}

.compound-rule-row select:focus,
.compound-rule-row input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.compound-rule-field {
    flex: 2;
    min-width: 180px;
}

.compound-rule-mode {
    width: 120px;
    flex-shrink: 0;
}

.compound-rule-value {
    flex: 1.5;
    min-width: 120px;
}

.compound-rule-threshold {
    width: 80px;
    flex-shrink: 0;
}

.compound-rule-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
    flex-shrink: 0;
}

.compound-rule-remove:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.compound-group-actions {
    display: flex;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
}

.compound-editor-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-light);
}

.compound-editor-actions .btn-primary {
    margin-left: auto;
}

.compound-group-connector {
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 2px 0;
}
.compound-rule-connector {
    text-align: center;
    padding: 2px 0;
}
.connector-and {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 1px 10px;
    border-radius: var(--radius-sm);
}

.compound-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-faint);
    font-size: 0.875rem;
}

/* ===== Compare Tab ===== */

.compare-trigger-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.compare-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    max-width: 600px;
}

.compare-form-actions {
    display: flex;
    gap: var(--space-sm);
}

/* Status panel shown during polling */
.compare-status-panel {
    margin-top: var(--space-lg);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.compare-status-panel h4 {
    margin: 0 0 var(--space-sm) 0;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.compare-worker-statuses {
    display: flex;
    gap: var(--space-lg);
}

.compare-worker-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.compare-worker-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 100px;
}

/* Summary stat cards */
.compare-stat-cards {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.compare-stat-card {
    flex: 1;
    text-align: center;
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.compare-stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 4px;
}

.compare-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.compare-stat-duckdb .compare-stat-value { color: var(--warning); }
.compare-stat-both    .compare-stat-value { color: var(--success); }
.compare-stat-es      .compare-stat-value { color: var(--info); }
.compare-stat-overlap .compare-stat-value { color: var(--text); }

/* Section title inside compare tab */
.compare-section-title {
    margin: var(--space-lg) 0 var(--space-sm) 0;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Filter tabs (All / Both / ES Only / DuckDB Only) */
.compare-filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 3px;
    width: fit-content;
    margin-bottom: var(--space-md);
}

.compare-filter-tab {
    padding: 6px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
    font-family: inherit;
}

.compare-filter-tab:hover {
    color: var(--text);
    background: var(--surface);
}

.compare-filter-tab.active {
    background: var(--surface);
    color: var(--text);
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Found-by badges */
.compare-found-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.compare-found-both {
    background: var(--success-light);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.compare-found-es {
    background: var(--info-light);
    color: var(--info-text);
    border: 1px solid var(--info-border);
}

.compare-found-duckdb {
    background: var(--warning-light);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}

/* Small field tags inside results cells */
.compare-field-tag {
    display: inline-block;
    background: var(--bg-alternate);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1px 6px;
    font-size: 0.7rem;
    margin: 1px 2px;
    color: var(--text-secondary);
}

/* Dark theme overrides */
[data-theme="dark"] .compare-trigger-section,
[data-theme="dark"] .compare-status-panel,
[data-theme="dark"] .compare-stat-card {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .compare-filter-tabs {
    background: var(--bg);
}

[data-theme="dark"] .compare-filter-tab.active {
    background: var(--bg-secondary);
}

/* ===== ES Profiles Tab ===== */

.es-preset-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--info-light);
    color: var(--info-text);
    border: 1px solid var(--info-border);
}

.es-custom-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--primary-light);
    color: var(--primary-text);
    border: 1px solid var(--primary-border);
}

/* Editor layout: form + preview side-by-side on wide screens */
.es-profile-editor-layout {
    display: flex;
    gap: var(--space-lg);
    align-items: flex-start;
}

.es-profile-form-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.es-profile-preview-col {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
}

/* Profile section (collapsible) */
.es-profile-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.es-section-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md);
    cursor: pointer;
    user-select: none;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition-fast);
}

.es-section-header:hover {
    background: var(--bg-alternate);
}

.es-section-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.es-section-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

.es-section-chevron {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 3px;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.es-section-body {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Signal cards within a section */
.es-signal-card {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.es-signal-card-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px var(--space-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
}

.es-signal-card-header strong {
    font-size: 0.85rem;
    color: var(--text);
}

.es-signal-card-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.es-signal-rows {
    display: flex;
    flex-direction: column;
}

/* Individual signal row */
.es-signal-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px var(--space-md);
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
}

.es-signal-row:last-child {
    border-bottom: none;
}

.es-signal-row:hover {
    background: var(--primary-50);
}

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

.es-signal-label {
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text);
}

.es-signal-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Importance/Impact select */
.es-importance-select {
    flex-shrink: 0;
    width: 100px;
    padding: 4px 6px;
    font-size: 0.78rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.es-importance-select:focus {
    outline: none;
    box-shadow: var(--focus-ring);
    border-color: var(--primary-border);
}

/* Toggle switch */
.es-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.es-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.es-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border-medium);
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
}

.es-toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.es-toggle input:checked + .es-toggle-slider {
    background: var(--primary);
}

.es-toggle input:checked + .es-toggle-slider::before {
    transform: translateX(16px);
}

.es-toggle input:focus + .es-toggle-slider {
    box-shadow: var(--focus-ring);
}

/* Filters grid */
.es-filters-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.es-filters-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

/* Profile actions */
.es-profile-actions {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md) 0;
}

/* Live preview panel */
.es-preview-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.es-preview-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px var(--space-md);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.84rem;
}

.es-preview-icon {
    font-size: 1rem;
}

.es-preview-body {
    padding: var(--space-md);
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
    min-height: 120px;
}

/* Tab header with back button */
.tab-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.tab-header-left h2 {
    margin: 0;
}

/* Label hint text */
.label-hint {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
}

/* Dark theme overrides */
[data-theme="dark"] .es-signal-card {
    background: var(--bg);
    border-color: var(--border);
}

[data-theme="dark"] .es-signal-card-header {
    background: var(--bg-secondary);
    border-color: var(--border);
}

[data-theme="dark"] .es-profile-section {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .es-section-header {
    background: var(--bg-secondary);
    border-color: var(--border);
}

[data-theme="dark"] .es-importance-select {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .es-preview-panel {
    background: var(--bg-secondary);
    border-color: var(--border);
}

[data-theme="dark"] .es-preview-header {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .es-toggle-slider {
    background: var(--border-medium);
}

[data-theme="dark"] .es-toggle input:checked + .es-toggle-slider {
    background: var(--primary);
}

/* Responsive: stack preview below form on narrow screens */
@media (max-width: 900px) {
    .es-profile-editor-layout {
        flex-direction: column;
    }
    .es-profile-preview-col {
        width: 100%;
        position: static;
    }
    .es-filters-row {
        grid-template-columns: 1fr;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== Edit Client Modal (wide, tabbed) ===== */
/* Reuses .modal-wide for the outer sizing (min-width 800px, max-width 1200px,
   max-height 85vh, flex column, padding 0). This block handles the internal
   layout: sticky header with close button, tab strip, scrolling form body,
   and sticky footer so Save/Cancel stays pinned on tall forms. */
.edit-client-modal {
    height: 90vh;
    max-height: 90vh;
}

.edit-client-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.edit-client-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.edit-client-tabs {
    display: flex;
    gap: 0;
    padding: 0 var(--space-xl);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
}

.edit-client-tab {
    background: transparent;
    border: none;
    padding: 12px 18px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.edit-client-tab:hover {
    color: var(--text);
}

.edit-client-tab.active {
    color: var(--accent, #3b82f6);
    border-bottom-color: var(--accent, #3b82f6);
}

.edit-client-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0; /* allow inner flex child to scroll */
}

.edit-client-tab-content {
    display: none;
    flex: 1 1 auto;
    overflow-y: auto;
    padding: var(--space-lg) var(--space-xl);
}

.edit-client-tab-content.active {
    display: block;
}

.edit-client-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
}

.edit-client-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-lg) var(--space-xl);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
}

/* Per-section card inside the AI Prompt tab. One card per AiPromptSection,
   each with a header (title + status badge + actions) and a body containing
   the editable textarea. Collapsed-by-default via a [hidden] body when the
   section isn't being edited, so operators can scan the list quickly. */
.prompt-override-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.prompt-override-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.prompt-override-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.prompt-override-title small {
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
}

.prompt-override-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.prompt-override-body {
    margin-top: var(--space-sm);
}

.prompt-override-body textarea {
    width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    resize: vertical;
    min-height: 360px;
    background: var(--surface);
    color: var(--text);
}

/* Theme-aware preview pane for AI prompt content (global admin list,
   edit modal factory-default, and per-client override globals). Replaces
   inline `background: var(--bg-subtle, #f5f5f5)` which rendered as a light
   grey block in dark mode — unreadable against dark surrounding text. */
.ai-prompt-preview {
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    max-height: 480px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

[data-theme="dark"] .ai-prompt-preview {
    background: var(--header-bg-light);
    color: var(--text-on-dark);
    border-color: var(--header-border);
}

/* Selection inside the preview pane uses the brand green; in dark mode
   bump alpha so the highlight remains visible against the dark surface. */
[data-theme="dark"] ::selection {
    background: rgba(0, 255, 80, 0.35);
    color: var(--color-white);
}

/* Dashboard AI prompt cards */
.ai-prompt-status-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.ai-prompt-status-table th { text-align: left; padding: 6px 8px; color: var(--text-muted); font-weight: 500; border-bottom: 1px solid var(--border-light); }
.ai-prompt-status-table td { padding: 8px; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.ai-prompt-status-table tr:last-child td { border-bottom: none; }
.ai-prompt-section-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.ai-prompt-status-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}
.ai-prompt-status-default { background: rgba(16, 185, 129, 0.15); color: var(--success-dark); }
.ai-prompt-status-custom  { background: rgba(245, 158, 11, 0.15); color: var(--warning-text); }
.ai-prompt-status-override { background: rgba(99, 102, 241, 0.15); color: var(--info-text); }
[data-theme="dark"] .ai-prompt-status-default { color: var(--color-digital-green); }
[data-theme="dark"] .ai-prompt-status-custom  { color: var(--color-yellow); }
[data-theme="dark"] .ai-prompt-status-override { color: var(--color-blue); }

.ai-prompt-composed-summary { cursor: pointer; color: var(--text-muted); font-size: 0.85rem; padding: 4px 0; }
.ai-prompt-composed-actions { margin: 8px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.ai-prompt-composed-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 12px 0 4px; }

.link-button {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary-text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
}
.link-button:hover { text-decoration: underline; }
.link-button:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
[data-theme="dark"] .link-button { color: var(--color-digital-green); }

.prompt-override-status {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.prompt-override-status.using-global {
    background: rgba(16, 185, 129, 0.15);
    color: #0f766e;
}

.prompt-override-status.overridden {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}
