/* ChemTrust dashboard shell — the eudr-x shell (sidebar.css + the shell
 * parts of style.css / operator-react.css) ported verbatim to ct-* classes.
 * Geometry, clamps, z-indices and transition timings are kept 1:1 with the
 * eudr-x source.
 *
 * Colour: the sidebar, top bar and footer are SOLID Storm Green in both
 * themes and take every colour from the --chrome-* tokens (tokens.css);
 * dark.css never flips them, so this file needs no theme blocks for the
 * chrome. Cyan (--chrome-active-ink) marks where you are. Icons use the
 * OPAQUE --chrome-dim rather than an opacity, so crossing strokes never
 * double up. Menus that open from the bar are solid content surfaces
 * (--surface-raised) and flip with the theme through their tokens.
 *
 * OWNED BY WP1. Later packages add their OWN files (states.css, topbar.css,
 * dashboard.css, …) — nobody else edits this one.
 *
 * z-index ladder (keep — spec-shell §15.11):
 *   topbar 40 · sidebar 50 · toggle tab 51 · global-search menu 60 ·
 *   user dropdown 200 · notification panel 2000 · lang menu 9999
 */

/* ═══════════════════════════════════════════════════════════════
   GROUND: the brand gradient, painted on a FIXED layer behind everything
   (EUDR phone-kit.css:1681-1689). iOS ignores `background-attachment:
   fixed`, so a position:fixed pseudo-element is the one way to keep the
   gradient still while content scrolls, on every device. The body itself
   paints nothing; <html> carries the base colour for overscroll (tokens.css,
   dark.css). Public pages (login, portal) get the same ground.
   ═══════════════════════════════════════════════════════════════ */
body.ct-shell-active,
body[data-public-page] {
  background: transparent;
}
body.ct-shell-active::before,
body[data-public-page]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--ground-art);
}
/* The ground layer only shows if nothing above it paints. app.css gives the
   portal's .ct-main an opaque var(--bg) (the shell's own .ct-main is cleared
   further down), which hid the gradient on the supplier portal. */
body[data-public-page] .ct-main {
  background: transparent;
}

/* Focus rings inside the chrome: the global --focus is the darker cyan tuned
   for white; on Storm the full cyan reads far better (10.7:1). */
.ct-sidebar :focus-visible,
.ct-sidebar-toggle:focus-visible,
.ct-topbar :focus-visible,
.ct-header :focus-visible,
.ct-bottom-footer :focus-visible {
  outline-color: var(--chrome-active-ink);
}

/* ── Dashboard shell — horizontal layout (sidebar.css:22-50) ── */
.ct-shell {
  /* dvh tracks the visual viewport on iOS so the shell shrinks when the
     Safari URL bar slides in — no more white strip at the bottom. Fall
     back to vh on browsers that don't support dvh yet. */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
}

/* ── Right column: topbar + main + footer ── */
.ct-right {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ═══════════════════ SIDEBAR (sidebar.css:52-288) ═══════════════════ */
.ct-shell .ct-sidebar {
  width: var(--sidebar-width);
  background: var(--chrome-bg);
  display: flex;
  flex-direction: column;
  /* The shell already owns the dvh height and this is one of its flex items —
     re-asserting `height/min-height: 100vh` here made the sidebar taller than
     its own parent on mobile (vh ignores the URL bar) and gave the aside a
     SECOND scrollbar nested inside the nav's own. One height, one scroll host:
     the aside clips, .ct-sidebar-sections below scrolls. */
  height: 100%;
  min-height: 0;
  overflow: hidden;
  transition: width 0.25s ease;
  z-index: 50;
  flex-shrink: 0;
}
.ct-shell .ct-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

/* Collapsed state: hide labels/badges/brand text/section text/logout text.
   eudr-x removes them from the DOM (React); the vanilla port hides them —
   `white-space: nowrap; overflow: hidden` below prevents wrap-flash during
   the width transition (spec-shell §1). */
.ct-sidebar.collapsed .ct-sidebar-label,
.ct-sidebar.collapsed .ct-sidebar-badge,
.ct-sidebar.collapsed .ct-sidebar-brand-text,
.ct-sidebar.collapsed .ct-sidebar-section-text,
.ct-sidebar.collapsed .ct-sidebar-logout span {
  display: none;
}

/* Sidebar brand */
.ct-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 52px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--chrome-line);
  transition: justify-content 0.25s ease;
}
.ct-sidebar.collapsed .ct-sidebar-brand {
  justify-content: center;
  padding: 0;
}
.ct-sidebar-logo-link {
  display: inline-flex;
  perspective: 800px; /* the Y-spin below reads as 3-D (house rule) */
  flex-shrink: 0;
}
.ct-sidebar-logo {
  /* Was 64px inside a 60px row — the logo was taller than the row that holds
     it, so it overflowed the brand into the nav below and ate a third of a
     200px sidebar. 38px reads as a brand mark rather than a banner, keeps the
     Y-spin, and leaves room for "ChemTrust · Ops" on ONE line. */
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
  /* One Y-spin shortly after the page appears, and again on hover or
     keyboard focus of the link (EUDR sidebar.css:90-117). It used to repeat
     every 20 s forever, which kept the page from ever being idle: every frame
     re-composited the whole dashboard. No spin under reduced motion or in the
     lite tier (lite.css). */
  animation: ctSidebarLogoSpinY 0.9s linear 1s 1;
  transform-origin: center;
  transform-style: preserve-3d;
  backface-visibility: visible;
  transition: width 0.25s ease, height 0.25s ease;
}
.ct-sidebar-logo-link:hover .ct-sidebar-logo,
.ct-sidebar-logo-link:focus-visible .ct-sidebar-logo {
  /* A second keyframe name restarts the spin on every hover. */
  animation: ctSidebarLogoSpinYAgain 0.9s linear 1;
}
@media (prefers-reduced-motion: reduce) {
  .ct-sidebar-logo,
  .ct-sidebar-logo-link:hover .ct-sidebar-logo,
  .ct-sidebar-logo-link:focus-visible .ct-sidebar-logo {
    animation: none;
  }
}
.ct-sidebar.collapsed .ct-sidebar-logo {
  width: 30px;
  height: 30px;
}
.ct-sidebar-brand-text {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--chrome-ink);
  /* At the old 64px the logo left ~165px here and "ChemTrust · Ops" had to wrap
     to two lines to avoid being hard-clipped to "ChemTrust ·" (an ops console
     that named itself wrong). The 38px mark leaves enough room for it to sit on
     one line; the wrap allowance stays as the fallback for a longer suffix,
     since truncating the product name is not an option. */
  letter-spacing: 0.5px;
  /* Deliberately NOT uppercased: the product is written "ChemTrust", and
     `text-transform: uppercase` rendered the one place the name is always on
     screen as "CHEMTRUST". A brand's casing is part of its spelling. */
  line-height: 1.15;
  min-width: 0;
  overflow: hidden;
}

/* The spin and its hover twin (keyframe names are global: pages.css has its
   own pair for the portal's brand). */
@keyframes ctSidebarLogoSpinY {
  from {
    transform: rotateY(0deg);
  }
  to {
    transform: rotateY(360deg);
  }
}
@keyframes ctSidebarLogoSpinYAgain {
  from {
    transform: rotateY(0deg);
  }
  to {
    transform: rotateY(360deg);
  }
}

/* Nav sections wrapper — grows to fill sidebar, pushes logout to bottom.
   Deliberately BLOCK, not a flex column: as a flex column it shrank its own
   children whenever the nav was taller than the sidebar, so on any laptop-height
   window (≤~700px) every section label was squeezed 36px → 24px and the bottom
   half of its glyphs was sliced off, and the last item ("Submissions") was cut
   through the middle. Flex was crushing the nav instead of scrolling it. Block
   layout cannot crush a child, so the nav keeps its true height and this one
   element scrolls if it genuinely has to. */
.ct-sidebar-sections {
  flex: 1 1 auto;
  min-height: 0;
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  /* Don't chain the wheel to the page once the nav hits its end. */
  overscroll-behavior: contain;
  /* Reserve the gutter so appearing/disappearing scrollbars never shift labels. */
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--storm-lift-3) transparent;
}
/* The default Chrome scrollbar is a light-grey slab with arrow buttons — on the
   Storm sidebar it read as a bright vertical stripe down the middle of the
   nav. Thin, a lifted Storm, no buttons. */
.ct-sidebar-sections::-webkit-scrollbar {
  width: 6px;
}
.ct-sidebar-sections::-webkit-scrollbar-track {
  background: transparent;
}
.ct-sidebar-sections::-webkit-scrollbar-thumb {
  background: var(--storm-lift-3);
  border-radius: 3px;
}
.ct-sidebar-sections::-webkit-scrollbar-thumb:hover {
  background: var(--chrome-dim);
}
.ct-sidebar-sections::-webkit-scrollbar-button {
  display: none;
}

/* Section label (the div keeps its padding when collapsed — rhythm).
   line-height is explicit so the row's height is arithmetic, not whatever the
   font's default leading happens to be, and the label truncates rather than
   clipping mid-glyph if a translation runs long. */
.ct-sidebar-section {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--chrome-sec);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 13px 16px 5px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ct-sidebar-section:first-of-type {
  padding-top: 10px;
}

/* Navigation items */
.ct-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}
/* Role gates (core/session.js) hide sidebar entries a role cannot open with
   the hidden attribute; the display rules here would otherwise override it. */
.ct-sidebar-sections [hidden] {
  display: none !important;
}
.ct-sidebar-nav--grow {
  flex: 1;
}
/* The ungrouped first item (Dashboard) has no section label above it, so it
   needs the label's top breathing room itself. */
.ct-sidebar-nav--root {
  padding-top: 8px;
}

.ct-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  border-radius: 0;
  border: none;
  background: none;
  color: var(--chrome-sec);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-align: left;
  width: 100%;
  text-decoration: none;
}
.ct-sidebar-item:hover {
  background: var(--chrome-hover);
  color: var(--chrome-ink);
}
/* Active-state trick (eudr-x sidebar.css:619): no border — the marker
   colour (cyan) becomes the TEXT colour on the cyan-washed active background.
   Items are full-width, zero-radius, edge-to-edge. */
.ct-sidebar-item.active {
  background: var(--chrome-active);
  color: var(--chrome-active-ink);
  font-weight: 600;
  /* "Where am I" is the one question a sidebar must answer at a glance. Tone
     alone did that weakly; the 2px rail is unmistakable. inset box-shadow, not
     a border, so the item's box never shifts by 2px when it becomes active. */
  box-shadow: inset 2px 0 0 var(--chrome-active-ink);
}
/* Icons take their own OPAQUE dim colour instead of `opacity: 0.7` on the
   translucent label colour: translucent strokes double up where icon lines
   cross. They brighten with the row on hover and turn cyan when active. */
.ct-sidebar-item .ct-sidebar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--chrome-dim);
  transition: color 0.15s ease;
}
.ct-sidebar-icon svg {
  width: 20px;
  height: 20px;
}
.ct-sidebar-item:hover .ct-sidebar-icon {
  color: var(--chrome-ink);
}
.ct-sidebar-item.active .ct-sidebar-icon {
  color: var(--chrome-active-ink);
}
.ct-sidebar-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Count badge: a cyan fill with Storm ink (10.7:1). The chrome is Storm in
   both themes, so the badge must not flip; the status tokens do flip (dark.css
   turns them into light text tones), which would leave white-on-pastel. */
.ct-sidebar-badge {
  margin-left: auto;
  background: var(--highlight);
  color: var(--highlight-ink);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
  line-height: 1.4;
}

/* Step indicator (numbered circle for wizard steps) */
.ct-sidebar-step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--chrome-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
/* Storm ink on the cyan disc: white on cyan is only 1.44:1. */
.ct-sidebar-item.active .ct-sidebar-step-num {
  border-color: var(--chrome-active-ink);
  background: var(--chrome-active-ink);
  color: var(--chrome-bg);
}
.ct-sidebar-item.completed .ct-sidebar-step-num {
  border-color: var(--chrome-active-ink);
  color: var(--chrome-active-ink);
}

/* Sidebar bottom (logout) — pinned at bottom via sidebar flex column */
.ct-sidebar-bottom {
  flex-shrink: 0;
  /* No inline padding here: it inset the logout row by 8px on top of its own
     12px, so the logout icon sat 4px right of every nav icon above it. The row
     owns its 16px inset like the nav items do, and the rule separates the
     destructive action from navigation. */
  padding: 6px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid var(--chrome-line);
}
.ct-sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 0;
  border: none;
  background: none;
  color: var(--chrome-sec);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
  width: 100%;
  text-align: left;
}
/* Match the 20px nav-icon box so the logout label lines up with every nav
   label above it instead of sitting 2px short. */
.ct-sidebar-logout svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--chrome-dim);
}
/* Red on hover marks the one action that leaves. The chrome is Storm in both
   themes but --confirmed flips (deep red in light, salmon in dark), and deep
   red on Storm is only ~2.4:1, so the hover tone is lifted toward the chrome
   ink: ≥5:1 on Storm in either theme. */
.ct-sidebar-logout:hover {
  background: color-mix(in srgb, var(--confirmed) 16%, transparent);
  color: color-mix(in srgb, var(--confirmed) 60%, var(--chrome-ink));
}
.ct-sidebar-logout:hover svg {
  color: inherit;
}

/* Edge toggle — 3D tab hugging the sidebar's outer edge. `left` is driven
   inline by core/shell.js: calc(var(--sidebar-width) - 1px) expanded,
   calc(var(--sidebar-collapsed-width) - 1px) collapsed. */
.ct-sidebar-toggle {
  position: fixed;
  /* Vertically centred rather than pinned at 80px, where it landed exactly on
     the page-title row and butted against the first character of every heading
     and page description. Mid-height it never collides with content, and it is
     where a collapse handle is conventionally looked for. */
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 48px;
  background: var(--chrome-bg);
  color: var(--chrome-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 51;
  padding: 0;
  border-radius: 0 6px 6px 0;
  border: 1px solid var(--chrome-line);
  border-left: none;
  box-shadow: 2px 0 6px rgb(var(--storm-rgb) / 0.25);
  transition: left 0.25s ease, color 0.15s ease, background 0.15s ease;
}
/* The tab floats over the page, not over the sidebar, so its hover must be
   OPAQUE: the translucent --chrome-hover would let the ground show through
   and turn the tab pale in light mode. */
.ct-sidebar-toggle:hover {
  background: var(--chrome-bg-2);
  color: var(--chrome-ink);
}

/* ═══════════════════ TOPBAR (sidebar.css:290-373) ═══════════════════ */
.ct-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: var(--chrome-bg);
  flex-shrink: 0;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 40;
}
/* Small/medium laptops: tighter topbar so the dashboard content gets more
   vertical room. Mobile (≤768) is handled separately in mobile.css. */
@media (min-width: 769px) and (max-width: 1599px) {
  .ct-topbar {
    height: 46px;
    padding: 0 18px;
    gap: 10px;
  }
}
.ct-topbar-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--chrome-ink);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}
.ct-topbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ct-topbar-center {
  flex: 1;
  display: flex;
  max-width: 400px;
}

/* The order trick (sidebar.css:333-346): DOM order is left→center→right
   (screen-reader friendly), but on desktop the icon cluster is visually
   moved next to the profile chip on the right. */
@media (min-width: 601px) {
  .ct-topbar-left {
    order: 2;
    margin-left: auto;
  }
  .ct-topbar-center {
    order: 1;
  }
  .ct-topbar-right {
    order: 3;
    margin-left: 0;
  }
}

.ct-topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* Desktop override — the earlier @media block (next to .ct-topbar-left)
   lost to this .ct-topbar-right base rule because both have equal
   specificity and the base rule is defined later in the source. Repeat
   the `margin-left: 0` here so the icon group can claim the spare space
   and pack flush against the profile without a gap. (eudr-x documents this
   trap in sidebar.css itself — keep both blocks.) */
@media (min-width: 601px) {
  .ct-topbar-right {
    margin-left: 0;
  }
}

/* Icon buttons (sidebar.css:556-572) */
.ct-topbar-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--chrome-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.ct-topbar-icon-btn:hover {
  background: var(--chrome-hover);
  color: var(--chrome-ink);
}

/* The existing flag lang-toggle (core/i18n.js renders flag + target-language
   label into [data-lang-toggle]) relocated into the icon cluster: widen the
   32px icon-button chrome to fit "🇬🇷 ΕΛ" while keeping its height/hover. */
.ct-topbar .ct-lang-toggle {
  width: auto;
  min-width: 32px;
  padding: 0 8px;
  border: none;
  background: none;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--chrome-sec);
}
.ct-topbar .ct-lang-toggle:hover {
  background: var(--chrome-hover);
  color: var(--chrome-ink);
}

/* Theme toggle (inert until dark.css/theme.js — WP7 — land): light mode
   shows the outline moon; dark.css swaps in the filled sun. This base rule
   keeps the button single-icon meanwhile. */
#themeToggle .icon-sun {
  display: none;
}

/* Empty widget slots (WP4 fills them): reserve no space while empty. */
.ct-global-search:empty,
.ct-bell-container:empty {
  display: none;
}
.ct-bell-container {
  position: relative;
  display: flex;
  align-items: center;
}

/* ═══════════ USER AVATAR CHIP (sidebar.css:693-742 + style.css:457-499) ═══════════ */
.ct-topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
  padding-left: 10px;
  border-left: 1px solid var(--chrome-line);
}
.ct-topbar-user-clickable {
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 8px 4px 10px;
  transition: background 0.15s ease;
}
.ct-topbar-user-clickable:hover {
  background: var(--chrome-hover);
}
.ct-topbar-user-clickable:focus-visible {
  outline: 2px solid var(--chrome-active-ink);
  outline-offset: 2px;
}
.ct-topbar-user .ct-header-avatar {
  width: 28px;
  height: 28px;
  font-size: 0.72rem;
}
/* Initials on every screen size (core/shell.js sets data-initials from the
   session name); without them the desktop avatar was an empty disc. */
.ct-topbar-user .ct-header-avatar::after {
  content: attr(data-initials);
  letter-spacing: 0.02em;
}
.ct-topbar-user-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.2;
}
.ct-topbar-user-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--chrome-ink);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* --chrome-dim is the same tone the old 0.75-opacity secondary text landed
   on, but opaque and without dimming the whole span. */
.ct-topbar-user-email {
  font-size: 0.68rem;
  color: var(--chrome-dim);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Tenant name · role separator (the middot only appears once session.js has
   filled the tenant span — gt staff have none). */
.ct-topbar-user-email [data-session-tenant]:not(:empty)::after {
  content: " · ";
}

/* --- HEADER AVATAR: the brand accent pop (spec-shell §15.8), now a cyan
   disc with Storm initials. It sits on the Storm chrome in both themes, so it
   is drawn from palette tokens that never flip; no dark-mode variant. --- */
.ct-header-avatar {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--cyan-75) 0%, var(--cyan-deep) 100%);
  box-shadow:
    0 3px 8px rgb(var(--cyan-rgb) / 0.28),
    inset 0 1px 2px color-mix(in srgb, var(--brand-white) 40%, transparent);
  color: var(--brand-storm);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  border: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ct-header-avatar:hover {
  transform: translateY(-1px);
  box-shadow:
    0 5px 12px rgb(var(--cyan-rgb) / 0.38),
    inset 0 1px 2px color-mix(in srgb, var(--brand-white) 40%, transparent);
}

/* ═══════════ DROPDOWN MENU (style.css:2486-2563; shared vocabulary for the
   user menu, bell panel chrome and future menus — WP4/WP7 reuse) ═══════════
   A solid content surface, not chrome: it flips with the theme through its
   tokens, so it needs no dark-mode block. No backdrop-filter (tokens.css). */
.ct-dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: 50px;
  background: var(--surface-raised);
  color: var(--text);
  min-width: 240px;
  box-shadow: var(--glass-shadow);
  border-radius: 14px;
  z-index: 200;
  border: 1px solid var(--border);
  padding: 10px 0;
  overflow: hidden;
}
.show-dropdown {
  display: block;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.ct-dropdown-header {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-2);
}
.ct-dropdown-email {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.ct-dropdown-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.ct-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 14px;
}
.ct-dropdown-item {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  color: var(--text);
  align-items: center;
  gap: 12px;
  transition: background-color 0.18s ease, transform 0.18s ease;
}
.ct-dropdown-item:hover {
  background-color: var(--primary-soft);
  transform: translateY(-1px);
}
.ct-menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--accent);
  background: var(--primary-soft);
  border-radius: 8px;
}
.ct-menu-icon svg {
  width: 18px;
  height: 18px;
}

/* ═══════════════════ MAIN CONTENT (sidebar.css:755-770) ═══════════════════
   `overflow: hidden` is load-bearing: the main area itself never scrolls —
   its child is the scroll host. Full-bleed apart from the content-column cap
   below. Background is transparent so the fixed ground layer shows through;
   no shell container (.ct-shell, .ct-right, .ct-main, #page-root) may paint
   an opaque background over it. */
.ct-shell .ct-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  /* 32px inline so content clears the 14px collapse tab riding the sidebar's
     edge; 20px left the first character of every title touching it. */
  padding: 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  background: transparent;
}
@media (min-width: 769px) and (max-width: 1599px) {
  .ct-shell .ct-main {
    /* Asymmetric on purpose: the 14px collapse tab rides the sidebar edge, and
       at a symmetric 14px the tab landed flush against the first card's left
       border and read as a handle glued to the card rather than to the sidebar. */
    padding: 10px 16px 10px 26px;
  }
}

/* Cap and center every screen's content column for readable line lengths
   (moved here from app.css — single owner). Wrapped in :where() so this is
   a zero-specificity DEFAULT — a screen that needs another width overrides
   it with a plain class selector without a specificity fight. */
:where(.ct-main) > * {
  /* width:100% is load-bearing, not belt-and-braces. .ct-main is a COLUMN flex
     container, and an auto inline margin on a column flex item cancels the
     default cross-axis stretch — so each child shrank to its own content and
     centred itself independently. Every page then opened at a different left
     edge (a narrow findings table vs a wide SDS table), and the layout visibly
     jumped sideways on navigation. Pinning the width first, then centring the
     box, gives every page one shared column. */
  width: 100%;
  max-width: 1120px;
  /* Centred, not left-hugging. With margin-inline:0 the column stayed pinned
     left and every pixel gained by collapsing the sidebar turned into dead
     space on the right — collapsing appeared to do nothing but push the page
     off-centre. */
  margin-inline: auto;
}

/* Existing pages mount into #page-root: it becomes the scroll host so the
   body/shell never scroll (eudr-x rigid pattern, spec-shell §8.1). */
.ct-shell .ct-main > #page-root:not(.ct-card-rigid) {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
/* The page card (EUDR .admin-content-card): a screen that opens with a page
   head (render.js mount() adds .ct-page-card) is ONE large card filling the
   content area, from the top bar to the footer, and scrolls inside itself.
   Inside it the glass tokens are re-pointed, so every glass panel, form and
   tab strip a screen already uses turns into a flat framed panel on the
   card instead of a floating card in a card. Phones keep the page on the
   ground (no card): every pixel of width goes to the content there. */
@media (min-width: 601px) {
  .ct-shell .ct-main > #page-root.ct-page-card {
    max-width: none;
    padding: 24px 24px 32px;
    background: var(--page-card);
    border: 1px solid var(--page-card-edge);
    border-radius: var(--radius);
    box-shadow: var(--page-card-shadow);
    --glass: var(--page-panel);
    --glass-lit: none;
    --glass-shadow: 0 0 0 transparent;
    --glass-edge: var(--border);
  }
  /* Tables sit on the card's own surface (dark: the glass, not a slab). */
  .ct-page-card .ct-table {
    background: var(--page-panel);
  }
}

/* Pinned siblings never get squeezed.
   (:not(#page-root) carries ID specificity, so rigid cards are excluded
   explicitly or they would lose their flex-shrink.) */
.ct-shell .ct-main > :not(#page-root):not(.ct-card-rigid) {
  flex-shrink: 0;
}

/* Rigid card (operator-react.css:254-305): fills the remaining viewport,
   never scrolls itself — a pinned header row (flex-shrink:0) plus one inner
   scroll host (flex:1; min-height:0; overflow-y:auto) live inside it. */
.ct-shell .ct-main > .ct-card-rigid {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ct-card-rigid > .ct-card-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ═══════════════════ FOOTER (sidebar.css:772-798) ═══════════════════ */
.ct-bottom-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 24px;
  background: var(--chrome-bg);
  height: 36px;
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--chrome-sec);
  flex-wrap: wrap;
  border-top: 1px solid var(--chrome-line);
}
.ct-bottom-footer a {
  color: var(--chrome-sec);
  text-decoration: none;
  transition: color 0.15s ease;
}
.ct-bottom-footer a:hover {
  color: var(--chrome-ink);
}
.ct-bottom-footer-divider {
  color: var(--chrome-dim);
  font-size: 0.6rem;
}

/* ═══════════ RESPONSIVE SHELL TIERS (sidebar.css:853-868) ═══════════
   ≤900px: JS auto-collapses the sidebar (core/shell.js matchMedia — width
   is owned by the JS class, NOT by CSS, or the toggle tab detaches from the
   sidebar edge, spec-shell §15.9). CSS only trims chrome here. */
@media (max-width: 900px) {
  /* The title is NOT hidden here any more. It used to be, back when it was
     unpopulated chrome; from 601px up the sidebar is auto-collapsed to icons, so
     this line is the only thing naming the current screen. (≤600px it does go
     away with the whole .ct-topbar-center — there the bottom nav names the
     screen.) It ellipsises rather than pushing the icon cluster around. */
  .ct-topbar-title {
    font-size: 0.88rem;
  }
  .ct-topbar-user-email {
    display: none;
  }
  .ct-shell .ct-main {
    padding: 16px 14px;
  }
}
@media (max-width: 600px) {
  .ct-shell .ct-sidebar {
    display: none;
  }
  .ct-sidebar-toggle {
    display: none;
  }
  .ct-topbar-center {
    display: none;
  }
  .ct-shell .ct-main {
    padding: 10px 8px;
  }
}

/* ═══════════ THEME CONTRACT (spec-theme §1.6 / spec-shell §2.3) ═══════════
   The sidebar/topbar chrome is solid Storm in BOTH themes. It used to be
   re-asserted here with navy literals (body:not(.dark-mode) + body.dark-mode
   blocks); the --chrome-* tokens now carry that contract (tokens.css defines
   them once and dark.css never flips them), so there is nothing to re-assert.
   The old body.dark-mode.ct-shell-active background was deleted too: it
   painted an opaque colour + SVG on <body> and hid the fixed ground layer. */
