/*
 * VexsAI design system — light theme.
 * Replaces core's dark app.css. Every screen shares one vocabulary of classes
 * (card, btn, pill, sev-*, grid-table, list-toolbar, tool-tabs, …), so they are
 * all styled here. Tokens first, then base, shell, components, page specifics.
 */

/* ------------------------------------------------------------------ tokens */
:root {
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f4f9;
    --line: #e4e7ec;
    --line-strong: #d0d5dd;
    --ink: #101828;
    --ink-2: #344054;
    --muted: #667085;
    --faint: #98a2b3;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --primary-line: #c7d2fe;
    --primary-ink: #3730a3;
    --accent: #0ea5e9;

    --crit: #d92d20;  --crit-soft: #fef3f2;  --crit-line: #fecdca;  --crit-ink: #b42318;
    --high: #e8590c;  --high-soft: #fff4ed;  --high-line: #fdd6bd;  --high-ink: #b93815;
    --med:  #ca8504;  --med-soft:  #fefbe8;  --med-line:  #feeaa0;  --med-ink:  #a15c07;
    --low:  #079455;  --low-soft:  #ecfdf3;  --low-line:  #abefc6;  --low-ink:  #067647;
    --info: #475467;  --info-soft: #f2f4f7;  --info-line: #d0d5dd;  --info-ink: #344054;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-md: 0 8px 24px -4px rgba(16, 24, 40, .10), 0 2px 6px -2px rgba(16, 24, 40, .05);
    --shadow-lg: 0 20px 48px -12px rgba(16, 24, 40, .18);
    --ring: 0 0 0 4px rgba(79, 70, 229, .14);

    --sidebar-w: 264px;
    --topbar-h: 64px;

    /* names core's templates still use in inline styles */
    --panel: var(--surface);
    --panel-2: var(--surface-2);
    --accent-ink: #fff;
}

/* -------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--ink);
    font: 14px/1.55 var(--font); font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 2px; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
code, pre, kbd { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-3); border: 1px solid var(--line); border-radius: 5px; padding: .08rem .35rem; color: var(--ink-2); word-break: break-word; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; overflow-x: auto; }
pre code { background: none; border: 0; padding: 0; }
::selection { background: var(--primary-soft); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

h1, h2, h3, h4 { color: var(--ink); letter-spacing: -.015em; }
h1 { font-size: 1.5rem; font-weight: 650; line-height: 1.25; margin: 0 0 1.25rem; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 1.75rem 0 .75rem; }
h3 { font-size: .98rem; font-weight: 600; margin: 0 0 .35rem; }
h4 { font-size: .9rem; font-weight: 600; margin: 1rem 0 .4rem; }
p { margin: 0 0 .9rem; }
.muted { color: var(--muted); }
.small, .small-text { font-size: .8rem; }
.hint { color: var(--muted); font-size: .8rem; margin: .3rem 0 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.req { color: var(--crit); }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > div { min-width: 0; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.inline { display: inline; margin: 0; }
.counts span { margin-right: 1rem; }
.counts span:last-child { margin-right: 0; }

/* page header: core's "spread" with an h1 + actions */
.container > .spread:first-child, .container > .flash + .spread, .app-list-heading { margin-bottom: 1.5rem; align-items: flex-start; }
.container > .spread:first-child > h1, .app-list-heading h1 { margin: 0; }
.app-list-heading p { margin: .35rem 0 0; max-width: 72ch; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: .35rem 0 0; color: var(--muted); max-width: 72ch; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ------------------------------------------------------------------- shell */
.app-shell { min-height: 100vh; }
.app-shell.has-sidebar { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.workspace { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.container { width: 100%; max-width: 1320px; margin: 0 auto; padding: 1.75rem 2rem 2.5rem; flex: 1; }
.foot { color: var(--faint); font-size: .76rem; padding: 1rem 2rem 1.5rem; text-align: center; }

/* sidebar */
.sidebar {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--line); z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: .65rem; height: var(--topbar-h); padding: 0 1.25rem; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.sidebar-brand:hover { text-decoration: none; }
.brand-mark {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 45%, #0ea5e9 100%);
    box-shadow: 0 4px 12px -2px rgba(79, 70, 229, .45); font-size: 1.1rem;
}
.brand-name { font-weight: 700; color: var(--ink); font-size: 1.02rem; letter-spacing: -.02em; line-height: 1.1; }
.brand-name small { display: block; color: var(--muted); font-weight: 500; font-size: .7rem; letter-spacing: .02em; }
.side-nav { flex: 1; overflow-y: auto; padding: .9rem .75rem 1.25rem; scrollbar-width: thin; }
.side-section { margin-bottom: .35rem; }
.side-section > summary {
    display: flex; align-items: center; gap: .5rem; list-style: none; cursor: pointer; user-select: none;
    padding: .55rem .6rem .4rem; color: var(--faint); font-size: .68rem; font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
}
.side-section > summary::-webkit-details-marker { display: none; }
.side-section > summary .ti { margin-left: auto; font-size: .85rem; transition: transform .15s; }
.side-section:not([open]) > summary .ti { transform: rotate(-90deg); }
.side-section > summary:hover { color: var(--muted); }
.side-link {
    display: flex; align-items: center; gap: .65rem; padding: .48rem .65rem; margin: 1px 0; border-radius: 8px;
    color: var(--ink-2); font-weight: 500; font-size: .875rem; line-height: 1.3;
}
.side-link .ti { font-size: 1.15rem; color: var(--faint); flex: 0 0 auto; transition: color .12s; }
.side-link:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.side-link:hover .ti { color: var(--ink-2); }
.side-link[aria-current="page"] { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.side-link[aria-current="page"] .ti { color: var(--primary); }
.sidebar-foot { border-top: 1px solid var(--line); padding: .75rem 1rem; font-size: .72rem; color: var(--faint); flex: 0 0 auto; }

/* topbar */
.topbar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem;
    height: var(--topbar-h); padding: 0 2rem; background: rgba(255, 255, 255, .86);
    backdrop-filter: saturate(180%) blur(10px); -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar .brand { display: none; }
.crumbs { display: flex; align-items: center; gap: .45rem; min-width: 0; color: var(--muted); font-size: .86rem; white-space: nowrap; overflow: hidden; }
.crumbs .ti { font-size: .9rem; color: var(--faint); }
.crumbs strong { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.topbar-account { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.icon-btn {
    position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
    border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; font-size: 1.25rem;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.nav-toggle { display: none; }

/* user menu */
.user-menu { position: relative; }
.user-trigger {
    display: flex; align-items: center; gap: .6rem; padding: .3rem .5rem .3rem .3rem; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface); cursor: pointer; font: inherit; color: var(--ink);
}
.user-trigger:hover { border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.avatar {
    display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
    background: linear-gradient(135deg, #818cf8, #4f46e5); color: #fff; font-weight: 650; font-size: .75rem; letter-spacing: .02em;
}
.user-trigger .who { font-weight: 600; font-size: .84rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-trigger .ti { color: var(--faint); font-size: .9rem; }
.menu-panel {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 60; padding: .4rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.menu-panel[hidden] { display: none; }
.menu-head { padding: .6rem .7rem .7rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; }
.menu-head strong { display: block; font-size: .88rem; }
.menu-head span { color: var(--muted); font-size: .78rem; word-break: break-all; }
.menu-item, .menu-panel button.link {
    display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .7rem; border-radius: 8px;
    color: var(--ink-2); font-size: .86rem; background: none; border: 0; cursor: pointer; text-align: left; font-family: inherit;
}
.menu-item:hover, .menu-panel button.link:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.menu-item .ti, .menu-panel button.link .ti { font-size: 1.05rem; color: var(--muted); }
.menu-panel form { margin: 0; }
.menu-sep { height: 1px; background: var(--line); margin: .3rem 0; }

/* ------------------------------------------------------------------- cards */
.card {
    position: relative; display: block; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-lg); padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; box-shadow: var(--shadow-xs);
    color: inherit;
}
a.card { transition: border-color .15s, box-shadow .15s, transform .15s; }
a.card:hover { text-decoration: none; border-color: var(--primary-line); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card.muted { color: var(--muted); }
.card[style*="padding:0"] > .table-scroll, .card[style*="padding: 0"] > .table-scroll { border-radius: inherit; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.1rem; margin-bottom: 1.25rem; }
.grid > .card { margin-bottom: 0; }

/* empty state inside a card */
.card.muted:only-child, .empty { text-align: center; padding: 2.25rem 1.5rem; }
.empty .ti { display: block; font-size: 2rem; color: var(--faint); margin-bottom: .5rem; }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1.1rem; margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; box-shadow: var(--shadow-xs); display: flex; gap: .9rem; align-items: flex-start; color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--primary-line); box-shadow: var(--shadow-md); }
.stat-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; font-size: 1.35rem; flex: 0 0 auto; background: var(--primary-soft); color: var(--primary); }
.stat-icon.green { background: var(--low-soft); color: var(--low); }
.stat-icon.orange { background: var(--high-soft); color: var(--high); }
.stat-icon.red { background: var(--crit-soft); color: var(--crit); }
.stat-icon.sky { background: #f0f9ff; color: #0284c7; }
.stat-label { color: var(--muted); font-size: .78rem; font-weight: 500; }
.stat-value { font-size: 1.55rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; margin-top: .1rem; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: .85rem; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.stat-sub { color: var(--muted); font-size: .76rem; margin-top: .15rem; }
.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: .55rem; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.meter.warn > span { background: var(--high); }

/* section heading row */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.75rem 0 .75rem; }
.section-head h2 { margin: 0; }

/* ------------------------------------------------------------------- forms */
label { display: block; margin: 1rem 0 .35rem; font-weight: 550; font-size: .84rem; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search],
input[type=date], input[type=datetime-local], input[type=time], input[type=tel], select, textarea {
    width: 100%; min-height: 40px; padding: .5rem .75rem; font: inherit; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow-xs);
    transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 96px; line-height: 1.5; resize: vertical; }
select {
    appearance: none; -webkit-appearance: none; padding-right: 2.2rem; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .65rem center; background-size: 16px;
}
select[multiple] { background-image: none; padding-right: .75rem; min-height: 110px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: #b4bcc8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
input[type=color] { width: 56px; height: 40px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); cursor: pointer; }
input[type=file] { font: inherit; font-size: .84rem; color: var(--muted); }
input[type=file]::file-selector-button {
    margin-right: .75rem; padding: .45rem .8rem; border-radius: 8px; border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--ink-2); font: inherit; font-weight: 550; cursor: pointer;
}
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.check { display: flex; align-items: flex-start; gap: .6rem; margin: .65rem 0; font-weight: 400; color: var(--ink-2); font-size: .875rem; }
.check input { margin-top: .15rem; flex: 0 0 auto; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .1rem 1.25rem; }
.field-error { color: var(--crit-ink); font-size: .8rem; margin: .35rem 0 0; }
.field-error::before { content: "\ea05"; font-family: "tabler-icons"; margin-right: .3rem; }

/* ----------------------------------------------------------------- buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 38px;
    padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--primary); background: var(--primary); color: #fff;
    font: inherit; font-weight: 600; font-size: .86rem; line-height: 1.2; cursor: pointer; white-space: nowrap;
    box-shadow: 0 1px 2px rgba(79, 70, 229, .25), inset 0 1px 0 rgba(255, 255, 255, .12);
    transition: background .12s, border-color .12s, box-shadow .12s, color .12s;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn .ti { font-size: 1.05rem; }
.btn.secondary { background: var(--surface); color: var(--ink-2); border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.btn.secondary:hover { background: var(--surface-2); color: var(--ink); border-color: #b4bcc8; }
.btn.danger, button.danger:not(.link-button) { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn.danger:hover { background: var(--crit-ink); border-color: var(--crit-ink); }
.btn.small { min-height: 32px; padding: .35rem .75rem; font-size: .8rem; }
.btn.secondary.danger { background: var(--surface); color: var(--crit-ink); border-color: var(--crit-line); }
.btn.secondary.danger:hover { background: var(--crit-soft); }
button.link, .link-button {
    background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; font-weight: 550;
}
button.link:hover, .link-button:hover { color: var(--primary-hover); text-decoration: underline; }
.link-button.danger { color: var(--crit-ink); }

/* -------------------------------------------------------------------- tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .865rem; }
th, td { text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
    color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
    background: var(--surface-2); white-space: nowrap;
}
th a { color: inherit; }
th a:hover { color: var(--ink); text-decoration: none; }
tbody tr:last-child td, table tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: #fafbfd; }
td .muted, td.muted { font-size: .82rem; }
.card > table, .card > .table-scroll { margin: 0 -1.4rem; width: calc(100% + 2.8rem); }
.card > table:first-child, .card > .table-scroll:first-child { margin-top: -1.25rem; }
.card > table:last-child, .card > .table-scroll:last-child { margin-bottom: -1.25rem; }
.card > table th:first-child, .card > table td:first-child { padding-left: 1.4rem; }
.card > table th:last-child, .card > table td:last-child { padding-right: 1.4rem; }
.card > table:first-child tr:first-child th:first-child { border-top-left-radius: var(--radius-lg); }
.card > table:first-child tr:first-child th:last-child { border-top-right-radius: var(--radius-lg); }
.card[style*="padding:0"] > .table-scroll, .card[style*="padding: 0"] > .table-scroll { margin: 0; width: 100%; }
.table-scroll { overflow-x: auto; }
.table-scroll.tall { max-height: none; }
.table-scroll th:first-child, .table-scroll td:first-child { padding-left: 1.4rem; }
.table-scroll th:last-child, .table-scroll td:last-child { padding-right: 1.4rem; }
.grid-table thead th { position: sticky; top: 0; z-index: 1; }
table.data { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: .5rem 0 1rem; }
table.data td { vertical-align: top; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; margin: 0 0 0 .4rem; }
.row-actions a + a, .row-actions a + form, .row-actions form + a { margin-left: .6rem; }
tr.row-deleted td { background: #fcfcfd; color: var(--muted); }
tr.row-deleted td a { color: var(--muted); }
tr.job-error td { background: var(--crit-soft); border-top: 0; font-size: .8rem; }

/* ------------------------------------------------------------- pills / status */
.pill, .tab-count {
    display: inline-flex; align-items: center; gap: .3rem; padding: .14rem .55rem; border-radius: 999px;
    font-size: .7rem; font-weight: 600; line-height: 1.45; letter-spacing: .01em; white-space: nowrap; vertical-align: middle;
    border: 1px solid var(--info-line); background: var(--info-soft); color: var(--info-ink);
}
.pill.sev-critical { background: var(--crit-soft); border-color: var(--crit-line); color: var(--crit-ink); }
.pill.sev-high     { background: var(--high-soft); border-color: var(--high-line); color: var(--high-ink); }
.pill.sev-medium   { background: var(--med-soft);  border-color: var(--med-line);  color: var(--med-ink); }
.pill.sev-low      { background: var(--low-soft);  border-color: var(--low-line);  color: var(--low-ink); }
.pill.sev-info     { background: var(--info-soft); border-color: var(--info-line); color: var(--info-ink); }
.pill.sev-critical::before, .pill.sev-high::before, .pill.sev-medium::before, .pill.sev-low::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85;
}
.pill[style*="background"] { border-color: transparent; }
/* bare sev-* (not a pill): solid swatch, as core used it */
.sev-critical:not(.pill):not(.toast) { color: var(--crit-ink); }
.sev-high:not(.pill):not(.toast) { color: var(--high-ink); }
.sev-medium:not(.pill):not(.toast) { color: var(--med-ink); }
.sev-low:not(.pill):not(.toast) { color: var(--low-ink); }
.tab-count { margin-left: .35rem; padding: .02rem .45rem; font-size: .68rem; }

.status { font-weight: 600; text-transform: capitalize; white-space: nowrap; }
.status::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: .45rem; background: currentColor; vertical-align: middle; position: relative; top: -1px; }
.status-queued { color: #6172f3; }
.status-running { color: var(--accent); }
.status-running::before { animation: pulse 1.4s ease-in-out infinite; }
.status-completed { color: var(--low); }
.status-partial { color: var(--med); }
.status-failed, .status-timed_out, .status-cancelled { color: var(--crit); }
.status-skipped { color: var(--faint); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, .5); } 50% { box-shadow: 0 0 0 5px rgba(14, 165, 233, 0); } }

.delta-new { color: var(--high-ink); font-weight: 600; }
.delta-recurring { color: var(--med-ink); }
.delta-fixed { color: var(--low-ink); font-weight: 600; }

.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .4s; }

/* --------------------------------------------------------------- alerts */
.flash, .errors {
    display: flex; gap: .65rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius);
    margin-bottom: 1.25rem; font-size: .875rem; border: 1px solid;
}
.flash { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary-ink); }
.flash::before { content: "\ea67"; font-family: "tabler-icons"; font-size: 1.1rem; line-height: 1.25; }
.errors { background: var(--crit-soft); border-color: var(--crit-line); color: var(--crit-ink); }
.errors::before { content: "\ea05"; font-family: "tabler-icons"; font-size: 1.1rem; line-height: 1.25; }
.errors ul { margin: 0; padding-left: 1.1rem; }
.errors > ul:only-child { padding-left: 1.1rem; }

/* ------------------------------------------------------------ list pages */
.list-toolbar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; margin: 0 0 1rem; padding: .85rem 1rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.list-toolbar .list-search {
    flex: 1 1 260px; max-width: 420px; padding-left: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2398a2b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: .7rem center; background-size: 16px;
}
.list-filter { display: flex; flex-direction: column; gap: .25rem; margin: 0; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.list-filter span { color: var(--faint); }
.list-filter select { width: auto; min-width: 130px; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .86rem; }
.list-summary { margin: 0 0 .75rem; font-size: .8rem; color: var(--muted); }
.list-summary strong { color: var(--ink-2); }
.list-pagination { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; margin: 1rem 0 0; }
.list-pagination a, .list-pagination span {
    display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 .7rem; border-radius: 8px;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: .82rem; font-weight: 500;
}
.list-pagination a:hover { border-color: var(--line-strong); background: var(--surface-2); text-decoration: none; color: var(--ink); }
.list-pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.list-pagination .disabled { opacity: .45; }
.list-pagination span.muted { border: 0; background: none; min-width: 0; padding: 0 .2rem; }

/* ---------------------------------------------------------------- tabs */
.tool-editor, .catalog-tabbed-editor { padding: 0; overflow: hidden; }
.tool-tabs {
    display: flex; gap: .25rem; overflow-x: auto; padding: 0 1rem; border-bottom: 1px solid var(--line);
    background: var(--surface); scrollbar-width: none;
}
.tool-tab {
    position: relative; flex: 0 0 auto; padding: .9rem .85rem; border: 0; background: none; cursor: pointer;
    color: var(--muted); font: inherit; font-weight: 550; font-size: .86rem; display: inline-flex; align-items: center;
}
.tool-tab::after { content: ""; position: absolute; left: .6rem; right: .6rem; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: transparent; }
.tool-tab:hover { color: var(--ink); }
.tool-tab[aria-selected="true"] { color: var(--primary-ink); }
.tool-tab[aria-selected="true"]::after { background: var(--primary); }
.tool-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: -4px; border-radius: 8px; }
.tool-tab-panel { padding: 1.4rem; }
.tool-tab-panel[hidden] { display: none; }
.tool-tab-panel > h2:first-child { margin-top: 0; }
.tool-tab-nav { display: flex; justify-content: flex-end; gap: .5rem; margin: 1.5rem 0 0; padding-top: 1rem; border-top: 1px dashed var(--line); }
.tool-form-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.4rem; border-top: 1px solid var(--line); background: var(--surface-2); }
.tool-editor[data-active-tab="options"] .tool-form-actions { display: none; }
.tool-category-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .1rem 1.25rem; }
.tool-category-list .check { margin: .4rem 0; }
.tool-option-actions { white-space: nowrap; }
.tool-option-actions form { display: inline; margin: 0 0 0 .4rem; }
.tool-empty-state { margin: 1rem 0 0; }

/* ------------------------------------------------- application / scan screens */
.application-card { margin-bottom: 0; display: flex; flex-direction: column; }
.application-card h2 { margin: 0; font-size: 1.02rem; }
.app-title-row { align-items: flex-start; }
.application-meta { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin-top: .55rem; font-size: .8rem; color: var(--muted); }
.latest-scan {
    display: flex; flex-wrap: wrap; gap: .4rem .75rem; align-items: center; font-size: .82rem;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem .8rem; margin: .9rem 0;
}
.application-actions { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin-top: auto; }
.application-actions form { margin: 0; }
.typecard { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.typecard:hover { border-color: var(--primary-line); }
.typecard.selected { border-color: var(--primary); box-shadow: var(--ring); }
details.tool { border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: .6rem; background: var(--surface); }
details.tool[open] { box-shadow: var(--shadow-xs); }
details.tool summary { cursor: pointer; font-weight: 600; }
.step-card { background: var(--surface-2) !important; border-style: dashed; }
.step-title { font-weight: 600; }
.job-mode { white-space: nowrap; }
.fetch-required { font-size: .8rem; color: var(--primary-ink); margin: .4rem 0 .2rem; }
.fetch-btn { animation: fetchPulse 1.9s ease-in-out infinite; }
.fetch-btn.fetched { animation: none; }
@keyframes fetchPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, .45); } 50% { box-shadow: 0 0 0 6px rgba(79, 70, 229, 0); } }

/* --------------------------------------------- notifications: bell, toasts */
.bell-wrap { position: relative; display: inline-flex; }
.bell-count {
    position: absolute; top: 4px; right: 4px; min-width: 17px; height: 17px; padding: 0 .3rem; border-radius: 999px;
    background: var(--crit); color: #fff; font-size: .64rem; font-weight: 700; display: grid; place-items: center;
    border: 2px solid var(--surface); line-height: 1;
}
.bell-count[hidden] { display: none; }
.bell-panel {
    position: absolute; right: 0; top: calc(100% + 8px); width: 360px; z-index: 60; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.bell-panel[hidden] { display: none; }
.bell-head, .bell-foot { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; font-size: .84rem; }
.bell-head { border-bottom: 1px solid var(--line); }
.bell-foot { border-top: 1px solid var(--line); background: var(--surface-2); }
.bell-list { list-style: none; margin: 0; padding: .25rem 0; max-height: 360px; overflow-y: auto; }
.bell-list li { padding: .65rem 1rem; font-size: .82rem; border-bottom: 1px solid var(--surface-3); }
.bell-list li:last-child { border-bottom: 0; }
.bell-list li:hover { background: var(--surface-2); }
.bell-list a { display: block; color: inherit; text-decoration: none; }
.bell-list strong { color: var(--ink); font-weight: 600; }
.bell-list .muted { font-size: .76rem; }

.toast-stack { position: fixed; right: 1.25rem; bottom: 1.25rem; width: 360px; max-width: calc(100vw - 2rem); display: flex; flex-direction: column; gap: .6rem; z-index: 100; }
.toast {
    position: relative; padding: .8rem 2.2rem .8rem 1rem; font-size: .84rem; background: var(--surface);
    border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: 10px; box-shadow: var(--shadow-lg);
    animation: toast-in .25s ease-out;
}
.toast a { color: inherit; text-decoration: none; }
.toast strong { display: block; color: var(--ink); }
.toast.leaving { opacity: 0; transform: translateX(12px); transition: opacity .35s, transform .35s; }
.toast-x { position: absolute; top: .45rem; right: .55rem; background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 1.1rem; line-height: 1; }
.toast-x:hover { color: var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.sev-edge-critical { border-left-color: var(--crit) !important; }
.sev-edge-high { border-left-color: var(--high) !important; }
.sev-edge-medium { border-left-color: var(--med) !important; }
.sev-edge-low { border-left-color: var(--low) !important; }
.sev-edge-info { border-left-color: var(--info) !important; }

.notif { display: flex; gap: .8rem; align-items: flex-start; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.notif:last-child { border-bottom: 0; }
.notif.unread { background: linear-gradient(90deg, var(--primary-soft), transparent 60%); margin: 0 -1.4rem; padding-left: 1.4rem; padding-right: 1.4rem; }
.notif-main { flex: 1; min-width: 0; }
.pref-grid td, .pref-grid th { text-align: center; }
.pref-grid td:first-child, .pref-grid th:first-child { text-align: left; }
.pref-grid select { min-height: 32px; padding: .2rem 1.8rem .2rem .5rem; font-size: .78rem; width: auto; }

/* ------------------------------------------------------------ public / login */
body.public { background: var(--bg); }
body.public .container { max-width: 1180px; padding: clamp(1rem, 4vh, 3rem) 1.25rem; }
.public-top { display: flex; align-items: center; justify-content: space-between; max-width: 1180px; margin: 0 auto; padding: 1.25rem 1.25rem 0; }
.public-top .sidebar-brand { border: 0; padding: 0; height: auto; }
.public-secure-label { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .12em; }
.public-secure-label .ti { color: var(--low); font-size: .95rem; }

.login-page {
    display: grid; grid-template-columns: 1.05fr .95fr; min-height: min(680px, calc(100vh - 160px)); overflow: hidden;
    background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg);
}
.login-intro {
    position: relative; display: flex; align-items: center; overflow: hidden; padding: clamp(2.2rem, 5vw, 4.5rem); color: #eef2ff;
    background:
        radial-gradient(ellipse at 15% 10%, rgba(129, 140, 248, .45), transparent 45%),
        radial-gradient(ellipse at 95% 95%, rgba(14, 165, 233, .35), transparent 45%),
        linear-gradient(150deg, #1e1b4b 0%, #312e81 45%, #1e3a8a 100%);
}
.login-intro::before {
    position: absolute; inset: 0; content: ""; opacity: .22; pointer-events: none;
    background-image: linear-gradient(rgba(199, 210, 254, .18) 1px, transparent 1px), linear-gradient(90deg, rgba(199, 210, 254, .18) 1px, transparent 1px);
    background-size: 44px 44px; mask-image: linear-gradient(130deg, #000, transparent 75%);
}
.login-intro-content { position: relative; z-index: 1; max-width: 520px; }
.login-eyebrow { display: inline-flex; align-items: center; gap: .55rem; margin-bottom: 1.75rem; padding: .35rem .8rem; border-radius: 999px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(199, 210, 254, .2); color: #c7d2fe; font-size: .7rem; font-weight: 700; letter-spacing: .14em; }
.login-eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 12px rgba(52, 211, 153, .9); }
.login-intro h1 { margin: 0; color: #fff; font-size: clamp(2.2rem, 4vw, 3.5rem); line-height: 1.08; letter-spacing: -.04em; font-weight: 700; }
.login-intro h1 span { background: linear-gradient(90deg, #a5b4fc, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-lead { max-width: 470px; margin: 1.3rem 0 1.8rem; color: #c7d2fe; font-size: 1.02rem; line-height: 1.7; }
.login-benefits { display: grid; gap: .85rem; margin: 0; padding: 0; list-style: none; color: #e0e7ff; font-size: .92rem; }
.login-benefits li { display: flex; align-items: flex-start; gap: .75rem; }
.login-check { display: inline-grid; place-items: center; flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%; background: rgba(52, 211, 153, .15); border: 1px solid rgba(52, 211, 153, .4); color: #6ee7b7; font-size: .72rem; }
.login-intro-foot { display: flex; align-items: center; gap: .55rem; margin-top: 2.4rem; color: #a5b4fc; font-size: .8rem; }
.login-shield { color: #6ee7b7; }
.login-orbit { position: absolute; width: 300px; height: 300px; border: 1px solid rgba(199, 210, 254, .14); border-radius: 50%; pointer-events: none; }
.login-orbit-one { right: -160px; top: -150px; box-shadow: 0 0 0 36px rgba(199, 210, 254, .04), 0 0 0 72px rgba(199, 210, 254, .025); }
.login-orbit-two { left: -240px; bottom: -255px; width: 420px; height: 420px; box-shadow: 0 0 0 44px rgba(199, 210, 254, .03); }
.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: clamp(1.75rem, 4vw, 3.5rem); background: var(--surface); }
.login-card { width: 100%; max-width: 380px; }
.login-card-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 1.5rem; border-radius: 14px; color: #fff; font-size: 1.3rem; font-weight: 800; background: linear-gradient(135deg, #6366f1, #4f46e5 45%, #0ea5e9); box-shadow: 0 8px 20px -6px rgba(79, 70, 229, .55); }
.login-card-kicker { margin: 0 0 .3rem; color: var(--primary); font-size: .7rem; font-weight: 700; letter-spacing: .14em; }
.login-card h2 { margin: 0; font-size: 1.65rem; font-weight: 700; letter-spacing: -.03em; }
.login-card-subtitle { margin: .5rem 0 1.6rem; color: var(--muted); }
.login-errors { margin: 0 0 1rem; }
.login-form label { margin: 0 0 .4rem; }
.login-password-label { display: flex; justify-content: space-between; align-items: baseline; }
.login-form input[type=email], .login-form input[type=password], .login-form input[type=text] { min-height: 46px; margin-bottom: 1.05rem; }
.login-form .login-submit { width: 100%; min-height: 46px; margin-top: .35rem; font-size: .92rem; }
.login-submit span { font-size: 1.1rem; transition: transform .18s ease; }
.login-submit:hover span { transform: translateX(3px); }
.login-secure { margin: 1.25rem 0 0; color: var(--muted); font-size: .76rem; text-align: center; }
.login-panel-foot { margin-top: auto; padding-top: 2rem; color: var(--faint); font-size: .74rem; }
.login-panel-foot span { margin: 0 .3rem; color: var(--primary); }

/* ------------------------------------------------------------ responsive */
.nav-backdrop { display: none; }
@media (max-width: 1080px) {
    .app-shell.has-sidebar { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(16, 24, 40, .35); z-index: 35; }
    .nav-toggle { display: inline-grid; }
    .topbar { padding: 0 1rem; }
    .container { padding: 1.25rem 1rem 2rem; }
}
@media (max-width: 760px) {
    .login-page { grid-template-columns: 1fr; min-height: 0; }
    .login-panel { order: 1; padding: 2rem 1.5rem 1.25rem; }
    .login-intro { order: 2; padding: 2rem 1.5rem; }
    .login-intro h1 { font-size: 2rem; }
    .user-trigger .who, .user-trigger .ti { display: none; }
    .user-trigger { padding: .2rem; }
    .crumbs > :not(strong) { display: none; }
    .card { padding: 1rem 1.1rem; }
    .card > table, .card > .table-scroll { margin-left: -1.1rem; margin-right: -1.1rem; width: calc(100% + 2.2rem); }
    .list-toolbar .list-search { max-width: none; }
    .bell-panel { position: fixed; top: calc(var(--topbar-h) + 4px); right: .5rem; width: calc(100vw - 1rem); }
    .tool-tab-panel { padding: 1rem; }
}
@media print {
    .sidebar, .topbar, .foot, .toast-stack, .list-toolbar, .list-pagination { display: none !important; }
    .app-shell.has-sidebar { display: block; }
    body { background: #fff; }
    .card { box-shadow: none; }
}

/* ------------------------------------------------------- table refinements */
/* actions inside table rows: quiet, inline, never stacked */
td .btn { min-height: 30px; padding: .3rem .7rem; font-size: .78rem; box-shadow: none; }
td .btn:not(.secondary):not(.danger) { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary-ink); }
td .btn:not(.secondary):not(.danger):hover { background: #e0e7ff; color: var(--primary-hover); }
td:last-child:has(.btn, form, .link-button) { white-space: nowrap; text-align: right; }
td:last-child .btn + form, td:last-child form + .btn, td:last-child .btn + .btn, td:last-child form + form { margin-left: .35rem; }
td form.inline, td > form { display: inline-flex; vertical-align: middle; }
/* first column holds the name: give it room */
table td:first-child { min-width: 170px; }
td > a:first-child { font-weight: 550; }
/* yes / no and similar single-word states inside a cell read as badges */
td > .delta-fixed, td > .delta-new, td > .delta-recurring {
    display: inline-flex; align-items: center; padding: .1rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; border: 1px solid;
}
td > .delta-fixed { background: var(--low-soft); border-color: var(--low-line); color: var(--low-ink); }
td > .delta-new { background: var(--crit-soft); border-color: var(--crit-line); color: var(--crit-ink); }
td > .delta-recurring { background: var(--med-soft); border-color: var(--med-line); color: var(--med-ink); }
/* page-header action group */
.container > .spread:first-child > div:last-child:not(:only-child) { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.container > .spread:first-child > div:last-child .btn.small { min-height: 38px; padding: .5rem 1rem; font-size: .86rem; }
/* wide tables scroll inside their card instead of spilling out of it */
.card:has(> table) { overflow-x: auto; }
td .muted, td.muted { overflow-wrap: anywhere; }
.stat-value small { margin-left: .2rem; }
/* hints sit inside <label> in several forms: keep them light */
.hint, label .hint, label .muted { font-weight: 400; }
/* sub-headings inside a card need air above them */
.card h3:not(:first-child), .card h4:not(:first-child), .tool-tab-panel h3:not(:first-child) {
    margin-top: 1.6rem; padding-top: 1.1rem; border-top: 1px solid var(--line);
}
/* tables nested in a form inside a card scroll too */
.card:has(table) { overflow-x: auto; }
@media (max-width: 760px) {
    /* inline min-widths written for desktop must not force sideways scrolling */
    .card[style*="min-width"], .row > [style*="min-width"] { min-width: 0 !important; }
    .notif.unread { margin: 0 -1.1rem; padding-left: 1.1rem; padding-right: 1.1rem; }
}
