/* SIDOF24 Publisher — Material Design 3 token layer (M5-T01).
 *
 * Hand-rolled MD3 tokens + the foundational app-shell classes. We adopt Material 3 as
 * a CSS token layer (option A, decided 2026-06-18) rather than the @material/web custom
 * elements, because the web build is pure Scala.js (no npm/ESM bundler) and the project
 * keeps a minimal dependency graph. The SPA stays one main.js + this one stylesheet.
 *
 * LIGHT THEME ONLY for now (dark deferred, dfraile 2026-06-18). The color roles below
 * are the single source of truth; re-seeding the palette is a one-block edit. Dark mode,
 * when it lands, is a `[data-theme="dark"]` block overriding the same --md-sys-color-*
 * variables plus a toggle — see the placeholder near the end of this file.
 *
 * Class naming: `md-<block>` with `md-<block>--<modifier>` (BEM-ish). The Scala side
 * references these names through `web.styles.Css` constants so a typo is a compile error.
 *
 * M5-T01 defines the tokens + the app-shell classes (top app bar, nav drawer, main).
 * The reusable component classes (.md-button, .md-card, .md-dialog, .md-text-field, …)
 * are authored in M5-T02 alongside the shared-component migration.
 */

/* ── Web font (vendored, never CDN) ───────────────────────────────────────────────────
 * Roboto is the MD3 default type family. It must be vendored as woff2 under
 * web/src/main/resources/fonts/ (Apache-2.0; the tool runs on-prem / possibly offline, so
 * a runtime Google Fonts CDN link is unacceptable). Until the binary is dropped in, the
 * @font-face simply fails to load and the UI renders in the system fallback stack below —
 * no breakage. See fonts/README.md. */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 100 900;                 /* variable font covers the full weight axis */
  font-display: swap;
  src: url("/assets/fonts/Roboto-variable.woff2") format("woff2");
}

:root {
  /* ── Color roles (MD3 light, Navantia blue) ─────────────────────────────────────────
   * Re-seeded 2026-06-18 from purple to the Navantia brand blue: primary = #375DAE, the
   * "Blue Navantia" from navantia_ietp_app's applicationStyles.css (white text on it is
   * ~6.3:1, AA). Containers / surface tints / inverse follow an MD3 blue tonal palette
   * (closest-Material, not exact, per dfraile). Error + the success/warning accents below
   * stay semantic; only the brand/neutral-tint roles changed. One block, no other files. */
  --md-sys-color-primary:                 #375DAE;
  --md-sys-color-on-primary:              #FFFFFF;
  --md-sys-color-primary-container:       #D9E2FF;
  --md-sys-color-on-primary-container:    #001A41;
  --md-sys-color-secondary:               #565F71;
  --md-sys-color-on-secondary:            #FFFFFF;
  --md-sys-color-secondary-container:     #DAE2F9;
  --md-sys-color-on-secondary-container:  #131C2B;
  --md-sys-color-tertiary:                #3B608F;
  --md-sys-color-on-tertiary:             #FFFFFF;
  --md-sys-color-tertiary-container:      #D3E3FF;
  --md-sys-color-on-tertiary-container:   #001B3C;
  --md-sys-color-error:                   #B3261E;
  --md-sys-color-on-error:                #FFFFFF;
  --md-sys-color-error-container:         #F9DEDC;
  --md-sys-color-on-error-container:      #410E0B;
  --md-sys-color-background:              #FAF9FD;
  --md-sys-color-on-background:           #1A1B20;
  --md-sys-color-surface:                 #FAF9FD;
  --md-sys-color-on-surface:              #1A1B20;
  --md-sys-color-surface-variant:         #E1E2EC;
  --md-sys-color-on-surface-variant:      #44474F;
  --md-sys-color-surface-container-lowest:  #FFFFFF;
  --md-sys-color-surface-container-low:     #F4F3FA;
  --md-sys-color-surface-container:         #EEEDF4;
  --md-sys-color-surface-container-high:    #E8E7EF;
  --md-sys-color-surface-container-highest: #E2E2E9;
  --md-sys-color-outline:                 #74777F;
  --md-sys-color-outline-variant:         #C4C6D0;
  --md-sys-color-inverse-surface:         #2F3036;
  --md-sys-color-inverse-on-surface:      #F1F0F7;
  --md-sys-color-inverse-primary:         #B0C6FF;
  --md-sys-color-scrim:                   #000000;
  --md-sys-color-shadow:                  #000000;

  /* Semantic accent palette — MD3 has no success/warning sys roles; these back the
   * green/amber used by chips, success text, and status glyphs (referenced as CSS vars
   * so the Scala side never hardcodes a hex). */
  --md-ref-palette-success: #1B5E20;
  --md-ref-palette-warning: #8A5000;

  /* ── Typeface ───────────────────────────────────────────────────────────────────── */
  --md-ref-typeface-plain: "Roboto", system-ui, "Segoe UI", Arial, sans-serif;
  --md-ref-typeface-mono:  "Roboto Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  /* ── Type scale (size / line-height / weight) ───────────────────────────────────── */
  --md-sys-typescale-display-large:   400 57px/64px var(--md-ref-typeface-plain);
  --md-sys-typescale-display-medium:  400 45px/52px var(--md-ref-typeface-plain);
  --md-sys-typescale-display-small:   400 36px/44px var(--md-ref-typeface-plain);
  --md-sys-typescale-headline-large:  400 32px/40px var(--md-ref-typeface-plain);
  --md-sys-typescale-headline-medium: 400 28px/36px var(--md-ref-typeface-plain);
  --md-sys-typescale-headline-small:  400 24px/32px var(--md-ref-typeface-plain);
  --md-sys-typescale-title-large:     400 22px/28px var(--md-ref-typeface-plain);
  --md-sys-typescale-title-medium:    500 16px/24px var(--md-ref-typeface-plain);
  --md-sys-typescale-title-small:     500 14px/20px var(--md-ref-typeface-plain);
  --md-sys-typescale-body-large:      400 16px/24px var(--md-ref-typeface-plain);
  --md-sys-typescale-body-medium:     400 14px/20px var(--md-ref-typeface-plain);
  --md-sys-typescale-body-small:      400 12px/16px var(--md-ref-typeface-plain);
  --md-sys-typescale-label-large:     500 14px/20px var(--md-ref-typeface-plain);
  --md-sys-typescale-label-medium:    500 12px/16px var(--md-ref-typeface-plain);
  --md-sys-typescale-label-small:     500 11px/16px var(--md-ref-typeface-plain);

  /* ── Elevation (box-shadow per MD3 level) ───────────────────────────────────────── */
  --md-sys-elevation-level0: none;
  --md-sys-elevation-level1: 0 1px 2px 0 rgba(0,0,0,.30), 0 1px 3px 1px rgba(0,0,0,.15);
  --md-sys-elevation-level2: 0 1px 2px 0 rgba(0,0,0,.30), 0 2px 6px 2px rgba(0,0,0,.15);
  --md-sys-elevation-level3: 0 1px 3px 0 rgba(0,0,0,.30), 0 4px 8px 3px rgba(0,0,0,.15);
  --md-sys-elevation-level4: 0 2px 3px 0 rgba(0,0,0,.30), 0 6px 10px 4px rgba(0,0,0,.15);
  --md-sys-elevation-level5: 0 4px 4px 0 rgba(0,0,0,.30), 0 8px 12px 6px rgba(0,0,0,.15);

  /* ── Shape (corner radii) ───────────────────────────────────────────────────────── */
  --md-sys-shape-corner-none: 0;
  --md-sys-shape-corner-xs:   4px;
  --md-sys-shape-corner-s:    8px;
  --md-sys-shape-corner-m:    12px;
  --md-sys-shape-corner-l:    16px;
  --md-sys-shape-corner-xl:   28px;
  --md-sys-shape-corner-full: 9999px;

  /* ── Spacing (4px grid) ─────────────────────────────────────────────────────────── */
  --md-space-1: 4px;
  --md-space-2: 8px;
  --md-space-3: 12px;
  --md-space-4: 16px;
  --md-space-5: 20px;
  --md-space-6: 24px;
  --md-space-8: 32px;
  --md-space-10: 40px;
}

/* ── Base / reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-background);
  background: var(--md-sys-color-background);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* A visible, token-driven focus ring on every interactive element (accessibility sanity
 * is verified in M5-T06; the ring is established here so later tickets inherit it). */
:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* ── App shell (M5-T01 pilot) ───────────────────────────────────────────────────────
 * Same grid as before (header row + nav/main columns, full viewport) — re-skin only, no
 * reflow. The side nav is a permanent MD navigation drawer (M5.md Open item #3 default). */
.md-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 16rem 1fr;
  grid-template-areas: "header header" "nav main";
  height: 100vh;
  font: var(--md-sys-typescale-body-medium);
}

/* Top app bar */
.md-top-app-bar {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--md-space-4);
  height: 64px;
  padding: 0 var(--md-space-6);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-sys-elevation-level2);
  z-index: 10;
}
.md-top-app-bar__title {
  font: var(--md-sys-typescale-title-large);
  letter-spacing: .02em;
}
.md-top-app-bar__actions {
  display: flex;
  align-items: center;
  gap: var(--md-space-4);
}

/* User badge in the top app bar */
.md-user-badge {
  display: flex;
  align-items: center;
  gap: var(--md-space-2);
  font: var(--md-sys-typescale-label-large);
}
.md-user-badge__role {
  font: var(--md-sys-typescale-label-small);
  opacity: .8;
  text-transform: capitalize;
}

/* Navigation drawer */
.md-nav-drawer {
  grid-area: nav;
  display: flex;
  flex-direction: column;
  gap: var(--md-space-1);
  padding: var(--md-space-3) var(--md-space-3);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
  border-right: 1px solid var(--md-sys-color-outline-variant);
  overflow-y: auto;
}
.md-nav-section-label {
  padding: var(--md-space-4) var(--md-space-4) var(--md-space-1);
  font: var(--md-sys-typescale-label-small);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--md-sys-color-on-surface-variant);
}
/* Nav item: MD3 navigation-drawer pill (full-radius, active = secondary-container) */
.md-nav-item {
  display: flex;
  align-items: center;
  gap: var(--md-space-3);
  height: 56px;
  padding: 0 var(--md-space-6);
  border-radius: var(--md-sys-shape-corner-full);
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  font: var(--md-sys-typescale-label-large);
  cursor: pointer;
  transition: background-color .1s ease;
}
.md-nav-item:hover {
  background: var(--md-sys-color-surface-container-high);
}
.md-nav-item--active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

/* Main content area */
.md-main {
  grid-area: main;
  padding: var(--md-space-6);
  overflow-y: auto;
  background: var(--md-sys-color-background);
}

/* ── Dark theme placeholder (NOT built in M5 — architecture note only) ────────────────
 * When dark mode is picked up, add here (and a toggle that sets data-theme on <html>):
 *
 *   [data-theme="dark"] {
 *     --md-sys-color-primary: #D0BCFF;
 *     --md-sys-color-surface: #141218;
 *     ... the dark MD3 role set ...
 *   }
 *
 * Every component already reads --md-sys-color-* tokens, so no component CSS changes —
 * dark is a single token-override block plus the toggle. Deferred (dfraile 2026-06-18). */

/* ════════════════════════════════════════════════════════════════════════════════════
 * Reusable component classes (M5-T02).
 * Consumed by the shared components in web/.../components/ and, from T03 on, by pages.
 * ════════════════════════════════════════════════════════════════════════════════════ */

/* ── Buttons ──────────────────────────────────────────────────────────────────────── */
.md-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--md-space-2);
  height: 40px;
  padding: 0 var(--md-space-6);
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-large);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .1s ease, box-shadow .1s ease, opacity .1s ease;
}
.md-button:disabled { cursor: not-allowed; opacity: .38; box-shadow: none; }
.md-button--sm { height: 32px; padding: 0 var(--md-space-4); font: var(--md-sys-typescale-label-medium); }

.md-button--filled { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.md-button--filled:hover:not(:disabled) { box-shadow: var(--md-sys-elevation-level1); }

.md-button--tonal { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.md-button--tonal:hover:not(:disabled) { box-shadow: var(--md-sys-elevation-level1); }

.md-button--outlined { background: transparent; color: var(--md-sys-color-primary); border: 1px solid var(--md-sys-color-outline); }
.md-button--outlined:hover:not(:disabled) { background: var(--md-sys-color-surface-container-high); }

.md-button--text { background: transparent; color: var(--md-sys-color-primary); padding: 0 var(--md-space-3); }
.md-button--text:hover:not(:disabled) { background: var(--md-sys-color-surface-container-high); }

.md-button--danger { background: var(--md-sys-color-error); color: var(--md-sys-color-on-error); }
.md-button--danger:hover:not(:disabled) { box-shadow: var(--md-sys-elevation-level1); }

.md-button--text-danger { background: transparent; color: var(--md-sys-color-error); padding: 0 var(--md-space-3); }
.md-button--text-danger:hover:not(:disabled) { background: var(--md-sys-color-error-container); }

/* ── Text fields (filled style) ───────────────────────────────────────────────────── */
.md-text-field {
  width: 100%;
  height: 48px;
  padding: 0 var(--md-space-4);
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  border: none;
  border-bottom: 1px solid var(--md-sys-color-on-surface-variant);
  border-radius: var(--md-sys-shape-corner-xs) var(--md-sys-shape-corner-xs) 0 0;
  font: var(--md-sys-typescale-body-large);
}
.md-text-field:focus { outline: none; border-bottom: 2px solid var(--md-sys-color-primary); }
.md-text-field--mono { font-family: var(--md-ref-typeface-mono); }

/* ── Card ─────────────────────────────────────────────────────────────────────────── */
.md-card {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-l);
  box-shadow: var(--md-sys-elevation-level1);
  padding: var(--md-space-6);
}

/* ── Dialog (Modal) ───────────────────────────────────────────────────────────────── */
.md-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .32);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.md-dialog {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border-radius: var(--md-sys-shape-corner-xl);
  box-shadow: var(--md-sys-elevation-level3);
  max-width: 32rem;
  width: 100%;
  padding: var(--md-space-6);
  max-height: 90vh;
  overflow-y: auto;
}
.md-dialog__title { margin: 0 0 var(--md-space-3); font: var(--md-sys-typescale-headline-small); }
.md-dialog__text  { margin: 0 0 var(--md-space-4); font: var(--md-sys-typescale-body-medium); color: var(--md-sys-color-on-surface-variant); }
.md-dialog__actions { display: flex; justify-content: flex-end; gap: var(--md-space-2); margin-top: var(--md-space-4); }

/* ── Snackbar (Toasts) — semantic colors preserved (success/error/info) ───────────── */
.md-snackbar-stack {
  position: fixed;
  top: var(--md-space-4);
  right: var(--md-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--md-space-2);
  z-index: 1000;
}
.md-snackbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--md-space-3);
  min-width: 14rem;
  padding: var(--md-space-3) var(--md-space-4);
  border-radius: var(--md-sys-shape-corner-xs);
  box-shadow: var(--md-sys-elevation-level3);
  font: var(--md-sys-typescale-body-medium);
  background: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
}
.md-snackbar--success { background: #1B5E20; color: #FFFFFF; }
.md-snackbar--error   { background: var(--md-sys-color-error); color: var(--md-sys-color-on-error); }
.md-snackbar--info    { background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface); }
.md-snackbar__close   { background: transparent; border: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }

/* ── Chips / status pills ─────────────────────────────────────────────────────────── */
.md-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--md-space-1);
  padding: 2px 10px;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-small);
  font-weight: 600;
  white-space: nowrap;
}
.md-chip--success { background: #C8E6C9; color: #1B5E20; }
.md-chip--warning { background: #FFE0B2; color: #8A5000; }
.md-chip--info    { background: #BBDEFB; color: #0D47A1; }
.md-chip--error   { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.md-chip--neutral { background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface-variant); }

/* ── Data table ───────────────────────────────────────────────────────────────────── */
.md-data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-m);
  overflow: hidden;
}
.md-data-table thead tr { background: var(--md-sys-color-surface-variant); }
.md-data-table th {
  text-align: left;
  padding: var(--md-space-3);
  font: var(--md-sys-typescale-title-small);
  color: var(--md-sys-color-on-surface-variant);
}
.md-data-table td {
  padding: var(--md-space-3);
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface);
  vertical-align: middle;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}
.md-data-table tbody tr:hover { background: var(--md-sys-color-surface-container); }
.md-table-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--md-space-3) 0;
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface-variant);
}
.md-table-pagination__nav { display: flex; gap: var(--md-space-2); }

/* ── Sticky action bar (bulk selection) ───────────────────────────────────────────── */
.md-action-bar {
  position: fixed;
  left: 50%;
  bottom: var(--md-space-6);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--md-space-4);
  padding: var(--md-space-3) var(--md-space-5);
  border-radius: var(--md-sys-shape-corner-l);
  background: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  box-shadow: var(--md-sys-elevation-level3);
  font: var(--md-sys-typescale-body-medium);
  z-index: 400;
}
.md-action-bar__actions { display: flex; gap: var(--md-space-2); }
.md-action-bar__cancel {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 var(--md-space-4);
  background: transparent;
  color: var(--md-sys-color-inverse-on-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-full);
  cursor: pointer;
  font: var(--md-sys-typescale-label-medium);
}

/* ── Drop zone ────────────────────────────────────────────────────────────────────── */
.md-dropzone {
  width: 200px;
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--md-space-2);
  border: 2px dashed var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-m);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-body-medium);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.md-dropzone--dragover { border-color: var(--md-sys-color-primary); background: var(--md-sys-color-primary-container); }
.md-dropzone__icon { font-size: 2.25rem; line-height: 1; }
.md-dropzone__label { margin: 0; padding: 0 var(--md-space-4); }

/* ── Drag-to-reorder rows ─────────────────────────────────────────────────────────── */
.md-reorder-row {
  display: flex;
  align-items: flex-start;
  gap: var(--md-space-2);
  padding: var(--md-space-3);
  margin-bottom: var(--md-space-2);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-s);
  background: var(--md-sys-color-surface-container-low);
  outline: none;
}
.md-reorder-handle { cursor: grab; user-select: none; color: var(--md-sys-color-on-surface-variant); font-size: 1.125rem; padding-top: 2px; }
.md-reorder-body { flex: 1; min-width: 0; }

/* ── Segmented control (e.g. EN/ES language switch) ───────────────────────────────── */
.md-segmented {
  display: inline-flex;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-full);
  overflow: hidden;
}
.md-segmented__seg {
  padding: var(--md-space-1) var(--md-space-3);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  border: none;
  cursor: pointer;
  font: var(--md-sys-typescale-label-medium);
}
.md-segmented__seg--active { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
/* On the (primary-colored) top app bar the segmented control needs light-on-dark contrast. */
.md-top-app-bar .md-segmented { border-color: rgba(255, 255, 255, .5); }
.md-top-app-bar .md-segmented__seg { color: rgba(255, 255, 255, .8); }
.md-top-app-bar .md-segmented__seg--active { background: rgba(255, 255, 255, .20); color: var(--md-sys-color-on-primary); }
/* Same light-on-dark fix for buttons (e.g. Sign out): the default outlined text is primary-on-primary
   = invisible until hover. Use on-primary text + a translucent-white border/hover on the bar. */
.md-top-app-bar .md-button--outlined { color: var(--md-sys-color-on-primary); border-color: rgba(255, 255, 255, .5); }
.md-top-app-bar .md-button--outlined:hover:not(:disabled) { background: rgba(255, 255, 255, .15); }

/* ── Compile-report panel (CompileReportPanel) ───────────────────────────────────── */
.md-report {
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-m);
  padding: var(--md-space-3);
}
.md-report__row { border-top: 1px solid var(--md-sys-color-outline-variant); padding: var(--md-space-2) 0; }
.md-report__row:first-child { border-top: none; }
.md-report__head { display: flex; align-items: center; justify-content: space-between; gap: var(--md-space-3); }
.md-report__name { font: var(--md-sys-typescale-body-medium); font-family: var(--md-ref-typeface-mono); }
.md-report__error {
  margin: var(--md-space-2) 0 0;
  padding: var(--md-space-2);
  background: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-error);
  border-radius: var(--md-sys-shape-corner-xs);
  font: var(--md-sys-typescale-body-small);
  font-family: var(--md-ref-typeface-mono);
  white-space: pre-wrap;
  color: var(--md-sys-color-on-surface);
}
.md-toolbar-end { display: flex; justify-content: flex-end; margin-bottom: var(--md-space-2); }

/* ── Bulk-upload result sections (CategoryResultTable) ────────────────────────────── */
.md-chip-row { display: flex; gap: var(--md-space-2); flex-wrap: wrap; margin: var(--md-space-3) 0; }
.md-result-section {
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-m);
  background: var(--md-sys-color-surface);
  margin-bottom: var(--md-space-2);
}
.md-result-section__summary {
  cursor: pointer;
  padding: var(--md-space-3);
  font: var(--md-sys-typescale-title-small);
  display: flex;
  align-items: center;
  gap: var(--md-space-2);
}
.md-result-section__count { color: var(--md-sys-color-on-surface-variant); font-weight: 400; }
.md-result-section__body { padding: 0 var(--md-space-3) var(--md-space-2); }
.md-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--md-space-2);
  padding: var(--md-space-1) 0;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  font: var(--md-sys-typescale-body-small);
}
.md-result-row__name { font-family: var(--md-ref-typeface-mono); color: var(--md-sys-color-on-surface); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-result-row__end { display: flex; align-items: center; gap: var(--md-space-2); flex-shrink: 0; }
.md-result-row__tag { color: var(--md-sys-color-on-surface-variant); font: var(--md-sys-typescale-label-small); font-family: var(--md-ref-typeface-mono); }

/* ════════════════════════════════════════════════════════════════════════════════════
 * Page & form primitives (M5-T03).
 * Shared by the auth / identity pages (login, dashboard, profile, admin) and reused by
 * the page tickets that follow (T04, T05).
 * ════════════════════════════════════════════════════════════════════════════════════ */

.md-page-title { margin: 0 0 var(--md-space-4); font: var(--md-sys-typescale-headline-small); color: var(--md-sys-color-on-surface); }
.md-card-title { margin: 0 0 var(--md-space-4); font: var(--md-sys-typescale-title-large); color: var(--md-sys-color-on-surface); }
.md-muted { color: var(--md-sys-color-on-surface-variant); }

/* Vertical stack with consistent gap (e.g. a column of cards, or a form's fields). */
.md-stack { display: flex; flex-direction: column; gap: var(--md-space-6); }
.md-stack--tight { gap: var(--md-space-4); }

/* Form field: a label above its control. */
.md-field { display: flex; flex-direction: column; gap: var(--md-space-1); }
.md-field__label { font: var(--md-sys-typescale-body-small); color: var(--md-sys-color-on-surface-variant); }
.md-form-row { display: flex; gap: var(--md-space-3); align-items: flex-end; flex-wrap: wrap; }
.md-form-row .md-field { min-width: 12rem; }

/* Select (native, MD-styled). */
.md-select {
  height: 40px;
  padding: 0 var(--md-space-3);
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-xs);
  font: var(--md-sys-typescale-body-medium);
  cursor: pointer;
}

.md-button--block { width: 100%; }

/* Inline banner (form-level errors / warnings). */
.md-banner {
  padding: var(--md-space-3) var(--md-space-4);
  border-radius: var(--md-sys-shape-corner-xs);
  margin-bottom: var(--md-space-4);
  font: var(--md-sys-typescale-body-medium);
}
.md-banner--error   { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.md-banner--warning { background: #FFE0B2; color: #8A5000; }

/* Key/value detail row (profile, detail pages). */
.md-detail-row {
  display: flex;
  justify-content: space-between;
  padding: var(--md-space-2) 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.md-detail-row:last-child { border-bottom: none; }
.md-detail-row__label { color: var(--md-sys-color-on-surface-variant); }
.md-detail-row__value { font-weight: 500; }

/* Chromeless login surface (rendered outside the app shell). */
.md-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--md-space-8);
  background: var(--md-sys-color-surface-container);
}
.md-login__card { max-width: 24rem; width: 100%; }

/* Quick-action links (dashboard). */
.md-quicklinks { display: flex; gap: var(--md-space-4); flex-wrap: wrap; margin: var(--md-space-4) 0; }

/* ════════════════════════════════════════════════════════════════════════════════════
 * List / detail page primitives (M5-T04).
 * Shared by collections, resource lists (CIR/applic/legacy), pubdef detail, layouts,
 * and the collection-detail tabs.
 * ════════════════════════════════════════════════════════════════════════════════════ */

/* Header row: title on the left, primary action on the right. */
.md-page-header { display: flex; align-items: center; justify-content: space-between; gap: var(--md-space-4); margin-bottom: var(--md-space-5); }

/* Empty state card. */
.md-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--md-space-10) var(--md-space-4);
  color: var(--md-sys-color-on-surface-variant);
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-m);
  text-align: center;
}
.md-empty-state__icon { font-size: 2.25rem; margin-bottom: var(--md-space-2); }

/* Icon button (⋯, ✕, etc.). */
.md-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.md-icon-button:hover { background: var(--md-sys-color-surface-container-high); }

/* Row action cell + dropdown menu. */
.md-actions-cell { position: relative; text-align: right; }
.md-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--md-space-1);
  min-width: 9rem;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-xs);
  box-shadow: var(--md-sys-elevation-level2);
  z-index: 50;
  overflow: hidden;
}
.md-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--md-space-3) var(--md-space-4);
  background: transparent;
  border: none;
  cursor: pointer;
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
}
.md-menu__item:hover { background: var(--md-sys-color-surface-container-high); }
.md-menu__item--danger { color: var(--md-sys-color-error); }

/* Search / filter row. */
.md-search-row { display: flex; gap: var(--md-space-2); margin-bottom: var(--md-space-4); }
.md-search-row .md-text-field { flex: 1; }
.md-text-field--sm { height: 40px; font: var(--md-sys-typescale-body-medium); }

/* Inline monospace. */
.md-mono { font-family: var(--md-ref-typeface-mono); font-size: .8125rem; }

/* Textarea (matches the filled text-field). */
.md-textarea {
  width: 100%;
  padding: var(--md-space-2) var(--md-space-4);
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  border: none;
  border-bottom: 1px solid var(--md-sys-color-on-surface-variant);
  border-radius: var(--md-sys-shape-corner-xs) var(--md-sys-shape-corner-xs) 0 0;
  font: var(--md-sys-typescale-body-large);
  resize: vertical;
}
.md-textarea:focus { outline: none; border-bottom: 2px solid var(--md-sys-color-primary); }

/* Links. */
.md-link { color: var(--md-sys-color-primary); text-decoration: none; }
.md-link:hover { text-decoration: underline; }
.md-link--plain { color: var(--md-sys-color-on-surface); text-decoration: none; font-weight: 500; }
.md-link--plain:hover { text-decoration: underline; }

/* Field-level error helper text. */
.md-field-error { color: var(--md-sys-color-error); font: var(--md-sys-typescale-body-small); margin: 0 0 var(--md-space-2); }

/* Sticky detail header (collection / pubdef detail). */
.md-sticky-header {
  position: sticky;
  top: 0;
  background: var(--md-sys-color-background);
  padding: var(--md-space-4) 0 var(--md-space-3);
  margin-bottom: var(--md-space-4);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  z-index: 10;
}
.md-breadcrumb { display: flex; align-items: center; gap: var(--md-space-1); font: var(--md-sys-typescale-body-small); color: var(--md-sys-color-on-surface-variant); margin-bottom: var(--md-space-1); }
.md-breadcrumb__sep { margin: 0 var(--md-space-1); }
.md-detail-title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--md-space-4); }

/* Key/value meta rows (pubdef detail). */
.md-meta-row { display: flex; gap: var(--md-space-4); padding: var(--md-space-2) 0; font: var(--md-sys-typescale-body-medium); }
.md-meta-row__label { width: 11rem; color: var(--md-sys-color-on-surface-variant); flex-shrink: 0; }

/* Right-side slide-in drawer. */
.md-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 28rem;
  max-width: 100vw;
  height: 100vh;
  background: var(--md-sys-color-surface-container-low);
  box-shadow: var(--md-sys-elevation-level3);
  overflow-y: auto;
  padding: var(--md-space-6);
  z-index: 400;
}
.md-drawer__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--md-space-4); }

/* Danger button, outlined variant (white surface + red border/text) — used by the
 * "delete" affordances in sticky headers and drawers. */
.md-button--danger-outlined {
  background: transparent;
  color: var(--md-sys-color-error);
  border: 1px solid var(--md-sys-color-error);
}
.md-button--danger-outlined:hover:not(:disabled) { background: var(--md-sys-color-error-container); }

/* Collection-detail tabs. */
.md-tabs { display: flex; gap: var(--md-space-1); border-bottom: 1px solid var(--md-sys-color-outline-variant); margin-bottom: var(--md-space-4); }
.md-tab {
  padding: var(--md-space-3) var(--md-space-4);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font: var(--md-sys-typescale-title-small);
  color: var(--md-sys-color-on-surface-variant);
}
.md-tab:hover { color: var(--md-sys-color-on-surface); }
.md-tab--active { color: var(--md-sys-color-primary); border-bottom-color: var(--md-sys-color-primary); }

/* A horizontal toolbar of controls (e.g. the images-tab actions). */
.md-toolbar { display: flex; align-items: center; gap: var(--md-space-4); flex-wrap: wrap; margin-bottom: var(--md-space-5); }
.md-toolbar__group { display: flex; align-items: center; gap: var(--md-space-2); }

/* Centered upload / progress card (bulk-upload tab). */
.md-dropcard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--md-space-4);
  padding: var(--md-space-8) var(--md-space-4);
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-m);
}

/* Linear progress bar. */
.md-progress { width: min(28rem, 100%); height: 8px; background: var(--md-sys-color-surface-variant); border-radius: var(--md-sys-shape-corner-full); overflow: hidden; }
.md-progress__bar { height: 100%; background: var(--md-sys-color-primary); }

/* Danger-zone card (error outline). */
.md-card--danger { border: 1px solid var(--md-sys-color-error); }
.md-card-title--danger { color: var(--md-sys-color-error); }

/* Success-colored inline text (e.g. image % saved). MD3 has no success role; matches the
 * green used by .md-chip--success. */
.md-text-success { color: var(--md-ref-palette-success); font-weight: 600; }

/* ════════════════════════════════════════════════════════════════════════════════════
 * Jobs / sets / publish-flow primitives (M5-T05).
 * ════════════════════════════════════════════════════════════════════════════════════ */

/* Filter chips (jobs-list status filter). */
.md-filter-chips { display: flex; gap: var(--md-space-2); margin-bottom: var(--md-space-4); flex-wrap: wrap; }
.md-filter-chip {
  padding: var(--md-space-1) var(--md-space-3);
  border-radius: var(--md-sys-shape-corner-full);
  border: 1px solid var(--md-sys-color-outline);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  font: var(--md-sys-typescale-label-medium);
}
.md-filter-chip--active { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); border-color: transparent; }

/* Uppercase section label. */
.md-section-title { margin: 0; font: var(--md-sys-typescale-title-small); text-transform: uppercase; letter-spacing: .05em; color: var(--md-sys-color-on-surface-variant); }

/* Pipeline progress card (job detail). */
.md-pipeline { background: var(--md-sys-color-surface-container-low); border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-sys-shape-corner-m); padding: var(--md-space-4); }
.md-pipeline__row { display: flex; align-items: center; gap: var(--md-space-3); padding: var(--md-space-2) var(--md-space-1); border-bottom: 1px solid var(--md-sys-color-outline-variant); font: var(--md-sys-typescale-body-medium); }
.md-pipeline__row:last-child { border-bottom: none; }
.md-pipeline__badge { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; border-radius: var(--md-sys-shape-corner-full); font: var(--md-sys-typescale-label-small); font-weight: 600; flex-shrink: 0; }
.md-pipeline__badge--completed { background: #C8E6C9; color: #1B5E20; }
.md-pipeline__badge--current   { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.md-pipeline__badge--failed    { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.md-pipeline__badge--pending   { background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface-variant); }
.md-pipeline__label--completed { color: #1B5E20; }
.md-pipeline__label--current   { color: var(--md-sys-color-primary); font-weight: 600; }
.md-pipeline__label--failed    { color: var(--md-sys-color-error); font-weight: 600; }
.md-pipeline__label--pending   { color: var(--md-sys-color-on-surface-variant); }

/* Log viewer (dark terminal surface). Amber/green accents are terminal conventions, not
 * MD3 sys roles. */
.md-log { position: relative; background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface); border-radius: var(--md-sys-shape-corner-m); height: 24rem; }
.md-log__pre { margin: 0; padding: var(--md-space-3); font-family: var(--md-ref-typeface-mono); font-size: .75rem; line-height: 1.4; height: 100%; overflow-y: auto; white-space: pre-wrap; word-break: break-all; }
.md-log__line { display: flex; gap: var(--md-space-2); }
.md-log__file { color: var(--md-sys-color-outline); flex-shrink: 0; }
.md-log__text { white-space: pre-wrap; }
.md-log__gap { color: #FBBF24; font-style: italic; padding: var(--md-space-1) 0; }
.md-log__terminal { color: #34D399; padding: var(--md-space-1) 0; }
.md-log__jump {
  position: absolute; left: 50%; bottom: var(--md-space-4); transform: translateX(-50%);
  background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary);
  border: none; border-radius: var(--md-sys-shape-corner-full);
  padding: var(--md-space-2) var(--md-space-4); font: var(--md-sys-typescale-label-medium);
  cursor: pointer; box-shadow: var(--md-sys-elevation-level3);
}

/* Job-detail header card (title + actions row). */
.md-job-header { display: flex; align-items: center; justify-content: space-between; gap: var(--md-space-4); }

/* Broken-references modal row. */
.md-broken-row { display: flex; align-items: center; gap: var(--md-space-2); padding: var(--md-space-2) var(--md-space-3); background: var(--md-sys-color-error-container); border-radius: var(--md-sys-shape-corner-xs); }
.md-broken-row__label { font-family: var(--md-ref-typeface-mono); font-size: .8125rem; color: var(--md-sys-color-on-error-container); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Uppercase field label (publish drawer). */
.md-field-label-upper { display: block; font: var(--md-sys-typescale-label-small); text-transform: uppercase; letter-spacing: .05em; color: var(--md-sys-color-on-surface-variant); margin-bottom: var(--md-space-1); }

/* ENH-03: active PUBLISH sub-phase line + inline spinner (Antenna House gives no
   page-level progress, so the spinner signals liveness during the opaque step). */
.md-pipeline__sub { display: inline-flex; align-items: center; gap: var(--md-space-2); margin-left: var(--md-space-2); font-size: .8rem; color: var(--md-sys-color-on-surface-variant); }
@keyframes md-spin { to { transform: rotate(360deg); } }
.md-spinner { display: inline-block; width: .85em; height: .85em; border: 2px solid var(--md-sys-color-outline-variant); border-top-color: var(--md-sys-color-primary); border-radius: 50%; animation: md-spin .8s linear infinite; }
