@charset "UTF-8";
/* ==========================================================================
   Archinet UI — Bootstrap-free design system for projects.archinet.net
   Evolved from /help/css/archi.help.css. Pure CSS: no framework, no JS deps.
   Uses: @layer, nesting, oklch/light-dark(), color-mix(), :has(), container
   queries, popover + anchor positioning, @starting-style, ::details-content,
   interpolate-size, scroll-driven animations, cross-document view transitions.
   ========================================================================== */

@layer reset, tokens, base, layout, components, utilities;

/* ---------- Fonts (same Alleyn family, now one family w/ real weights) ---------- */
@font-face { font-family: "Alleyn"; font-weight: 300; font-display: swap; src: url("fonts/ArchinetFontKit/webFonts/AlleynLight/font.woff2") format("woff2"); }
@font-face { font-family: "Alleyn"; font-weight: 400; font-display: swap; src: url("fonts/ArchinetFontKit/webFonts/AlleynBook/font.woff2") format("woff2"); }
@font-face { font-family: "Alleyn"; font-weight: 500; font-display: swap; src: url("fonts/ArchinetFontKit/webFonts/AlleynMedium/font.woff2") format("woff2"); }
@font-face { font-family: "Alleyn"; font-weight: 600; font-display: swap; src: url("fonts/ArchinetFontKit/webFonts/AlleynSemiBold/font.woff2") format("woff2"); }
@font-face { font-family: "Alleyn"; font-weight: 700; font-display: swap; src: url("fonts/ArchinetFontKit/webFonts/AlleynBold/font.woff2") format("woff2"); }

@view-transition { navigation: auto; }

/* ---------- Reset ---------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { -webkit-text-size-adjust: none; text-size-adjust: none; interpolate-size: allow-keywords; }
  /* Font Awesome's inline SVG icons keep their own sizing: max-width:100% would let them shrink to 0 in tight cells */
  img, svg:not(.svg-inline--fa), video { display: block; max-width: 100%; }
  input, button, select, textarea { font: inherit; color: inherit; }
  ul[role="list"], ol[role="list"], menu { list-style: none; }
  table { border-collapse: collapse; }
  :where(h1, h2, h3, h4) { text-wrap: balance; }
  :where(p, li, td) { text-wrap: pretty; }
  /* The hidden attribute must win over component display values (.btn, .row, .card-actions, …). */
  [hidden] { display: none !important; }
}

/* ---------- Tokens ---------- */
@layer tokens {
  :root {
    color-scheme: light dark;

    /* Brand — Help Center blue */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: light-dark(#dbeafe, color-mix(in oklch, #2563eb 22%, #0f141b));
    --primary-ink: light-dark(#1d4ed8, #93b4ff);
    --on-primary: #ffffff;
    --archinet-gray: #53585a;
    --archinet-yellow: #ffc708;

    /* Neutrals (cool slate, as in /help) */
    --bg:        light-dark(#f8fafc, #0f141b);
    --surface:   light-dark(#ffffff, #161c24);
    --surface-2: light-dark(#f1f5f9, #1d2530);
    --text:      light-dark(#1f2937, #dde3ea);
    --heading:   light-dark(#111827, #f5f7fa);
    --muted:     light-dark(#5b6678, #95a1b2);
    --border:    light-dark(#e2e8f0, #28313d);
    --border-strong: light-dark(#94a3b8, #4a5667);

    /* Status */
    --success: light-dark(#15803d, #4ade80);
    --warning-bg: light-dark(#fef3c7, #3a2e0d);
    --warning-ink: light-dark(#92400e, #fcd34d);
    --danger: light-dark(#b91c1c, #f87171);
    --danger-bg: light-dark(#fee2e2, #3b1414);
    --info-bg: var(--primary-soft);

    /* Type */
    --font: "Alleyn", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --mono: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
    --fs-xs: .75rem; --fs-sm: .875rem; --fs-md: 1rem; --fs-lg: 1.125rem;
    --fs-xl: 1.375rem; --fs-2xl: clamp(1.5rem, 1.1rem + 1.4vw, 2rem);

    /* Shape & depth */
    --r-sm: .5rem; --r-md: .75rem; --r-lg: 1rem; --r-pill: 9999px;
    --shadow-sm: 0 1px 2px rgb(15 23 42 / .06);
    --shadow-md: 0 4px 12px -2px rgb(15 23 42 / .10), 0 2px 4px -2px rgb(15 23 42 / .06);
    --shadow-lg: 0 18px 36px -12px rgb(15 23 42 / .22), 0 6px 12px -6px rgb(15 23 42 / .10);
    --ring: 0 0 0 3px color-mix(in oklch, var(--primary) 35%, transparent);

    /* Space */
    --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
    --space-5: 1.5rem; --space-6: 2rem; --space-7: 3rem;
    --pad-cell: .75rem 1rem;

    /* Motion */
    --ease-out: cubic-bezier(.2, .7, .2, 1);
    --ease-spring: linear(0, .35 8%, .78 18%, 1.02 30%, 1.06 38%, 1.01 52%, .99 70%, 1);
    --t-fast: 150ms; --t-med: 250ms; --t-slow: 420ms;

    /* Layout */
    --page-max: 1400px;
    --aside: 300px;
    --brand-banner: #f8fafc;          /* overridden per client from brandingQuery */
  }

  /* Density switch: <html data-density="compact"> */
  [data-density="compact"] { --pad-cell: .45rem .75rem; --space-5: 1rem; --fs-md: .9375rem; }

  @media (prefers-reduced-motion: reduce) {
    :root { --t-fast: 0ms; --t-med: 0ms; --t-slow: 0ms; }
  }
}

/* ---------- Base ---------- */
@layer base {
  body {
    font-family: var(--font);
    font-weight: 400;
    font-size: var(--fs-md);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100dvh;
    display: flex; flex-direction: column;
    -webkit-font-smoothing: antialiased;
  }
  h1, h2, h3, h4 { color: var(--heading); line-height: 1.2; font-weight: 600; }
  a { color: var(--primary-ink); text-decoration: none; transition: color var(--t-fast); }
  a:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: .2em; }
  :focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
  ::selection { background: var(--primary-soft); }
  hr { border: 0; border-top: 1px solid var(--border); margin-block: var(--space-4); }
  pre, code { font-family: var(--mono); font-size: .8125rem; }
  /* The Font Awesome kit draws SVG icons; "nest" mode keeps each <i> and moves the fa-* classes onto its <svg>. */
  i[class*="fa-"], i[data-fa-i2svg] { line-height: 1; }
  input, select, textarea { accent-color: var(--primary); }
}

/* ---------- Layout ---------- */
@layer layout {
  .page { width: min(100% - 2rem, var(--page-max)); margin-inline: auto; padding-block: var(--space-5) var(--space-7); flex: 1; }
  .layout {
    display: grid; gap: var(--space-6);
    grid-template-columns: minmax(0, 1fr) var(--aside);
    align-items: start;
    @media (width < 1024px) { grid-template-columns: minmax(0, 1fr); }
    /* role-gated asides are not rendered at all when empty: use the full width */
    &:not(:has(> .aside)) { grid-template-columns: minmax(0, 1fr); }
  }
  .stack { display: flex; flex-direction: column; gap: var(--space-4); }
  .aside { display: flex; flex-direction: column; gap: var(--space-5); position: sticky; top: calc(var(--header-h, 110px) + 1rem);
    @media (width < 1024px) { position: static; &:not(:has(> :not(.hide-lt-lg))) { display: none; } }
    /* a sticky aside taller than the window (long announcements, notification lists) scrolls on its own, so its
       lower panels stay reachable; the padding/negative margin keeps the cards' shadows from being clipped */
    @media (width >= 1024px) {
      max-height: calc(100dvh - var(--header-h, 110px) - 2rem); overflow-y: auto; scrollbar-width: thin;
      padding: .5rem; margin: -.5rem;
    }
  }
}

/* ---------- Components ---------- */
@layer components {

  /* --- Site header: brand banner + nav --- */
  .site-header {
    position: sticky; top: 0; z-index: 50;
    /* oklab, not oklch: an oklch mix with transparent drops the hue and tints the dark header red */
    background: color-mix(in oklab, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--border);
    animation: header-lift linear both;
    animation-timeline: scroll(root);
    animation-range: 0 120px;
  }
  @keyframes header-lift { to { box-shadow: var(--shadow-md); border-bottom-color: transparent; } }

  .brand-banner {
    background: var(--brand-banner);
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
    padding: .55rem clamp(1rem, 3vw, 1.5rem);
    min-height: 44px;
    border-bottom: 1px solid var(--border);
    & img { height: 25px; width: auto; }
  }
  .powered-by {
    font-size: var(--fs-xs); letter-spacing: .02em;
    color: var(--banner-ink, #5b6678);
    display: inline-flex; align-items: center; gap: .4em; white-space: nowrap;
    & a { color: inherit; font-weight: 600; }
    & a:hover { text-decoration: none; opacity: .85; }
    & .gray { color: var(--archinet-gray); } & .yellow { color: var(--archinet-yellow); }
    @media (width < 560px) { & .label { display: none; } }
  }

  .navbar {
    display: flex; align-items: center; gap: var(--space-2);
    padding: .4rem clamp(.5rem, 2vw, 1rem);
    min-height: 56px;
  }
  .nav-list {
    display: flex; align-items: center; gap: 2px;
    overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0;
    mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
    @media (width < 1180px) { & .nav-link .nav-text { display: none; } }
    /* phones: every menu goes icon-only (My Projects and Add included) so all of them fit without scrolling */
    @media (width < 640px) { & .nav-link .nav-label, & .nav-link .caret { display: none; } & .nav-link { padding-inline: .65rem; } }
    @media (width >= 1180px) { mask-image: none; }
  }
  .nav-link {
    appearance: none; border: 0; background: transparent; cursor: pointer;
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .5rem .8rem; border-radius: var(--r-sm);
    color: var(--text); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap;
    transition: background var(--t-fast), color var(--t-fast);
    & i:first-child { color: var(--muted); transition: color var(--t-fast); }
    & .caret { font-size: .65em; opacity: .6; transition: rotate var(--t-med) var(--ease-out); }
    &:hover { background: var(--surface-2); color: var(--heading); text-decoration: none; & i:first-child { color: var(--primary); } }
    &[aria-current="page"], &.is-active { background: var(--primary-soft); color: var(--primary-ink); & i:first-child { color: var(--primary); } }
    &:has(+ .menu:popover-open) { background: var(--surface-2); & .caret { rotate: 180deg; } }
  }

  /* Dropdown menus: native popover, anchor-positioned, animated in & out */
  .menu {
    position: fixed; inset: auto; margin: 0;
    position-area: bottom span-right;
    position-try-fallbacks: flip-inline;
    margin-top: 6px;
    min-width: 240px; max-height: min(70dvh, 520px); overflow: auto;
    padding: .4rem;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    opacity: 0; translate: 0 -6px; scale: .98; transform-origin: top left;
    transition: opacity var(--t-med) var(--ease-out), translate var(--t-med) var(--ease-out), scale var(--t-med) var(--ease-out),
                display var(--t-med) allow-discrete, overlay var(--t-med) allow-discrete;
    &:popover-open { opacity: 1; translate: 0 0; scale: 1;
      @starting-style { opacity: 0; translate: 0 -6px; scale: .98; }
    }
    &.menu-end { position-area: bottom span-left; transform-origin: top right; }
    & a, & button.menu-item {
      display: flex; align-items: center; gap: .65rem; width: 100%;
      padding: .5rem .7rem; border-radius: var(--r-sm); border: 0; background: none; text-align: left; cursor: pointer;
      color: var(--text); font-size: var(--fs-sm);
      & i { width: 1.1em; text-align: center; color: var(--muted); }
      &:hover { background: var(--primary-soft); color: var(--primary-ink); text-decoration: none; & i { color: var(--primary); } }
      &[aria-current="page"] { color: var(--primary-ink); font-weight: 600; & i { color: var(--primary); } }
    }
  }
  .menu-label { padding: .6rem .7rem .25rem; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  .menu-sep { height: 1px; background: var(--border); margin: .35rem .25rem; }
  .menu-card { padding: .7rem; font-size: var(--fs-sm); line-height: 1.45; color: var(--muted);
    & strong { color: var(--heading); display: block; font-weight: 600; }
  }
  /* Fallback when anchor positioning is unsupported */
  @supports not (position-area: bottom) {
    .menu { position: fixed; inset: auto auto auto auto; top: var(--header-h, 110px); left: 1rem; }
    .menu.menu-end { left: auto; right: 1rem; }
  }

  /* Anchor names (one per trigger) */
  #nav-projects-btn { anchor-name: --nav-projects; } #nav-projects { position-anchor: --nav-projects; }
  #nav-clients-btn  { anchor-name: --nav-clients; }  #nav-clients  { position-anchor: --nav-clients; }
  #nav-add-btn      { anchor-name: --nav-add; }      #nav-add      { position-anchor: --nav-add; }
  #nav-manage-btn   { anchor-name: --nav-manage; }   #nav-manage   { position-anchor: --nav-manage; }
  #nav-user-btn     { anchor-name: --nav-user; }     #nav-user     { position-anchor: --nav-user; }

  /* Nav search */
  .nav-search {
    position: relative; display: flex; align-items: center; gap: .5rem;
    /* direct child only: the "this project only" checkbox label also holds an icon */
    & > i { position: absolute; left: .85rem; color: var(--muted); pointer-events: none; transition: color var(--t-fast); }
    & .switch-row { gap: .35rem; color: var(--muted); white-space: nowrap; }
    & input[type="search"] {
      width: clamp(10rem, 22vw, 22rem); height: 38px;
      padding: 0 .9rem 0 2.3rem; border-radius: var(--r-pill);
      border: 1px solid var(--border); background: var(--surface-2);
      font-size: var(--fs-sm);
      transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), width var(--t-med) var(--ease-out);
      &::placeholder { color: var(--muted); }
      &:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: var(--ring); width: clamp(12rem, 28vw, 26rem); }
    }
    &:focus-within > i { color: var(--primary); }
    @media (width < 760px) { & input[type="search"] { width: 9rem; } }
    /* phones: collapse to the magnifier; the field opens when tapped */
    @media (width < 560px) {
      & input[type="search"] { width: 38px; padding-right: 0; cursor: pointer;
        &::placeholder { color: transparent; }
        &:focus, &:not(:placeholder-shown) { width: 11rem; padding-right: .9rem; cursor: text; &::placeholder { color: var(--muted); } }
      }
      & .switch-row { display: none; }
    }
  }
  @media (width < 640px) { #nav-user-btn { padding-inline: .5rem; & .caret { display: none; } } }
  .avatar {
    inline-size: 30px; block-size: 30px; border-radius: 50%;
    display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 600;
    background: var(--primary-soft); color: var(--primary-ink);
  }

  /* --- Breadcrumbs (Help Center style) --- */
  .crumbs {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    padding: .7rem 1rem; margin-bottom: var(--space-5);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
    box-shadow: var(--shadow-sm); font-size: var(--fs-sm);
    & ol { display: flex; align-items: center; gap: .5rem; list-style: none; flex-wrap: wrap; }
    & li { display: inline-flex; align-items: center; gap: .5rem; max-width: 100%; }
    /* long unbroken labels (file names) wrap instead of widening the page */
    & li > :is(a, span) { min-width: 0; overflow-wrap: anywhere; }
    & li + li::before { content: "/"; color: var(--border-strong); }
    & [aria-current="page"] { color: var(--muted); }
    & .mark { height: 1.1rem; width: auto; }
  }

  /* --- Page title --- */
  .page-title {
    /* baseline, no wrap: on a phone a long title wraps beside its icon instead of dropping below it */
    display: flex; align-items: baseline; gap: .75rem;
    font-family: var(--font); font-weight: 300; font-size: var(--fs-2xl); letter-spacing: -.01em;
    color: var(--heading);
    & i { font-size: .8em; color: var(--primary); flex: none; }
    & .count { font-size: var(--fs-sm); font-weight: 500; }
  }
  .section-label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

  /* --- Buttons --- */
  .btn {
    --_bg: var(--surface); --_fg: var(--text); --_bd: var(--border);
    display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
    padding: .55rem 1rem; min-height: 40px;
    border-radius: var(--r-sm); border: 1px solid var(--_bd);
    background: var(--_bg); color: var(--_fg);
    font-size: var(--fs-sm); font-weight: 500; line-height: 1.2; cursor: pointer; white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-med), translate var(--t-med) var(--ease-out);
    &:hover { text-decoration: none; translate: 0 -1px; box-shadow: var(--shadow-md); border-color: var(--border-strong); color: var(--_fg); }
    &:active { translate: 0 0; box-shadow: var(--shadow-sm); }
    &:disabled, &[aria-disabled="true"] { opacity: .5; cursor: not-allowed; translate: none; box-shadow: none; border-color: var(--_bd); }
    &[aria-disabled="true"] { pointer-events: none; }
    & i { font-size: .95em; }
  }
  .btn-primary { --_bg: var(--primary); --_fg: var(--on-primary); --_bd: var(--primary);
    &:hover { --_bg: var(--primary-hover); border-color: var(--primary-hover); }
  }
  .btn-soft { --_bg: var(--primary-soft); --_fg: var(--primary-ink); --_bd: transparent; box-shadow: none;
    &:hover { --_bg: var(--primary); --_fg: var(--on-primary); border-color: transparent; }
  }
  .btn-ghost { --_bg: transparent; --_bd: transparent; box-shadow: none; &:hover { --_bg: var(--surface-2); box-shadow: none; } }
  .btn-lg { min-height: 52px; font-size: var(--fs-md); padding-inline: 1.25rem; border-radius: var(--r-md); }
  .btn-sm { min-height: 32px; padding: .35rem .75rem; font-size: var(--fs-xs); }
  .btn-block { width: 100%; }

  /* --- Segmented control (Active / Completed) --- */
  .segmented {
    display: inline-flex; padding: 4px; gap: 4px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill);
    & a {
      display: inline-flex; align-items: center; gap: .5rem;
      padding: .4rem 1rem; border-radius: var(--r-pill);
      font-size: var(--fs-sm); font-weight: 500; color: var(--muted);
      transition: background var(--t-med) var(--ease-out), color var(--t-fast), box-shadow var(--t-med);
      &:hover { color: var(--heading); text-decoration: none; }
      &[aria-current="page"] { background: var(--surface); color: var(--heading); box-shadow: var(--shadow-sm); }
    }
  }

  /* --- Badges / pills --- */
  .badge {
    display: inline-flex; align-items: center; gap: .3rem;
    min-width: 1.6rem; justify-content: center;
    padding: .15rem .55rem; border-radius: var(--r-pill);
    font-size: var(--fs-xs); font-weight: 600; line-height: 1.4;
    background: var(--primary-soft); color: var(--primary-ink);
    font-variant-numeric: tabular-nums;
  }
  .badge-neutral { background: var(--surface-2); color: var(--muted); }
  .badge-warning { background: var(--warning-bg); color: var(--warning-ink); }
  .badge-success { background: light-dark(#dcfce7, #10301c); color: var(--success); }
  .badge-danger { background: var(--danger-bg); color: var(--danger); }

  /* --- Card --- */
  .card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm); padding: var(--space-5);
    transition: box-shadow var(--t-med), border-color var(--t-med);
    &:hover { box-shadow: var(--shadow-md); }
  }
  .card-title { font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--space-3); }
  .card-actions { display: grid; gap: var(--space-3);
    /* long labels ("Download File (6,225 KB)") wrap instead of overflowing the 300px aside */
    & .btn { white-space: normal; text-align: center; }
  }

  /* --- Client accordion (native <details>, animated) --- */
  .client-list { display: flex; flex-direction: column; gap: var(--space-4); }
  .client, .disclosure {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm); overflow: clip;
    transition: box-shadow var(--t-med), border-color var(--t-med);
    animation: rise var(--t-slow) var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 60ms);
    &:hover { border-color: var(--border-strong); }
    &[open] { box-shadow: var(--shadow-md); }
    /* Links to #client_N / category anchors land below the sticky header. */
    scroll-margin-top: calc(var(--header-h, 110px) + 1rem);

    &::details-content {
      block-size: 0; overflow: clip;
      transition: block-size var(--t-slow) var(--ease-out), content-visibility var(--t-slow) allow-discrete;
    }
    &[open]::details-content { block-size: auto; }
  }
  .client-summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: .85rem;
    padding: 1rem 1.25rem;
    transition: background var(--t-fast);
    &::-webkit-details-marker { display: none; }
    &:hover { background: color-mix(in oklch, var(--primary-soft) 55%, var(--surface)); }
    & .chev {
      inline-size: 28px; block-size: 28px; border-radius: var(--r-sm);
      display: grid; place-items: center; flex: none;
      background: var(--surface-2); color: var(--muted); font-size: .75rem;
      transition: rotate var(--t-med) var(--ease-spring), background var(--t-fast), color var(--t-fast);
    }
    & h3 { font-size: var(--fs-lg); font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  }
  :is(.client, .disclosure)[open] > .client-summary {
    border-bottom: 1px solid var(--border);
    & .chev { rotate: 90deg; background: var(--primary); color: var(--on-primary); }
  }

  /* --- Data table (plain HTML, responsive via container query) --- */
  /* position: relative keeps .sr-only labels inside the sideways scroll instead of widening the page */
  .table-wrap { container-type: inline-size; overflow-x: auto; position: relative; }
  .table {
    width: 100%; font-size: var(--fs-sm);
    & th {
      text-align: left; font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em;
      color: var(--muted); padding: var(--pad-cell); border-bottom: 1px solid var(--border); white-space: nowrap;
      background: var(--surface-2);
    }
    & td { padding: var(--pad-cell); border-bottom: 1px solid var(--border); vertical-align: middle; }
    & tbody tr { transition: background var(--t-fast); }
    & tbody tr:hover { background: color-mix(in oklch, var(--primary-soft) 45%, transparent); }
    /* rows a page script marks as chosen (notify lists on Upload and the Dropbox transfer) */
    & tbody tr.selected { background: var(--primary-soft); }
    & tbody tr:last-child td { border-bottom: 0; }
    & .num { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
    & .name a { font-weight: 600; color: var(--heading); &:hover { color: var(--primary-ink); } }
    & .actions { text-align: right; width: 1%; white-space: nowrap; }
    & td.is-empty { color: var(--warning-ink); }
    & td.is-empty .doc-count { background: var(--warning-bg); }
  }
  .doc-count { display: inline-flex; align-items: center; gap: .4rem; padding: .1rem .5rem; border-radius: var(--r-pill); font-variant-numeric: tabular-nums;
    & i { opacity: .7; }
  }
  @container (width < 640px) {
    .table .col-created, .table .col-number { display: none; }
  }
  @container (width < 460px) {
    .table .col-latest { display: none; }
    .table .actions .label { display: none; }
  }

  /* --- Alerts --- */
  .alert {
    display: flex; gap: .75rem; align-items: flex-start;
    padding: .85rem 1rem; border-radius: var(--r-md); font-size: var(--fs-sm);
    background: var(--info-bg); color: var(--primary-ink);
    &.alert-danger { background: var(--danger-bg); color: var(--danger); }
    &.alert-warning { background: var(--warning-bg); color: var(--warning-ink); }
  }

  /* --- Admin log --- */
  .log {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 1rem; max-height: 220px; overflow: auto; color: var(--muted); white-space: pre-wrap;
  }
  /* View Group: zip progress lines streamed into an initially empty .log */
  .server-events { font-size: var(--fs-xs); padding: .6rem .75rem; &:empty { display: none; } }

  /* --- Footer --- */
  .site-footer {
    border-top: 1px solid var(--border); background: var(--surface);
    padding-block: var(--space-6) var(--space-5); font-size: var(--fs-sm);
    & .inner { width: min(100% - 2rem, var(--page-max)); margin-inline: auto; }
    & .cols { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
    & h4 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: var(--space-3); }
    & ul { list-style: none; display: grid; gap: .35rem; }
    & a { color: var(--text); &:hover { color: var(--primary-ink); } }
    & .legal { display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; align-items: center;
      margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border); color: var(--muted);
      & nav { display: flex; gap: var(--space-4); }
    }
    & .build { margin-top: var(--space-3); font-size: var(--fs-xs); color: var(--muted); text-align: center; }
  }

  /* --- Back to top: appears via scroll-driven animation, no JS --- */
  .back-to-top {
    position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 40;
    inline-size: 46px; block-size: 46px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--surface); color: var(--heading); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
    animation: reveal linear both; animation-timeline: scroll(root); animation-range: 300px 500px;
    &:hover { color: var(--primary); text-decoration: none; }
  }
  @supports not (animation-timeline: scroll()) { .back-to-top { opacity: 1; } }
  @keyframes reveal { from { opacity: 0; scale: .6; pointer-events: none; } to { opacity: 1; scale: 1; pointer-events: auto; } }

  /* Motion primitives */
  @keyframes rise { from { opacity: 0; translate: 0 10px; } to { opacity: 1; translate: 0 0; } }
  .rise { animation: rise var(--t-slow) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 60ms); }
}

/* ---------- Utilities ---------- */
@layer utilities {
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .muted { color: var(--muted); }
  .row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
  .spread { justify-content: space-between; }
  .ml-auto { margin-left: auto; }
  .blurred { filter: blur(6px); }
  /* long lists (Download / Response Required, …) scroll inside their panel instead of paginating */
  .scroll-y { max-height: var(--max-h, 22rem); overflow-y: auto; overscroll-behavior: contain; }
  /* Legacy page scripts still toggle Bootstrap's .hidden class. */
  .hidden { display: none !important; }
  /* Rich text saved from CKEditor (announcements, comments, descriptions): restore the spacing the reset removes. */
  .prose { overflow-wrap: anywhere;
    & > * + * { margin-top: .6em; }
    & :is(ul, ol) { padding-left: 1.25em; }
    & li + li { margin-top: .2em; }
    & img { height: auto; }
  }
  @media (width < 1024px) { .hide-lt-lg { display: none !important; } }
  @media (width >= 1024px) { .show-lt-lg { display: none !important; } }
}

/* ==========================================================================
   Detail-page components (View Project, View Group, View Document, Upload)
   ========================================================================== */
@layer components {

  /* --- Panel: card with header row --- */
  .panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm); overflow: clip;
    transition: box-shadow var(--t-med);
    &:hover { box-shadow: var(--shadow-md); }
  }
  .panel-head {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .85rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--surface-2);
    & h2, & h3 { font-size: var(--fs-md); font-weight: 600; display: flex; align-items: center; gap: .55rem; flex: 1; min-width: 0; }
    & h2 > i, & h3 > i { color: var(--primary); }
  }
  .panel-body { padding: 1.25rem; display: flex; flex-direction: column; gap: var(--space-4); }
  .panel-body.flush { padding: 0; gap: 0; }
  details.panel > summary.panel-head { cursor: pointer; list-style: none; border-bottom-color: transparent; transition: background var(--t-fast);
    &::-webkit-details-marker { display: none; }
    &:hover { background: var(--primary-soft); }
    /* A plus drawn with gradients: the Font Awesome kit is SVG-only, so no icon font exists for a pseudo-element. */
    &::after { content: ""; flex: none; inline-size: .75rem; block-size: .75rem; color: var(--muted);
      background: linear-gradient(currentColor 0 0) center / 100% 2px no-repeat, linear-gradient(currentColor 0 0) center / 2px 100% no-repeat;
      transition: rotate var(--t-med) var(--ease-spring); }
  }
  details.panel[open] > summary.panel-head { border-bottom-color: var(--border); &::after { rotate: 45deg; } }
  details.panel::details-content { block-size: 0; overflow: clip; transition: block-size var(--t-slow) var(--ease-out), content-visibility var(--t-slow) allow-discrete; }
  details.panel[open]::details-content { block-size: auto; }

  /* --- Tabs: pure CSS (radio + :has) --- */
  .tabs { display: flex; flex-direction: column; gap: var(--space-4); }
  .tab-list {
    display: flex; gap: 4px; padding: 4px; overflow-x: auto; scrollbar-width: none;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
    & input { position: absolute; opacity: 0; pointer-events: none; }
  }
  .tab {
    display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; cursor: pointer;
    padding: .55rem 1rem; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 500; color: var(--muted);
    transition: background var(--t-med) var(--ease-out), color var(--t-fast), box-shadow var(--t-med);
    &:hover { color: var(--heading); }
    &:has(input:checked) { background: var(--surface); color: var(--heading); box-shadow: var(--shadow-sm); & i { color: var(--primary); } }
    &:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 1px; }
  }
  .tab-panel { display: none; animation: rise var(--t-slow) var(--ease-out) both; }
  .tabs:has([data-tab="1"]:checked) [data-panel="1"],
  .tabs:has([data-tab="2"]:checked) [data-panel="2"],
  .tabs:has([data-tab="3"]:checked) [data-panel="3"],
  .tabs:has([data-tab="4"]:checked) [data-panel="4"],
  .tabs:not(:has(.tab-list input:checked)) [data-panel="1"] { display: block; }
  .tabs:not(:has(.tab-list input:checked)) .tab:first-child { background: var(--surface); color: var(--heading); box-shadow: var(--shadow-sm); }

  /* --- Meta list: icon + text rows --- */
  .meta-list {
    list-style: none; display: grid; gap: .4rem; font-size: var(--fs-sm);
    & li { display: flex; align-items: baseline; gap: .6rem; }
    & li > i:first-child { width: 1.1em; flex: none; text-align: center; color: var(--muted); }
    & .is-danger, & .is-danger i { color: var(--danger) !important; }
  }
  .kv-title { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .5rem; display: flex; align-items: center; gap: .4rem; }
  .split { container-type: inline-size; }
  /* minmax(0, …): a long unbreakable label must not push the other column out of the panel */
  .split-grid { display: grid; gap: var(--space-5) var(--space-6); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  @container (width < 36rem) { .split-grid { grid-template-columns: minmax(0, 1fr); } }

  /* --- List group (Download / Response Required) --- */
  .list-group { list-style: none; display: flex; flex-direction: column;
    & > li { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.25rem; border-top: 1px solid var(--border); font-size: var(--fs-sm); transition: background var(--t-fast); }
    & > li:first-child { border-top: 0; }
    & > li:hover { background: color-mix(in oklch, var(--primary-soft) 45%, transparent); }
    & .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    /* narrow lists (View Document aside): labels that share a long prefix wrap instead of all reading "2023.08…" */
    &.wrap-labels .grow { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; }
    & .empty { color: var(--muted); }
    & [aria-current="page"] { font-weight: 600; color: var(--heading); }
    & > li:has(> [aria-current="page"]) { background: var(--primary-soft); }
  }
  .icon-btn {
    inline-size: 32px; block-size: 32px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none;
    color: var(--muted); background: transparent; border: 0; cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
    &:hover { background: var(--primary-soft); color: var(--primary-ink); text-decoration: none; }
  }

  /* --- Image placeholder / thumbnail --- */
  .thumb {
    position: relative; display: grid; place-items: center; overflow: hidden;
    aspect-ratio: var(--ratio, 4 / 3); inline-size: var(--w, 100%);
    border-radius: var(--r-sm); border: 1px solid var(--border);
    background: repeating-linear-gradient(135deg, var(--surface-2) 0 8px, color-mix(in oklch, var(--surface-2) 60%, var(--border)) 8px 9px);
    color: var(--muted); font: 500 .6875rem/1.2 var(--mono); text-align: center; padding: .25rem;
    transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med);
    /* opaque so the file-type label behind it only shows when the image is missing (onerror removes the img) */
    & img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface); }
  }
  a:hover > .thumb, .thumb:is(a):hover { transform: scale(1.03); box-shadow: var(--shadow-md); }

  /* --- Document rows (categories / groups) --- */
  .doc-row {
    display: grid; gap: .5rem 1.25rem; align-items: center;
    grid-template-columns: 72px minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1fr);
    padding: 1rem 1.25rem; border-top: 1px solid var(--border);
    transition: background var(--t-fast);
    &:first-child { border-top: 0; }
    &:hover { background: color-mix(in oklch, var(--primary-soft) 35%, transparent); }
    & h4 { font-size: var(--fs-md); font-weight: 600; line-height: 1.3; }
    & h4 a { color: var(--heading); }
    & .file { font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    &.is-nested { background: color-mix(in oklch, var(--surface-2) 70%, transparent); padding-left: 2.5rem; }
  }
  .doc-rows { container-type: inline-size; }
  @container (width < 640px) {
    .doc-row { grid-template-columns: 64px minmax(0, 1fr); }
    .doc-row > :nth-child(n+3) { grid-column: 2; }
  }
  .dl-link { display: inline-flex; align-items: center; gap: .35rem; font-size: var(--fs-sm); }
  .zero { color: var(--muted); opacity: .7; }

  /* --- Group file rows with actions --- */
  .file-row {
    display: grid; gap: 1rem; align-items: center;
    grid-template-columns: 110px minmax(0, 1fr) auto;
    padding: 1rem 1.25rem; border-top: 1px solid var(--border);
    &:first-child { border-top: 0; }
    & .actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
  }
  @container (width < 640px) { .file-row { grid-template-columns: 90px minmax(0, 1fr); } .file-row .actions { grid-column: 1 / -1; justify-content: stretch; & .btn { flex: 1; } } }

  /* --- Buttons: extra variants --- */
  .btn-warning { --_bg: light-dark(#fff7e6, #3a2e0d); --_fg: var(--warning-ink); --_bd: light-dark(#f5d48a, #6b5317); }
  .btn-danger { --_bg: var(--danger-bg); --_fg: var(--danger); --_bd: light-dark(#fecaca, #5b1f1f);
    &:hover { --_bg: var(--danger); --_fg: #fff; border-color: var(--danger); }
  }
  .btn-group { display: flex; gap: .4rem; flex-wrap: wrap; }

  /* --- Alerts: success variant + announcement --- */
  .alert-success { background: light-dark(#dcfce7, #10301c); color: light-dark(#166534, #86efac); }
  .announcement {
    border-radius: var(--r-md); padding: 1rem; display: grid; gap: .5rem;
    background: light-dark(#f0fdf4, #0f2618); border: 1px solid light-dark(#bbf7d0, #1f4d30);
    & h4 { font-size: var(--fs-md); }
    & p { font-size: var(--fs-sm); }
    & .by { font-size: var(--fs-xs); color: var(--muted); }
    &.is-old { background: var(--surface-2); border-color: var(--border); }
  }
  .announce-more > summary { list-style: none; cursor: pointer; font-size: var(--fs-sm); color: var(--primary-ink); display: inline-flex; align-items: center; gap: .4rem;
    &::-webkit-details-marker { display: none; }
    & i { transition: rotate var(--t-med) var(--ease-spring); }
  }
  .announce-more[open] > summary i { rotate: 45deg; }
  .announce-more > .stack { margin-top: .75rem; }

  /* --- Notifications (grouped users) --- */
  .people { list-style: none; display: grid; gap: var(--space-4); font-size: var(--fs-sm);
    & > li > strong { display: block; font-weight: 600; color: var(--heading); margin-bottom: .35rem; }
    & ul { list-style: none; display: grid; gap: .35rem; padding-left: .75rem; border-left: 2px solid var(--border); }
    & .req { list-style: none; display: grid; gap: .15rem; padding: .2rem 0 0 .25rem; border: 0; font-size: var(--fs-xs); color: var(--muted);
      & li { display: flex; gap: .4rem; align-items: center; }
    }
  }
  .ok { color: var(--success); } .no { color: var(--danger); }
  .dl-pill { display: inline-flex; align-items: center; gap: .25rem; font-size: var(--fs-xs); font-weight: 600; margin-left: .35rem; font-variant-numeric: tabular-nums; }

  /* --- Comments thread --- */
  .thread { list-style: none; display: grid; gap: var(--space-3); }
  .comment {
    margin-left: calc(var(--depth, 0) * 1.5rem);
    display: grid; gap: .5rem; padding: .9rem 1rem; border-radius: var(--r-md);
    background: var(--surface-2); border: 1px solid var(--border);
    &.is-root { background: var(--primary-soft); border-color: transparent; }
    & p { font-size: var(--fs-sm); color: var(--text); }
    & footer { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
    & footer .btn { margin-left: auto; }
  }

  /* --- Forms --- */
  .form { display: grid; gap: var(--space-5); }
  .field { display: grid; gap: .4rem;
    & > label, & > .label { font-size: var(--fs-sm); font-weight: 600; color: var(--heading); }
    & .hint { font-size: var(--fs-xs); color: var(--muted); }
    & .error { display: none; font-size: var(--fs-xs); color: var(--danger); }
    &:has(:user-invalid) .error, &:has([aria-invalid="true"]) .error { display: block; }
  }
  .input, .select, .textarea {
    width: 100%; min-height: 44px; padding: .6rem .85rem;
    border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface);
    font-size: var(--fs-sm); color: var(--text);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    &::placeholder { color: var(--muted); }
    &:hover { border-color: var(--border-strong); }
    &:disabled { opacity: .6; cursor: not-allowed; background-color: var(--surface-2); border-color: var(--border); }
    &:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
    &:user-invalid, &[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in oklch, var(--danger) 18%, transparent); }
  }
  .select { appearance: none; padding-right: 2.25rem; cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
  }
  .textarea { field-sizing: content; min-height: 7.5rem; resize: vertical; line-height: 1.5; }
  .char-count { font-size: var(--fs-xs); color: var(--muted); justify-self: end; font-variant-numeric: tabular-nums; }

  input[type="checkbox"].check { inline-size: 18px; block-size: 18px; cursor: pointer; }

  /* Radio segmented (access flags) */
  .choice { display: inline-flex; padding: 4px; gap: 4px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap;
    & label { position: relative; display: inline-flex; align-items: center; gap: .5rem; padding: .5rem .95rem; border-radius: var(--r-sm); cursor: pointer; font-size: var(--fs-sm); font-weight: 500; color: var(--muted); transition: background var(--t-med) var(--ease-out), color var(--t-fast); }
    & input { position: absolute; opacity: 0; }
    & label:has(input:checked) { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
    & label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
  }

  /* Switch */
  input[type="checkbox"].switch {
    appearance: none; inline-size: 40px; block-size: 24px; border-radius: 99px; position: relative; cursor: pointer; flex: none;
    background: var(--border-strong); transition: background var(--t-med);
    &::before { content: ""; position: absolute; inset: 3px auto 3px 3px; aspect-ratio: 1; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: translate var(--t-med) var(--ease-spring); }
    &:checked { background: var(--primary); &::before { translate: 16px 0; } }
  }
  .switch-row { display: flex; align-items: center; gap: .75rem; font-size: var(--fs-sm); cursor: pointer; }

  /* Dropzone */
  .dropzone {
    position: relative; display: grid; place-items: center; gap: .5rem; text-align: center;
    padding: 2.25rem 1rem; border: 2px dashed var(--border-strong); border-radius: var(--r-lg);
    background: var(--surface-2); color: var(--muted); cursor: pointer;
    transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-med) var(--ease-out);
    & i { font-size: 1.75rem; color: var(--primary); transition: translate var(--t-med) var(--ease-spring); }
    & strong { color: var(--heading); font-weight: 600; }
    & input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
    &:hover, &.is-over, &:has(input:focus-visible) { border-color: var(--primary); background: var(--primary-soft); & i { translate: 0 -4px; } }
    &.is-over { transform: scale(1.01); }
  }
  .queue { list-style: none; display: grid; gap: .5rem;
    & li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; padding: .65rem .85rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); font-size: var(--fs-sm); animation: rise var(--t-med) var(--ease-out) both; }
    & .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
    & .size { color: var(--muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
    & progress { grid-column: 2 / -1; }
  }
  progress {
    appearance: none; inline-size: 100%; block-size: 8px; border: 0; border-radius: 99px; overflow: hidden; background: var(--surface-2);
    &::-webkit-progress-bar { background: var(--surface-2); }
    &::-webkit-progress-value { background: var(--primary); border-radius: 99px; transition: inline-size var(--t-slow) var(--ease-out); }
    &::-moz-progress-bar { background: var(--primary); border-radius: 99px; }
  }
  .steps { list-style: none; counter-reset: step; display: grid; gap: .75rem; font-size: var(--fs-sm);
    & > li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: .75rem; align-items: start; }
    & > li::before { content: counter(step); inline-size: 28px; block-size: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; font-size: var(--fs-xs); }
    & ul { list-style: none; display: grid; gap: .3rem; margin-top: .4rem; color: var(--muted); }
  }
  .table .center { text-align: center; }
  .table-scroll { max-height: var(--max-h, 320px); overflow: auto; position: relative; border: 1px solid var(--border); border-radius: var(--r-md);
    /* the whole thead sticks, so two-row headers stay stacked instead of overlapping */
    & thead { position: sticky; top: 0; z-index: 1; }
  }
  .panel > .table-scroll { border: 0; border-radius: 0; }

  /* --- Native <dialog> modal --- */
  dialog.modal {
    margin: auto; inline-size: min(100% - 2rem, 460px); padding: 0; border: 1px solid var(--border); border-radius: var(--r-lg);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
    opacity: 0; translate: 0 12px; scale: .97;
    transition: opacity var(--t-med) var(--ease-out), translate var(--t-med) var(--ease-out), scale var(--t-med) var(--ease-out), display var(--t-med) allow-discrete, overlay var(--t-med) allow-discrete;
    &[open] { opacity: 1; translate: 0 0; scale: 1; @starting-style { opacity: 0; translate: 0 12px; scale: .97; } }
    &::backdrop { background: rgb(15 23 42 / 0); backdrop-filter: blur(0); transition: background var(--t-med), backdrop-filter var(--t-med), display var(--t-med) allow-discrete, overlay var(--t-med) allow-discrete; }
    &[open]::backdrop { background: rgb(15 23 42 / .45); backdrop-filter: blur(4px); @starting-style { background: rgb(15 23 42 / 0); backdrop-filter: blur(0); } }
    & .panel-head { background: transparent; }
    & footer { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
  }
  .copy-field { display: flex; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden;
    & span { padding: .6rem .8rem; background: var(--surface-2); font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; display: grid; place-items: center; }
    & input { flex: 1; min-width: 0; border: 0; padding: .6rem .8rem; font: 500 var(--fs-sm) var(--mono); background: var(--surface); }
  }

  /* --- Document hero --- */
  .doc-title { font-size: clamp(1.4rem, 1rem + 1.4vw, 2rem); font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
  .doc-desc { font-size: var(--fs-lg); color: var(--text); font-weight: 300; }
  .qr { --ratio: 1; --w: 160px; justify-self: center; }
}

/* ==========================================================================
   Login
   ========================================================================== */
@layer components {
  .nav-note { margin-left: auto; font-size: var(--fs-sm); color: var(--muted); padding-inline: .75rem; text-align: right;
    & time { font-variant-numeric: tabular-nums; }
    @media (width < 760px) { & .when { display: none; } }
  }
  .login-grid { display: grid; gap: var(--space-6); grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); align-items: start;
    @media (width < 900px) { grid-template-columns: minmax(0, 1fr); }
  }
  .auth-card { display: grid; gap: var(--space-5); padding: var(--space-5);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-md);
    animation: rise var(--t-slow) var(--ease-out) both;
    & h2 { font-size: var(--fs-lg); display: flex; align-items: center; gap: .55rem; & i { color: var(--primary); font-size: .9em; } }
    & form { display: grid; gap: var(--space-3); }
    & .fine { font-size: var(--fs-xs); color: var(--muted); line-height: 1.5; }
  }
  .or { display: flex; align-items: center; gap: .75rem; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
    &::before, &::after { content: ""; flex: 1; height: 1px; background: var(--border); }
  }
  .btn-ms { --_bg: var(--surface); --_fg: var(--heading); --_bd: var(--border-strong); min-height: 52px; font-size: var(--fs-md); white-space: normal;
    & i { color: #0078d4; font-size: 1.1em; }
  }
  .input-lg { min-height: 52px; font-size: var(--fs-md); padding-inline: 1rem; }
  .input-icon { position: relative;
    & > i { position: absolute; left: 1rem; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; transition: color var(--t-fast); }
    & .input { padding-left: 2.6rem; }
    & .reveal { position: absolute; right: .4rem; top: 50%; translate: 0 -50%; }
    &:focus-within > i { color: var(--primary); }
    &:has(.input:user-invalid) > i, &:has(.input[aria-invalid="true"]) > i { color: var(--danger); }
  }
  .mini-details { font-size: var(--fs-sm);
    & > summary { cursor: pointer; list-style: none; color: var(--primary-ink); display: inline-flex; align-items: center; gap: .4rem; font-weight: 500;
      &::-webkit-details-marker { display: none; }
      &::before { content: ""; inline-size: .45em; block-size: .45em; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; rotate: -45deg; transition: rotate var(--t-med) var(--ease-spring); }
    }
    &[open] > summary::before { rotate: 45deg; }
    & > :not(summary) { margin-top: .5rem; color: var(--muted); line-height: 1.55; }
    &::details-content { block-size: 0; overflow: clip; transition: block-size var(--t-med) var(--ease-out), content-visibility var(--t-med) allow-discrete; }
    &[open]::details-content { block-size: auto; }
  }
  .promo { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--space-6); align-items: start; padding: var(--space-6);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
    animation: rise var(--t-slow) var(--ease-out) 80ms both;
    & img { width: 100%; height: auto; border-radius: var(--r-md); box-shadow: var(--shadow-md); transition: transform var(--t-slow) var(--ease-out); }
    & a:hover img { transform: scale(1.02); }
    & h2 { font-size: var(--fs-2xl); font-weight: 300; color: var(--primary-ink); margin-bottom: var(--space-4); }
    & h3 { font-size: var(--fs-lg); margin: var(--space-5) 0 var(--space-2); }
    & p { margin-bottom: var(--space-3); }
    @container (width < 720px) { grid-template-columns: minmax(0, 1fr); }
  }
  .promo-wrap { container-type: inline-size; }
  .social { display: flex; gap: .75rem; margin-top: var(--space-3);
    & a { display: grid; place-items: center; inline-size: 40px; block-size: 40px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); transition: translate var(--t-med) var(--ease-spring), box-shadow var(--t-med); }
    & a:hover { translate: 0 -2px; box-shadow: var(--shadow-md); }
    & img { width: 22px; height: 22px; }
  }
}

/* ==========================================================================
   Add Comment / Add Announcement
   ========================================================================== */
@layer components {
  .form-narrow { max-width: 760px; }
  .picker { display: grid; gap: var(--space-3); container-type: inline-size; }
  .picker-toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-size: var(--fs-sm);
    & .input { min-height: 38px; flex: 1; min-width: 180px; max-width: 280px; }
  }
  .picker-groups { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
  .picker-group { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: clip;
    & > header { display: flex; align-items: center; gap: .6rem; padding: .6rem .85rem; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); font-weight: 600; color: var(--heading); cursor: pointer; }
    & > header .badge { margin-left: auto; }
    & ul { list-style: none; display: grid; padding: .35rem; }
    & li label { display: flex; align-items: center; gap: .6rem; padding: .45rem .5rem; border-radius: var(--r-sm); font-size: var(--fs-sm); cursor: pointer; transition: background var(--t-fast); }
    & li label:hover { background: var(--primary-soft); }
    & li label:has(input:checked) { color: var(--heading); font-weight: 500; }
    & li label:has(input:disabled) { cursor: default; color: var(--muted); }
    & .tag { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); font-weight: 400; }
    &:has(input:checked) { border-color: color-mix(in oklch, var(--primary) 45%, var(--border)); }
  }
  .quote { display: grid; gap: .5rem; padding: 1rem 1.1rem; border-radius: var(--r-md); background: var(--primary-soft); border-left: 0; position: relative;
    & p { font-size: var(--fs-sm); color: var(--text); }
    & footer { display: flex; gap: .9rem; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
    &::before { content: "\201C"; position: absolute; top: -.2rem; right: .8rem; font-size: 3rem; line-height: 1; color: color-mix(in oklch, var(--primary) 30%, transparent); font-family: Georgia, serif; }
  }
  .form-actions { display: flex; gap: .6rem; flex-wrap: wrap; padding-top: var(--space-2); }
  .success-hero { display: grid; justify-items: start; gap: var(--space-3); animation: rise var(--t-slow) var(--ease-out) both;
    & .check-badge { inline-size: 48px; block-size: 48px; border-radius: 50%; display: grid; place-items: center; background: light-dark(#dcfce7, #10301c); color: var(--success); font-size: 1.35rem; animation: pop .5s var(--ease-spring) both; }
  }
  @keyframes pop { from { scale: .4; opacity: 0; } to { scale: 1; opacity: 1; } }
  .notified { list-style: none; display: grid; gap: .4rem; font-size: var(--fs-sm);
    & li { display: flex; align-items: center; gap: .6rem; animation: rise var(--t-med) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 40ms); }
    & li > i { color: var(--muted); width: 1.1em; text-align: center; }
    & .tag { font-size: var(--fs-xs); }
  }
}

/* ==========================================================================
   DataTables skin — only for the few pages that keep DataTables (LOCAL.uiDataTables) for search, sort and paging on
   long admin / report / location lists. DataTables' own stylesheet is not loaded.
   ========================================================================== */
@layer components {
  .dataTables_wrapper {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3);
    font-size: var(--fs-sm);
    /* only the controls are muted; the table inside the wrapper keeps the normal text colour */
    & :is(.dataTables_length, .dataTables_filter, .dataTables_info, .dataTables_paginate) { color: var(--muted); }
    & > table.dataTable, & > .dataTables_scroll { flex: 1 0 100%; }
    & :is(.dataTables_length select, .dataTables_filter input) {
      min-height: 36px; padding: .35rem .7rem; margin-inline: .35rem; border: 1px solid var(--border); border-radius: var(--r-sm);
      background: var(--surface); color: var(--text); font-size: var(--fs-sm);
      &:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
    }
    & .dataTables_paginate { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
    & .paginate_button {
      min-width: 32px; padding: .3rem .6rem; border: 1px solid var(--border); border-radius: var(--r-sm);
      background: var(--surface); color: var(--text); text-align: center; cursor: pointer;
      &:hover { background: var(--primary-soft); color: var(--primary-ink); text-decoration: none; }
      &.current { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
      &.disabled { opacity: .45; pointer-events: none; }
    }
    & .ellipsis { padding-inline: .35rem; }
    & .dataTables_processing { color: var(--primary-ink); }
  }
  table.dataTable { width: 100% !important;
    & thead :is(.sorting, .sorting_asc, .sorting_desc) { cursor: pointer; padding-right: 1.6rem; position: relative; }
    & thead :is(.sorting, .sorting_asc, .sorting_desc)::after { position: absolute; right: .6rem; top: 50%; translate: 0 -50%; color: var(--border-strong); font-size: .85em; }
    & thead .sorting::after { content: "\2195"; }
    & thead .sorting_asc::after { content: "\2191"; color: var(--primary); }
    & thead .sorting_desc::after { content: "\2193"; color: var(--primary); }
    & tbody tr.selected { background: var(--primary-soft); }
    & td.dataTables_empty { text-align: center; color: var(--muted); }
    /* Responsive extension: the +/- control in the first cell and the child-row details */
    &.dtr-inline.collapsed > tbody > tr > td:first-child { position: relative; padding-left: 2.2rem; cursor: pointer; }
    &.dtr-inline.collapsed > tbody > tr > td:first-child::before {
      content: "+"; position: absolute; left: .6rem; top: 50%; translate: 0 -50%; inline-size: 1.15rem; block-size: 1.15rem;
      display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-weight: 600; font-size: .8rem; line-height: 1;
    }
    &.dtr-inline.collapsed > tbody > tr.parent > td:first-child::before { content: "\2212"; background: var(--danger); }
    & > tbody > tr.child ul.dtr-details { list-style: none; display: grid; gap: .35rem; }
    & > tbody > tr.child span.dtr-title { font-weight: 600; margin-right: .5rem; color: var(--heading); }
  }
}

/* ==========================================================================
   jQuery UI autocomplete skin — the admin and report pages still use jQuery UI 1.11 autocomplete for company / user /
   project look-ups. jQuery UI's own stylesheet is not loaded, so the menu and its screen-reader live region are styled here.
   ========================================================================== */
@layer components {
  .ui-helper-hidden-accessible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .ui-autocomplete {
    position: absolute; top: 0; left: 0; z-index: 60; list-style: none; cursor: default;
    max-height: min(50dvh, 22rem); overflow-y: auto; overscroll-behavior: contain; padding: .35rem;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-md);
    box-shadow: var(--shadow-lg); font-size: var(--fs-sm);
    & .ui-menu-item { list-style: none; padding: .45rem .6rem; border-radius: var(--r-sm); cursor: pointer; line-height: 1.35; }
    & .ui-menu-item a { display: block; color: inherit; text-decoration: none; }
    & .text-muted { color: var(--muted); }
    & .ui-state-focus, & .ui-state-active { background: var(--primary-soft); color: var(--primary-ink); }
  }
}
