/* ============================================================================
 * elviana - C4X Base Styles  (web/styles/base.css)
 * ----------------------------------------------------------------------------
 * Reset + base elements + the shared C4X "App / admin-tool chrome" component
 * set. As of T-029 (run R-022) the canonical component CSS comes from the
 * c4x-website-style skill (~/.claude/skills/c4x-website-style/SKILL.md,
 * sections "Design tokens", "Page canvas" and "App / admin-tool chrome") and
 * consumes the tokens in styles/c4x-tokens.css.
 *
 * Load order:
 *     <link rel="stylesheet" href="styles/c4x-tokens.css">
 *     <link rel="stylesheet" href="styles/base.css">
 *
 * Layers in this file:
 *   A. Skill page-canvas + typography + plain-top-nav (.topbar) - verbatim.
 *   B. Skill app-chrome components - .btn 4-tier hierarchy, forms (light
 *      field chips), .panel/.section-panel, .status-banner-*, .badge,
 *      .stat-card, data table - verbatim except where AA corrections are
 *      documented inline (dark ink on gold/accent fills instead of white).
 *   C. Legacy compatibility classes (.c4x-btn*, .c4x-field/.c4x-input…,
 *      .c4x-badge*) kept so existing screen JS/markup keeps working; each is
 *      implemented BY DELEGATION to the skill classes above so the visuals
 *      are identical and there is one source of truth.
 *   D. A11y machinery: skip link, focus-visible ring, live-region toasts,
 *      utilities, reduced-motion, forced-colors.
 * ========================================================================= */

/* ============================================================================
 * A. Skill page canvas + base elements (verbatim from the skill)
 * ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--c4x-text-md);
  background-color: var(--c4x-body-bg);
  background-image:
    radial-gradient(900px circle at 12% 0%, color-mix(in srgb, var(--c4x-glow-cyan) 22%, transparent), transparent 60%),
    radial-gradient(700px circle at 92% 18%, color-mix(in srgb, var(--c4x-glow-teal) 20%, transparent), transparent 55%),
    radial-gradient(800px circle at 50% 100%, color-mix(in srgb, var(--c4x-hero) 30%, transparent), transparent 60%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--c4x-body-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.6;
}

img, svg, video { display: block; max-width: 100%; }
input, button, textarea { font: inherit; }
/* Fields must NOT inherit from the dark-canvas body text color - they sit on
 * white chips in this design system. Explicitly pin the field text + bg. */
input, select, textarea { color: var(--c4x-field-text); background-color: var(--c4x-white); }
/* `<select>` dropdown options render on white chips in every engine; without
 * this they inherit the page's dark-theme text color (invisible on white). */
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

h1, h2, h3, h4, .brand { font-family: var(--font-heading); line-height: 1.15; }
h1 { font-size: clamp(2rem, 4vw, 2.9rem); font-weight: 800; margin: 0 0 1rem; }
h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); font-weight: 700; margin: 0 0 0.75rem; }
h3 { font-size: 1.2rem; font-weight: 700; margin: 0 0 0.5rem; }
p { margin: 0 0 1rem; }

a {
  color: var(--c4x-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  border-radius: var(--c4x-radius-sm);
}
a:hover { color: var(--c4x-accent-dark); text-decoration-thickness: 2px; }

code {
  font-family: var(--c4x-font-family-mono);
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--c4x-border);
  border-radius: var(--c4x-radius-sm);
  padding: 0.05em 0.35em;
}

/* Skill - plain top nav (internal tool). The shared admin chrome: brand logo
 * + product tagline + flat section links. */
.topbar {
  display: flex; align-items: center; gap: 20px; padding: 10px 24px;
  background: linear-gradient(160deg, var(--c4x-hero-deep) 0%, var(--c4x-hero) 100%);
  color: var(--c4x-white);
}
.topbar .brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-heading); font-size: 19px; font-weight: 700;
  color: var(--c4x-white); text-decoration: none;
}
/* elviana delta: the brand asset is a transparent-PNG logotype drawn for
 * LIGHT surfaces, and the topbar is a dark navy gradient - invert it to
 * light rather than recoloring with filter: invert() (which trades the
 * navy-on-navy problem for a light-blur-on-dark one). A sourced light logo
 * variant should replace this when the brand pack provides one. */
.topbar .brand img { display: block; height: 30px; width: auto; filter: brightness(0) invert(1); }
.topbar .brand-tag {
  font-size: 13px; color: rgba(255, 255, 255, 0.75);
  border-left: 1px solid rgba(255, 255, 255, 0.25); padding-left: 20px;
  white-space: nowrap;
}
/* Auth surfaces (login) make the logotype the hero of the dark canvas. */
.auth-brand img.brand-logo-light { filter: brightness(0) invert(1); }
.topbar nav { display: flex; gap: 20px; align-items: center; margin-left: auto; }
.topbar nav a { color: var(--c4x-topnav-link); text-decoration: none; font-size: 14px; font-weight: 500; padding: 6px 2px; }
.topbar nav a:hover, .topbar nav a.active { color: var(--c4x-white); }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; padding: 10px 16px; }
  .topbar .brand img { height: 26px; }
  .topbar .brand-tag { display: none; }
  .topbar nav { width: 100%; gap: 14px; overflow-x: auto; }
}


/* Skill page-canvas container: centered column on the dark canvas. */
main { max-width: 1280px; margin: 0 auto; padding: 0 1.5rem 3rem; }

/* ============================================================================
 * B. Skill "App / admin-tool chrome" components (verbatim; AA deltas noted)
 * ========================================================================= */

/* ---- Button hierarchy (4 tiers), skill-verbatim with one AA correction ----
 * The skill's source CSS puts white text on the gold and accent fills; on this
 * palette white-on-#e8b84b measures 1.8:1 and white-on-#00a4bf 3.0:1 - both
 * fail WCAG AA. The skill itself already uses dark ink on gold for its own
 * Jarvis send button ("Dark ink on the accent-teal bubble for contrast"), so
 * the fills here carry the skill's dark-ink colors --c4x-on-gold (8.8:1) and
 * --c4x-on-accent (5.6:1). Everything else verbatim. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 6px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: filter 0.12s ease, background 0.12s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-gold { background: var(--c4x-gold); color: var(--c4x-on-gold); }
.btn-gold:hover:not(:disabled) { background: var(--c4x-gold-dark); }
.btn-accent { background: var(--c4x-accent); color: var(--c4x-on-accent); }
.btn-accent:hover:not(:disabled) { background: var(--c4x-accent-dark); }
.btn-outline { background: transparent; border-color: var(--c4x-border); color: var(--c4x-body-text); }
.btn-outline:hover:not(:disabled) { border-color: var(--c4x-accent); color: var(--c4x-accent); }
.btn-ghost { background: transparent; color: var(--c4x-muted); border: none; padding: 6px 10px; }
.btn-ghost:hover:not(:disabled) { color: var(--c4x-body-text); }
.btn-danger { background: transparent; color: var(--c4x-danger); border: 1px solid var(--c4x-danger); }
.btn-danger:hover:not(:disabled) { background: var(--c4x-danger-bg); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---- Forms (skill-verbatim): light field chips on the dark chrome --------
 * Fields stay on a light background regardless of the page's dark theme; the
 * field text is the dedicated --c4x-field-text (#0e283a), never the page's
 * own near-white body text (the skill's "invisible text" warning). */
label {
  display: block; font-size: 13px; font-weight: 600; color: var(--c4x-body-text); margin-bottom: 4px;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="search"], input[type="url"], input[type="tel"],
input:not([type]), textarea {
  width: 100%; font-family: var(--font-body); font-size: 14px;
  color: var(--c4x-field-text);
  background: var(--c4x-white);
  border: 1px solid var(--c4x-border); border-radius: 6px; padding: 9px 11px;
}
/* Hard rule (a11y): this console's inputs are >=16px so iOS never auto-zooms.
 * The SKILL spec is 14px; AA/iOS beats visual parity for these six screens. */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="search"], input[type="url"], input[type="tel"],
input:not([type]) { height: 40px; font-size: 16px; }
input[type="date"], input[type="datetime-local"] { -webkit-appearance: none; appearance: none; line-height: 20px; height: 40px; }
select { height: 40px; font-size: 16px; }
textarea { font-size: 16px; }
input::placeholder, textarea::placeholder { color: var(--c4x-field-placeholder); opacity: 1; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--c4x-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c4x-accent) 18%, transparent);
}
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; min-width: 0; }
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field label { margin: 0; }
@media (max-width: 640px) { .field-row { flex-direction: column; gap: 0; } }

/* ---- Panel container (skill-verbatim) ---- */
.panel { background: var(--c4x-panel-bg); border: 1px solid var(--c4x-border); border-radius: 10px; box-shadow: 0 10px 28px rgba(0, 8, 16, 0.35); }
.section-panel { padding: 24px; margin-bottom: 24px; }

/* ---- Status banners (skill-verbatim) ---- */
.status-banner { padding: 12px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.status-banner-info { background: rgba(255, 255, 255, 0.05); color: var(--c4x-muted); border: 1px solid var(--c4x-border); }
.status-banner-warn { background: color-mix(in srgb, var(--c4x-gold) 12%, transparent); color: var(--c4x-gold); border: 1px solid color-mix(in srgb, var(--c4x-gold) 40%, transparent); }
.status-banner-error { background: var(--c4x-danger-bg); color: var(--c4x-danger); border: 1px solid var(--c4x-danger-border); }

/* Delivery-attempt drill-in row inside the jobs table (expands under a job). */
.attempts-detail td { background: color-mix(in srgb, var(--c4x-panel-bg) 60%, var(--c4x-body-bg)); padding: var(--c4x-space-sm) var(--c4x-space-lg); }
.attempts-detail .c4x-table { margin: 0; }

/* Shared empty-state (used by every screen with a list/table; keep in sync with
 * tokens). */
.empty-state { padding: var(--c4x-space-xl) var(--c4x-space-md); text-align: center; color: var(--c4x-muted); margin: 0; }

/* Console-wide section nav inside the .topbar (flat, skill-styled - plain top nav
 * uses text links, no dropdowns). Active section is underlined; hover goes to white. */
.topbar-nav { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; margin-left: auto; }
.topnav-link { color: var(--c4x-topnav-link); text-decoration: none; font-size: 14px; font-weight: 500; padding: 6px 2px; border-bottom: 2px solid transparent; }
.topnav-link:hover, .topnav-link.active { color: var(--c4x-white); }
.topnav-link.active { border-bottom-color: var(--c4x-accent); }
@media (max-width: 56rem) { .topbar { flex-wrap: wrap; } .topbar-user { margin-left: auto; } .topbar-nav { order: 3; width: 100%; margin-left: 0; gap: 1rem; } }

/* ---- Status badges (skill-verbatim + elviana semantic variants) ----
 * The legacy elviana badge taxonomy (neutral/info/success/warning/danger with
 * a leading dot, kept by every screen's JS) is layered on the skill's .badge
 * base. Per the skill, "Example semantic variants - name these for whatever states the
 * project actually has": ours are below, each with a measured AA text/tint
 * pair from c4x-tokens.css. The legacy markup injects an empty
 * .c4x-badge-dot span in addition to the ::before dot, so the pseudo-element
 * is suppressed when that span is present (no double dot). */
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--c4x-border); color: var(--c4x-muted); background: var(--c4x-body-bg);
}
.badge-positive { color: var(--c4x-on-accent); background: var(--c4x-accent); border-color: var(--c4x-accent); }
.badge-pending { color: var(--c4x-gold); border-color: color-mix(in srgb, var(--c4x-gold) 50%, transparent); background: color-mix(in srgb, var(--c4x-gold) 14%, transparent); }
.badge-negative { color: var(--c4x-danger); border-color: var(--c4x-danger-border); background: var(--c4x-danger-bg); }

/* ---- Stat cards (skill-verbatim) ---- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { padding: 20px; text-align: center; }
.stat-card .value { font-family: var(--font-heading); font-size: 32px; font-weight: 700; color: var(--c4x-accent); }
.stat-card .label { font-size: 13px; color: var(--c4x-muted); margin-top: 4px; }

/* ---- Data table (skill-verbatim) ---- */
table { width: 100%; border-collapse: collapse; }
/* Words are never torn apart in table cells: a column is as wide as its longest word, and a table wider than its wrapper scrolls
 * inside .c4x-table-wrap. Identifiers (ids, paths, action names) stay on one line. */
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--c4x-border); font-size: 14px; overflow-wrap: normal; word-break: normal; }
td.c4x-mono, .c4x-table .c4x-mono { white-space: nowrap; }
dd.c4x-mono { overflow-x: auto; white-space: nowrap; }
/* A long identifier inside running text or a definition list: stays whole and scrolls sideways within its own box. */
.c4x-token { display: inline-block; max-width: 100%; overflow-x: auto; white-space: nowrap; vertical-align: bottom; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--c4x-muted); font-weight: 700; }
tbody tr:hover { background: rgba(255, 255, 255, 0.04); }

/* ============================================================================
 * C. Legacy compatibility classes → delegated to the skill components above
 *    (existing screens & their JS keep working; visuals come from one source)
 * ========================================================================= */

/* Layout helper (stack of form fields/groups). */
.c4x-stack { display: flex; flex-direction: column; gap: var(--c4x-space-sm); }

/* Buttons: legacy .c4x-btn[--primary|--secondary|--danger|--ghost][--sm]
 * mapped onto the skill's 4-tier hierarchy.
 *   --primary   (old default action)  → .btn-accent treatment (teal fill);
 *                                       screens that are the one commit
 *                                       action of their form now use .btn-gold
 *                                       directly in markup.
 *   --secondary (white-outline)       → .btn-outline treatment
 *   --danger    (filled red)          → .btn-danger outline treatment (the
 *                                       skill's destructive tier is outline-
 *                                       styled so it never competes with the
 *                                       primary action)
 *   --ghost                           → .btn-ghost treatment
 */
.c4x-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--c4x-space-2xs);
  min-height: var(--c4x-control-height);
  padding: 0 var(--c4x-space-sm);
  font-size: var(--c4x-text-sm);
  font-weight: var(--c4x-font-weight-semibold);
  line-height: 1;
  white-space: nowrap;
  border: var(--c4x-control-border-width) solid transparent;
  border-radius: var(--c4x-radius-md);
  background-color: var(--c4x-accent);
  color: var(--c4x-on-accent);
  cursor: pointer;
  user-select: none;
  transition: background-color var(--c4x-motion-fast),
              border-color var(--c4x-motion-fast),
              filter var(--c4x-motion-fast);
}
.c4x-btn:hover:not(:disabled) { background-color: var(--c4x-accent-dark); }

.c4x-btn--secondary {
  background-color: transparent;
  color: var(--c4x-body-text);
  border-color: var(--c4x-border);
}
.c4x-btn--secondary:hover:not(:disabled) {
  background-color: transparent;
  border-color: var(--c4x-accent);
  color: var(--c4x-accent);
}

.c4x-btn--danger {
  background-color: transparent;
  color: var(--c4x-danger);
  border-color: var(--c4x-danger);
}
.c4x-btn--danger:hover:not(:disabled) { background-color: var(--c4x-danger-bg); }

.c4x-btn--ghost {
  background-color: transparent;
  color: var(--c4x-muted);
  border-color: transparent;
}
.c4x-btn--ghost:hover:not(:disabled) {
  background-color: transparent;
  color: var(--c4x-body-text);
}

.c4x-btn--sm {
  min-height: var(--c4x-control-height-sm);
  padding: 0 var(--c4x-space-xs);
  font-size: var(--c4x-text-xs);
}

.c4x-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.c4x-btn:focus-visible { opacity: 1; }

/* Form controls: legacy .c4x-field/.c4x-label/.c4x-input/.c4x-select/
 * .c4x-textarea delegated to the skill's light-chip treatment. Field text is
 * --c4x-field-text on white chips; never the page's light body color. */
.c4x-field { display: flex; flex-direction: column; gap: var(--c4x-space-3xs); }

.c4x-label {
  font-size: var(--c4x-text-sm);
  font-weight: var(--c4x-font-weight-semibold);
  color: var(--c4x-body-text);
  letter-spacing: var(--c4x-letterspacing-label);
}
.c4x-label[aria-disabled="true"] { color: var(--c4x-muted); }

.c4x-input,
.c4x-select,
.c4x-textarea {
  width: 100%;
  min-width: 0; /* never let content squeeze controls inside a flex/grid parent */
  min-height: var(--c4x-control-height);
  padding: var(--c4x-space-xs) var(--c4x-space-sm);
  font-size: var(--c4x-text-md);
  line-height: var(--c4x-line-normal);
  color: var(--c4x-field-text);
  background-color: var(--c4x-white);
  border: var(--c4x-control-border-width) solid var(--c4x-color-border-strong);
  border-radius: var(--c4x-radius-md);
  transition: border-color var(--c4x-motion-fast), box-shadow var(--c4x-motion-fast);
}
.c4x-textarea { min-height: calc(var(--c4x-control-height) * 2); resize: vertical; }

/* Select menus: give the collapsed control a reliable min-width so the visible
 * value isn't cropped regardless of option content. Options pop up full-width
 * in the browser/native menu, so nothing else clips them. */
select, select.c4x-select, .c4x-field select.c4x-select {
  /* Vertical-centred text in a 40px box; painted chevron; no appearance chrome.
     Fixes the "text is 2/3rds visible behind a pseudo-border" artifact caused by
     an earlier min-height+line-height collision against the native groove. */
  height: 40px;
  min-height: 40px;
  padding: 0 2.4rem 0 var(--c4x-space-sm);
  line-height: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--c4x-field-text) 50%), linear-gradient(135deg, var(--c4x-field-text) 50%, transparent 50%);
  background-position: calc(100% - 1.3rem) 50%, calc(100% - 0.85rem) 50%;
  background-size: 0.45rem 0.45rem, 0.45rem 0.45rem;
  background-repeat: no-repeat;
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.c4x-field select.c4x-select option { color: var(--c4x-field-text); background: var(--c4x-white); padding: 6px 10px; line-height: normal; }

.c4x-input::placeholder,
.c4x-textarea::placeholder {
  color: var(--c4x-field-placeholder); /* 6.0:1 on the white chip */
  opacity: 1;
}

.c4x-input:hover:not(:disabled),
.c4x-select:hover:not(:disabled),
.c4x-textarea:hover:not(:disabled) {
  border-color: var(--c4x-muted);
}

.c4x-input:focus-visible,
.c4x-select:focus-visible,
.c4x-textarea:focus-visible {
  border-color: var(--c4x-accent);
  box-shadow: var(--c4x-shadow-focus);
}

.c4x-input:disabled,
.c4x-select:disabled,
.c4x-textarea:disabled {
  background-color: rgba(255, 255, 255, 0.55);
  border-color: var(--c4x-border);
  color: var(--c4x-field-placeholder);
  cursor: not-allowed;
}

.c4x-input[aria-invalid="true"],
.c4x-select[aria-invalid="true"],
.c4x-textarea[aria-invalid="true"] {
  border-color: var(--c4x-invalid); /* dark red vs the white chip = AA UI */
}

.c4x-help-text { font-size: var(--c4x-text-sm); color: var(--c4x-muted); }
/* Help text sits clear of the table or field above it. */
.c4x-table-wrap + .c4x-help-text { margin-top: var(--c4x-space-sm); }
.c4x-field > .c4x-help-text { display: block; margin-top: var(--c4x-space-xs); }
.c4x-error-text {
  font-size: var(--c4x-text-sm);
  font-weight: var(--c4x-font-weight-semibold);
  color: var(--c4x-danger);
  display: inline-flex;
  align-items: center;
  gap: var(--c4x-space-3xs);
}

.c4x-checkbox,
.c4x-radio {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--c4x-accent);
  flex: none;
}

/* Tables: legacy .c4x-table on the skill's data-table treatment (dark). */
.c4x-table-wrap {
  width: 100%;
  overflow-x: auto;
  background-color: var(--c4x-panel-bg);
  border: var(--c4x-control-border-width) solid var(--c4x-border);
  border-radius: var(--c4x-radius-lg);
  box-shadow: var(--c4x-shadow-sm);
}
.c4x-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--c4x-text-sm);
  line-height: var(--c4x-line-dense);
}
.c4x-table caption {
  caption-side: top;
  text-align: left;
  font-size: var(--c4x-text-md);
  font-weight: var(--c4x-font-weight-semibold);
  color: var(--c4x-body-text);
  padding: var(--c4x-space-sm) var(--c4x-space-md);
}
.c4x-table thead th {
  position: sticky;
  top: 0;
  z-index: var(--c4x-z-sticky);
  background-color: var(--c4x-color-bg-subtle);
  color: var(--c4x-muted);
  font-size: var(--c4x-text-xs);
  font-weight: var(--c4x-font-weight-bold);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-align: left;
  padding: var(--c4x-space-xs) var(--c4x-space-md);
  border-bottom: 1px solid var(--c4x-border);
  white-space: nowrap;
}
.c4x-table tbody td {
  padding: var(--c4x-space-xs) var(--c4x-space-md);
  min-height: var(--c4x-table-row-height);
  color: var(--c4x-body-text);
  border-bottom: 1px solid var(--c4x-border);
  vertical-align: middle;
}
.c4x-table tbody tr:nth-child(even) { background-color: rgba(255, 255, 255, 0.03); }
.c4x-table tbody tr:hover { background-color: rgba(255, 255, 255, 0.04); }
.c4x-table tbody tr:focus-visible {
  outline: var(--c4x-focus-ring-width) solid var(--c4x-focus-ring-color);
  outline-offset: calc(-1 * var(--c4x-focus-ring-width));
}
.c4x-table .c4x-num { font-variant-numeric: tabular-nums; text-align: right; }

/* Status badges: legacy variants delegated to the skill's badge treatments. */
.c4x-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--c4x-space-3xs);
  padding: 1px var(--c4x-space-2xs);
  font-size: var(--c4x-text-xs);
  font-weight: var(--c4x-font-weight-bold);
  line-height: 1.6;
  border-radius: var(--c4x-radius-pill);
  border: 1px solid currentColor;
  white-space: nowrap;
}
.c4x-badge::before {
  content: "";
  width: var(--c4x-badge-dot-size);
  height: var(--c4x-badge-dot-size);
  border-radius: var(--c4x-radius-pill);
  background-color: currentColor;
  flex: none;
}
/* The legacy elviana badge markup injects an explicit .c4x-badge-dot span;
 * when present it carries the dot styling and the ::before is suppressed so
 * there is never a double dot. */
.c4x-badge:has(> .c4x-badge-dot)::before { display: none; }
.c4x-badge-dot {
  width: var(--c4x-badge-dot-size);
  height: var(--c4x-badge-dot-size);
  border-radius: var(--c4x-radius-pill);
  background-color: currentColor;
  flex: none;
  display: inline-block;
}
.c4x-badge--neutral {
  color: var(--c4x-color-statusneutral-strong-text);
  background-color: var(--c4x-color-statusneutral-tint);
}
.c4x-badge--info {
  color: var(--c4x-color-info-strong-text);
  background-color: var(--c4x-color-info-tint);
  border-color: var(--c4x-border);
}
.c4x-badge--success {
  color: var(--c4x-color-success-strong-text);
  background-color: var(--c4x-color-success-tint);
}
.c4x-badge--warning {
  color: var(--c4x-color-warning-strong-text);
  background-color: var(--c4x-color-warning-tint);
}
.c4x-badge--danger {
  color: var(--c4x-color-danger-strong-text);
  background-color: var(--c4x-color-danger-tint);
}

/* ============================================================================
 * D. A11y machinery + utilities
 * ========================================================================= */

/* Visible keyboard focus: single accent ring + halo, applied to every
 * natively-focusable element. Never `outline: none` without a replacement -
 * form fields above get the skill's border+glow; their :focus-visible (below)
 * additionally draws the same global ring shape. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--c4x-focus-ring-width) solid var(--c4x-focus-ring-color);
  outline-offset: var(--c4x-focus-ring-offset);
}
@supports not selector(:focus-visible) {
  :where(a, button, input, select, textarea, summary, [tabindex]):focus {
    outline: var(--c4x-focus-ring-width) solid var(--c4x-focus-ring-color);
    outline-offset: var(--c4x-focus-ring-offset);
  }
}

/* Skip link (WCAG 2.4.1). Visually hidden until focused; sits above chrome. */
.c4x-skip-link {
  position: absolute;
  top: calc(-1 * var(--c4x-space-xl));
  left: var(--c4x-space-sm);
  z-index: var(--c4x-z-skip);
  padding: var(--c4x-space-xs) var(--c4x-space-sm);
  background: var(--c4x-hero-deep);
  color: var(--c4x-white);
  text-decoration: none;
  border-radius: var(--c4x-radius-md);
}
.c4x-skip-link:focus-visible { top: var(--c4x-space-sm); outline-color: var(--c4x-white); }

/* Live-region toasts (one polite region per screen; hoisted here in R-022 so
 * every screen shares styled toasts - login.html previously lacked them). */
.live-region {
  position: fixed;
  right: var(--c4x-space-sm);
  bottom: var(--c4x-space-sm);
  z-index: var(--c4x-z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--c4x-space-2xs);
  max-width: 24rem;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--c4x-space-2xs);
  padding: var(--c4x-space-sm) var(--c4x-space-md);
  border-radius: var(--c4x-radius-md);
  border: 1px solid var(--c4x-border);
  background: var(--c4x-panel-bg);
  color: var(--c4x-body-text);
  box-shadow: var(--c4x-shadow-md);
  font-size: var(--c4x-text-sm);
}
.toast--success { border-color: var(--c4x-color-success-solid); }
.toast--error   { border-color: var(--c4x-color-danger-solid); }
.toast--info    { border-color: var(--c4x-color-info-solid); }

/* Utility */
.c4x-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.c4x-text-secondary { color: var(--c4x-muted); }
.c4x-text-muted { color: var(--c4x-color-neutral-500); }
.c4x-mono { font-family: var(--c4x-font-family-mono); font-feature-settings: "tnum"; }
.c4x-nowrap { white-space: nowrap; }

/* Reduced motion */
@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;
  }
}

/* Forced-colors (Windows High Contrast): tints/shadows drop; system borders
 * carry meaning; the visible outline focus ring survives. */
@media (forced-colors: active) {
  body { background-image: none; }
  .c4x-btn, .c4x-input, .c4x-select, .c4x-textarea, .c4x-badge, .c4x-table-wrap, .panel, .btn {
    border: 1px solid ButtonText;
  }
  .c4x-btn, .btn { background: ButtonFace; color: ButtonText; }
  .c4x-btn--primary, .c4x-btn--danger, .btn-gold, .btn-danger { border-style: solid; }
  .c4x-badge::before { background-color: currentColor; }
  .c4x-table tbody tr:hover { background: Canvas; }
  :where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid Highlight;
  }
}

/* ---- Layout utilities (replace former inline style attributes) ---- */
.u-row { display: flex; gap: var(--c4x-space-sm); align-items: center; flex-wrap: wrap; }
.u-row-end { align-items: flex-end; }
.u-flush { margin: 0; }
.u-maxw-field { max-width: 26rem; }
.u-mt-0 { margin-top: 0; }
.u-mt-sm { margin-top: var(--c4x-space-sm); }
.u-mt-md { margin-top: var(--c4x-space-md); }
.u-pad { padding: 1rem; }
.u-grid-health { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1rem; margin: 0; }

/* ---- Topbar account avatar + menu (skill: circular toggle + kebab popover) ---- */
.topbar-user { display: flex; align-items: center; margin-left: 4px; }
.user-avatar-btn {
  width: 36px; height: 36px; border-radius: 50%; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c4x-panel-bg); border: 1px solid var(--c4x-border); color: var(--c4x-body-text);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.user-avatar-btn:hover { border-color: var(--c4x-accent); color: var(--c4x-accent); }
.user-avatar-btn[aria-expanded="true"] { background: var(--c4x-accent); border-color: var(--c4x-accent); color: var(--c4x-on-accent); }
.user-menu {
  position: fixed; z-index: 300; min-width: 220px; padding: 6px; text-align: left;
  background: var(--c4x-hero-deep); color: var(--c4x-white);
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.user-menu[hidden] { display: none; }
.user-menu-info { display: flex; flex-direction: column; padding: 8px 10px; font-size: 13px; }
.user-menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--c4x-muted); margin-top: 6px; }
.user-menu-label:first-child { margin-top: 0; }
.user-menu-info strong { overflow-wrap: break-word; text-transform: capitalize; }
.user-menu-sep { height: 1px; background: rgba(255, 255, 255, 0.14); margin: 4px 2px; }
.user-menu-item {
  display: flex; width: 100%; padding: 9px 10px; border: none; border-radius: 6px; background: none;
  font: inherit; font-size: 13px; color: var(--c4x-white); cursor: pointer; text-align: left;
}
.user-menu-item:hover { background: rgba(255, 255, 255, 0.1); }
.c4x-field select.c4x-select { width: 100%; min-width: 100%; }
.user-initials { font-family: var(--font-heading); font-weight: 700; font-size: 13px; letter-spacing: 0.02em; line-height: 1; }
.user-menu-email { text-transform: none !important; margin-bottom: 4px; }
.user-icon[hidden] { display: none; }

/* Buttons sitting beside form fields (inline field+action rows, filter toolbars)
 * match the 40px control height so the row reads as one aligned line. */
.u-row-end > .btn, .toolbar > .btn { height: 40px; padding-top: 0; padding-bottom: 0; }
.u-row-end > .btn-ghost, .toolbar > .btn-ghost { padding-left: 14px; padding-right: 14px; }

/* ---- Tabs (WAI-ARIA tablist; skill tokens, underline-active like the topbar nav) ---- */
.tabs { display: flex; gap: 4px; box-shadow: inset 0 -1px 0 var(--c4x-border); margin-bottom: var(--c4x-space-md); overflow-x: auto; overflow-y: hidden; }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 10px 14px; font: inherit; font-size: 14px; font-weight: 600; color: var(--c4x-muted);
  cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--c4x-body-text); }
.tab[aria-selected="true"] { color: var(--c4x-body-text); border-bottom-color: var(--c4x-accent); }
[role="tabpanel"][hidden] { display: none; }

/* ---- Grouped primary nav + acting-as banner ---- */
.topnav-sep { width: 1px; align-self: stretch; margin: 4px 2px; background: rgba(255, 255, 255, 0.22); }
.acting-banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--c4x-space-sm); flex-wrap: wrap;
  padding: 8px 24px; font-size: 14px; font-weight: 600;
  background: var(--c4x-gold); color: var(--c4x-on-gold);
}
.acting-banner .btn-outline { color: var(--c4x-on-gold); border-color: var(--c4x-on-gold); }
.acting-banner .btn-outline:hover:not(:disabled) { color: var(--c4x-on-gold); background: rgba(0, 0, 0, 0.1); border-color: var(--c4x-on-gold); }
a.user-menu-item { text-decoration: none; }
@media (max-width: 720px) { .acting-banner { padding: 8px 16px; } }

.user-role-select { min-width: 8.5rem; width: auto; }

/* ---- Modal dialogs (replace native confirm/prompt): panel on a dark scrim, C4X buttons ---- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(4, 14, 24, 0.72);
  animation: modal-fade 0.12s ease-out;
}
.modal { width: 100%; max-width: 30rem; max-height: calc(100vh - 32px); overflow: auto; padding: 24px; border-left: 3px solid var(--c4x-accent); }
.modal-danger { border-left-color: var(--c4x-danger); }
.modal h2 { margin: 0; font-size: 1.25rem; }
.modal-message { margin: 0; color: var(--c4x-body-text); overflow-wrap: break-word; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.modal-error { color: var(--c4x-danger); font-size: 13px; min-height: 0; }
.modal-error:empty { display: none; }
body.modal-open { overflow: hidden; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal-backdrop { animation: none; } }
@media (max-width: 480px) { .modal { padding: 18px; } .modal-actions .btn { flex: 1; } }

/* ---- Table polish: action cells fit their buttons; labels never break mid-word ---- */
.btn { white-space: nowrap; }
.c4x-table td:has(> .btn), table td:has(> .btn) { white-space: nowrap; width: 1%; }
.c4x-nowrap { white-space: nowrap; }

/* Avatar menu: platform section + "you are here" cue for pages that live in the menu */
.user-menu-heading { padding: 8px 10px 2px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--c4x-muted); }
.user-menu-item.is-current { color: var(--c4x-accent-dark); font-weight: 600; }
.user-avatar-btn.has-current { border-color: var(--c4x-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c4x-accent) 35%, transparent); }
.user-menu { max-height: calc(100vh - 16px); overflow-y: auto; }
