/*
 * Port of the platform design (girisimg/platform @ c739774, apps/web):
 *   - tokens: apps/web/src/index.css (shadcn neutral, oklch) — copied verbatim, test-pinned;
 *   - components: apps/web/src/shared/ui/{button,badge,card,input,textarea,table,skeleton,states}.tsx;
 *   - shell: apps/web/src/shell/layout/app-layout.tsx.
 * Class names map 1:1 to those components. No new tokens are introduced except Tailwind v4
 * defaults the platform already uses (emerald-700 for positive badges, red-50/950 in ErrorState).
 */

/* ---------------------------------------------------------------- tokens (index.css :root) */
:root {
  --radius: 0.625rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary: oklch(0.205 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.97 0 0);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-ring: oklch(0.708 0 0);
  /* Tailwind v4 defaults used by platform components */
  --emerald-700: oklch(0.508 0.118 165.612);
  --red-50: oklch(0.971 0.013 17.38);
  --red-950: oklch(0.258 0.092 26.042);
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.4);
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color-scheme: light;
}

/* index.css `.dark` — applied by system preference (the platform toggles the same tokens via .dark) */
@media (prefers-color-scheme: dark) {
  :root {
    --background: oklch(0.145 0 0);
    --foreground: oklch(0.985 0 0);
    --card: oklch(0.205 0 0);
    --card-foreground: oklch(0.985 0 0);
    --popover: oklch(0.205 0 0);
    --popover-foreground: oklch(0.985 0 0);
    --primary: oklch(0.922 0 0);
    --primary-foreground: oklch(0.205 0 0);
    --secondary: oklch(0.269 0 0);
    --secondary-foreground: oklch(0.985 0 0);
    --muted: oklch(0.269 0 0);
    --muted-foreground: oklch(0.708 0 0);
    --accent: oklch(0.269 0 0);
    --accent-foreground: oklch(0.985 0 0);
    --destructive: oklch(0.704 0.191 22.216);
    --border: oklch(1 0 0 / 10%);
    --input: oklch(1 0 0 / 15%);
    --ring: oklch(0.556 0 0);
    --sidebar: oklch(0.205 0 0);
    --sidebar-foreground: oklch(0.985 0 0);
    --sidebar-primary: oklch(0.488 0.243 264.376);
    --sidebar-primary-foreground: oklch(0.985 0 0);
    --sidebar-accent: oklch(0.269 0 0);
    --sidebar-accent-foreground: oklch(0.985 0 0);
    --sidebar-border: oklch(1 0 0 / 10%);
    --sidebar-ring: oklch(0.556 0 0);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- base (preflight + @layer base) */
*, *::before, *::after { box-sizing: border-box; border: 0 solid var(--border); margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; font-family: var(--font-sans); line-height: 1.5; }
body { background: var(--background); color: var(--foreground); font-size: 1rem; line-height: 1.5rem; min-height: 100svh; }
a { color: inherit; }
a:not([class]) { text-decoration: underline; text-underline-offset: 4px; }
img, svg { display: block; vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid color-mix(in oklab, var(--ring) 50%, transparent); outline-offset: 2px; }
code, .mono { font-family: var(--font-mono); font-size: 0.875em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; }
.icon { flex-shrink: 0; }
.size-3 { width: 0.75rem; height: 0.75rem; } .size-4 { width: 1rem; height: 1rem; } .size-5 { width: 1.25rem; height: 1.25rem; }
.size-6 { width: 1.5rem; height: 1.5rem; } .size-10 { width: 2.5rem; height: 2.5rem; } .size-12 { width: 3rem; height: 3rem; }
.muted { color: var(--muted-foreground); }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; } .text-xs { font-size: 0.75rem; line-height: 1rem; } .text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; }
.stack > * + * { margin-top: 1.5rem; } .stack-sm > * + * { margin-top: 0.75rem; } .stack-xs > * + * { margin-top: 0.375rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.grid-2 { display: grid; gap: 1.5rem; } .grid-3 { display: grid; gap: 1.5rem; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.wrap { white-space: normal; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- shell (app-layout.tsx)
 * Breakpoints (Tailwind v4 defaults used by platform; CSS custom properties cannot drive @media):
 *   sm 640px · md 768px · lg 1024px. Plus content-driven 480px for single-column key/value and card headers.
 * The persistent sidebar starts at lg (1024px), not platform's md: at 768-1023px a 16rem sidebar left 512-767px for
 * header + content and collapsed the header (docs/admin-responsive-update/RESPONSIVE_ROOT_CAUSE.md). Below lg the same
 * nav opens in a modal drawer (platform <Sheet side="left" className="w-72">), built on native <dialog>.
 * z-index scale: topbar 40, account menu 45, drawer/dialog top layer (native), skip link 70.
 */
/* platform: sr-only focus:not-sr-only focus:absolute focus:top-2 focus:left-2 focus:z-50 */
.skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.skip-link:focus { position: absolute; left: 0.5rem; top: 0.5rem; z-index: 70; border-radius: var(--radius-md); background: var(--background); padding: 0.75rem; }
.app { min-height: 100svh; background: var(--background); }
@media (min-width: 1024px) { .app { display: grid; grid-template-columns: 16rem minmax(0, 1fr); } }
.sidebar { display: none; border-right: 1px solid var(--sidebar-border); background: var(--sidebar); color: var(--sidebar-foreground); padding: 1rem; }
@media (min-width: 1024px) { .sidebar { display: block; position: sticky; top: 0; height: 100svh; overflow-y: auto; overscroll-behavior: contain; } }
.app-name { margin-bottom: 1.5rem; padding: 0 0.75rem; font-size: 1.125rem; line-height: 1.75rem; font-weight: 600; overflow-wrap: anywhere; }
.nav { display: flex; flex-direction: column; gap: 1rem; }
.nav ul { list-style: none; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-group-label { padding: 0 0.75rem 0.25rem; font-size: 0.875rem; line-height: 1.25rem; font-weight: 600; letter-spacing: 0.025em; text-transform: uppercase; color: var(--muted-foreground); }
.nav-link { display: flex; align-items: center; gap: 0.75rem; min-height: 2.75rem; border-radius: var(--radius-md); padding: 0.625rem 0.75rem; font-size: 1rem; line-height: 1.5rem; font-weight: 500; color: var(--sidebar-foreground); text-decoration: none; }
.nav-text { min-width: 0; overflow-wrap: anywhere; } /* long / translated labels wrap inside the 16rem rail */
.nav-link:hover { background: var(--sidebar-accent); }
.nav-link:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.nav-link[aria-current="page"] { background: var(--sidebar-primary); color: var(--sidebar-primary-foreground); }
.main-col { display: flex; min-width: 0; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 40; display: flex; height: 4rem; min-width: 0; align-items: center; gap: 0.5rem; border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--background) 95%, transparent); backdrop-filter: blur(8px); padding: 0 1rem; }
@media (min-width: 768px) { .topbar { padding: 0 2rem; } }
.topbar-title { min-width: 0; flex: 1 1 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
/* menu trigger: only below lg, and only when JS can open the drawer (no-JS fallback is the <noscript> disclosure) */
.topbar .menu-trigger { display: none; } /* scoped: must beat .btn's display, which comes later in the cascade */
@media (max-width: 1023.98px) { .js .topbar .menu-trigger { display: inline-flex; } }
.nojs-nav { position: relative; flex: none; }
@media (min-width: 1024px) { .nojs-nav { display: none; } }
.nojs-nav > summary { list-style: none; } .nojs-nav > summary::-webkit-details-marker { display: none; }
.nojs-sheet { position: absolute; top: 3rem; left: 0; width: min(18rem, calc(100svw - 2rem)); background: var(--sidebar); border: 1px solid var(--sidebar-border); border-radius: var(--radius-lg); padding: 1rem; box-shadow: var(--shadow-sm); }

/* drawer: native modal <dialog> (focus containment, Escape, inert background, top layer) */
.drawer { position: fixed; inset: 0 auto 0 0; margin: 0; width: min(18rem, calc(100% - 3rem)); max-width: none; height: 100%; max-height: none;
  overflow-y: auto; overscroll-behavior: contain; border: 0; border-right: 1px solid var(--sidebar-border); background: var(--sidebar);
  color: var(--sidebar-foreground); padding: 1rem; box-shadow: var(--shadow-sm); }
.drawer::backdrop { background: rgb(0 0 0 / 0.5); }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; margin-bottom: 1rem; }
.drawer-header .app-name { margin-bottom: 0; padding-top: 0.25rem; min-width: 0; }
html.drawer-open { overflow: hidden; } /* scroll lock only while the modal drawer is open */
@media (prefers-reduced-motion: no-preference) { .drawer[open] { animation: drawer-in 150ms ease-out; } }
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: none; } }

/* account menu (platform UserMenu: name visible from sm, everything else inside the menu) */
.account-menu { position: relative; flex: none; min-width: 0; }
.account-menu > summary { list-style: none; } .account-menu > summary::-webkit-details-marker { display: none; }
.account-trigger { max-width: 16rem; }
.account-name { display: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 640px) { .account-name { display: inline; max-width: 12rem; } }
.menu-panel { position: absolute; right: 0; top: calc(100% + 0.25rem); z-index: 45; width: min(16rem, calc(100svw - 2rem)); border: 1px solid var(--border);
  border-radius: var(--radius-md); background: var(--popover); color: var(--popover-foreground); padding: 0.25rem; box-shadow: var(--shadow-sm); }
.menu-label { padding: 0.5rem; border-bottom: 1px solid var(--border); margin-bottom: 0.25rem; }
.menu-item { display: flex; width: 100%; align-items: center; gap: 0.5rem; min-height: 2.75rem; border-radius: var(--radius-sm); padding: 0.375rem 0.5rem; font-size: 1rem;
  text-decoration: none; background: transparent; cursor: pointer; text-align: left; }
.menu-item:hover, .menu-item:focus-visible { background: var(--accent); color: var(--accent-foreground); outline: none; }

main#main { margin: 0 auto; width: 100%; min-width: 0; max-width: 72rem; flex: 1; padding: 1rem; }
@media (min-width: 768px) { main#main { padding: 2rem; } }
main#main:focus { outline: none; }

/* ---------------------------------------------------------------- button.tsx */
.btn { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; gap: 0.5rem; border-radius: var(--radius-md); font-size: 1rem;
  line-height: 1.5rem; font-weight: 500; white-space: nowrap; transition: all 150ms; height: 2.5rem; padding: 0.5rem 1rem; cursor: pointer;
  text-decoration: none; border: 1px solid transparent; }
.btn:focus-visible { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent); }
.btn:disabled, .btn[aria-disabled="true"] { pointer-events: none; opacity: 0.5; }
.btn .icon { width: 1rem; height: 1rem; }
.btn-default { background: var(--primary); color: var(--primary-foreground); }
.btn-default:hover { background: color-mix(in oklab, var(--primary) 90%, transparent); }
.btn-destructive { background: var(--destructive); color: #fff; }
.btn-destructive:hover { background: color-mix(in oklab, var(--destructive) 90%, transparent); }
.btn-outline { border-color: var(--border); background: var(--background); box-shadow: var(--shadow-xs); }
.btn-outline:hover, .btn-ghost:hover { background: var(--accent); color: var(--accent-foreground); }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover { background: color-mix(in oklab, var(--secondary) 80%, transparent); }
.btn-ghost { background: transparent; }
.btn-link { background: transparent; color: var(--primary); text-underline-offset: 4px; height: auto; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.btn-sm { height: 2rem; gap: 0.375rem; padding: 0 0.75rem; }
.btn-icon { width: 2.25rem; height: 2.25rem; padding: 0; }

/* ---------------------------------------------------------------- badge.tsx (+ status-badge.tsx tones) */
.badge { display: inline-flex; width: fit-content; flex-shrink: 0; align-items: center; justify-content: center; gap: 0.25rem; overflow: hidden;
  border-radius: 9999px; border: 1px solid transparent; padding: 0.125rem 0.5rem; font-size: 0.75rem; line-height: 1rem; font-weight: 500; white-space: nowrap; }
.badge .icon { width: 0.75rem; height: 0.75rem; }
.badge-default { background: var(--primary); color: var(--primary-foreground); }
.badge-secondary, .badge-progress { background: var(--secondary); color: var(--secondary-foreground); }
.badge-outline, .badge-neutral, .badge-warning { border-color: var(--border); color: var(--foreground); }
.badge-positive { background: var(--emerald-700); color: #fff; }
.badge-destructive, .badge-negative { background: var(--destructive); color: #fff; }
/* platform: dark:bg-destructive/60 on Badge and Button */
@media (prefers-color-scheme: dark) { .badge-destructive, .badge-negative, .btn-destructive { background: color-mix(in oklab, var(--destructive) 60%, var(--background)); } }
a.badge { text-decoration: none; }
a.badge:hover { background: var(--accent); color: var(--accent-foreground); }

/* ---------------------------------------------------------------- card.tsx */
.card { display: flex; flex-direction: column; gap: 1.5rem; border-radius: var(--radius-xl); border: 1px solid var(--border); background: var(--card);
  padding: 1.5rem 0; color: var(--card-foreground); box-shadow: var(--shadow-sm); min-width: 0; }
.card-header { display: grid; gap: 0.5rem; padding: 0 1.5rem; }
.card-header.with-action { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
@media (max-width: 479.98px) { .card-header.with-action { grid-template-columns: minmax(0, 1fr); } }
.card-title { line-height: 1; font-weight: 600; }
h2.card-title, h3.card-title { font-size: 1rem; }
.card-description { font-size: 0.875rem; line-height: 1.25rem; color: var(--muted-foreground); }
.card-content { padding: 0 1.5rem; min-width: 0; }
.card-footer { display: flex; align-items: center; gap: 0.5rem; padding: 0 1.5rem; flex-wrap: wrap; }

/* ---------------------------------------------------------------- input / textarea / select / label / checkbox */
.input, .textarea, .select { width: 100%; min-width: 0; border-radius: var(--radius-md); border: 1px solid var(--input); background: transparent;
  padding: 0.25rem 0.75rem; font-size: 1rem; line-height: 1.5rem; box-shadow: var(--shadow-xs); transition: color 150ms, box-shadow 150ms; }
.input, .select { height: 2.5rem; }
.select { padding-right: 2rem; appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.textarea { min-height: 4rem; padding: 0.5rem 0.75rem; resize: vertical; }
.textarea.tall { min-height: 16rem; }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--destructive); }
.input::placeholder, .textarea::placeholder { color: var(--muted-foreground); }
.input[type="file"] { padding-top: 0.375rem; }
.label { display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; line-height: 1; font-weight: 500; }
.field { display: grid; gap: 0.5rem; }
.hint { font-size: 0.875rem; line-height: 1.25rem; color: var(--muted-foreground); }
.checkbox { width: 1rem; height: 1rem; flex-shrink: 0; border-radius: 4px; accent-color: var(--primary); }
.checks { display: grid; gap: 0.5rem; }
.check { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.875rem; line-height: 1.25rem; }
.check input { margin-top: 0.125rem; }
fieldset { border: 0; min-width: 0; }
legend { font-weight: 500; margin-bottom: 0.5rem; }

/* ---------------------------------------------------------------- table.tsx */
.table-container { position: relative; width: 100%; overflow-x: auto;
  /* scroll affordance: edge shadows appear only when content is clipped (background-attachment: local/scroll) */
  background: linear-gradient(to right, var(--card), var(--card)) left / 1rem 100% no-repeat local,
              linear-gradient(to left, var(--card), var(--card)) right / 1rem 100% no-repeat local,
              radial-gradient(farthest-side at 0 50%, rgb(0 0 0 / 0.14), transparent) left / 0.5rem 100% no-repeat scroll,
              radial-gradient(farthest-side at 100% 50%, rgb(0 0 0 / 0.14), transparent) right / 0.5rem 100% no-repeat scroll; }
.table-container[tabindex]:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.table { width: 100%; caption-side: bottom; font-size: 1rem; border-collapse: collapse; }
.table thead tr { border-bottom: 1px solid var(--border); }
.table tbody tr { border-bottom: 1px solid var(--border); transition: background-color 150ms; }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in oklab, var(--muted) 50%, transparent); }
.table th { height: 2.5rem; padding: 0 0.5rem; text-align: left; vertical-align: middle; font-weight: 500; white-space: nowrap; color: var(--foreground); }
.table td { padding: 0.5rem; vertical-align: top; }
.table td.nowrap, .table th.nowrap { white-space: nowrap; }
.table caption { margin-top: 1rem; font-size: 0.875rem; color: var(--muted-foreground); }

/* ---------------------------------------------------------------- states.tsx / status-pages.tsx / skeleton.tsx */
.page-header { margin-bottom: 1.5rem; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.page-header h1 { font-size: 1.5rem; line-height: 2rem; font-weight: 600; letter-spacing: -0.025em; }
@media (min-width: 768px) { .page-header h1 { font-size: 1.875rem; line-height: 2.25rem; } }
.page-header p { color: var(--muted-foreground); }
.page-header .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
h2.section { font-size: 1.25rem; line-height: 1.75rem; font-weight: 600; letter-spacing: -0.025em; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; border-radius: var(--radius-lg); border: 1px dashed var(--border); padding: 2rem; text-align: center; }
.empty-state .icon { width: 2.5rem; height: 2.5rem; color: var(--muted-foreground); }
.empty-state .title { font-size: 1.125rem; line-height: 1.75rem; font-weight: 500; }
.empty-state .desc { max-width: 28rem; color: var(--muted-foreground); }
.error-state { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; border-radius: var(--radius-lg); border: 1px solid color-mix(in oklab, var(--destructive) 40%, transparent);
  background: var(--red-50); padding: 2rem; text-align: center; color: var(--red-950); }
.error-state .icon { width: 2.5rem; height: 2.5rem; color: var(--destructive); }
.error-state .title { font-size: 1.125rem; line-height: 1.75rem; font-weight: 500; }
.status-view { margin: 0 auto; display: flex; max-width: 32rem; flex-direction: column; align-items: center; gap: 1rem; padding: 4rem 0; text-align: center; }
.status-view > .icon { width: 3rem; height: 3rem; color: var(--muted-foreground); }
.status-view h1 { font-size: 1.5rem; line-height: 2rem; font-weight: 600; }
.status-view p { font-size: 1.125rem; line-height: 1.75rem; color: var(--muted-foreground); }
.skeleton { border-radius: var(--radius-md); background: var(--accent); animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; height: 1rem; }
@keyframes pulse { 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { transition: none !important; } }

/* Inline notices: error-state tones (destructive) and neutral; always with icon + text */
.notice { display: flex; gap: 0.75rem; align-items: flex-start; border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 0.75rem 1rem; }
.notice .icon { width: 1.25rem; height: 1.25rem; margin-top: 0.125rem; }
.notice-error { border-color: color-mix(in oklab, var(--destructive) 40%, transparent); background: var(--red-50); color: var(--red-950); }
.notice-error .icon { color: var(--destructive); }
.notice-warning { background: var(--muted); color: var(--foreground); }
/* muted-foreground on muted is 4.34:1 (below AA): use foreground text on muted surfaces */
.notice-warning .muted, .segment[data-candidate] .loc, .segment:target .loc { color: var(--foreground); }

/* ---------------------------------------------------------------- page-specific, built from the same tokens */
.kv { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 0.375rem 1rem; font-size: 0.875rem; line-height: 1.25rem; }
.kv dt { color: var(--muted-foreground); }
.kv dd { overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 479.98px) { .kv { grid-template-columns: minmax(0, 1fr); } .kv dd { margin-bottom: 0.375rem; } }
.statement { display: grid; gap: 0.375rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.statement:last-child { border-bottom: 0; }
.ids { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.stat { display: grid; gap: 0.25rem; }
.stat .value { font-size: 1.5rem; line-height: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.review-grid { display: grid; gap: 1.5rem; }
@media (min-width: 1024px) { .review-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); } .review-source { position: sticky; top: 5rem; max-height: calc(100svh - 6rem); overflow-y: auto; } }
.segment { padding: 0.5rem 0.75rem; border-left: 3px solid transparent; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.segment[data-candidate] { border-left-color: var(--ring); background: color-mix(in oklab, var(--muted) 60%, transparent); }
.segment:target { border-left-color: var(--primary); background: var(--accent); }
.segment .loc { font-size: 0.75rem; color: var(--muted-foreground); }
.source-text { white-space: pre-wrap; font-size: 0.875rem; line-height: 1.5rem; max-height: 32rem; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem; }
.timeline { list-style: none; display: grid; gap: 0.5rem; }
.timeline li { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; font-size: 0.875rem; }
.delta-up::before { content: "▲ "; } .delta-down::before { content: "▼ "; }
.pagination { display: flex; flex-wrap: wrap; width: 100%; align-items: center; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }
.filters { display: grid; gap: 0.75rem; }
@media (min-width: 768px) { .filters { grid-template-columns: 2fr 1fr 1fr 1fr auto; align-items: end; }
  .filters.filters-3 { grid-template-columns: 2fr 1fr 1fr auto; } .filters.filters-4 { grid-template-columns: 1.5fr 1fr 1fr auto auto; } }
.filters-check { align-self: center; }
details.disclosure > summary { cursor: pointer; font-weight: 500; }
details.disclosure > summary:focus-visible { outline: 2px solid var(--ring); border-radius: var(--radius-sm); }
.login-wrap { min-height: calc(100svh - 3.5rem); display: grid; place-items: center; padding: 1rem; background: var(--background); }
.login-card { width: 100%; max-width: 24rem; }

/* ---------------------------------------------------------------- touch targets (WCAG 2.5.8; 44px on coarse pointers) */
.btn-icon { min-width: 2.5rem; min-height: 2.5rem; } /* must precede the coarse-pointer block below */
@media (pointer: coarse) {
  .btn, .btn-sm { min-height: 2.75rem; } .btn-icon { min-width: 2.75rem; min-height: 2.75rem; }
  .check { min-height: 2.75rem; align-items: center; } .check input { margin-top: 0; }
  .checkbox { width: 1.25rem; height: 1.25rem; }
}
/* ---------------------------------------------------------------- self-review + forbidden state */
.self-review-ack { border: 1px dashed var(--destructive); border-radius: var(--radius-md); padding: 0.75rem; display: grid; gap: 0.5rem; }
.self-review-ack legend { padding: 0 0.25rem; margin-bottom: 0; }
.status-detail { width: 100%; text-align: left; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; }
.status-view .status-detail p { font-size: 0.875rem; line-height: 1.25rem; color: var(--foreground); }
.status-actions { justify-content: center; }

/* ---------------------------------------------------------------- admin panel */
.member-cards { list-style: none; display: grid; gap: 0.75rem; }
.member-card { display: grid; gap: 0.5rem; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; min-width: 0; }
.member-card .btn { justify-self: start; }
.member-card-head { justify-content: space-between; }
.perm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; max-width: 100%; }
.perm code { overflow-wrap: anywhere; }
.perm-list { list-style: none; display: grid; }
.perm-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.75rem; align-items: start; padding: 0.625rem 0; border-bottom: 1px solid var(--border); }
.perm-row:last-child { border-bottom: 0; }
.perm-row[data-has="no"] .perm-body { color: var(--muted-foreground); }
.perm-row[data-has="no"] .perm-body .muted { color: var(--muted-foreground); }
.perm-mark { padding-top: 0.125rem; }
.perm-change { display: block; }
.matrix { table-layout: fixed; min-width: 18rem; }
.matrix .matrix-perm { white-space: normal; font-weight: 400; vertical-align: top; padding: 0.625rem 0.5rem; overflow-wrap: anywhere; }
.matrix .matrix-role { width: 4.75rem; text-align: center; white-space: normal; overflow-wrap: anywhere; }
.matrix .matrix-cell { text-align: center; vertical-align: middle; }
.matrix .matrix-cell .icon { display: inline-block; vertical-align: -2px; margin-right: 0.125rem; }
/* < 480px: each permission becomes a stacked card with labelled role cells (no squeezed columns, no clipping) */
@media (max-width: 479.98px) {
  .matrix, .matrix tbody, .matrix tr, .matrix th, .matrix td { display: block; width: auto; min-width: 0; }
  .matrix thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .matrix tbody tr { padding: 0.5rem 0; }
  .matrix .matrix-perm { padding: 0.25rem 0; }
  .matrix .matrix-perm .hint { display: none; }
  .matrix .matrix-perm .perm { display: flex; margin-top: 0.25rem; }
  .matrix .matrix-cell { display: flex; align-items: center; gap: 0.25rem; text-align: left; padding: 0.25rem 0; }
  .matrix .matrix-cell::before { content: attr(data-role); color: var(--muted-foreground); margin-right: auto; }
}
.audit-list { list-style: none; display: grid; }
.audit-item { display: grid; gap: 0.25rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); min-width: 0; }
.audit-item:last-child { border-bottom: 0; }
.audit-item[data-high="yes"] { border-left: 3px solid var(--primary); padding-left: 0.75rem; }

/* ---------------------------------------------------------------- visibility utilities (last + doubled class: must win over component display rules) */
.only-wide.only-wide { display: none; }
@media (min-width: 768px) { .only-narrow.only-narrow { display: none; } .only-wide.only-wide { display: block; } }

/* Language switch (src/teamui/i18n.py). Unauthenticated pages: top bar; signed in: inside the account menu. */
.lang-switch { margin: 0; }
.bare-top { display: flex; justify-content: flex-end; padding: 0.5rem 0.75rem; min-height: 3.5rem; align-items: center; }
