:root {
  color-scheme: light dark;
  /* ── efb brand system (light) ─────────────────────────────
     Indigo #5e5ce6 primary + teal #0fb5a6 secondary, mirroring the
     iOS/web product so the console reads as the same product. Variable
     NAMES are preserved so admin.js / index.html / login.html keep working;
     only the values change. */
  --bg: #fbfbfd;
  --ink: #1c1c1e;
  --muted: #6a6a70;
  --panel: #ffffff;
  --panel-2: #f1f1f5;
  /* --panel-3: very-light tinted card/surface fill (was literal #fbfdfe). */
  --panel-3: #f7f7fb;
  /* --raised: input / inner-card surface (was literal #fff used as bg). */
  --raised: #ffffff;
  --line: #e3e3ea;
  --line-strong: #d4d4dd;
  /* Alias: a few rules reference var(--border) (one with no fallback). */
  --border: #e3e3ea;
  /* Sidebar: indigo-tinted dark (brand-consistent, not generic navy). */
  --nav: #16151f;
  --nav-2: #1f1d2b;
  --accent: #5e5ce6;
  --accent-2: #0fb5a6;
  /* Readable indigo-dark for text on a tint (links, code, chips). */
  --accent-ink: #4744c4;
  --good: #34c759;
  --warn: #ff9500;
  --bad: #ff3b30;
  --info: #5e5ce6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15,30,45,.06), 0 1px 3px rgba(15,30,45,.04);
  --shadow-md: 0 6px 18px rgba(15,30,45,.08), 0 2px 6px rgba(15,30,45,.05);
  --shadow-lg: 0 20px 44px rgba(15,30,45,.16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 88% -8%, rgba(15,181,166,.10) 0%, rgba(15,181,166,0) 55%),
    radial-gradient(900px 500px at 0% 0%, rgba(94,92,230,.10) 0%, rgba(94,92,230,0) 50%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--ink);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s, color .15s;
}

button:hover { border-color: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Primary action = the indigo→teal brand gradient. */
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 6px rgba(94,92,230,.28);
}
button.primary:hover { background: linear-gradient(135deg, #6d6bef, #19c2b3); color: #fff; box-shadow: 0 4px 12px rgba(94,92,230,.34); }

button.danger {
  background: var(--bad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 6px rgba(255,59,48,.25);
}
button.danger:hover { color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(255,59,48,.3); }

button.secondary { background: var(--panel-2); }

button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  background: var(--panel-2);
  border-color: var(--line);
  box-shadow: none;
  transform: none;
  opacity: .7;
}
button:disabled:hover { color: var(--muted); border-color: var(--line); }

/* ── App shell ─────────────────────────────────────────── */

/* Top console layout: brand/actions plus horizontally scrollable page tabs. */
.app-shell {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────── */

.sidebar {
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  z-index: 10;
  width: 100%;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-align-items: center;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, var(--nav-2) 0%, var(--nav) 60%, #110f18 100%);
  color: #e6e5ef;
  box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 8px 24px rgba(0,0,0,.20);
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  height: auto;
  min-height: 64px;
  padding: 0 18px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 0;
  border-bottom: none;
  white-space: nowrap;
}

.sidebar-brand strong {
  font-size: 15px;
  letter-spacing: .01em;
  color: #f4f4f8;
}

/* Brand mark = the canonical efb indigo→teal gradient. */
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: 10px;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(94,92,230,.35);
}

/* ── Side nav ──────────────────────────────────────────── */

.side-nav {
  -webkit-flex: 1;
  flex: 1;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  -webkit-align-items: center;
  align-items: center;
  min-width: 280px;
  padding: 0 4px;
  gap: 4px;
  /* Wrap tabs onto a second line instead of a horizontal scrollbar that hides
     系统/用户/账号 — the header bar (.sidebar) is flex-wrap + height:auto, so a
     taller nav is fine. Critical at high Windows display scaling (DPR 1.75-2.0),
     where the effective CSS viewport is only ~770-900px. */
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
}

.side-nav button {
  /* Full-width block so the entire row (incl. padding) is the click target,
     not just the text glyphs. Previously a click landing on the button's own
     padding or the inter-button gap could miss on the first try. */
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  width: auto;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #9d9cb0;
  padding: 18px 12px 15px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: color .15s, background .15s, border-color .15s;
}

.side-nav button:hover {
  color: #f0f0f6;
  background: rgba(255,255,255,.06);
}

.side-nav button[aria-selected="true"] {
  color: #fff;
  background: linear-gradient(180deg, rgba(94,92,230,.22), rgba(15,181,166,.04));
  border-bottom-color: var(--accent);
  box-shadow: inset 0 -1px 0 rgba(94,92,230,.22);
}

.sidebar-footer {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  -webkit-align-items: center;
  align-items: center;
  gap: 8px;
  padding: 0;
  border-top: none;
  margin-left: auto;
}

.sidebar-footer select {
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 6px;
  background: rgba(255,255,255,.08);
  color: #e6e5ef;
  padding: 7px 8px;
  font-size: 13px;
}

.sidebar-footer button {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: #e6e5ef;
  padding: 7px 12px;
  font-size: 13px;
}

/* ── Main panel / tabs ─────────────────────────────────── */

.main-panel {
  -webkit-flex: 1;
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 24px 28px 40px;
  max-width: 1440px;
  margin: 0 auto;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.tab-header {
  margin-bottom: 22px;
}

.tab-header h2 {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 5px;
}

.tab-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* ── Status metrics ────────────────────────────────────── */

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.metric {
  position: relative;
  padding: 16px 16px 16px 18px;
  overflow: hidden;
  transition: box-shadow .15s, transform .12s;
}

.metric::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
}

.metric:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 6px;
}

/* Overview "needs attention" + "recent activity" regions. */
.overview-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.attention-list,
.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.attention-item {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 7px;
  background: var(--panel-3);
  font-size: 13px;
}

.attention-item.attention-bad { border-left-color: var(--bad); background: rgba(255,59,48,.08); }
.attention-item.attention-warn { border-left-color: var(--warn); background: rgba(255,149,0,.10); }

.attention-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
}

.attention-bad .attention-dot { background: var(--bad); }
.attention-warn .attention-dot { background: var(--warn); }

.attention-message {
  -webkit-flex: 1;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.attention-jump { flex-shrink: 0; }

.activity-item {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
  font-size: 13px;
}

.activity-label {
  -webkit-flex: 1;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.activity-time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Empty states ──────────────────────────────────────── */

.empty-state {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 22px 12px;
  text-align: center;
  color: var(--muted);
}

.empty-state-glyph {
  font-size: 26px;
  line-height: 1;
  opacity: .7;
}

.empty-state p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* ── Loading / skeleton states ─────────────────────────── */
/* Shimmer placeholders injected into panels before their fetch resolves, so the
   operator sees "loading" instead of an empty void. Built only from efb tokens. */

.loading-state {
  display: grid;
  gap: 8px;
  padding: 4px 0;
}

/* Loud failure block: shown when a panel's load fails/times out instead of
   leaving the skeleton spinning. Carries an error message + a retry button. */
.loading-error {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.loading-error button {
  justify-self: start;
}

.loading-state-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
}

.loading-row {
  display: block;
}

.skeleton {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: var(--panel-2);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.55) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: skeleton-shimmer 1.25s ease-in-out infinite;
}

.skeleton-bar {
  height: 14px;
  width: 100%;
}

.skeleton-bar.short {
  width: 40%;
  height: 11px;
}

/* Skeleton metric card: keep the four-up grid footprint while loading. */
.metric-skeleton {
  display: grid;
  gap: 8px;
  align-content: center;
}

.metric-skeleton .skeleton-bar { height: 22px; }
.metric-skeleton .skeleton-bar.short { height: 10px; }

@keyframes skeleton-shimmer {
  100% { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; }
}

/* ── Panel error (load failed + retry) ─────────────────── */
.panel-error {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 14px 0;
}

.panel-error p {
  margin: 0;
  font-size: 13px;
  color: var(--bad);
}

.panel-retry {
  align-self: start;
}

/* ── Content grid ──────────────────────────────────────── */

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, .8fr);
  gap: 16px;
  margin-bottom: 16px;
}

.content-grid.single {
  grid-template-columns: 1fr;
}

/* ── Per-page two-pane layout (IA): left secondary menu + right content ──────
   The left subnav is intentionally NON-sticky (in normal document flow): each
   page renders only the selected sub-section on the right, so single-screen
   height drops and the menu scrolling away with the page is acceptable. */
.page-split {
  display: grid;
  grid-template-columns: minmax(170px, 240px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.page-subnav {
  display: grid;
  gap: 6px;
  align-content: start;
}

.page-subnav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  box-shadow: none;
  transition: border-color .15s, background .15s, color .15s;
}

.page-subnav-item:hover {
  background: var(--panel-2);
}

.page-subnav-item.active {
  border-color: rgba(94, 92, 230, .5);
  background: linear-gradient(90deg, rgba(94, 92, 230, .14), rgba(15, 181, 166, .08));
  color: var(--accent);
  font-weight: 600;
}

.page-subnav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-subnav-badge {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
}

.page-subnav-label small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-nav-modes {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.ac-nav-heading {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  padding: 4px 2px;
}

.ac-nav-back {
  color: var(--accent-ink);
  justify-content: flex-start;
}

.ac-nav-item {
  align-items: flex-start;
}

.page-content {
  min-width: 0;
}

/* Airlines page: wider left column to hold the entity list (airline names +
   filters), like the Countries page. */
.page-split.airlines-split {
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
}

/* Left entity-list column for the Airlines page: holds the heading, filter
   row and the selectable airline list, stacked vertically. */
.page-subnav-wide {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Collapse to a single column at the app-wide 900px breakpoint; the subnav
   becomes a horizontal wrap-row above the content. */
@media (max-width: 900px) {
  .page-split,
  .page-split.airlines-split {
    grid-template-columns: 1fr;
  }
  .page-subnav {
    display: flex;
    flex-wrap: wrap;
  }
  .page-subnav-item {
    width: auto;
  }
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel.wide {
  min-height: 200px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2,
.panel-heading h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 0;
}

.panel-heading span {
  color: var(--muted);
  font-size: 12px;
}

/* Subtitle under a panel heading: clarifies a panel whose title could be
   confused with another (e.g. Data Domains vs the Data sources tab). */
.panel-subtitle {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: -6px 0 14px;
}

/* ── Rows ──────────────────────────────────────────────── */

.row-list {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  transition: border-color .15s, box-shadow .15s;
}

.row:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }

.row strong {
  font-size: 14px;
}

.row span, .row p {
  color: var(--muted);
  margin: 0;
  font-size: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.row-actions button {
  padding: 7px 10px;
}

.small-button {
  padding: 6px 9px;
  font-size: 12px;
}

/* ── Badges ────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

/* Green: terminal "good" states (published live, built/complete, covered…).
   Tint backgrounds use rgba of the status token so they adapt in dark mode. */
.badge.succeeded, .badge.authoritative, .badge.published, .badge.complete, .badge.built,
.badge.covered, .badge.ready, .badge.valid { background: rgba(52,199,89,.14); color: var(--good); }
/* Red: hard failures + missing credentials/data. */
.badge.failed, .badge.missing, .badge.error, .badge.partial-success, .badge.blocked,
.badge.invalid, .badge.exhausted { background: rgba(255,59,48,.14); color: var(--bad); }
/* Amber: needs-action / in-progress-but-incomplete states. */
.badge.needs_manual_action, .badge.partial, .badge.uploaded, .badge.not-built,
.badge.warning, .badge.pending { background: rgba(255,149,0,.16); color: var(--warn); }
/* Indigo (info): active/transient states — running jobs and verified-but-not-yet-
   published releases (ready for the publish action). */
.badge.running, .badge.checking_daily, .badge.checking-daily, .badge.verified { background: rgba(94,92,230,.14); color: var(--info); }
/* Gray: neutral/inert states (never uploaded, rolled back, none). */
.badge.not-uploaded, .badge.rolled-back, .badge.rolled_back, .badge.revoked, .badge.none { background: var(--panel-2); color: var(--muted); }

/* Keep status labels textual; generated glyphs were being exposed as stray
   check/cross runs in browser accessibility snapshots. */
.badge::before { content: none !important; }

/* Small leading glyph for the most operationally meaningful states so a
   configured/blocked source is distinguishable beyond color alone. */
.badge.ready::before, .badge.succeeded::before, .badge.verified::before,
.badge.published::before, .badge.covered::before, .badge.complete::before,
.badge.built::before, .badge.valid::before { content: "✓ "; }
.badge.blocked::before, .badge.failed::before, .badge.missing::before,
.badge.error::before, .badge.invalid::before { content: "✕ "; }
.badge.running::before { content: "● "; }
.badge.warning::before, .badge.needs_manual_action::before { content: "! "; }

/* ── Table ─────────────────────────────────────────────── */

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 9px 7px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

/* ── Login page ────────────────────────────────────────── */

.login-body {
  display: grid;
  place-items: center;
  background:
    radial-gradient(1000px 700px at 50% -10%, rgba(94,92,230,.30) 0%, rgba(94,92,230,0) 60%),
    linear-gradient(160deg, var(--nav-2), #100e17);
}

.login-panel {
  width: min(400px, calc(100vw - 32px));
  background: var(--raised);
  border-radius: 16px;
  padding: 32px 30px;
  border: 1px solid rgba(255,255,255,.5);
  box-shadow: 0 30px 70px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.3);
}

.login-panel h1 {
  margin: 18px 0 4px;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.login-panel p {
  color: var(--muted);
  margin: 0 0 20px;
}

.login-language {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 16px;
}

.login-language select {
  min-width: 104px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--raised);
  color: var(--ink);
  padding: 8px 10px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label,
#password-form label,
#raw-eaip-upload-form label,
#publication-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-form input,
#password-form input,
#raw-eaip-upload-form input,
#raw-eaip-upload-form textarea,
#publication-form input {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  background: var(--panel-2);
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.login-form input:focus,
#password-form input:focus,
#publication-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--raised);
  box-shadow: 0 0 0 3px rgba(94,92,230,.18);
}

#raw-eaip-upload-form textarea {
  resize: vertical;
}

.login-form button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
  padding: 12px;
  box-shadow: 0 4px 14px rgba(94,92,230,.3);
}
.login-form button:hover { color: #fff; box-shadow: 0 6px 18px rgba(94,92,230,.38); }

.form-error {
  min-height: 18px;
  color: var(--bad);
  font-size: 13px;
}

/* ── Settings ──────────────────────────────────────────── */

.settings-panel {
  display: grid;
  gap: 14px;
}

.settings-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: var(--panel-3);
}

.settings-status.ready {
  border-color: rgba(52, 199, 89, 0.4);
  background: rgba(52, 199, 89, 0.10);
}

.settings-status.blocked {
  border-color: rgba(255, 149, 0, 0.4);
  background: rgba(255, 149, 0, 0.10);
}

.settings-status p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-group {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
  overflow: hidden;
}

.settings-group-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.settings-group-summary::-webkit-details-marker { display: none; }

.settings-group-summary:hover { background: rgba(0,0,0,.03); }

.settings-group-summary strong { font-size: 14px; }

.settings-group-key {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.settings-group-chevron {
  display: inline-block;
  font-size: 10px;
  color: var(--muted);
  transition: transform .15s;
  flex-shrink: 0;
}

.settings-group[open] > .settings-group-summary .settings-group-chevron {
  transform: rotate(90deg);
}

.settings-group-body {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.settings-group-body > p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 10px;
}

.data-sources-section {
  border-top: none;
  padding-top: 0;
}

.data-sources-section > p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.data-source-category {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.data-source-category-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: var(--panel-3);
}

.data-source-category-summary::-webkit-details-marker { display: none; }

.data-source-category-summary:hover { background: rgba(0,0,0,.03); }

.data-source-category h4 {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-source-category-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

.data-source-category-chevron {
  display: inline-block;
  font-size: 10px;
  color: var(--muted);
  transition: transform .15s;
  flex-shrink: 0;
}

.data-source-category[open] > .data-source-category-summary .data-source-category-chevron {
  transform: rotate(90deg);
}

.data-source-category .data-source-list {
  padding: 8px 10px;
}

.data-source-list {
  display: grid;
  gap: 6px;
}

/* Public library folder tree (Document Library v3) — reuses the
   .data-source-category chrome, adds nesting indentation, an inline folder
   management toolbar, and a compact leaf (document) row. */
.library-workbench {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) minmax(280px, 320px);
  gap: 16px;
  align-items: start;
}

.library-index-panel,
.library-ingest-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 56px);
  overflow: auto;
}

.library-scope-heading {
  align-items: flex-start;
}

.library-scope-heading > div {
  min-width: 0;
}

.library-scope-heading .panel-subtitle {
  margin: 4px 0 0;
}

.library-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 12px;
}

.library-stats div {
  display: grid;
  gap: 2px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
}

.library-stats strong {
  font-size: 18px;
  line-height: 1.1;
}

.library-stats span {
  color: var(--muted);
  font-size: 11px;
}

.library-catalog {
  display: grid;
  gap: 6px;
}

.library-nav-tree,
.library-nav-children {
  display: grid;
  gap: 5px;
}

.library-nav-children {
  margin-top: 5px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.library-nav-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.library-nav-toggle {
  flex: 0 0 22px;
  width: 22px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.library-nav-toggle:disabled {
  opacity: 0.35;
}

.library-nav-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--raised);
  color: var(--ink);
  text-align: left;
  box-shadow: none;
}

.library-nav-item:hover {
  background: var(--panel-2);
}

.library-nav-root-node > .library-nav-item {
  width: 100%;
}

.library-nav-item.active {
  border-color: rgba(94,92,230,.5);
  background: linear-gradient(90deg, rgba(94,92,230,.12), rgba(15,181,166,.08));
  color: var(--accent-ink);
}

.library-nav-text {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.library-nav-text strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.library-nav-text small,
.library-nav-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.library-nav-count {
  flex: 0 0 auto;
  white-space: nowrap;
}

.library-nav-node-l2 .library-nav-item,
.library-nav-node-l3 .library-nav-item,
.library-nav-node-l4 .library-nav-item {
  padding-top: 7px;
  padding-bottom: 7px;
}

/* ⋯ folder-actions trigger at the right edge of each tree row. Kept in layout
   (no row shift) but faded until the row is hovered/focused or its menu is open,
   so a 59-folder tree stays a clean single-line-per-folder list instead of a
   wall of per-folder toolbars. */
.library-folder-menu-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  box-shadow: none;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity .12s ease, background .12s ease, border-color .12s ease;
}
.library-nav-row:hover .library-folder-menu-btn,
.library-nav-row:focus-within .library-folder-menu-btn,
.library-folder-menu-btn[aria-expanded="true"] { opacity: 1; }
.library-folder-menu-btn:hover,
.library-folder-menu-btn[aria-expanded="true"] {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--ink);
}

/* Shared folder-actions popover (a single element appended to <body> and moved
   under whichever ⋯ button was clicked). */
.folder-menu-popover {
  position: fixed;
  z-index: 1200;
  min-width: 190px;
  max-width: 240px;
  padding: 6px;
  display: grid;
  gap: 1px;
  background: var(--raised, #fff);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .20);
}
.folder-menu-popover[hidden] { display: none; }
.folder-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  box-shadow: none;
  cursor: pointer;
}
.folder-menu-item:hover:not(:disabled) { background: var(--panel-2); }
.folder-menu-item:disabled { opacity: 0.4; cursor: default; }
.folder-menu-item.danger { color: var(--bad, #c0392b); }
.folder-menu-item.danger:hover:not(:disabled) { background: rgba(255, 59, 48, .10); }
.folder-menu-move {
  display: grid;
  gap: 4px;
  padding: 7px 10px 4px;
  font-size: 12px;
  color: var(--muted);
}
.folder-menu-move select {
  width: 100%;
  font-size: 13px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--raised);
  color: var(--ink);
}
.folder-menu-popover hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  margin: 4px 0;
}

.library-file-list {
  display: grid;
  gap: 7px;
}

.library-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel, #fff);
  color: var(--ink);
  text-align: left;
  box-shadow: none;
}

.library-entry:hover {
  background: var(--panel-3);
  border-color: var(--accent);
}

.library-entry-icon,
.library-entry-count {
  flex: 0 0 auto;
  color: var(--muted);
}

.library-entry-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.library-entry-main strong,
.library-entry-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-entry-main small {
  color: var(--muted);
  font-size: 12px;
}

.library-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.library-overview-card {
  display: grid;
  gap: 6px;
  min-height: 104px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
  text-align: left;
  align-content: start;
}

.library-overview-card:hover {
  border-color: var(--accent);
  background: var(--raised);
}

.library-overview-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.library-overview-meta {
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 650;
}

.library-overview-sub {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.library-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(130px, 170px) minmax(130px, 170px) auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.library-filters input,
.library-filters select {
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--raised);
}

.library-add-forms {
  display: grid;
  gap: 10px;
}

.library-form {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
}

.library-form h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.library-form input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 9px;
  background: var(--raised);
}

.library-tree { display: grid; gap: 8px; }
.library-folder-l2 { margin-left: 16px; }
.library-folder-l3 { margin-left: 16px; }
.library-folder-l4 { margin-left: 16px; }
.library-folder-body { display: grid; gap: 6px; }
.library-folder-body > .library-folder { margin-bottom: 0; }

.library-folder-root > .library-folder-summary { background: var(--panel-2); }

/* Folder summary row: name + optional description + count + control toolbar. */
.library-folder-summary { gap: 8px; flex-wrap: wrap; }
.library-folder-summary h4 { color: var(--ink); text-transform: none; letter-spacing: 0; font-weight: 700; }
.library-folder-desc {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}
.library-folder-empty { margin: 2px 2px 0; font-size: 12px; }

.library-folder-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  flex: 0 0 auto;
  opacity: 0.55;
  transition: opacity .12s;
}
.library-folder-summary:hover .library-folder-controls,
.library-folder-controls:focus-within { opacity: 1; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--raised);
  color: var(--muted);
  cursor: pointer;
}
.icon-button:hover:not(:disabled) { background: var(--panel-2); }
.icon-button:disabled { opacity: 0.35; cursor: default; }
.icon-button.danger { color: var(--bad, #c0392b); }
.icon-button.danger:hover:not(:disabled) { background: rgba(255,59,48,.10); }

.library-folder-move,
.library-leaf-move {
  font-size: 12px;
  padding: 4px 6px;
  max-width: 150px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--raised);
}

.library-leaf {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel, #fff);
}
.library-leaf:hover { background: var(--panel-3); }

.library-leaf-main {
  display: grid;
  gap: 3px;
  flex: 1 1 240px;
  min-width: 0;
}

.library-leaf-titleline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.library-leaf-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-leaf-subline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.library-leaf-meta {
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}

.library-leaf-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex: 0 0 auto;
}

/* Target-folder picker inside each add-document form. */
.library-form-folder {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}
.library-form-folder select {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--raised);
}

.library-modal-section {
  display: grid;
  gap: 9px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.library-modal-section h3 {
  margin: 0;
  font-size: 14px;
}

.library-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.library-taxonomy-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.library-taxonomy-column {
  display: grid;
  align-content: start;
  gap: 5px;
  min-height: 120px;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
}

.library-taxonomy-column > strong {
  font-size: 12px;
  color: var(--muted);
}

.library-taxonomy-option {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  line-height: 1.35;
}

.library-taxonomy-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.library-attachment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.data-source-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
}

/* The summary line of a source card: name + credential badges + test + toggle. */
.data-source-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Read-only usage bar row (commercial providers), shown under the head. */
.data-source-usage-row {
  display: flex;
}

/* Editable configuration inputs for a source (credentials, quota, endpoints). */
.data-source-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.data-source-fields-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

/* Single-column credential / option blocks under a source card head. Each is a
   simple vertical stack (no 2-col grid) so there is never a dead right cell. */
.data-source-credentials, .data-source-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.data-source-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

/* Inside a source card the credential/option fields already sit under a labelled
   section, so drop the per-field box chrome (border/background/padding) — the
   nested double box and the narrow left-aligned 520px column (empty space on the
   right) were the "crammed left, blank right" complaint. The input now uses the
   card width. */
.data-source-credentials .settings-field, .data-source-options .settings-field {
  max-width: 640px;
  border: 0;
  background: transparent;
  padding: 0;
}

.data-source-name {
  flex: 1 1 160px;
  min-width: 160px;
}

.data-source-creds {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.data-source-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.data-source-toggle em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.data-source-toggle-static {
  cursor: default;
}

/* ── Test connection button + inline result ── */
.data-source-test {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.data-source-test-button {
  font-size: 12px;
  padding: 3px 10px;
}

.data-source-test-result {
  font-size: 12px;
  color: var(--muted);
}

/* ── Quota usage progress bar ── */
.data-source-usage {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}

.data-source-usage-label {
  white-space: nowrap;
}

.quota-bar {
  display: block;
  width: 120px;
  height: 6px;
  border-radius: 4px;
  background: var(--panel-2);
  overflow: hidden;
}

.quota-bar-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--good);
  transition: width 0.2s ease;
}

.quota-bar-warn .quota-bar-fill { background: var(--warn); }
.quota-bar-danger .quota-bar-fill { background: var(--bad); }

.settings-field {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
}

.settings-field > span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.settings-field strong {
  font-size: 13px;
}

.settings-field em,
.settings-field small {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.settings-field input,
.settings-field select,
.settings-field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: var(--raised);
  transition: border-color .15s, box-shadow .15s;
}

.settings-field input:focus,
.settings-field select:focus,
.settings-field textarea:focus,
dialog input:focus,
dialog select:focus,
dialog textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94,92,230,.16);
}

.settings-field textarea {
  resize: vertical;
}

/* Compact inline checkbox field: checkbox + label on a single line, sized to its
   content so an on/off toggle (e.g. "Enable China eAIP auto-sync") never spans
   the whole row as an empty full-width box. */
.settings-field.settings-field-bool {
  display: -webkit-inline-flex;
  display: inline-flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  width: -webkit-fit-content;
  width: fit-content;
  max-width: 100%;
}
.settings-field-bool input[type="checkbox"] {
  width: auto;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  margin: 0;
}
.settings-field-bool .settings-field-bool-text {
  display: grid;
  gap: 2px;
}

.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.inline-checkbox input {
  width: auto;
}

.settings-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.settings-actions span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* ── Dialogs ───────────────────────────────────────────── */

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  width: min(440px, calc(100vw - 32px));
  padding: 22px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(8,8,12,.5);
  backdrop-filter: blur(2px);
}

dialog.wide-dialog {
  width: min(1080px, calc(100vw - 32px));
}

.dialog-heading {
  display: grid;
  gap: 4px;
}

.dialog-heading h2 {
  margin: 0;
}

.dialog-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.dialog-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
}

#password-form,
#raw-eaip-upload-form,
#publication-form {
  display: grid;
  gap: 14px;
}

/* ── Upload dialog internals ───────────────────────────── */

.upload-results {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.build-log {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.upload-results h3,
.build-log h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.upload-results p,
.build-log p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.cycle-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
}

.cycle-tab {
  display: grid;
  gap: 2px;
  min-height: 62px;
  text-align: left;
  border-color: var(--line);
  background: var(--panel-3);
}

.cycle-tab strong {
  font-size: 16px;
}

.cycle-tab span {
  color: var(--muted);
  font-size: 12px;
}

.cycle-tab[aria-selected="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.cycle-tab.not_uploaded { border-color: var(--line-strong); }
.cycle-tab.uploaded  { border-color: var(--warn); background: rgba(255,149,0,.12); }
.cycle-tab.built     { border-color: var(--good); background: rgba(52,199,89,.12); }
.cycle-tab.error     { border-color: var(--bad); background: rgba(255,59,48,.10); }

.inline-loading {
  color: var(--muted);
  font-size: 13px;
  padding: 10px 0;
}

.raw-eaip-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 14px;
  align-items: start;
  min-height: 300px;
}

.raw-eaip-required {
  min-height: 260px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.section-heading h3 {
  margin: 0;
  font-size: 14px;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
}

.eaip-cn-sync {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0;
  background: var(--panel-3);
}

.eaip-cn-hint {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 8px;
}

.eaip-cn-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.eaip-cn-auto-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.eaip-cn-auto-toggle em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.eaip-cn-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.eaip-cn-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px 16px;
  margin: 0;
  font-size: 12px;
}

.eaip-cn-meta dt {
  color: var(--muted);
  font-weight: 600;
}

.eaip-cn-meta dd {
  margin: 0;
}

.eaip-cn-result {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.raw-eaip-controls {
  display: grid;
  gap: 12px;
  align-content: start;
}

.required-doc-list {
  display: grid;
  gap: 7px;
  min-height: 140px;
  align-content: start;
}

.uploaded-files-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
}

.uploaded-files-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.uploaded-file-list {
  display: grid;
  gap: 6px;
}

.uploaded-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--raised);
}

.uploaded-file-row div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.uploaded-file-row.unassigned {
  border-color: var(--warn);
  background: rgba(255,149,0,.10);
}

.uploaded-file-row .uploaded-file-actions {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  min-width: 0;
}

.uploaded-file-row .reassign-controls {
  display: -webkit-flex;
  display: flex;
  gap: 6px;
  align-items: center;
}

.reassign-slot-select {
  min-width: 150px;
  font-size: 12px;
  padding: 4px 6px;
}

.required-doc-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.2fr) repeat(3, minmax(150px, 1fr));
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
}

.required-doc-row.warning {
  border-color: var(--bad);
  background: rgba(255,59,48,.08);
}

.required-doc-row.covered {
  border-color: rgba(52, 199, 89, 0.4);
  background: rgba(52,199,89,.10);
}

.required-doc-row > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.required-doc-row strong,
.required-doc-row span,
.required-doc-row small,
.uploaded-file-row strong,
.uploaded-file-row span,
.unmatched-files span {
  overflow-wrap: anywhere;
}

.required-doc-row span,
.required-doc-row small {
  color: var(--muted);
  font-size: 12px;
}

.required-doc-row strong { font-size: 13px; }
.uploaded-file-row strong { font-size: 13px; }
.uploaded-file-row span { color: var(--muted); font-size: 12px; }

.inline-delete-button {
  justify-self: start;
  margin-top: 4px;
}

/* ── Build history accordion ───────────────────────────────── */

.build-history-heading {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.build-history-list {
  display: grid;
  gap: 6px;
}

.build-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.build-item-header {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  gap: 8px;
  padding: 0;
  background: var(--panel-3);
}

.build-item-header.succeeded { background: rgba(52,199,89,.10); border-bottom-color: rgba(52,199,89,.25); }
.build-item-header.failed    { background: rgba(255,59,48,.08); }
.build-item-header.running   { background: rgba(94,92,230,.08); }
.build-item-header.published { background: rgba(94,92,230,.08); }
.build-item-header.verified  { background: rgba(52,199,89,.10); }
.build-item-header.revoked   { background: var(--panel-3); opacity: .75; }

.build-item-toggle {
  -webkit-flex: 1;
  flex: 1;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}

.build-item-toggle:hover { background: rgba(0,0,0,.04); }

.build-item-chevron {
  display: inline-block;
  font-size: 10px;
  color: var(--muted);
  transition: transform .15s;
  flex-shrink: 0;
}

.build-item-toggle[aria-expanded="true"] .build-item-chevron {
  transform: rotate(90deg);
}

.build-item-time {
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
}

.build-item-release-id {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.build-item-actions {
  display: -webkit-flex;
  display: flex;
  gap: 6px;
  padding: 6px 10px 6px 0;
  flex-shrink: 0;
}

.build-item-body {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
}

.build-sections-label {
  margin: 10px 0 6px;
  font-size: 13px;
  color: var(--muted);
}

/* ── Build steps ────────────────────────────────────────── */

.build-step-list {
  display: grid;
  gap: 6px;
  margin: 8px 0;
  padding: 0;
  list-style: none;
}

.build-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
}

.build-step.failed,
.build-step.partial_success {
  border-color: rgba(255, 59, 48, 0.4);
  background: rgba(255,59,48,.08);
}

.build-step.succeeded {
  border-color: rgba(52, 199, 89, 0.4);
  background: rgba(52,199,89,.10);
}

.build-step div { display: grid; gap: 2px; min-width: 0; }
.build-step strong, .build-step small { overflow-wrap: anywhere; }
.build-step small { color: var(--muted); font-size: 12px; }

.inline-warning { color: var(--bad) !important; }

.unmatched-files,
.duplicate-preflight {
  display: grid;
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--bad);
  border-radius: 7px;
  background: rgba(255,59,48,.08);
  color: var(--bad);
  font-size: 13px;
}

.upload-progress {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.upload-progress progress {
  width: 100%;
  height: 12px;
}

/* ── File-slot select ──────────────────────────────────── */

.file-slot-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  background: var(--raised);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

.file-slot-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.muted-text {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

/* ── Dialog scroll fix ─────────────────────────────────── */

/* Plain block + max-height scroll. The earlier flex-column/flex:1 layout made
   Safari ignore the min-heights on the nested workbench grid, collapsing the
   panel to near-zero; a block dialog with overflow-y:auto scrolls identically
   in all browsers and lets those min-heights apply normally. */
dialog.wide-dialog {
  max-height: 90vh;
  overflow-y: auto;
}

dialog.wide-dialog form {
  display: grid;
  gap: 14px;
}

/* ── Responsive ────────────────────────────────────────── */

/* Medium screens: stack workbench before full 900px breakpoint */
@media (max-width: 680px) {
  .raw-eaip-workbench { grid-template-columns: 1fr; }
  .required-doc-row { grid-template-columns: 1fr; }
}

@media (max-width: 1600px) {
  .library-workbench {
    grid-template-columns: minmax(210px, 260px) minmax(0, 1fr);
  }
  .library-ingest-panel {
    position: static;
    max-height: none;
    grid-column: 1 / -1;
  }
  .library-add-forms {
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    align-items: start;
  }
}

/* ── Manual upload help block ──────────────────────────── */

.upload-help {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
  padding: 0 12px;
  font-size: 13px;
  color: var(--ink);
}

.upload-help > summary {
  cursor: pointer;
  padding: 10px 0;
  font-weight: 600;
  color: var(--info);
  list-style: revert;
}

.upload-help-body {
  padding: 0 0 12px;
  display: grid;
  gap: 6px;
}

.upload-help-body p { margin: 4px 0 0; }

.upload-help-body ul {
  margin: 2px 0 6px;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}

.upload-help-body code {
  background: rgba(94,92,230,.12);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* ── Build failure block ───────────────────────────────── */

.build-failure {
  display: grid;
  gap: 6px;
  border: 1px solid var(--bad);
  border-radius: 8px;
  background: rgba(255,59,48,.08);
  padding: 11px 13px;
  margin-bottom: 12px;
  color: var(--bad);
}

.build-failure > strong { font-size: 14px; }

.build-failure-detail {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.build-failure > small { color: var(--muted); }

/* Failed section rows in the build sections table */
.section-failed > td { background: rgba(255,59,48,.08); color: var(--bad); }

/* Narrow screens: collapse the fixed sidebar into a stacked top region so the
   nav becomes a horizontally scrollable strip above the content. */
@media (max-width: 900px) {
  .app-shell { -webkit-flex-direction: column; flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    -webkit-flex-direction: row;
    flex-direction: row;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-align-items: center;
    align-items: center;
    box-shadow: 0 1px 6px rgba(0,0,0,.25);
  }
  .sidebar-brand { border-bottom: none; padding: 10px 12px; }
  .side-nav {
    -webkit-order: 3;
    order: 3;
    width: 100%;
    -webkit-flex-direction: row;
    flex-direction: row;
    /* Wrap tabs (full-width stacked header here) rather than scroll, so no tab
       is hidden behind an overflow scrollbar at narrow/zoomed viewports. */
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    padding: 6px 8px;
  }
  .side-nav button {
    border-left: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
  }
  .side-nav button[aria-selected="true"] {
    background: transparent;
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }
  .sidebar-footer {
    -webkit-flex-direction: row;
    flex-direction: row;
    border-top: none;
    padding: 8px 12px;
    margin-left: auto;
    -webkit-align-items: center;
    align-items: center;
  }
  .status-grid, .content-grid { grid-template-columns: 1fr; }
  .cycle-tabs { grid-template-columns: 1fr; }
  .raw-eaip-workbench { grid-template-columns: 1fr; }
  .required-doc-row { grid-template-columns: 1fr; }
  .uploaded-file-row { grid-template-columns: 1fr; }
  .settings-field-grid { grid-template-columns: 1fr; }
  .settings-actions { display: grid; justify-items: start; }
  .library-workbench { grid-template-columns: 1fr; }
  .library-index-panel {
    position: static;
    max-height: none;
  }
  .library-add-forms { grid-template-columns: 1fr; }
  .library-filters { grid-template-columns: 1fr 1fr; }
  .library-filters input[type="search"] { grid-column: 1 / -1; }
  .library-taxonomy-picker,
  .library-modal-grid { grid-template-columns: 1fr; }
  .library-leaf-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 520px) {
  .library-stats,
  .library-filters,
  .library-overview-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Toasts ────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(16, 24, 32, 0.18);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
}

.toast.toast-show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { border-color: rgba(52, 199, 89, 0.5); background: rgba(52,199,89,.12); color: var(--good); }
.toast-error { border-color: rgba(255, 59, 48, 0.5); background: rgba(255,59,48,.12); color: var(--bad); }

/* ── Country detail page (P2) ──────────────────────────── */

.country-detail-header {
  display: grid;
  gap: 10px;
}

.link-back {
  justify-self: start;
  border: none;
  background: transparent;
  color: var(--info);
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
}

.link-back:hover { text-decoration: underline; }

#country-detail-title h2 {
  font-size: 22px;
  margin: 0 0 4px;
}

.country-detail-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* eAIP CN auto-sync as a persistent detail-page card (overrides the old inline
   boxed look from the dialog era). */
.eaip-cn-sync-card .eaip-cn-hint { margin: 4px 0 10px; }

.detail-build-control {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
}

.detail-build-cycle {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.detail-build-cycle select {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 9px;
  background: var(--raised);
  min-width: 200px;
}

.detail-build-control small {
  color: var(--muted);
  font-size: 12px;
  -webkit-flex-basis: 100%;
  flex-basis: 100%;
}

.data-acquisition {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.acquisition-option {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
  padding: 12px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.acquisition-option h4 {
  margin: 0;
  font-size: 14px;
}

.acquisition-option p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.acquisition-option button { justify-self: start; }

/* ── Account tab ───────────────────────────────────────── */

.account-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-3);
  padding: 12px;
  margin-bottom: 12px;
  display: grid;
  gap: 6px;
}

.account-card .account-meta {
  color: var(--muted);
  font-size: 13px;
}

.audit-controls {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 10px;
}

.audit-controls label {
  display: grid;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}

.audit-controls select,
.audit-controls input {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  background: var(--raised);
  min-width: 120px;
}

.audit-pager {
  display: -webkit-flex;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* ═══════════════════════════════════════════════════════════
   Aircraft library section — rich cards, thumbnails, chips
   ═══════════════════════════════════════════════════════════ */

#tab-aircraft .content-grid { gap: 18px; }

/* code/inline tokens used across the aircraft renders */
.ac-mfr code, .ac-series code, .ac-model code, .ac-row code, code.ac-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-ink);
  background: rgba(94,92,230,.10);
  border: 1px solid rgba(94,92,230,.20);
  border-radius: 6px;
  padding: 1px 6px;
  letter-spacing: .02em;
}

.muted { color: var(--muted); font-size: 12px; }

/* Manufacturer group card */
.ac-mfr {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 14px;
}

.ac-mfr-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

.ac-avatar {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 3px 8px rgba(94,92,230,.3);
  overflow: hidden;
}
.ac-avatar img { width: 100%; height: 100%; object-fit: contain; }

.ac-mfr-titles { flex: 1; min-width: 0; }
.ac-mfr-title { font-size: 16px; font-weight: 700; letter-spacing: -0.005em; }
.ac-mfr-sub { color: var(--muted); font-size: 12px; margin-top: 1px; }

.ac-mfr-body { padding: 6px 12px 12px; }

/* Series block */
.ac-series { padding: 8px 2px 2px; }
.ac-series-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 6px;
}
.ac-series-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.ac-series-line { flex: 1; height: 1px; background: var(--line); }

/* Model card */
.ac-model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }

.ac-model-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.ac-model-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.ac-thumb {
  width: 84px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 8px;
  object-fit: cover;
  background:
    repeating-linear-gradient(135deg, var(--panel-2) 0 10px, var(--panel-3) 10px 20px);
  border: 1px solid var(--line);
}
.ac-thumb-placeholder {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 22px;
  background: linear-gradient(135deg, rgba(15,181,166,.12), rgba(94,92,230,.08));
}

.ac-model-main { flex: 1; min-width: 0; }
.ac-model-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.ac-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.ac-chip {
  font-size: 11px;
  color: var(--ink-2, var(--ink));
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.ac-chip.ac-chip-accent { color: var(--accent-ink); background: rgba(94,92,230,.10); border-color: rgba(94,92,230,.22); }

.ac-model-actions { display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }
.ac-model-actions button, .ac-mfr-head .row-actions button, .ac-series-head .row-actions button { padding: 5px 9px; font-size: 12px; }

/* Generic flat row used by airlines / submissions / model-detail checklist rows */
.ac-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  margin-bottom: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.ac-row:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.ac-row:last-child { margin-bottom: 0; }
.ac-row > span:first-child { min-width: 0; overflow-wrap: anywhere; font-size: 14px; }

/* Airline tile */
.ac-airline {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  margin-bottom: 8px;
}
.ac-airline-badge {
  width: 30px; height: 30px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--nav); color: #d7d6ec;
  font-weight: 700; font-size: 12px;
}
.ac-airline-main { flex: 1; min-width: 0; }
.ac-airline-name { font-size: 14px; font-weight: 600; }
.ac-airline-sub { font-size: 12px; color: var(--muted); }

/* The whole airline item selects its detail in the right pane. */
.ac-airline {
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ac-airline:hover { border-color: rgba(94, 92, 230, .4); }
.ac-airline.active {
  border-color: rgba(94, 92, 230, .5);
  background: linear-gradient(90deg, rgba(94, 92, 230, .14), rgba(15, 181, 166, .08));
}
/* Inner action buttons should not inherit the item-select cursor/affordance. */
.ac-airline .row-actions { cursor: auto; }

/* Empty-state polish */
.empty-state-glyph { font-size: 30px; }

/* Back link (aircraft detail) */
.link-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent-ink);
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  margin-bottom: 14px;
}
.link-button:hover { color: var(--accent-ink); }

@media (max-width: 720px) {
  .ac-model-grid { grid-template-columns: 1fr; }
  .ac-country-browser { grid-template-columns: 1fr; }
}

/* Aircraft structured spec editor (replaces the raw-JSON textarea) */
.ac-specrows-field { display: flex; flex-direction: column; gap: 6px; }
.ac-specrows { display: flex; flex-direction: column; gap: 6px; }
.ac-specrow { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; align-items: center; }
.ac-specrow input { width: 100%; }
.ac-specrow-del {
  width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
}
.ac-specrow-del:hover { background: rgba(255, 59, 48, 0.12); color: var(--bad); border-color: rgba(255, 59, 48, 0.4); }
.ac-specrow-add { align-self: flex-start; padding: 4px 2px; }

/* Aircraft admin v2: scalable catalog and airline fleet workbench */
.aircraft-status-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.aircraft-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(4, minmax(140px, auto)) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.aircraft-filters input,
.aircraft-filters select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 9px;
  background: var(--raised);
}

.ac-mfr > summary,
.ac-series > summary,
.ac-fleet-mfr > summary,
.ac-fleet-series > summary,
.ac-fleet-model > summary {
  cursor: pointer;
  list-style: none;
}

.ac-mfr > summary::-webkit-details-marker,
.ac-series > summary::-webkit-details-marker,
.ac-fleet-mfr > summary::-webkit-details-marker,
.ac-fleet-series > summary::-webkit-details-marker,
.ac-fleet-model > summary::-webkit-details-marker {
  display: none;
}

.ac-mfr-head::before,
.ac-series-head::before,
.ac-fleet-mfr > summary::before,
.ac-fleet-series > summary::before,
.ac-fleet-model > summary::before {
  content: "›";
  color: var(--muted);
  font-weight: 800;
  transition: transform .15s;
}

.ac-mfr[open] > .ac-mfr-head::before,
.ac-series[open] > .ac-series-head::before,
.ac-fleet-mfr[open] > summary::before,
.ac-fleet-series[open] > summary::before,
.ac-fleet-model[open] > summary::before {
  transform: rotate(90deg);
}

.ac-series-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.ac-model-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

.ac-model-table th,
.ac-model-table td,
.ac-tail-table th,
.ac-tail-table td {
  vertical-align: middle;
}

.ac-model-table td:first-child,
.ac-tail-table td:first-child {
  width: 74px;
}

.ac-title-button {
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  box-shadow: none;
  text-align: left;
  font-weight: 700;
}

.ac-title-button:hover {
  color: var(--accent-ink);
  box-shadow: none;
  text-decoration: underline;
}

.ac-chip-warn {
  color: var(--warn);
  background: rgba(255,149,0,.12);
  border-color: rgba(255,149,0,.28);
}

.ac-country-browser {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.ac-country-list {
  display: grid;
  gap: 6px;
  align-content: start;
}

.ac-country-list-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  padding: 0 2px 4px;
}

.ac-country-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--raised);
  color: var(--ink);
  padding: 9px 10px;
}

.ac-country-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.ac-country-item strong {
  color: var(--accent-ink);
  font-size: 13px;
}

.ac-country-item small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}

.ac-country-item.active {
  border-color: rgba(94, 92, 230, .45);
  background: linear-gradient(90deg, rgba(94, 92, 230, .14), rgba(15, 181, 166, .08));
}

.ac-country-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.ac-country-main-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.ac-country-main-head h3 {
  margin: 0 0 2px;
  font-size: 18px;
}

.ac-card-list {
  display: grid;
  gap: 10px;
}

.ac-select-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
  padding: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.ac-select-card:hover {
  border-color: rgba(94, 92, 230, .45);
  background: linear-gradient(90deg, rgba(94, 92, 230, .10), rgba(15, 181, 166, .06));
  box-shadow: var(--shadow-sm);
}

.ac-select-card .row-actions {
  cursor: auto;
}

.ac-load-more {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

.ac-series-more {
  padding: 8px 10px 2px;
}

.ac-airline-list {
  display: grid;
  gap: 8px;
}

.ac-airline-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 2px;
}

.ac-detail-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.ac-detail-hero h3 {
  margin: 0 0 4px;
  font-size: 20px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--ink);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
}

.button-link:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}

.ac-description {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
}

.ac-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.ac-info-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
  padding: 9px 10px;
  min-width: 0;
}

.ac-info-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.ac-info-item strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.ac-source-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.ac-source-list a {
  color: var(--accent-ink);
  overflow-wrap: anywhere;
}

.ac-fleet-tree {
  display: grid;
  gap: 10px;
}

.ac-fleet-mfr,
.ac-fleet-series,
.ac-fleet-model {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
  overflow: hidden;
}

.ac-fleet-mfr > summary,
.ac-fleet-series > summary,
.ac-fleet-model > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.ac-fleet-series,
.ac-fleet-model {
  margin: 8px 10px;
  background: var(--panel);
}

.ac-fleet-model > summary {
  grid-template-columns: auto auto 1fr auto auto;
}

.ac-tail-table {
  min-width: 560px;
}

.ac-tail-table .ac-thumb {
  width: 58px;
  height: 38px;
}

@media (max-width: 980px) {
  .aircraft-filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .aircraft-filters { grid-template-columns: 1fr; }
  .ac-detail-hero { align-items: flex-start; flex-direction: column; }
  .ac-mfr-head, .ac-series-head, .ac-airline { align-items: flex-start; }
  .ac-select-card { grid-template-columns: auto minmax(0, 1fr); }
  .ac-select-card .row-actions { grid-column: 1 / -1; }
}

/* ═══════════════════════════════════════════════════════════
   Dark mode — efb dark surfaces/text/accents.
   Most rules read var(--x) or rgba()-of-status, so overriding the
   tokens here cascades automatically. A few rules whose values are
   intrinsically light (rgba-over-white overlays, the body gradient,
   the all-white toast) are re-stated below for coherence.
   ═══════════════════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --ink: #f5f5f7;
    --muted: #9a9aa2;
    --panel: #1b1d22;
    --panel-2: #25282f;
    --panel-3: #20232a;
    --raised: #25282f;
    --line: #34373f;
    --line-strong: #43464f;
    --border: #34373f;
    /* Sidebar nudged a touch darker than the panels so it still reads
       as a distinct, brand-tinted dark rail. */
    --nav: #131220;
    --nav-2: #1a1827;
    /* Brighter accents for contrast on dark surfaces. */
    --accent: #7b79f5;
    --accent-2: #30d5c8;
    --accent-ink: #a6a4ff;
    --good: #30d158;
    --warn: #ffa01a;
    --bad: #ff453a;
    --info: #7b79f5;
    /* Deeper shadows read better on dark. */
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 6px 18px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.35);
    --shadow-lg: 0 20px 44px rgba(0,0,0,.6);
  }

  /* Body radial-gradient was authored as light tints; re-state for dark. */
  body {
    background:
      radial-gradient(1200px 600px at 88% -8%, rgba(48,213,200,.10) 0%, rgba(48,213,200,0) 55%),
      radial-gradient(900px 500px at 0% 0%, rgba(123,121,245,.12) 0%, rgba(123,121,245,0) 50%),
      var(--bg);
  }

  /* The sidebar/login chrome already reads light-on-dark; only the bottom
     gradient stop needs to track the darker nav tokens. */
  .sidebar {
    background: linear-gradient(180deg, var(--nav-2) 0%, var(--nav) 60%, #0d0c16 100%);
  }

  /* Toast surface is an opaque panel (not a status tint) — keep it on the
     dark panel rather than near-white. */
  .toast { background: var(--panel); }

  /* Code/inline tokens: the hardcoded light fallback in var(--panel, #fff)
     would flash white in dark, so pin the leaf surface to a token. */
  .library-leaf { background: var(--panel); }

  /* The shimmer overlay was authored as a near-white sweep for light surfaces;
     soften it on dark so it reads as a subtle highlight, not a harsh flash. */
  .skeleton::after {
    background: linear-gradient(
      90deg,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 0.08) 50%,
      rgba(255, 255, 255, 0) 100%
    );
  }
}

/* ═══════════════════════════════════════════════════════════
   Users section — app users + organizations management
   ═══════════════════════════════════════════════════════════ */

.users-filters {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.users-filters input,
.users-filters select {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  background: var(--raised);
  min-width: 140px;
}

.users-filters input[type="search"] { -webkit-flex: 1 1 200px; flex: 1 1 200px; }

/* Inline checkbox field (Active toggle) inside the user/org dialogs. */
.settings-field.settings-field-inline {
  -webkit-flex-direction: row;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.settings-field.settings-field-inline > span { -webkit-flex: 1; flex: 1; }
.settings-field.settings-field-inline input[type="checkbox"] { width: auto; }

/* One-time temp-password reveal row. */
.temp-password-row {
  display: -webkit-flex;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.temp-password-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-ink);
  background: rgba(94, 92, 230, .10);
  border: 1px solid rgba(94, 92, 230, .20);
  border-radius: 7px;
  padding: 6px 10px;
  -webkit-flex: 1;
  flex: 1;
  word-break: break-all;
}

/* ── Installers tab (all-platform client download management) ─────────── */
.installer-platform-grid {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  gap: 14px;
}
.installer-platform-card {
  border: 1px solid var(--line, rgba(120, 120, 140, .22));
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--surface-muted, rgba(120, 120, 140, .04));
}
.installer-platform-head {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: baseline;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.installer-platform-head strong { font-size: 16px; }
.installer-platform-fields {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  gap: 10px;
}
.installer-toggles {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 14px;
}
.installer-toggle {
  display: -webkit-inline-flex;
  display: inline-flex;
  -webkit-align-items: center;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
.installer-toggle input { width: auto; }
.installer-platform-stats { margin-top: 10px; font-size: 13px; }
.installer-platform-packages { margin-top: 14px; }
.installer-platform-packages h4 { margin: 0 0 8px; font-size: 14px; }
.installer-packages-table, .installer-builds-table { width: 100%; }
.installer-pkg-actions, .installer-build-platforms {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 6px;
}
