/* Voitta RAG Enterprise — Apple-flavoured UI, lifted from voitta-rag's palette. */

:root {
    --color-bg: #f5f5f7;
    --color-bg-elevated: #ffffff;
    --color-bg-hover: #e8e8ed;
    --color-text-primary: #1d1d1f;
    --color-text-secondary: #86868b;
    --color-text-tertiary: #aeaeb2;
    --color-accent: #0071e3;
    --color-accent-hover: #0077ed;
    --color-border: #d2d2d7;
    --color-border-light: #e5e5ea;
    --color-success: #34c759;
    --color-error: #ff3b30;
    --color-warning: #ff9500;

    --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
        "Helvetica Neue", Helvetica, Arial, sans-serif;

    --xs: 4px;
    --sm: 8px;
    --md: 16px;
    --lg: 24px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --t: 150ms ease;
}

[data-theme="dark"] {
    --color-bg: #1d1d1f;
    --color-bg-elevated: #2c2c2e;
    --color-bg-hover: #3a3a3c;
    --color-text-primary: #f5f5f7;
    --color-text-secondary: #a1a1a6;
    --color-text-tertiary: #636366;
    --color-accent: #0a84ff;
    --color-accent-hover: #409cff;
    --color-border: #3a3a3c;
    --color-border-light: #48484a;
}

* { box-sizing: border-box; }

/* Re-assert the [hidden] attribute against display:flex/grid rules below. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text-primary);
    font: 13px/1.4 var(--font);
    -webkit-font-smoothing: antialiased;
    /* Vertical flex so the main pane fills exactly the remaining viewport
       under the sticky header — lets the folder list scroll internally
       instead of pushing the page below the fold. */
    display: flex;
    flex-direction: column;
}

/* ---------- Header ---------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-border-light);
}
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    max-width: 1600px;
    margin: 0 auto;
}
.logo {
    font-weight: 600;
    font-size: 15px;
    color: var(--color-text-primary);
    text-decoration: none;
}
.header-actions { display: flex; align-items: center; gap: 12px; }

.status-pill {
    display: inline-flex;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 500;
    text-transform: lowercase;
}
.status-pill.connected {
    background: rgba(52, 199, 89, 0.15);
    color: var(--color-success);
}
.status-pill.disconnected {
    background: rgba(255, 59, 48, 0.15);
    color: var(--color-error);
}

/* ---------- Layout ---------- */

.app-main {
    /* Fill the height left by the sticky app header so children can claim
       their share of the viewport with min-height:0 + flex:1. Without
       min-height:0 a flex child refuses to shrink below its intrinsic
       content size and the grid below would force the whole page to scroll. */
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--lg);
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    /* Box-sizing safety: padding shouldn't make us overflow. */
    box-sizing: border-box;
}
.browser-container {
    display: flex;
    flex-direction: column;
    gap: var(--md);
    flex: 1;
    min-height: 0;
}
.toolbar {
    display: flex;
    gap: var(--sm);
    align-items: center;
    flex-wrap: wrap;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
}
.toolbar-group { display: flex; gap: 6px; align-items: center; }
.toolbar-divider {
    width: 1px;
    height: 22px;
    background: var(--color-border);
    margin: 0 4px;
}
.upload-progress {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    min-width: 220px;
    max-width: 480px;
}
.upload-progress-label {
    font-size: 11px;
    color: var(--color-text-secondary);
    white-space: nowrap;
}
.upload-progress-bar {
    flex: 1;
    min-width: 120px;
    height: 6px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}
.upload-progress-fill {
    height: 100%;
    width: 0;
    background: var(--color-accent);
    transition: width 100ms linear;
}
.upload-file-list {
    flex-basis: 100%;
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    max-height: 140px;
    overflow-y: auto;
    font-size: 11px;
    color: var(--color-text-secondary);
}
.upload-file-list li {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
}
.upload-file-list li .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.upload-file-list li .pct {
    font-variant-numeric: tabular-nums;
    color: var(--color-text-secondary);
    min-width: 36px;
    text-align: right;
}
.upload-file-list li.done .pct,
.upload-file-list li.done .name { color: var(--color-accent); }
.upload-file-list li.failed .pct,
.upload-file-list li.failed .name { color: #c33; }
.browser-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: var(--lg);
    align-items: stretch;
    flex: 1;
    min-height: 0;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sm);
    padding: 8px 16px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--t), color var(--t);
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

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

.btn-secondary {
    background: var(--color-bg-elevated);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-bg-hover); }

.btn-danger { background: #dc3545; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c82333; }

.btn-text {
    background: transparent;
    color: var(--color-accent);
    padding: 4px 8px;
    font: inherit;
    font-size: 12px;
    border: none;
    cursor: pointer;
}
.btn-text:hover { text-decoration: underline; }

input[type="text"], input[type="file"] {
    background: var(--color-bg);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font: inherit;
    width: 100%;
}

/* ---------- Folder list ---------- */

/* Container fills its grid cell vertically and turns into a flex column
   so the head row pins to the top while the <ul> below scrolls. */
.folder-list-container {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* One source of truth for the column layout — every row (head + body)
   uses this so header text aligns with cell content. Switch columns are
   locked to a fixed width to keep alignment predictable. */
:root {
    /* name · files · indexed · status · search · share */
    --tree-cols: 1fr 56px 64px 100px 56px 56px;
    --tree-gap: 10px;
    --tree-pad-x: 16px;
}
/* Depth indentation lives as padding-left on the .name-cell (see main.js).
   That keeps chevron + glyph + label moving together as a unit while the
   metadata columns to the right stay aligned with the column header. */
.tree-row .name-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    min-width: 0;
}

.tree-head {
    display: grid;
    grid-template-columns: var(--tree-cols);
    gap: var(--tree-gap);
    padding: 8px var(--tree-pad-x);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    flex-shrink: 0;
    /* The ul is a separate scroll container, so this row doesn't need
       position:sticky — but keep a subtle shadow when content scrolls
       under it for visual continuity. */
    position: relative;
    z-index: 1;
}
.tree-head .num { text-align: right; }
.tree-head .center { text-align: center; }

.tree {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    /* Hide horizontal scroll-bars on tight viewports — the toggle column
       widths are fixed, so there's no horizontal overflow to expose. */
    overflow-x: hidden;
}
.tree-row {
    display: grid;
    grid-template-columns: var(--tree-cols);
    align-items: center;
    gap: var(--tree-gap);
    padding: 5px var(--tree-pad-x);
    border-bottom: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: background var(--t);
    user-select: none;
}
/* Read-only shared folders (someone else owns them) get a left-edge accent
   so they stand out from your own. The accent persists even when selected. */
.tree-row.folder-root.shared-readonly {
    border-left: 3px solid var(--color-accent);
    padding-left: 13px;
    background: linear-gradient(
        to right,
        color-mix(in srgb, var(--color-accent) 6%, transparent),
        transparent 40%
    );
}
.tree-row.folder-root.shared-readonly.selected {
    background: var(--color-accent);
}

/* "Sign in with Google" button — matches Google's Identity Branding
   guidelines (https://developers.google.com/identity/branding-guidelines):
   white surface, 1px #dadce0 border, four-colour G mark, Roboto-style
   label. We render a real <a>, not an iframe widget, because we just need
   to send the user to /api/auth/login/google — no client-side SDK. */
.gsi-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    padding: 0 16px;
    height: 40px;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid #dadce0;
    border-radius: 4px;
    color: #1f1f1f;
    font-family: "Google Sans", "Roboto", -apple-system, BlinkMacSystemFont,
        "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.25px;
    text-decoration: none;
    cursor: pointer;
    transition: box-shadow 120ms ease, background 120ms ease;
    /* Subtle Material-style elevation that lifts on hover. */
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.06),
                0 1px 3px 1px rgba(60, 64, 67, 0.04);
}
.gsi-button:hover {
    background: #f8faff;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.10),
                0 2px 6px 2px rgba(60, 64, 67, 0.08);
}
.gsi-button:active {
    background: #f1f3f4;
    box-shadow: 0 1px 1px rgba(60, 64, 67, 0.10);
}
.gsi-button:focus-visible {
    outline: 2px solid #4285F4;
    outline-offset: 2px;
}
.gsi-button-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}
.gsi-button-label {
    line-height: 1;
}
/* Dark theme: invert to the Google "filled blue" variant — same brand
   guidelines, white G on a #131314 surface with reduced opacity. */
[data-theme="dark"] .gsi-button {
    background: #131314;
    border-color: #8e918f;
    color: #e3e3e3;
}
[data-theme="dark"] .gsi-button:hover {
    background: #1a1b1d;
    border-color: #ffffff;
}
[data-theme="dark"] .gsi-button:active {
    background: #232427;
}

/* Segmented tabs (e.g. Google Drive auth-mode picker). Two-button row
   styled like an iOS segmented control: the active segment gets the
   accent fill, hover dims the inactive side. Picked over a select-box
   because the choices change which fields render below — visible options
   make that consequence obvious without a dropdown click. */
.seg-tabs {
    display: inline-flex;
    margin: 6px 0 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    padding: 2px;
    gap: 2px;
}
.seg-tab {
    padding: 6px 14px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: transparent;
    border: none;
    border-radius: calc(var(--radius-md) - 2px);
    cursor: pointer;
    transition: background var(--t), color var(--t);
}
.seg-tab:hover:not(.active) {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}
.seg-tab.active {
    background: var(--color-accent);
    color: #fff;
}

/* Compact iOS-style toggle switch used for the per-folder Active and Share
   flags. Built around an unstyled checkbox so screen readers and keyboard
   navigation work for free. */
.folder-switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    flex-shrink: 0;
}
.folder-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}
.folder-switch .track {
    position: absolute;
    inset: 0;
    background: var(--color-text-tertiary);
    border-radius: 9px;
    transition: background var(--t);
    pointer-events: none;
}
.folder-switch .track::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 2px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform 120ms ease;
}
.folder-switch input:checked + .track {
    background: var(--color-accent);
}
.folder-switch input:checked + .track::before {
    transform: translateX(14px);
}
.folder-switch input:disabled + .track {
    opacity: 0.4;
    cursor: not-allowed;
}
.folder-switch input:disabled {
    cursor: not-allowed;
}
.tree-row:last-child { border-bottom: none; }
.tree-row:hover { background: var(--color-bg-hover); }
.tree-row.selected,
.tree-row.selected:hover { background: var(--color-accent); color: #fff; }
.tree-row.selected .num,
.tree-row.selected .label,
.tree-row.selected .chevron { color: #fff; }
.tree-row.selected .glyph { color: #fff; }

/* Legacy indent span — unused since depth moved to label padding-left.
   Kept hidden in case any cached JS still emits it. */
.tree-row .indent { display: none; }
.tree-row .chevron {
    width: 14px;
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 10px;
    transition: transform 120ms ease;
}
.tree-row .chevron.open { transform: rotate(90deg); }
.tree-row .chevron.leaf { visibility: hidden; }
.tree-row .label {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    font-size: 13px;
}
.tree-row .label .glyph {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    position: relative;  /* anchor for the .source-lock overlay */
}
/* Private-source lock badge layered over the bottom-right corner
   of the glyph. ~9 px so it's a clear cue without obscuring the
   underlying brand mark; backdrop disc keeps it legible whether
   the underlying icon is dark or light. */
.tree-row .label .glyph .source-lock {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-bg-elevated);
    padding: 1px;
    box-shadow: 0 0 0 1px var(--color-border);
}
.tree-row .label .glyph .source-lock[hidden] { display: none; }
/* Vendored SVGs carry their own colour. ``<img>`` keeps the raster
   pixel-perfect on retina without the per-render decode overhead a
   plain inline-SVG would pay. */
.tree-row .label .glyph .icon-img {
    width: 16px;
    height: 16px;
    display: block;
    /* Selection background is dark — keep the icon legible by adding
       a tiny shadow under the SVG so light strokes don't disappear
       on the accent fill. */
    image-rendering: -webkit-optimize-contrast;
}
.tree-row.file .label { color: var(--color-text-secondary); }

.tree-row .num {
    text-align: right;
    font-size: 12px;
    color: var(--color-text-secondary);
}

/* Status pill: smaller and quieter inside tree rows. */
.tree-row .status-tag {
    min-width: auto;
    font-size: 10px;
    padding: 1px 8px;
    text-transform: lowercase;
}
.tree-row.selected .status-tag {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* ---------- Status pills ---------- */

.status-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 90px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}
.status-tag.indexed { background: rgba(52, 199, 89, 0.15); color: var(--color-success); }
.status-tag.indexing,
.status-tag.embedding,
.status-tag.extracting,
.status-tag.extracted {
    background: rgba(0, 113, 227, 0.15);
    color: var(--color-accent);
}
.status-tag.pending { background: rgba(255, 149, 0, 0.15); color: var(--color-warning); }
.status-tag.error { background: rgba(255, 59, 48, 0.15); color: var(--color-error); }
.status-tag.unsupported,
.status-tag.deleted,
.status-tag.none {
    background: rgba(142, 142, 147, 0.18);
    color: var(--color-text-secondary);
}

/* ---------- Sidebar ---------- */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--md);
    /* Match the folder-list pattern: the sidebar is a grid cell with
       height already fixed by the layout above, so it just needs to scroll
       internally when its sections (extension table, kv-grid) overflow. */
    min-height: 0;
    overflow-y: auto;
}
.sidebar-section {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    padding: var(--lg);
}
.sidebar-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 var(--md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-actions-inline { display: flex; gap: 4px; }

/* Sidebar tab strip — Details vs Jobs. Two equal-width buttons; the
   active one gets the accent fill (matching .seg-tab styling). */
.sidebar-tabs {
    display: flex;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
}
.sidebar-tab {
    flex: 1;
    padding: 8px 14px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: transparent;
    border: none;
    border-radius: calc(var(--radius-md) - 2px);
    cursor: pointer;
    transition: background var(--t), color var(--t);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.sidebar-tab:hover:not(.active) {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}
.sidebar-tab.active {
    background: var(--color-accent);
    color: #fff;
}
/* Activity dot on the Jobs tab while jobs are queued/running/errored.
   Small, accent-coloured pulse so the user notices motion in a tab they
   aren't currently looking at. Goes white-on-accent when its tab is the
   active one, so it stays visible against the new background. */
.tab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-accent);
    display: inline-block;
}
.sidebar-tab.active .tab-dot { background: #fff; }
.sidebar-tab[data-state="error"] .tab-dot { background: #dc3545; }
.sidebar-tab.active[data-state="error"] .tab-dot { background: #fff; }

/* Tab pane is a column-flex container so the inner sidebar-sections
   stack the same way they did pre-tabs. ``hidden`` works natively. */
.sidebar-tab-pane {
    display: flex;
    flex-direction: column;
    gap: var(--md);
    min-height: 0;
}

.sidebar-empty { text-align: center; }
.hint, .hint-large { color: var(--color-text-secondary); }
.hint { font-size: 11px; margin: 0; }
.hint-large { font-size: 13px; }

#folder-detail h3 {
    font-size: 17px;
    color: var(--color-text-primary);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 600;
    margin: 0 0 4px;
    display: block;
}
.path {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 11px;
    color: var(--color-text-secondary);
    word-break: break-all;
    margin: 0 0 var(--md);
}
.badge-row { display: flex; gap: 6px; margin-bottom: var(--md); }
.badge {
    background: rgba(142, 142, 147, 0.18);
    color: var(--color-text-secondary);
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}
.kv-grid {
    display: grid;
    grid-template-columns: 90px 1fr;
    row-gap: 6px;
    margin-bottom: var(--md);
    font-size: 12px;
}
.kv-grid .k { color: var(--color-text-secondary); }
.kv-grid .v { font-weight: 500; }

.actions { display: flex; gap: 8px; }
.actions-right { justify-content: flex-end; }

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: var(--md);
}
.stats-table th {
    text-align: left;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.05em;
    padding: 4px 0;
    border-bottom: 1px solid var(--color-border-light);
}
.stats-table th.num,
.stats-table td.num { text-align: right; }
.stats-table td {
    padding: 4px 0;
    border-bottom: 1px solid var(--color-border-light);
}
.stats-table tr:last-child td { border-bottom: none; }
.stats-table .ext { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* Per-extension row coloring in the by-extension table.
   Tints are subtle so the table still scans as a list, not a heatmap. */
.stats-table tr.ext-error td      { color: var(--color-error); }
.stats-table tr.ext-error .ext    { color: var(--color-error); }
.stats-table tr.ext-unsupported td { color: var(--color-text-secondary); font-style: italic; }
.stats-table tr.ext-pending td    { color: var(--color-warning); }
.stats-table tr.ext-indexed td    { color: var(--color-text); }

.file-rows, .job-rows {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 280px;
    overflow-y: auto;
}
.file-rows li, .job-rows li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-border-light);
    font-size: 12px;
}
.file-rows li:last-child, .job-rows li:last-child { border-bottom: none; }
.file-rows .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.job-rows .col { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.job-rows .meta { color: var(--color-text-tertiary); font-size: 11px; }
.job-rows .path {
    /* Filename / rel-path under the kind label. Mono so long paths
       wrap on slashes legibly; secondary colour so the bottleneck file
       doesn't shout louder than the kind line. */
    color: var(--color-text-secondary);
    font-size: 11px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    word-break: break-all;
    overflow-wrap: anywhere;
}
.job-rows .err { color: var(--color-error); font-size: 11px; word-break: break-word; }
.job-rows .retry {
    background: transparent;
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
    border-radius: var(--radius-sm);
    font-size: 11px;
    padding: 2px 8px;
    cursor: pointer;
}
.job-rows .retry:hover { background: var(--color-accent); color: #fff; }

/* Per-job cancel — danger-coloured to mirror the destructive intent.
   Same shape as .retry so they align when both happen to be visible
   (rare but possible: an error row plus a freshly-queued retry). */
.job-rows .cancel {
    background: transparent;
    border: 1px solid #dc2626;
    color: #dc2626;
    border-radius: var(--radius-sm);
    font-size: 11px;
    padding: 2px 8px;
    cursor: pointer;
}
.job-rows .cancel:hover:not(:disabled) { background: #dc2626; color: #fff; }
.job-rows .cancel:disabled { opacity: 0.5; cursor: not-allowed; }

#upload-card .btn,
#upload-card input { margin-top: 8px; }

/* ---------- Modal ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--color-bg-elevated);
    border-radius: var(--radius-lg);
    width: min(92vw, 520px);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}
.modal.modal-wide { width: min(94vw, 720px); }
.modal-body input[type="text"],
.modal-body input[type="password"],
.modal-body select,
.modal-body textarea {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 6px 10px;
    color: var(--color-text);
    font: inherit;
    width: 100%;
    box-sizing: border-box;
}
.modal-body textarea { font: 12px ui-monospace, "SF Mono", Menlo, monospace; resize: vertical; }
.modal-body select[multiple] { padding: 4px; }

/* Sync status header: ``status: error · last: …`` text on the left,
   inline ``Clear errors`` button on the right when an error exists. */
.sync-status-line-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--md);
}
.sync-error-clear {
    flex-shrink: 0;
}

/* Sync error banner under the status line. White-on-red so it reads
   as "stop — fix this" rather than the muted hint colour the rest of
   ``.hint`` text uses. Preserves newlines so multi-API failures from
   the preflight stack legibly. Fixed height + internal scroll so a
   long history (e.g. an hourly auto-sync run that's been failing for
   days) doesn't push the rest of the modal off-screen. */
.sync-error-block {
    margin: 8px 0 0;
    padding: 8px 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 3px solid #dc2626;
    border-radius: 4px;
    color: #7f1d1d;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 11px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 180px;
    overflow-y: auto;
}
.sync-error-block a {
    color: #1d4ed8;
    text-decoration: underline;
}

/* Provider picker on the GD sync OAuth pane: visually distinguish
   "picked from saved providers" from manual entry by tagging the
   following inputs while a provider is selected. The accent left-border
   is a subtle hint that the field's value came from somewhere else. */
.sync-gd-provider-row { margin: 0 0 4px; }
.sync-gd-pane.provider-picked input#sync-gd-client-id,
.sync-gd-pane.provider-picked input#sync-gd-client-secret {
    border-left: 3px solid var(--color-accent);
}
.modal-body .radio-row,
.modal-body .branches-row,
.modal-body .check-row {
    display: flex;
    align-items: center;
    gap: var(--md);
    flex-wrap: wrap;
}
.modal-body .radio-row label,
.modal-body .check-row label,
.modal-body .branches-row label {
    text-transform: none;
    color: var(--color-text);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--md) var(--lg);
    border-bottom: 1px solid var(--color-border-light);
}
.modal-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body {
    padding: var(--lg);
    display: flex;
    flex-direction: column;
    gap: var(--md);
    overflow-y: auto;
}
.modal-body label {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.agpl-footer {
    padding: var(--md);
    text-align: center;
    font-size: 12px;
    color: var(--color-text-tertiary);
    border-top: 1px solid var(--color-border-light);
    margin-top: var(--lg);
}
.agpl-footer a { color: var(--color-text-secondary); text-decoration: none; }
.agpl-footer a:hover { color: var(--color-accent); }

/* Admin panel
 *
 * Density choices:
 *   - 3-up grid for the three allowlist editors so vertical scrolling
 *     is rarely needed even on a 13" laptop.
 *   - Per-section header is one row: h4 + a small inline hint, no
 *     dedicated <p> blocks.
 *   - Lists capped at 140px scroll, since real allowlists rarely have
 *     more than a handful of entries; if they do, the user scrolls.
 *   - The Users table is the dense piece — 32px rows, monospace email,
 *     small action buttons.
 */
.admin-modal { max-width: 880px; }
.admin-body { padding: 16px 20px; gap: 14px; }

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 600px) {
    .admin-grid { grid-template-columns: 1fr; }
}

.admin-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}
.admin-section header {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.admin-section header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
}
.admin-section header .hint { font-size: 11px; line-height: 1.3; }

.admin-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    max-height: 140px;
    overflow-y: auto;
    /* modal-body is display:flex/column with overflow-y:auto; without
       flex-shrink:0 the column flex layout collapses non-fixed-height
       items even though the modal can scroll. */
    flex-shrink: 0;
    background: var(--color-bg);
}
.admin-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px 4px 10px;
    border-bottom: 1px solid var(--color-border-light);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
}
.admin-list li:last-child { border-bottom: none; }
.admin-list li.empty { color: var(--color-text-tertiary); font-family: inherit; font-style: italic; padding: 6px 10px; }
.admin-list .btn-remove {
    background: none;
    border: none;
    color: var(--color-text-tertiary);
    cursor: pointer;
    padding: 0 4px;
    font-size: 14px;
    line-height: 1;
}
.admin-list .btn-remove:hover { color: #ef4444; }

.admin-add-row {
    display: flex;
    gap: 6px;
}
.admin-add-row input {
    flex: 1;
    min-width: 0;
    padding: 4px 8px;
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 12px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.admin-users { margin-top: 4px; }
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.admin-table th, .admin-table td {
    text-align: left;
    padding: 5px 10px;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}
.admin-table th {
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: transparent;
    border-bottom-color: var(--color-border);
}
.admin-table td:first-child {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.admin-table td:last-child {
    text-align: right;
    width: 80px;
}
.admin-add-user { margin-top: 8px; }

/* Admin tab strip: reuses .seg-tab from the GD modal but laid out
   full-width so all three buckets get equal real estate. The
   ``.admin-tabs`` selector adds the ``display:flex`` override (the
   default seg-tabs is inline-flex). */
.admin-tabs {
    display: flex;
    width: 100%;
    margin-bottom: 14px;
}
.admin-tabs .seg-tab { flex: 1; }
.admin-tab-pane {
    display: flex;
    flex-direction: column;
    gap: var(--md);
    min-width: 0;
}

/* Auth-provider section: a wider table (the actions column carries a
   Check button + status pill + Delete). The Actions column overrides
   the global ``td:last-child {width:80px}`` rule because we need room
   for the inline check status. */
.admin-auth-providers { margin-top: 0; }
.admin-auth-providers .admin-table td:last-child {
    width: auto;
    text-align: left;
}
.admin-auth-providers .admin-table td input[type="text"] {
    padding: 4px 8px;
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 12px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* Add-provider card: a collapsible, labeled form. Rendered as a 2x2
   grid so each field has room to breathe and the credentials sit on
   their own lines (full-width). Never wider than the table above it. */
.admin-add-card {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    background: var(--color-bg);
}
.admin-add-card > summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
    user-select: none;
}
.admin-add-card > summary strong {
    color: var(--color-text-primary);
    font-weight: 600;
}
.admin-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    margin-bottom: 12px;
}
.admin-form-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 0;
}
.admin-form-grid label.span-2 { grid-column: span 2; }
.admin-form-grid input[type="text"],
.admin-form-grid select {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 10px;
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    background: var(--color-bg-elevated);
    color: var(--color-text);
    font-size: 13px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    text-transform: none;
    letter-spacing: 0;
}
.admin-inline-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    cursor: pointer;
    user-select: none;
    /* Match the input's vertical padding so all three controls in the
       row align on the same baseline. */
    padding: 0 6px;
}
.admin-inline-check input[type="checkbox"] { margin: 0; }

.admin-table .badge-super {
    font-size: 9px;
    background: var(--color-accent);
    color: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 6px;
    letter-spacing: 0.04em;
    font-family: var(--font);
}

