/* registered so --rail-w interpolates: animating it drives the rail width AND
   the on-map controls' offset smoothly in sync (a bare custom prop would snap). */
@property --rail-w {
  syntax: "<length>";
  inherits: true;
  initial-value: 240px;
}

:root {
  /* fixed track widths so per-row .files-row grids align header to content (no subgrid yet) */
  --files-col-date: 96px;     /* fits "Apr 12 2024" + chevron */
  --files-col-size: 110px;    /* fits "1000+ items" / "999.9 MB" */
  --files-col-actions: 120px; /* browse rows: one right-anchored .cat-kebab (⋮); search-hit rows still show up to 3 inline .files-act icons */
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  background: var(--bg-app);
  color: var(--text);
}

code, pre {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

button {
  font: inherit;
  cursor: pointer;
}

#app {
  display: grid;
  --rail-w: 240px;
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-rows: 100vh;
  height: 100vh;
  overflow: hidden;
  transition: --rail-w 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
/* Animating --rail-w reflows the grid AND the on-map control offsets in sync; the Maps canvas is full-bleed under the sidebar (maps.css) so it never resizes. */
html.sidebar-collapsed #app {
  --rail-w: 64px;
}

#sidebar {
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 3;  /* above the full-bleed Maps canvas (maps.css #maps-host) */
}
/* Glass lives on a pseudo, NOT on #sidebar itself: a backdrop-filter on #sidebar
   would make it the containing block for the collapsed (position:fixed) user-menu,
   re-trapping it under overflow:hidden. The pseudo blurs the map behind the rail. */
#sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--sidebar-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
/* High contrast: the rail is opaque (token), so drop the now-pointless blur. */
html.high-contrast #sidebar::before {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

#sidebar h1 {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  padding: 12px 16px;
  border-bottom: 1px solid var(--sidebar-divider);
  color: var(--sidebar-fg-strong);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;  /* clip the mark/text mid-collapse instead of letting them reflow */
  transition: padding 0.22s cubic-bezier(0.4, 0, 0.2, 1), gap 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
#sidebar h1 .sidebar-logo {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  color: var(--sidebar-fg-strong);  /* the mark's braces use currentColor — keep them strong on both themes */
  /* Collapse smoothly (width + fade) rather than snapping via display:none. */
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.16s ease;
}
#sidebar h1 .logo-text {
  margin-right: auto;
  white-space: nowrap;  /* never wrap "The engine" word-by-word while the rail is narrow */
  overflow: hidden;
  transition: opacity 0.14s ease, max-width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 200px;
}

#section-nav {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  border-bottom: 1px solid var(--sidebar-divider);
}

.nav-btn {
  background: transparent;
  border: 0;
  color: var(--sidebar-fg);
  padding: 10px 16px;
  text-align: left;
  font-size: var(--fs-base);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: padding 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-btn .lucide {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.nav-btn .nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 0.12s ease;
}

.nav-btn:hover {
  background: var(--sidebar-hover-weak);
}

.nav-btn.is-active {
  background: var(--sidebar-hover);
  color: var(--sidebar-fg-strong);
  border-left: 2px solid var(--sidebar-active-accent);
  padding-left: 14px;
}

/* anti-FOUC nav gating, mirrors nav.sectionAllowed(); !important to beat [hidden]'s display:none !important */
html[data-role="admin"] .nav-btn[data-gate],
html[data-role="user"] .nav-btn[data-gate="user"] {
  display: flex !important;
}

/* The instance-wide Dashboards opt-out outranks the role reveal above — including for admins. */
html[data-dashboards-hidden] .nav-btn[data-section="dashboards"] {
  display: none !important;
}

/* Collapsed rail: labels fade out (opacity, so the width holds and nothing
   rewraps — the overflow clips them), and icons glide to centre via padding
   rather than a justify-content snap. Centres in 64px: nav icon 18 → 23px,
   logo 26 → 19px, is-active less the 2px accent border → 21px. */
html.sidebar-collapsed .nav-btn .nav-label {
  opacity: 0;
}
/* Fade the mark + collapse the title's width so the header animates to the 64px rail (only the expand
   trigger remains, centred) instead of the logo blinking out and the text reflowing. */
html.sidebar-collapsed #sidebar h1 .logo-text {
  opacity: 0;
  max-width: 0;
  margin-right: 0;
}
html.sidebar-collapsed #sidebar h1 .sidebar-logo {
  opacity: 0;
  width: 0;
}
html.sidebar-collapsed .nav-btn {
  padding-left: 23px;
  padding-right: 0;
}
html.sidebar-collapsed .nav-btn.is-active {
  padding-left: 21px;
}
/* 64px rail: header stays a single centred row showing only the expand trigger,
   so it never adds a second row that would push the sections down. gap:0 so the zero-width mark/title
   don't offset the centred trigger. */
html.sidebar-collapsed #sidebar h1 {
  justify-content: center;
  gap: 0;
  padding-left: 0;
  padding-right: 0;
}

.hint {
  color: var(--sidebar-fg-dim);
  font-size: var(--fs-sm);
}

#main {
  position: relative;
  background: var(--surface);
  overflow: hidden;
}

.section-host {
  position: absolute;
  inset: 0;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}

table.data th, table.data td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--list-divider);
}

/* nowrap so the space-separated cron fields stay on one line and don't jitter the row height */
.cron-cell {
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

/* zebra on <tr> (state/disabled tints live on <td> and paint over it); declared before :hover so hover wins */
table.data tbody tr:nth-child(even) { background: var(--list-row-alt); }
table.data tbody tr:hover { background: var(--list-row-hover); }
table.data tbody tr:last-child td { border-bottom: none; }

.cat-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-relaxed);
  border: 1px solid transparent;
  white-space: nowrap;
}
.cat-badge.cat-ingest      { background: var(--cat-ingest-bg);  color: var(--cat-ingest-fg);  border-color: var(--cat-ingest-border); }
.cat-badge.cat-preparation { background: var(--cat-prep-bg);    color: var(--cat-prep-fg);    border-color: var(--cat-prep-border); }
.cat-badge.cat-compute     { background: var(--cat-compute-bg); color: var(--cat-compute-fg); border-color: var(--cat-compute-border); }
.cat-badge.cat-custom      { background: var(--cat-custom-bg);  color: var(--cat-custom-fg);  border-color: var(--cat-custom-border); }
.cat-badge.cat-none        { background: var(--cat-none-bg);    color: var(--cat-none-fg);    border-color: var(--cat-none-border); }

.cat-mgr-list {
  border: 1px solid var(--list-border); border-radius: var(--list-radius); overflow: hidden;
  background: var(--list-bg); margin: 8px 0 12px;
}
.cat-mgr-row {
  display: grid;
  grid-template-columns: 140px 1fr auto 32px;
  gap: 12px; align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--list-divider);
  font-size: var(--fs-base);
}
.cat-mgr-row:nth-child(even) { background: var(--list-row-alt); }
.cat-mgr-row:hover { background: var(--list-row-hover); }
.cat-mgr-row:last-child { border-bottom: none; }
.cat-mgr-slug { font-size: var(--fs-xs); color: var(--text-muted); }
.cat-mgr-action { text-align: right; }
.cat-lock .lucide { width: 14px; height: 14px; color: var(--text-faint); }
.cat-mgr-add { display: flex; gap: 8px; align-items: center; }
.cat-mgr-add input { flex: 1 1 240px; padding: 6px 9px; border: 1px solid var(--border-input); border-radius: var(--r-xs); background: var(--surface-raised); color: var(--text); }

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50;
  min-width: 220px;
  background: var(--list-bg);
  border: 1px solid var(--list-border); border-radius: var(--list-radius);
  box-shadow: 0 6px 24px var(--shadow-dropdown);
  padding: 4px;
}
/* Right-anchored in the page header so the menu opens inward, not off-screen. */
.page-actions .dropdown-menu { left: auto; right: 0; }
.dropdown-item {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  width: 100%; text-align: left;
  background: transparent; border: none; border-radius: var(--r-xs);
  padding: 7px 10px; cursor: pointer; font: inherit; font-size: var(--fs-base); color: var(--text-mono-dark);
}
.dropdown-item:hover { background: var(--list-row-hover); }
.dropdown-count { font-size: var(--fs-xs); }
.dropdown-loading, .dropdown-empty { padding: 8px 10px; }

.modal.proc-picker { width: min(520px, 92vw); }
.proc-picker-search { width: 100%; margin: 4px 0 10px; }
.proc-picker-list {
  list-style: none; margin: 0; padding: 0;
  max-height: 50vh; overflow-y: auto;
  border: 1px solid var(--list-border); border-radius: var(--list-radius);
}
.proc-picker-list li { border-bottom: 1px solid var(--list-divider); }
.proc-picker-list li:last-child { border-bottom: none; }
.proc-picker-item {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%; text-align: left; background: transparent; border: none;
  padding: 8px 12px; cursor: pointer; font: inherit;
}
.proc-picker-item:hover { background: var(--list-row-hover); }
.proc-picker-title { font-size: var(--fs-base); color: var(--text-mono-dark); }
.proc-picker-id { font-size: var(--fs-xs); color: var(--text-muted); font-family: var(--font-mono); }
.proc-picker-empty { padding: 12px; }

/* sticky on BOTH thead and th since engines disagree which sticks inside a table; !important to survive per-card specificity */
table.data thead {
  position: sticky !important;
  top: 0 !important;
  z-index: 10 !important;
  background: var(--list-head-bg);
}
table.data thead tr {
  background: var(--list-head-bg);
}
table.data th {
  font-weight: var(--fw-semibold);
  color: var(--list-head-fg);
  background: var(--list-head-bg) !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 10 !important;
  box-shadow: inset 0 -1px 0 var(--list-border);
}

button.uuid {
  -webkit-appearance: none; appearance: none;
  background: transparent; border: none;
  padding: 1px 4px; margin: 0;
  font: inherit; font-family: var(--font-mono);
  font-size: var(--fs-sm); color: var(--uuid-fg);
  cursor: pointer;
  border-radius: var(--r-xs);
}
button.uuid:hover { background: var(--uuid-hover-bg); color: var(--uuid-hover-fg); }
button.uuid:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

