/* XCET shared UI, v1.0.0
   The components every XCET tool shares: page shell, header, side menu, tabs, cards, buttons, fields, tables, badges,
   banners, dialogs, toasts, action bar. Built on xcet-tokens.css (load that first). Copy unchanged into each repo; put
   anything tool-specific in the tool's own stylesheet, loaded after this one. Distilled from the Bulk Asset Record Tool
   (app-shell, components, buttons and ui-shared CSS) with the accessibility fixes in the guidelines applied.

   Contents: 1 Base · 2 Shell and header · 3 Side menu · 4 Tabs · 5 Cards · 6 Buttons · 7 Fields · 8 Messages and badges
             9 Stat tiles and chips · 10 Tables · 11 Empty, progress · 12 Dialogs · 13 Toasts and action bar */

/* ============================== 1 Base ============================== */
* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  padding: var(--space-6) clamp(1rem, 4vw, 2.5rem) var(--space-8);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; }
h1 { margin: 0; font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: var(--fs-lg); font-weight: 700; }
h3 { font-size: var(--fs-base); font-weight: 700; }
p { margin: 0 0 var(--space-2); }
a { color: var(--link); }
a:visited { color: var(--link); }
a:hover { color: var(--link-hover); }
code, kbd, samp { font-family: var(--font-mono); font-size: 0.88em; }
code { background: var(--table-head-bg); padding: 0.05rem 0.3rem; border-radius: 4px; }
kbd { padding: 0 0.3rem; border: 1px solid var(--control-border); border-radius: 4px; background: var(--surface); }
main:focus { outline: none; }
.muted { color: var(--text-muted); }
.hint { margin: 0.6rem 0; font-size: 0.8rem; line-height: 1.5; color: var(--text-muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

/* One focus ring everywhere: solid, 3px, offset. Never remove it without putting one back. */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.app-header :focus-visible, .app > header :focus-visible { outline-color: var(--focus-on-header); }
.gnav :focus-visible, table :focus-visible { outline-offset: -2px; }

.sr-only, .gnav-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: fixed; top: -3rem; left: 0.75rem; z-index: var(--z-skip);
  padding: 0.6rem 1rem; border-radius: 0 0 8px 8px;
  background: var(--accent-fill); color: var(--accent-contrast); font-weight: 600; text-decoration: none;
  transition: top var(--motion);
}
.skip-link:visited { color: var(--accent-contrast); }
.skip-link:focus { top: 0; }

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

/* ======================= 2 Shell and header ======================= */
/* Suite shell: #gnav-layout holds [.gnav, .app]. Single-page shell: just .app under <body>. */
#gnav-layout { display: flex; align-items: flex-start; gap: var(--space-6); max-width: var(--content-max); margin: 0 auto; }
.app { flex: 1 1 0%; min-width: 0; width: 100%; max-width: var(--content-max); margin: 0 auto; }
@media (min-width: 900px) { #gnav-layout { width: 90%; } }

.app-header, .app > header {
  display: flex; flex-direction: column; align-items: flex-start;
  background: var(--header-bg); color: var(--header-text);
  border: 1px solid var(--header-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6); margin-bottom: var(--space-6);
}
.app-header h1, .app > header h1 { color: var(--header-text); }
.header-row { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.app-header .header-row, .app > header .header-row { width: 100%; }
.brand { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.brand-logo { width: 34px; height: 34px; flex-shrink: 0; align-self: center; }
.app-subtitle { margin: 0.6rem 0 0; font-size: 0.85rem; line-height: 1.5; color: var(--header-muted); }
.page-crumb { margin: 0.35rem 0 0; font-size: 0.95rem; color: var(--header-muted); }
.page-crumb strong { color: var(--header-text); font-weight: 700; }
.page-crumb .crumb-sep { margin: 0 0.15rem; opacity: 0.7; white-space: pre; }

/* Version chip (a button: opens the release notes) and BETA pill */
.version, .beta-pill {
  font: inherit; font-size: 0.7rem; font-weight: 600; line-height: 1.4;
  padding: 0.1rem 0.55rem; border-radius: var(--radius-pill);
  color: var(--header-text); background: var(--header-chip-bg); border: 1px solid var(--header-chip-border);
  min-height: 0; box-shadow: none;
}
.version { cursor: pointer; }
.beta-pill { letter-spacing: 0.06em; text-transform: uppercase; }
/* Round buttons in the header: menu toggle and "?" (Settings & Help) */
.gnav-toggle, .header-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; min-height: 0; padding: 0; flex-shrink: 0;
  border-radius: var(--radius-btn); cursor: pointer; box-shadow: none;
  border: 1px solid var(--header-chip-border); background: var(--header-chip-bg); color: var(--header-text);
}
.header-help { margin-left: auto; border-radius: 50%; font-size: 1.05rem; font-weight: 700; line-height: 1; text-decoration: none; }
.header-help:visited { color: var(--header-text); }
.gnav-toggle:hover, .header-help:hover { filter: brightness(1.25); }

/* Phones: one compact header row [menu] [logo + title] [?], pills under the title, so long tool names never stack the header into five rows */
@media (max-width: 640px) {
  .app-header, .app > header { padding: var(--space-4); margin-bottom: var(--space-4); }
  .app-header .header-row, .app > header .header-row { flex-wrap: nowrap; align-items: flex-start; gap: 0.6rem; }
  .app-header .brand, .app > header .brand { flex: 1 1 0; min-width: 0; align-items: center; gap: 0.35rem 0.5rem; }
  .brand-logo { width: 30px; height: 30px; }
  .app-header h1, .app > header h1 { flex: 1 1 calc(100% - 2.6rem); min-width: 0; font-size: 1.05rem; line-height: 1.25; overflow-wrap: anywhere; }
  .app-header .beta-pill { flex: 0 0 auto; }
  .gnav-toggle, .header-help { width: 2.25rem; height: 2.25rem; }
  .app-subtitle { margin-top: 0.5rem; font-size: 0.8rem; line-height: 1.45; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
}

/* Footer: built by xcet-footer.js. Row 1: tool name, version (opens the release notes), release-notes link. Then developer and contact, then the unauthorised-use notice. */
.app-footer { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-8); padding: var(--space-4) 0 var(--space-6); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--text-muted); }
.app-footer .footer-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.app-footer .footer-name { margin-right: auto; font-weight: 600; }
.app-footer .footer-meta, .app-footer .footer-notice { margin: 0; line-height: 1.5; }
.app-footer .footer-notice { font-size: var(--fs-xs); max-width: 70ch; }
.app-footer a { color: var(--link); }
.app-footer a:hover { color: var(--link-hover); }
.app-footer .version { color: var(--text); background: var(--surface-2); border-color: var(--control-border); }
.link-btn { font: inherit; color: var(--link); background: none; border: 0; padding: 0.25rem 0; min-height: 0; box-shadow: none; text-decoration: underline; text-underline-offset: 0.15em; cursor: pointer; }
.link-btn:hover { color: var(--link-hover); filter: none; }
@media (max-width: 640px) { .app-footer { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); } .app-footer .footer-name { flex-basis: 100%; } .app-footer .footer-row { gap: var(--space-2); } }
@media print { .app-footer { display: none; } }

/* ========================== 3 Side menu =========================== */
.gnav-backdrop { display: none; }
.gnav {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: var(--space-4); overflow-y: auto; overflow-x: hidden;
}
.gnav-list { display: flex; flex-direction: column; gap: 0.15rem; }
.gnav-link, .gnav-group-btn {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.25rem 0.5rem;
  width: 100%; min-height: 0; padding: 0.6rem 0.7rem;
  font: inherit; font-size: 0.88rem; font-weight: 600; line-height: 1.25; text-align: left; white-space: normal;
  color: var(--text); text-decoration: none; background: transparent; border: none; border-radius: var(--radius-sm);
  box-shadow: none; cursor: pointer;
}
.gnav-link:visited { color: var(--text); }
.gnav-link:hover, .gnav-group-btn:hover { background: var(--surface-2); filter: none; }
.gnav-link.active, .gnav-group-btn.gnav-group-active, .gnav-link.active:visited { background: var(--accent-fill); color: var(--accent-contrast); }
.gnav-link-label { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.gnav-icon { flex-shrink: 0; width: 18px; height: 18px; }
.gnav-icon svg { width: 100%; height: 100%; }
.gnav-chevron { flex-shrink: 0; transition: transform var(--motion); }
.gnav-group-btn[aria-expanded="true"] .gnav-chevron { transform: rotate(90deg); }
.gnav-submenu { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.2rem 0 0.3rem 0.9rem; margin: 0.1rem 0 0.3rem 1.05rem; border-left: 1px solid var(--border); }
.gnav-sublink {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.6rem;
  font-size: 0.82rem; font-weight: 500; line-height: 1.3; white-space: normal;
  color: var(--text-muted); text-decoration: none; border-radius: var(--radius-sm);
}
.gnav-sublink:visited { color: var(--text-muted); }
.gnav-sublink-icon { flex-shrink: 0; width: 16px; height: 16px; }
.gnav-sublink-icon svg { width: 100%; height: 100%; }
.gnav-sublink:hover { background: var(--surface-2); color: var(--text); }
.gnav-sublink.active, .gnav-sublink.active:visited { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.gnav-subheading { margin: 0.45rem 0 0.1rem; padding: 0 0.6rem; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.gnav-subheading:first-child { margin-top: 0.1rem; }
.gnav-badge { margin-right: 0; font-size: 0.62rem; padding: 0.1rem 0.4rem; flex-shrink: 0; }
.gnav-link.active .gnav-badge { background: rgba(255, 255, 255, 0.18); color: var(--accent-contrast); border-color: rgba(255, 255, 255, 0.3); }
/* "Other tools": sibling XCET tools, pinned to the bottom of the menu */
.gnav-other { margin-top: auto; padding-top: var(--space-4); }
.gnav-heading { margin: 0 0 0.3rem; padding: 0.75rem 0.7rem 0; border-top: 1px solid var(--border); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.gnav-external { flex-wrap: nowrap; }
.gnav-external .gnav-link-label { flex: 1 1 auto; }
.gnav-external-icon { flex-shrink: 0; color: var(--text-muted); }

/* "Go to page" button and dialog (Ctrl+K or /) */
.gnav-search {
  display: flex; align-items: center; gap: 0.55rem; width: calc(100% - 1.5rem); margin: 0.75rem 0.75rem 0.5rem; padding: 0.5rem 0.7rem; min-height: 0;
  font: inherit; font-size: 0.85rem; font-weight: 500; text-align: left; color: var(--text-muted);
  background: var(--input-bg); border: 1px solid var(--control-border); border-radius: var(--radius-md); box-shadow: none; cursor: pointer;
}
.gnav-search svg { width: 1rem; height: 1rem; flex: none; }
.gnav-search span { flex: 1; }
.gnav-search kbd { font-size: 0.7rem; color: var(--text-muted); }
.gnav-search:hover { border-color: var(--accent); color: var(--text); filter: none; }
.quick-nav { width: min(34rem, 92vw); max-height: 70vh; margin: 12vh auto auto; padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-card); box-shadow: var(--shadow-md); }
.quick-nav::backdrop { background: var(--scrim); }
.quick-nav-box { display: flex; flex-direction: column; max-height: 70vh; }
.quick-nav-input { width: 100%; max-width: none; min-height: 0; padding: 0.9rem 1rem; font: inherit; font-size: 1rem; color: var(--text); background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.quick-nav-list { list-style: none; margin: 0; padding: 0.35rem; overflow-y: auto; }
.quick-nav-item { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; padding: 0.5rem 0.7rem; border-radius: var(--radius-sm); cursor: pointer; }
.quick-nav-item.active { background: var(--accent-soft); }
.quick-nav-item.active .quick-nav-label { color: var(--accent); }
.quick-nav-label { font-weight: 600; font-size: 0.92rem; }
.quick-nav-where { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.quick-nav-none { padding: 0.8rem; font-size: 0.9rem; color: var(--text-muted); }
.quick-nav-hint { margin: 0; padding: 0.5rem 1rem; font-size: 0.75rem; color: var(--text-muted); border-top: 1px solid var(--border); }

/* Desktop: fixed full-height menu; the page makes room for it. Single-page tools have no .gnav and no offset. */
@media (min-width: 900px) {
  body:has(> #gnav-layout > .gnav) { padding-left: var(--gnav-w); transition: padding-left 0.18s ease; }
  .gnav { position: fixed; top: 0; left: 0; bottom: 0; width: var(--gnav-w); z-index: var(--z-nav); border-radius: 0; border-width: 0 1px 0 0; transition: width 0.18s ease, opacity 0.18s ease, padding 0.18s ease; }
  body.gnav-collapsed { padding-left: 0; }
  body.gnav-collapsed .gnav { width: 0; padding-left: 0; padding-right: 0; opacity: 0; border-width: 0; pointer-events: none; }
}
/* Phone and small tablet: the menu is a drawer over a backdrop */
@media (max-width: 899.98px) {
  .gnav { position: fixed; top: 0; left: 0; bottom: 0; width: min(82vw, 300px); z-index: var(--z-nav); border-radius: 0; transform: translateX(-100%); transition: transform 0.2s ease; }
  #gnav-layout.gnav-mobile-open .gnav { transform: translateX(0); }
  #gnav-layout.gnav-mobile-open .gnav-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: var(--scrim); }
}
@media (max-width: 480px) {
  .app-header, .app > header { padding: 1.1rem; border-radius: var(--radius-md); }
  h1 { font-size: 1.1rem; }
}

/* ============================== 4 Tabs ============================= */
/* Single-page tools: a tab bar under the header. Markup: <div class="tabs" role="tablist"><button class="tab" role="tab" aria-selected="true">…
   Arrow keys move between tabs (roving tabindex); the selected tab is plum. */
.tabs { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-5); }
.tab {
  min-height: var(--control-h); padding: 0.5rem 1rem;
  font: inherit; font-size: var(--fs-md); font-weight: 600; color: var(--text);
  background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--radius-btn);
  box-shadow: var(--btn-shadow-quiet); cursor: pointer;
}
.tab:hover { background: var(--surface-2); border-color: var(--accent); filter: none; }
.tab[aria-selected="true"], .tab.is-active { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-contrast); }
.tab .badge { margin: 0 0 0 0.4rem; }

/* ============================== 5 Cards ============================ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 1.25rem var(--space-6); margin-bottom: var(--space-6); min-width: 0;
}
.card-title, .card > h2:first-child {
  display: block; margin: 0 0 0.7rem;
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); margin-bottom: 0.7rem; }
.card-head .card-title { margin: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.card-grid > .card { margin: 0; }
.card-grid > .card.wide { grid-column: 1 / -1; }
.card-section { margin-top: var(--space-5); padding-top: 1.1rem; border-top: 1px solid var(--border); }

/* ============================= 6 Buttons =========================== */
/* A <button> with no class is the PRIMARY action (kept from the Bulk tool). New markup should always say which:
   primary · secondary · danger. a.primary / a.secondary give links the same look. */
button, a.primary, a.secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: var(--control-h); padding: 0.5rem 1.1rem;
  font: inherit; font-size: var(--fs-md); font-weight: 600; line-height: 1.2; text-decoration: none;
  color: var(--accent-contrast); background: var(--accent-fill); border: 1px solid var(--accent-fill);
  border-radius: var(--radius-btn); box-shadow: var(--btn-shadow); cursor: pointer;
  transition: background-color var(--motion), border-color var(--motion), box-shadow var(--motion), transform 0.05s ease, filter var(--motion);
}
a.primary:visited { color: var(--accent-contrast); }
button:hover:not(:disabled), a.primary:hover { filter: brightness(1.1); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

button.secondary, a.secondary { color: var(--text); background: var(--surface); border-color: var(--control-border); box-shadow: var(--btn-shadow-quiet); }
a.secondary:visited { color: var(--text); }
button.secondary:hover:not(:disabled), a.secondary:hover { background: var(--surface-2); border-color: var(--accent); filter: none; }
button.danger { color: var(--danger-contrast); background: var(--danger-fill); border-color: var(--danger-fill); }
button.success { color: var(--success-contrast); background: var(--success); border-color: var(--success); }
button.lookup { color: var(--lookup-text); background: var(--lookup); border-color: var(--lookup); }
button.small, a.small { min-height: 0; padding: 0.3rem 0.6rem; font-size: 0.75rem; flex-shrink: 0; box-shadow: var(--btn-shadow-quiet); }
button.link { min-height: 0; padding: 0; color: var(--link); background: none; border: 0; box-shadow: none; text-decoration: underline; font-weight: 500; }

button.is-loading { position: relative; color: transparent; }
button.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: var(--accent-contrast); animation: xcet-spin 0.7s linear infinite; }
button.secondary.is-loading::after { border: 2px solid var(--border-strong); border-top-color: var(--text); }
@keyframes xcet-spin { to { transform: rotate(360deg); } }

.btn-icon { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button.small .btn-icon { width: 1em; height: 1em; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: var(--space-4); }
.actions.actions-top { margin-top: 0; }
.theme-toggle { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.theme-toggle-btn { color: var(--text); background: var(--surface); border: 1px solid var(--control-border); box-shadow: none; font-weight: 500; }
.theme-toggle-btn[aria-checked="true"] { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: -1px; font-weight: 700; }

/* ============================== 7 Fields =========================== */
.field { margin-bottom: 0.9rem; }
.field:last-child { margin-bottom: 0; }
.field label, label.field-label { display: block; margin-bottom: 0.35rem; font-size: 0.85rem; font-weight: 600; color: var(--text); }
.field .hint { margin: 0.3rem 0 0; }
.field-error, .field-note-error { margin: 0.3rem 0 0; font-size: 0.8rem; color: var(--danger); }
.field-error::before { content: "Problem: "; font-weight: 700; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--space-4); align-items: end; }

:where(input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="date"], input[type="email"], input[type="url"], input[type="tel"], input:not([type]), select, textarea) {
  width: 100%; max-width: 100%; min-height: var(--control-h); padding: 0.45rem 0.7rem;
  font: inherit; font-size: var(--fs-md); line-height: 1.4; color: var(--text);
  background: var(--input-bg); border: 1px solid var(--control-border); border-radius: var(--radius-md);
  transition: border-color var(--motion), box-shadow var(--motion);
}
textarea { min-height: 5rem; resize: vertical; line-height: 1.5; }
select { padding-right: 1.8rem; cursor: pointer; }
input[type="number"] { width: 6rem; }
input[type="date"] { width: auto; }
input[type="search"] { min-width: 12rem; width: auto; }
::placeholder { color: var(--text-muted); opacity: 1; }
:where(input, select, textarea):hover:not(:disabled) { border-color: var(--text-muted); }
:where(input, select, textarea):focus-visible { border-color: var(--accent); }
:where(input, select, textarea):disabled { opacity: 0.6; cursor: not-allowed; }
[aria-invalid="true"], input.invalid { border-color: var(--danger); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; min-height: 0; min-width: 0; padding: 0; margin: 0; flex: none; cursor: pointer; }
.checkbox-label { display: inline-flex; align-items: center; gap: 0.5rem; font-size: var(--fs-md); cursor: pointer; }
.date-readout { display: inline-block; min-height: 1.2em; margin-left: 0.5rem; font-size: 0.8rem; line-height: 1.2; color: var(--text-muted); white-space: nowrap; vertical-align: middle; }

/* ======================= 8 Messages and badges ===================== */
/* Inline status next to the action that produced it (aria-live region) */
.status { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }
.status.status-success, .status.status-error { display: inline-block; padding: 0.4rem 0.7rem; border: 1px solid; border-radius: var(--radius-sm); }
.status.status-success { color: var(--success); background: var(--success-bg); border-color: var(--success); }
.status.status-error { color: var(--danger); background: var(--danger-bg); border-color: var(--danger); }
.status.status-success:empty, .status.status-error:empty { display: none; }

/* Banner: a message about a whole card or page. Variants: info (default) · success · warning · danger */
.banner { margin: 0 0 var(--space-4); padding: 0.85rem 1rem; font-size: var(--fs-md); border: 1px solid var(--info-border); border-radius: var(--radius-md); background: var(--info-bg); color: var(--info); }
.banner strong { color: inherit; }
.banner.banner-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.banner.banner-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.banner.banner-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }

/* Badge: always a word, never colour alone */
.badge { display: inline-flex; align-items: center; margin-right: 0.5rem; padding: 0.15rem 0.5rem; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; white-space: nowrap; border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-muted); }
.badge-success { color: var(--success); background: var(--success-bg); border-color: var(--success-border); }
.badge-warning { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-border); }
.badge-danger, .badge-error { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.badge-info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.badge-accent { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.badge-neutral { color: var(--text-muted); background: var(--surface-2); border-color: var(--border-strong); }

/* ===================== 9 Stat tiles and chips ====================== */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.75rem; margin: 0.4rem 0 var(--space-4); }
.stat-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; min-height: 0; padding: 0.7rem 0.9rem; text-align: left; font-weight: 400; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius-md); box-shadow: none; }
button.stat-tile { cursor: pointer; }
button.stat-tile:hover:not(:disabled) { background: var(--surface-2); filter: none; }
.stat-tile[aria-pressed="true"] { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -1px; }
.stat-tile-value { font-size: var(--fs-stat); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-tile-label { font-size: 0.78rem; color: var(--text-muted); }
.stat-tile.tile-success { border-left-color: var(--success); }
.stat-tile.tile-warning { border-left-color: var(--warning); }
.stat-tile.tile-danger { border-left-color: var(--danger); }
.stat-tile.tile-neutral { border-left-color: var(--border-strong); }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.chip { min-height: 0; padding: 0.25rem 0.75rem; font-size: 0.85rem; font-weight: 500; color: var(--accent); background: transparent; border: 1px solid var(--accent); border-radius: var(--radius-pill); box-shadow: none; }
.chip-removable::after { content: " \2715"; }
.chip:hover { background: var(--accent-soft); filter: none; }

/* ============================ 10 Tables ============================ */
.table-wrap, .table-scroll { overflow-x: auto; margin-top: 1.1rem; border: 1px solid var(--border); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
th, td { padding: 0.55rem 0.7rem; text-align: left; white-space: nowrap; vertical-align: middle; border-bottom: 1px solid var(--border); }
th { position: sticky; top: 0; z-index: var(--z-sticky); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); background: var(--table-head-bg); border-bottom: 1px solid var(--border-strong); }
tbody tr:nth-child(even) { background: var(--surface-2); }
tbody tr:hover { background: var(--accent-soft); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; }
/* Keep the identifying column in view on wide tables: add class="sticky-first" to the <table> */
table.sticky-first th:first-child, table.sticky-first td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 2px 0 4px -2px rgba(0, 0, 0, 0.2); }
table.sticky-first th:first-child { z-index: 3; background: var(--table-head-bg); }
table.sticky-first tbody tr:nth-child(even) td:first-child { background: var(--surface-2); }
table.sticky-first tbody tr:hover td:first-child { background: var(--accent-soft); }
/* Editable cells: borderless until hovered; an edited cell is warning-tinted with a bar until saved */
td input, td select { width: 100%; min-width: 100px; max-width: 230px; min-height: 0; padding: 0.3rem 0.4rem; font-size: var(--fs-sm); border-color: transparent; background: transparent; border-radius: var(--radius-sm); }
td input:hover, td select:hover { border-color: var(--control-border); }
td select { background: var(--surface-2); border-color: var(--border); }
td input[type="checkbox"], th input[type="checkbox"] { width: 1.1rem; min-width: 0; max-width: none; }
td.editable { position: relative; }
td.editable.dirty { background: var(--warning-bg); }
td.editable.dirty::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--warning); }
td.editable.dirty input, td.editable.dirty select { background: var(--surface); }
tr.row-error td { background: var(--danger-bg); }
tr.row-saved td { background: var(--success-bg); }
.row-note { min-width: 160px; font-size: 0.78rem; color: var(--text-muted); white-space: normal; }
.field-note { max-width: 200px; margin-top: 0.2rem; font-size: 0.72rem; color: var(--text-muted); white-space: normal; }
.row-status { display: inline-block; padding: 0.12rem 0.5rem; font-size: 0.76rem; font-weight: 600; white-space: nowrap; border-radius: var(--radius-pill); }
.row-status.st-ready { background: var(--success-bg); color: var(--success); }
.row-status.st-waiting { background: var(--warning-bg); color: var(--warning); }
.row-status.st-blocked { background: var(--danger-bg); color: var(--danger); }
.row-status.st-none { background: var(--surface-2); color: var(--text-muted); }
/* Sort button inside a header cell: <th aria-sort><button class="th-sort">Name <span class="sort-mark">▲</span></button></th> */
.th-sort { all: unset; display: inline-flex; align-items: center; gap: 0.15rem; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; border-radius: 4px; }
.th-sort:hover { color: var(--accent); }
.th-sort:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sort-mark { font-size: 0.7em; }
/* Filter, summary and column menu above a table */
.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 0.9rem; margin: 0 0 0.6rem; }
.table-tools-summary { font-size: 0.82rem; color: var(--text-muted); }
.table-tools-columns { position: relative; }
.table-tools-menu { position: absolute; z-index: 30; top: calc(100% + 0.3rem); left: 0; min-width: 13rem; max-height: 18rem; overflow-y: auto; padding: 0.5rem 0.7rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.table-tools-menu label { display: flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0; font-size: 0.85rem; white-space: nowrap; cursor: pointer; }
tr[data-filtered-out] { display: none; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin-top: var(--space-3); font-size: var(--fs-sm); color: var(--text-muted); }

/* ====================== 11 Empty states, progress ================== */
.empty-state { padding: 2.25rem 1.25rem; text-align: center; }
.empty-state-title { margin: 0; font-weight: 600; color: var(--text); }
.empty-state-hint { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--text-muted); }
.progress-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 0.75rem; }
.progress-bar { position: relative; flex: 1 1 10rem; max-width: 22rem; height: 0.5rem; overflow: hidden; border-radius: var(--radius-pill); background: var(--border); }
.progress-bar span { position: absolute; top: 0; bottom: 0; width: 40%; border-radius: var(--radius-pill); background: var(--accent-fill); animation: xcet-slide 1.3s ease-in-out infinite; }
.progress-bar[data-value] span { animation: none; left: 0; width: var(--progress, 0%); transition: width var(--motion); }
.progress-text { font-size: 0.85rem; color: var(--text-muted); }
@keyframes xcet-slide { 0% { left: -40%; } 100% { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .progress-bar span { animation: none; left: 0; width: 100%; opacity: 0.5; } }

/* ============================ 12 Dialogs =========================== */
/* Native <dialog>. .info-dialog = Help, Release notes, Settings & Help. .confirm-dialog = the app's own confirm box. */
.info-dialog { width: min(92vw, 560px); max-height: min(82vh, 640px); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.info-dialog::backdrop, .confirm-dialog::backdrop { background: var(--scrim); }
.info-dialog-header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: 0.9rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.info-dialog-header h2 { margin: 0; font-size: var(--fs-lg); }
.info-dialog-close { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; min-height: 0; padding: 0; flex-shrink: 0; color: var(--text-muted); background: transparent; border: 1px solid var(--control-border); border-radius: 999px; box-shadow: none; }
.info-dialog-close:hover:not(:disabled) { background: var(--surface-2); color: var(--text); filter: none; }
.help-dialog-body, .changelog-body { padding: 0.5rem 1.25rem 1.5rem; overflow-y: auto; max-height: calc(min(82vh, 640px) - 3.5rem); }
.help-dialog-body h3 { margin: 1.1rem 0 0.35rem; font-size: 0.95rem; }
.help-dialog-body h3:first-child { margin-top: 0.75rem; }
.help-dialog-body p, .help-dialog-body ul { margin: 0 0 0.6rem; font-size: 0.88rem; line-height: 1.5; color: var(--text-muted); }
.help-dialog-body ul { padding-left: 1.2rem; }
.changelog-entry { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.changelog-entry:first-child { padding-top: 0.5rem; }
.changelog-entry:last-child { border-bottom: none; }
.changelog-entry-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; }
.changelog-version { padding: 0.1rem 0.5rem; font-size: 0.72rem; font-weight: 700; white-space: nowrap; color: var(--text); background: var(--table-head-bg); border-radius: var(--radius-pill); }
.changelog-title { margin: 0; font-size: 0.92rem; font-weight: 700; }
.changelog-entry p { margin: 0.3rem 0 0; font-size: 0.85rem; color: var(--text-muted); }
.confirm-dialog { width: min(28rem, 92vw); padding: 1.25rem 1.4rem; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-card); box-shadow: var(--shadow-md); }
.confirm-dialog h2 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.confirm-dialog p { margin: 0 0 1.1rem; font-size: 0.92rem; line-height: 1.5; }
.confirm-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; }
@media (prefers-reduced-motion: no-preference) {
  .info-dialog, .confirm-dialog { transition: opacity 0.18s ease, transform 0.18s ease, overlay 0.18s allow-discrete, display 0.18s allow-discrete; }
  .info-dialog::backdrop, .confirm-dialog::backdrop { transition: opacity 0.18s ease, overlay 0.18s allow-discrete, display 0.18s allow-discrete; }
  @starting-style { .info-dialog[open], .confirm-dialog[open] { opacity: 0; transform: scale(0.96) translateY(-8px); } .info-dialog[open]::backdrop, .confirm-dialog[open]::backdrop { opacity: 0; } }
}

/* ===================== 13 Toasts and action bar ==================== */
.toast-stack { position: fixed; top: 1rem; right: 1rem; z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2); width: min(24rem, calc(100vw - 2rem)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.7rem 0.8rem 0.7rem 1rem; font-size: 0.9rem; line-height: 1.4; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-left-width: 5px; border-radius: var(--radius-md); box-shadow: var(--shadow-md); animation: xcet-toast-in 0.2s ease-out; }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close { flex: none; width: 1.6rem; height: 1.6rem; min-height: 0; padding: 0; font-size: 1.2rem; line-height: 1; color: var(--text-muted); background: transparent; border: 0; border-radius: 6px; box-shadow: none; }
.toast-close:hover { color: var(--text); background: var(--surface-2); filter: none; }
@keyframes xcet-toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Sticky bar of pending bulk actions. Its blank space lets clicks through; only its buttons take them. */
.action-bar { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: var(--z-action-bar); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.6rem; max-width: calc(100vw - 2rem); padding: 0.55rem 0.75rem 0.55rem 1rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); pointer-events: none; }
.action-bar > button, .action-bar > a { pointer-events: auto; }
.action-bar-count { font-weight: 600; font-size: 0.9rem; }
@media (min-width: 900px) { body:has(> #gnav-layout > .gnav):not(.gnav-collapsed) .action-bar { left: calc(50% + var(--gnav-w) / 2); } }
@media (max-width: 640px) { .action-bar { left: 0.5rem; right: 0.5rem; bottom: 0.5rem; transform: none; max-width: none; } }
body:has(.action-bar) { padding-bottom: 6rem; }

@media print { .gnav, .app-header, .action-bar, .toast-stack, .tabs, .skip-link { display: none !important; } body { padding: 0; background: #fff; color: #000; } .card { box-shadow: none; } }
