/* pbi-burst panel — light "frosted glass" theme (matches the approved mockups). No build step. */

:root {
  --bg: #E8EDF7;
  --text: #0F172A;
  --strong: #020617;
  --muted: #475569;
  --soft: #334155;
  --faint: #526079;

  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --border: rgba(255, 255, 255, 0.92);
  --shadow: 0 12px 40px rgba(30, 41, 82, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  --shadow-lift: 0 18px 48px rgba(30, 41, 82, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  --blur: 22px;

  --field: rgba(255, 255, 255, 0.78);
  --field-border: rgba(15, 23, 42, 0.10);
  --field-border-strong: rgba(15, 23, 42, 0.22);
  --chip: rgba(255, 255, 255, 0.6);
  --chip-border: rgba(15, 23, 42, 0.09);
  --row: rgba(255, 255, 255, 0.6);
  --track: rgba(15, 23, 42, 0.08);
  --active: #FFFFFF;
  --active-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  --nav-active: rgba(255, 255, 255, 0.95);
  --nav-active-border: rgba(37, 99, 235, 0.20);
  --nav-fg: #334155;
  --sel: rgba(255, 255, 255, 0.88);
  --sel-border: rgba(37, 99, 235, 0.40);
  --unsel: rgba(255, 255, 255, 0.5);
  --unsel-border: rgba(255, 255, 255, 0.9);
  --dashed: rgba(15, 23, 42, 0.22);
  --divider: rgba(15, 23, 42, 0.07);
  --thead: rgba(241, 245, 249, 0.9);
  --table-bg: rgba(255, 255, 255, 0.7);
  --panel: rgba(255, 255, 255, 0.65);
  --code: rgba(255, 255, 255, 0.82);
  --code-text: #1E293B;

  --accent: #2563EB;
  --ink: #FFFFFF;
  --link: #1D4ED8;
  --accent-shadow: 0 8px 22px rgba(37, 99, 235, 0.28);
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.35);

  --orb1: #93C5FD;
  --orb2: #D8B4FE;
  --orb3: #5EEAD4;
  --orb-opacity: 0.45;

  --warn-bg: rgba(254, 243, 199, 0.7);
  --warn-border: rgba(217, 119, 6, 0.30);
  --warn-title: #92400E;
  --warn-text: #78350F;
  --warn-link: #B45309;

  --blue-bg: rgba(37, 99, 235, 0.10);     --blue-fg: #1D4ED8;
  --green-bg: rgba(16, 185, 129, 0.13);   --green-fg: #047857;
  --amber-bg: rgba(245, 158, 11, 0.16);   --amber-fg: #92400E;
  --red-bg: rgba(239, 68, 68, 0.12);      --red-fg: #B91C1C;
  --violet-bg: rgba(124, 58, 237, 0.10);  --violet-fg: #6D28D9;  --violet-border: rgba(124, 58, 237, 0.22);
  --gray-bg: rgba(15, 23, 42, 0.06);      --gray-fg: #334155;
  --teal-bg: rgba(13, 148, 136, 0.12);    --teal-fg: #0F766E;
  --yellow-bg: rgba(202, 138, 4, 0.13);   --yellow-fg: #854D0E;
  --orange-bg: rgba(234, 88, 12, 0.10);   --orange-fg: #C2410C;

  --fmt-on-bg: rgba(37, 99, 235, 0.10);
  --fmt-on-fg: #1E40AF;
  --fmt-on-border: rgba(37, 99, 235, 0.45);

  --sx-kw: #A21CAF; --sx-fn: #0369A1; --sx-col: #92400E; --sx-str: #15803D; --sx-mea: #C2410C;
  --sx-par: #6D28D9; --sx-par-bg: rgba(124, 58, 237, 0.10); --sx-par-border: rgba(124, 58, 237, 0.28);

  --font-body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Space Grotesk", Inter, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --radius-xl: 24px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  color-scheme: light;
}

/* --- base -------------------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0; color: var(--strong); font-family: var(--font-head); font-weight: 600; }
h1 { font-size: 30px; letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--link); }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--font-mono); }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.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; }
.skip-link { position: absolute; left: 16px; top: -60px; z-index: 50; padding: 10px 16px; border-radius: 12px; background: var(--accent); color: var(--ink); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 16px; }

/* --- background orbs ---------------------------------------------------------------------------- */

.orbs { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.orb { position: absolute; border-radius: 50%; opacity: var(--orb-opacity); }
.orb-1 { width: 640px; height: 640px; left: -160px; top: -200px; background: var(--orb1); filter: blur(120px); }
.orb-2 { width: 560px; height: 560px; right: -120px; top: 120px; background: var(--orb2); filter: blur(130px); }
.orb-3 { width: 520px; height: 520px; left: 38%; bottom: -260px; background: var(--orb3); filter: blur(120px); }

/* --- animations (from the mockups) ------------------------------------------------------------ */

@keyframes pbPop { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes pbSlide { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
@keyframes pbFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pbOut { to { opacity: 0; transform: translateY(-8px) scale(.97); } }
@keyframes pbSpin { to { transform: rotate(360deg); } }
@keyframes pbPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* `backwards` (not `both`) so hover transforms still apply after the entrance animation ends. */
.pb-pop { animation: pbPop .6s var(--ease) backwards; animation-delay: calc(var(--d, 0) * 1ms); }
.pb-slide { animation: pbSlide .55s var(--ease) backwards; animation-delay: calc(var(--d, 0) * 1ms); }
.pb-fade { animation: pbFade .45s ease-out backwards; animation-delay: calc(var(--d, 0) * 1ms); }
.polled .pb-pop, .polled .pb-fade { animation: none; } /* no re-entrance on HTMX polling refreshes */
.pb-nav { transition: transform .18s var(--ease), filter .18s, background-color .18s, box-shadow .18s; }
.pb-nav:hover { transform: scale(1.05); filter: brightness(1.04); }
.pb-lift { transition: transform .22s var(--ease), box-shadow .22s; }
.pb-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.pb-row { transition: transform .18s var(--ease), background-color .18s; }
.pb-row:hover { transform: scale(1.015); }

/* --- layout ------------------------------------------------------------------------------------ */

.shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px;
  padding: 20px;
  min-height: 100vh;
}
.content { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

.glass {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  box-shadow: var(--shadow);
}
.panel { padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head .meta { font-size: 12.5px; color: var(--muted); }

.cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.col-main { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.col-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.col-narrow { flex: 1 1 250px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* --- sidebar ----------------------------------------------------------------------------------- */

.sidebar {
  flex: 0 0 232px;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-radius: var(--radius-xl);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  flex: none; width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), #A78BFA);
  display: flex; align-items: center; justify-content: center;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--strong); }
.brand-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: 14px; text-decoration: none; color: var(--nav-fg); font-weight: 500;
  border: 1px solid transparent; background: transparent;
}
.nav-link:hover { text-decoration: none; background: rgba(255, 255, 255, 0.45); }
.nav-link[aria-current="page"] {
  color: var(--strong); background: var(--nav-active); border-color: var(--nav-active-border); box-shadow: var(--active-shadow);
}
.nav-link svg { flex: none; }
.sidebar-spacer { flex: 1; min-height: 24px; }
.user-card {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 16px;
  background: var(--chip); border: 1px solid var(--chip-border);
}
.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #FFFFFF, #E2E8F0); border: 1px solid var(--chip-border);
  color: var(--strong); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12.5px;
}
.user-card .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-card .who span:first-child { font-weight: 600; color: var(--strong); font-size: 13px; }
.user-card .who span:last-child { font-size: 12px; color: var(--muted); }

/* --- top bar / page header -------------------------------------------------------------------- */

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 14px 14px 14px 22px; border-radius: 20px;
}
.topbar .titles { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12.5px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--link); text-decoration: underline; }
.topbar h1 { font-size: 26px; overflow-wrap: anywhere; }
.page-sub { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* dropdown menu (Run now) */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: min(380px, calc(100vw - 32px));
  padding: 16px; border-radius: 18px; background: var(--glass-strong); box-shadow: var(--shadow-lift);
  animation: pbPop .35s var(--ease) backwards;
}

/* --- buttons ----------------------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--chip-border); background: var(--chip); color: var(--text);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform .18s var(--ease), filter .18s, box-shadow .18s, background-color .18s;
}
.btn:hover { transform: scale(1.04); filter: brightness(1.04); text-decoration: none; background: rgba(255, 255, 255, 0.85); }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; filter: none; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--ink); font-weight: 600; box-shadow: var(--accent-shadow); }
.btn-primary:hover { background: var(--accent); }
.btn-danger { background: var(--red-bg); border-color: rgba(185, 28, 28, 0.25); color: var(--red-fg); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.18); }
.btn-sm { min-height: 34px; padding: 0 12px; border-radius: 10px; font-size: 13px; }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 34px; }
.btn-dashed { border: 1px dashed var(--dashed); background: transparent; color: var(--muted); min-height: 48px; border-radius: 18px; width: 100%; }
.btn-link { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; text-decoration: none; }
.btn-link:hover { text-decoration: underline; }
.link-arrow { font-size: 13px; color: var(--link); text-decoration: none; font-weight: 500; }
.inline-form { display: inline; margin: 0; }

.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: pbSpin .8s linear infinite; display: none; }
.htmx-request .spinner, .spinner.htmx-request { display: inline-block; }
.htmx-request.btn { opacity: .8; }

/* --- pills, badges, chips ---------------------------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--gray-bg); color: var(--gray-fg);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.no-dot::before { display: none; }
.pill.live::before { animation: pbPulse 1.4s ease-in-out infinite; }
.tone-blue { background: var(--blue-bg); color: var(--blue-fg); }
.tone-green { background: var(--green-bg); color: var(--green-fg); }
.tone-amber { background: var(--amber-bg); color: var(--amber-fg); }
.tone-red { background: var(--red-bg); color: var(--red-fg); }
.tone-violet { background: var(--violet-bg); color: var(--violet-fg); }
.tone-gray { background: var(--gray-bg); color: var(--gray-fg); }
.tone-teal { background: var(--teal-bg); color: var(--teal-fg); }
.tone-yellow { background: var(--yellow-bg); color: var(--yellow-fg); }
.tone-orange { background: var(--orange-bg); color: var(--orange-fg); }
.tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 7px; font-size: 11.5px; font-weight: 500; background: var(--gray-bg); color: var(--soft); white-space: nowrap; }
.tag.fmt { font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.param-chip {
  min-height: 30px; padding: 0 10px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--sx-par-border); background: var(--sx-par-bg); color: var(--sx-par);
  font-family: var(--font-mono); font-size: 12px;
}

/* --- KPI tiles --------------------------------------------------------------------------------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: 20px; }
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-icon { width: 30px; height: 30px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; }
.kpi-value { font-family: var(--font-head); font-size: 30px; font-weight: 600; letter-spacing: -0.02em; color: var(--strong); }
.kpi-note { color: var(--muted); font-size: 12.5px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; border-radius: 18px; display: flex; flex-direction: column; gap: 4px; }
.stat span:first-child { font-size: 12.5px; color: var(--muted); }
.stat span:last-child { font-family: var(--font-head); font-size: 22px; font-weight: 600; color: var(--strong); }

/* --- tables ------------------------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.list-table { width: 100%; min-width: 640px; border-collapse: separate; border-spacing: 0 6px; font-size: 13.5px; }
.list-table th {
  text-align: left; font-weight: 500; padding: 4px 12px; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.list-table td { padding: 12px; background: var(--row); vertical-align: middle; }
.list-table td:first-child { border-radius: 12px 0 0 12px; }
.list-table td:last-child { border-radius: 0 12px 12px 0; }
.list-table .primary { font-weight: 500; color: var(--strong); text-decoration: none; }
.list-table a.primary:hover { color: var(--link); text-decoration: underline; }
.list-table .sub { display: block; color: var(--faint); font-size: 12px; }
.list-table th.num, .list-table td.num { text-align: right; }

.data-wrap { overflow: auto; max-height: 480px; border-radius: 14px; border: 1px solid var(--field-border); background: var(--table-bg); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { position: sticky; top: 0; background: var(--thead); text-align: left; font-weight: 500; color: var(--muted); padding: 10px 14px; white-space: nowrap; }
.data-table td { padding: 9px 14px; border-top: 1px solid var(--divider); white-space: nowrap; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.wrap { white-space: normal; }
.empty-state { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; border: 1px dashed var(--dashed); border-radius: 14px; }
.empty-state p { margin: 0; }
.empty { padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--dashed); border-radius: 16px; }

/* --- forms ------------------------------------------------------------------------------------- */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.hint { font-size: 12px; color: var(--faint); }
.field-error { font-size: 12.5px; color: var(--red-fg); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--field-border); background: var(--field); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.select { padding: 0 12px; }
.textarea { padding: 12px 14px; resize: vertical; min-height: 88px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--field-border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input[readonly] { background: rgba(255, 255, 255, 0.45); color: var(--muted); }
.input.mono { font-family: var(--font-mono); font-size: 12.5px; }
.input.invalid, .select.invalid, .textarea.invalid { border-color: rgba(185, 28, 28, 0.6); }
.input-sm { min-height: 36px; padding: 0 10px; border-radius: 10px; font-size: 13px; }
select.input-sm { padding: 0 8px; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 8px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* toggle pills (formats, destinations) */
.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle {
  position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--chip-border); background: transparent; color: var(--muted);
  font-weight: 600; cursor: pointer; user-select: none;
  transition: transform .18s var(--ease), background-color .18s, border-color .18s, color .18s;
}
.toggle:hover { transform: scale(1.05); }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.toggle:has(input:checked) { background: var(--fmt-on-bg); color: var(--fmt-on-fg); border-color: var(--fmt-on-border); }
.toggle:has(input:focus-visible) { box-shadow: var(--focus); }
.toggle .tick { width: 14px; height: 14px; display: none; }
.toggle:has(input:checked) .tick { display: inline-block; }
.toggle.wide { width: 100%; justify-content: flex-start; font-weight: 500; padding: 10px 12px; min-height: 52px; }
.toggle.wide .detail { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }

/* key / value rows */
.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: center; }
.kv-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 34px; gap: 8px; font-size: 12px; color: var(--faint); }
.col-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 1fr) 70px 96px 34px; gap: 8px; align-items: center; }
.col-head { font-size: 12px; color: var(--faint); }

/* --- alerts and toasts ------------------------------------------------------------------------- */

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 13.5px; border: 1px solid transparent; }
.alert svg { flex: none; margin-top: 1px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert-error { background: rgba(254, 226, 226, 0.75); border-color: rgba(185, 28, 28, 0.25); color: #7F1D1D; }
.alert-success { background: rgba(209, 250, 229, 0.75); border-color: rgba(4, 120, 87, 0.25); color: #064E3B; }
.alert-info { background: rgba(219, 234, 254, 0.75); border-color: rgba(29, 78, 216, 0.22); color: #1E3A8A; }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.alert strong { color: inherit; }

.attention { background: var(--warn-bg); border: 1px solid var(--warn-border); }
.attention h2 { color: var(--warn-title); font-family: var(--font-body); font-size: 15px; }
.attention .title { display: flex; align-items: center; gap: 10px; color: var(--warn-title); }
.attention p, .attention li { color: var(--warn-text); font-size: 13.5px; }
.attention a { color: var(--warn-link); font-weight: 600; }
.attention ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.attention-item { display: flex; flex-direction: column; gap: 2px; }
.attention-ok { background: var(--glass); }

#toasts {
  position: fixed; top: 20px; right: 20px; z-index: 40; width: min(380px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 14px 14px 14px 16px;
  border-radius: 16px; background: var(--glass-strong); border: 1px solid var(--border);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%); backdrop-filter: blur(var(--blur)) saturate(150%);
  box-shadow: var(--shadow-lift); border-left: 4px solid var(--blue-fg);
  animation: pbPop .45s var(--ease) backwards;
}
.toast.leaving { animation: pbOut .3s ease-in forwards; }
.toast-error { border-left-color: var(--red-fg); }
.toast-success { border-left-color: var(--green-fg); }
.toast-info { border-left-color: var(--blue-fg); }
.toast-warn { border-left-color: var(--amber-fg); }
.toast-body { flex: 1; min-width: 0; font-size: 13.5px; overflow-wrap: anywhere; }
.toast-body strong { display: block; color: var(--strong); margin-bottom: 2px; }
.toast-close { flex: none; width: 28px; height: 28px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.toast-close:hover { background: var(--gray-bg); }

/* --- report editor ----------------------------------------------------------------------------- */

.section-head-row { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.section-head-row h2 { font-family: var(--font-body); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.section-select {
  flex: 1; min-width: 0; display: flex; gap: 12px; align-items: flex-start; padding: 8px; border: 0; border-radius: 14px;
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.section-card {
  display: flex; gap: 6px; align-items: flex-start; padding: 6px; border-radius: 18px;
  width: 100%; color: var(--text);
  background: var(--unsel); border: 1px solid var(--unsel-border); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%); backdrop-filter: blur(var(--blur)) saturate(150%);
}
.section-card[aria-current="true"] { background: var(--sel); border-color: var(--sel-border); }
.section-card.has-error { border-color: rgba(185, 28, 28, 0.45); }
.section-num {
  flex: none; width: 28px; height: 28px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: var(--chip); border: 1px solid var(--chip-border); font-family: var(--font-head); font-weight: 600; font-size: 13px;
}
.section-card .info { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.section-card .info .t { font-weight: 600; color: var(--strong); overflow-wrap: anywhere; }
.section-card .info .m { font-size: 12.5px; color: var(--muted); }
.section-card .moves { display: flex; flex-direction: column; gap: 4px; }
.section-card .moves button { width: 28px; height: 24px; border-radius: 8px; border: 1px solid var(--chip-border); background: var(--chip); color: var(--soft); cursor: pointer; font-size: 12px; line-height: 1; }
.section-card .moves button:hover { background: #fff; }
.section-card-wrap { position: relative; }

.section-editor { display: flex; flex-direction: column; gap: 16px; }
.code-box { border-radius: 16px; background: var(--code); border: 1px solid var(--field-border); overflow: hidden; }
.code-box:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.code-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--divider); font-size: 12px; color: var(--faint); }
.code-area {
  display: block; width: 100%; min-height: 220px; margin: 0; padding: 16px 18px; border: 0; outline: none; resize: vertical;
  background: transparent; color: var(--code-text); font-family: var(--font-mono); font-size: 13px; line-height: 1.7;
  white-space: pre; overflow-wrap: normal; overflow-x: auto; tab-size: 4;
}
.code-area:focus { box-shadow: none; }
.code-foot { padding: 10px 18px; border-top: 1px solid var(--divider); font-family: var(--font-mono); font-size: 12px; color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rendered-dax { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--code); border: 1px solid var(--field-border); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--code-text); max-height: 260px; overflow: auto; }
details summary { cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 500; }
details[open] summary { margin-bottom: 8px; }
.preview-meta { font-size: 12.5px; color: var(--muted); }

/* --- models ------------------------------------------------------------------------------------ */

.ws-head { display: flex; align-items: center; gap: 8px; padding: 8px 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.pick {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border-radius: 14px;
  text-decoration: none; color: var(--text); background: transparent; border: 1px solid transparent; width: 100%;
  font: inherit; text-align: left; cursor: pointer;
}
.pick:hover { text-decoration: none; background: rgba(255, 255, 255, 0.55); }
.pick[aria-current="page"], .pick[aria-current="true"] { background: var(--sel); border-color: rgba(13, 148, 136, 0.40); box-shadow: var(--active-shadow); }
.pick .icon { flex: none; width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.pick .info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pick .info .t { font-weight: 500; color: var(--strong); overflow-wrap: anywhere; }
.pick .info .m { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.schema-table { border-radius: 16px; border: 1px solid var(--field-border); background: var(--panel); overflow: hidden; }
.schema-table > .head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; background: var(--thead); }
.schema-table > .head .t { font-weight: 600; color: var(--strong); }
.schema-field { display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-top: 1px solid var(--divider); flex-wrap: wrap; }
.schema-field .kind { flex: none; width: 22px; height: 22px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.schema-field .name { font-family: var(--font-mono); font-size: 13px; min-width: 140px; color: var(--strong); overflow-wrap: anywhere; }
.schema-field .desc { font-size: 12px; color: var(--muted); flex: 1 1 160px; min-width: 0; }
.schema-field.is-hidden .name { color: var(--faint); }
.remote-item { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--chip); border: 1px solid var(--chip-border); }
.register-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto auto; gap: 8px; align-items: end; }

/* --- run detail -------------------------------------------------------------------------------- */

.timeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.log {
  margin: 0; padding: 14px 16px; border-radius: 14px; background: var(--code); border: 1px solid var(--field-border);
  font-size: 12.5px; line-height: 1.6; color: var(--code-text); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto;
}
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--chip); border: 1px solid var(--chip-border); text-decoration: none; color: var(--text); }
.file-row:hover { text-decoration: none; background: rgba(255, 255, 255, 0.85); }
.file-row .info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-row .info .t { font-weight: 500; color: var(--strong); overflow-wrap: anywhere; }
.file-row .info .m { font-size: 12px; color: var(--muted); }

/* --- login ------------------------------------------------------------------------------------- */

.login-wrap { position: relative; z-index: 1; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: min(420px, 100%); padding: 32px 28px; border-radius: var(--radius-xl); display: flex; flex-direction: column; gap: 20px; }
.login-card .brand { padding: 0; }
.error-wrap { padding: 28px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }

/* --- schedules, groups, batches ------------------------------------------------------------------ */

.tabs { display: inline-flex; gap: 4px; padding: 5px; border-radius: 16px; align-self: flex-start; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 16px; border-radius: 12px;
  color: var(--nav-fg); font-weight: 500; text-decoration: none; border: 1px solid transparent;
  transition: background-color .18s, transform .18s var(--ease);
}
.tab:hover { text-decoration: none; background: rgba(255, 255, 255, 0.6); }
.tab[aria-current="page"] { background: var(--nav-active); border-color: var(--nav-active-border); color: var(--strong); box-shadow: var(--active-shadow); }
.tab-count { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--gray-bg); color: var(--soft); font-size: 11.5px; font-weight: 600; text-align: center; }

.cron-preview { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--field-border); }
.cron-expr { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-weight: 500; color: var(--strong); }
.cron-expr code { padding: 3px 10px; border-radius: 8px; background: var(--code); border: 1px solid var(--chip-border); font-size: 12.5px; }
.fire-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.fire-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 10px; background: var(--chip); border: 1px solid var(--chip-border); font-size: 12.5px; }
.fire-list li:first-child { border-color: var(--sel-border); background: var(--sel); }

.audience-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.mode-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mode-card {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 16px; cursor: pointer;
  background: var(--unsel); border: 1px solid var(--unsel-border);
  transition: transform .18s var(--ease), background-color .18s, border-color .18s, box-shadow .18s;
}
.mode-card:hover { transform: translateY(-2px); }
.mode-card input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.mode-card:has(input:checked) { background: var(--sel); border-color: var(--sel-border); box-shadow: var(--active-shadow); }
.mode-card:has(input:focus-visible) { box-shadow: var(--focus); }
.mode-title { font-family: var(--font-head); font-weight: 600; color: var(--strong); }
.mode-title::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--field-border-strong); vertical-align: -1px; }
.mode-card:has(input:checked) .mode-title::before { border-color: var(--accent); background: radial-gradient(var(--accent) 45%, transparent 50%); }
.mode-help { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.upcoming { display: flex; flex-direction: column; gap: 4px; }
.upcoming-item { display: flex; gap: 14px; align-items: center; padding: 10px; border-radius: 14px; color: var(--text); text-decoration: none; }
.upcoming-item:hover { text-decoration: none; background: rgba(255, 255, 255, 0.55); }
.when-chip { width: 58px; flex: none; display: flex; flex-direction: column; align-items: center; padding: 6px 0; border-radius: 12px; background: var(--chip); border: 1px solid var(--chip-border); }
.when-time { font-family: var(--font-head); font-weight: 600; font-size: 15px; color: var(--strong); }
.when-day { font-size: 11px; color: var(--muted); }
.upcoming-item .info { display: flex; flex-direction: column; min-width: 0; }
.upcoming-item .info .t { font-weight: 500; color: var(--strong); overflow-wrap: anywhere; }
.upcoming-item .info .m { font-size: 12.5px; color: var(--muted); }

.history-table tbody.batch-group .batch-row td { background: rgba(255, 255, 255, 0.35); }
.batch-runs summary { cursor: pointer; color: var(--link); font-weight: 500; }
.child-runs { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.child-runs li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: var(--chip); border: 1px solid var(--chip-border); }
.child-runs .sub { flex-basis: 100%; }

/* --- responsive -------------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .shell { padding: 12px 16px; gap: 14px; }
  .sidebar { flex: 1 1 100%; position: static; max-height: none; padding: 14px; }
  .brand { padding: 0 4px 8px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .nav-link { min-height: 40px; padding: 0 12px; }
  .sidebar-spacer { display: none; }
  .user-card { padding: 8px 10px; }
  .content { flex-basis: 100%; }
  .topbar { padding: 14px; }
  h1, .topbar h1 { font-size: 24px; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .register-form { grid-template-columns: minmax(0, 1fr); }
  .col-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .col-row .col-head-only { display: none; }
  .kv-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .audience-grid, .mode-cards { grid-template-columns: minmax(0, 1fr); }
  .tabs { align-self: stretch; }
  .kpi-value { font-size: 26px; }
  .orb { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .pb-pop, .pb-slide, .pb-fade, .toast, .toast.leaving, .pill.live::before { animation: none !important; }
  .pb-nav:hover, .pb-lift:hover, .pb-row:hover, .btn:hover, .btn:active, .toggle:hover, .mode-card:hover { transform: none !important; }
  * { transition-duration: 0s !important; scroll-behavior: auto !important; }
  .spinner { animation-duration: 2s; }
}

/* --- section builder, XLSX template ------------------------------------------------------------- */

.mode-row { align-items: center; }
.mode-switch { padding: 4px; }
.mode-switch .tab { min-height: 32px; padding: 0 14px; cursor: pointer; background: transparent; font: inherit; }
.mode-switch .tab[aria-pressed="true"] { background: var(--nav-active); border-color: var(--nav-active-border); color: var(--strong); box-shadow: var(--active-shadow); }
.builder { display: grid; grid-template-columns: minmax(250px, 1fr) minmax(0, 2fr); gap: 16px; animation: pbFadeIn .3s var(--ease) both; }
.builder-picker { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--field-border); max-height: 460px; }
.builder-fields { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.builder-group-title { margin-top: 6px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.builder-field { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 10px; transition: background-color .15s; }
.builder-field:hover { background: var(--sel); }
.builder-field .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.builder-field .btn-sm { min-height: 26px; padding: 0 8px; font-size: 12px; }
.builder-field .kind { width: 20px; height: 20px; border-radius: 6px; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; }
.kind-m { background: var(--violet-bg, rgba(124, 58, 237, .12)); color: var(--violet-fg, #6D28D9); }
.kind-c { background: var(--blue-bg); color: var(--blue-fg); }
.builder-h { margin: 6px 0 0; font-size: 13px; font-weight: 600; color: var(--strong); }
.builder-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 0.8fr) 34px; gap: 8px; align-items: center; }
.builder-filter { grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 1.6fr) 34px; }
.builder-sort { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 90px auto; }
.builder-values { display: flex; gap: 6px; min-width: 0; }
.builder-values .input { min-width: 0; flex: 1; }
.builder-ref { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--soft); }
.builder-dax { white-space: pre-wrap; }
.builder-dax.is-error { color: var(--red-fg); }
.tmap-table { min-width: 0; font-size: 12.5px; }
.tmap-table td { padding: 6px; }
.tmap-table select, .tmap-table input { width: 100%; }
.tcell-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr) 34px; gap: 6px; align-items: center; }
.tchart-row { position: relative; padding: 10px 44px 10px 10px; border-radius: 14px; background: var(--panel); border: 1px solid var(--field-border); animation: pbFadeIn .3s var(--ease) both; }
.tchart-editor { display: flex; flex-direction: column; gap: 8px; }
.tchart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.tchart-remove { position: absolute; top: 8px; right: 8px; }
.chip-x { margin-left: 4px; border: 0; background: transparent; cursor: pointer; color: inherit; font-size: 14px; line-height: 1; }
.condition-result { padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--field-border); }
@keyframes pbFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (max-width: 1100px) { .builder { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .builder, .tchart-row { animation: none; } }
/* the mapping table lives in the narrow side column: one small card per section */
.tmap-table thead { display: none; }
.tmap-table, .tmap-table tbody { display: block; min-width: 0; }
.tmap-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 8px; margin-bottom: 8px; border-radius: 12px; background: var(--row); }
.tmap-table td, .tmap-table td:first-child, .tmap-table td:last-child { display: block; padding: 0; background: none; border-radius: 0; }
.tmap-table td:first-child { grid-column: 1 / -1; font-weight: 500; }
.tmap-table td:nth-child(3) { display: flex; flex-direction: column; gap: 6px; }
.tchart-grid { align-items: start; }
/* Templates panel: one block per kind (Excel, Word, PowerPoint); the tag list is a compact card list */
.tpl-h { margin: 18px 0 2px; padding-top: 12px; border-top: 1px solid var(--chip-border); font-size: 14px; font-weight: 600; color: var(--strong); }
.tag-table thead { display: none; }
.tag-table, .tag-table tbody { display: block; min-width: 0; }
.tag-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; padding: 8px; margin-bottom: 6px; border-radius: 12px; background: var(--row); }
.tag-table td, .tag-table td:first-child, .tag-table td:last-child { display: block; padding: 0; background: none; border-radius: 0; min-width: 0; }
.tag-table td:first-child code { overflow-wrap: anywhere; }
.tag-table td:last-child { grid-column: 1 / -1; }
.tag-table .pill { white-space: normal; }
#template .form-grid { grid-template-columns: minmax(0, 1fr); }
