/**
 * shadcn-html — Token Layer
 * Semantic CSS custom properties matching the tweakcn.com export format.
 * OKLCH color space. Full surface/foreground pair model.
 *
 * Export a theme from tweakcn.com, replace the :root and .dark blocks,
 * and every component rethemes instantly.
 */

:root {
  color-scheme: light;

  /* -- Surface / Foreground pairs ------------------------------ */
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --canvas: oklch(0.975 0.003 264);

  --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);
  --destructive-foreground: oklch(1 0 0);

  --success: oklch(0.627 0.1694 149.214);
  --success-foreground: oklch(1 0 0);
  --warning: oklch(0.759 0.156 70.42);
  --warning-foreground: oklch(0.278 0.077 62);

  /* -- Utility tokens ------------------------------------------- */
  --border: oklch(0.918 0.004 264);
  --input: oklch(0.918 0.004 264);
  --ring: oklch(0.585 0.233 264);

  /* -- Brand ---------------------------------------------------- */
  --brand: oklch(0.585 0.233 264);
  --brand-foreground: oklch(1 0 0);

  /* -- Sidebar tokens ------------------------------------------- */
  --sidebar: oklch(0.995 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.968 0.004 264);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.918 0.004 264);
  --sidebar-ring: oklch(0.585 0.233 264);

  /* -- Chart tokens --------------------------------------------- */
  --chart-1: oklch(0.81 0.1 252);
  --chart-2: oklch(0.62 0.19 260);
  --chart-3: oklch(0.55 0.22 263);
  --chart-4: oklch(0.49 0.22 264);
  --chart-5: oklch(0.42 0.18 266);

  /* -- Typography tokens ---------------------------------------- */
  --font-sans:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;

  /* -- Radius --------------------------------------------------- */
  --radius: 0.625rem;
  /* Derived — matches tweakcn/shadcn scale */
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);

  /* -- Spacing -------------------------------------------------- */
  --spacing: 0.25rem;

  /* -- Tracking ------------------------------------------------- */
  --tracking-normal: 0em;

  /* -- Shadow scale --------------------------------------------- */
  --shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
  --shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
  --shadow-sm:
    0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1);
  --shadow: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1);
  --shadow-md:
    0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 2px 4px -1px hsl(0 0% 0% / 0.1);
  --shadow-lg:
    0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 4px 6px -1px hsl(0 0% 0% / 0.1);
  --shadow-xl:
    0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 8px 10px -1px hsl(0 0% 0% / 0.1);
  --shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / 0.25);
}

/* -- Dark mode -------------------------------------------------- */
.dark {
  color-scheme: dark;

  --background: oklch(0.155 0.004 264);
  --foreground: oklch(0.985 0 0);
  --canvas: oklch(0.125 0.003 264);

  --card: oklch(0.195 0.005 264);
  --card-foreground: oklch(0.985 0 0);

  --popover: oklch(0.215 0.006 264);
  --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.371 0 0);
  --accent-foreground: oklch(0.985 0 0);

  --destructive: oklch(0.704 0.191 22.216);
  --destructive-foreground: oklch(0.985 0 0);

  --success: oklch(0.723 0.192 149.579);
  --success-foreground: oklch(0.205 0 0);
  --warning: oklch(0.828 0.156 80);
  --warning-foreground: oklch(0.205 0 0);

  --border: oklch(0.275 0.006 264);
  --input: oklch(0.32 0.006 264);
  --ring: oklch(0.75 0.14 264);

  --brand: oklch(0.75 0.14 264);
  --brand-foreground: oklch(0.18 0.02 264);

  --sidebar: oklch(0.165 0.004 264);
  --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.235 0.008 264);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(0.26 0.006 264);
  --sidebar-ring: oklch(0.75 0.14 264);

  --chart-1: oklch(0.81 0.1 252);
  --chart-2: oklch(0.62 0.19 260);
  --chart-3: oklch(0.55 0.22 263);
  --chart-4: oklch(0.49 0.22 264);
  --chart-5: oklch(0.42 0.18 266);
}

/* Generated by scripts/build-icons.mjs — regenerate with `npm run icons:build`.
   Paint vars keep a fixed stroke colour. */
:root {
  --icon-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6' /%3E%3C/svg%3E");
}

/* -- Button component ------------------------------------------ */

@layer components {
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-sans);
    line-height: 1;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 150ms ease;
    outline: none;
    flex-shrink: 0;
    height: 2.25rem;
    padding: 0 1rem;
    background-color: var(--primary);
    color: var(--primary-foreground);

    & svg {
      pointer-events: none;
      flex-shrink: 0;

      &:not([class*="size-"]) {
        width: 1rem;
        height: 1rem;
      }
    }

    &:focus-visible {
      outline: 2px solid var(--ring);
      outline-offset: 2px;
    }

    &:disabled,
    &[aria-disabled="true"] {
      pointer-events: none;
      opacity: 0.5;
    }

    /* -- Variants -------------------------------------------- */
    &[data-variant="default"] {
      background-color: var(--primary);
      color: var(--primary-foreground);

      &:hover {
        opacity: 0.9;
      }
    }

    &[data-variant="secondary"] {
      background-color: var(--secondary);
      color: var(--secondary-foreground);

      &:hover {
        opacity: 0.8;
      }
    }

    &[data-variant="outline"] {
      background-color: var(--background);
      color: var(--foreground);
      border: 1px solid var(--border);
      box-shadow: var(--shadow-xs);

      &:hover {
        background-color: var(--accent);
        color: var(--accent-foreground);
      }
    }

    &[data-variant="ghost"] {
      background-color: transparent;
      color: var(--foreground);
      border-color: transparent;

      &:hover {
        background-color: var(--accent);
        color: var(--accent-foreground);
      }
    }

    &[data-variant="destructive"] {
      background-color: var(--destructive);
      color: var(--destructive-foreground);

      &:hover {
        opacity: 0.9;
      }
    }

    /* Fork: brand-colored text actions (primary ≈ foreground in this theme,
       so plain text links needed a distinct color). */
    &[data-variant="link"] {
      height: auto;
      padding: 0;
      border-radius: var(--radius-sm);
      background-color: transparent;
      color: var(--brand);
      text-decoration: none;

      &:hover {
        color: color-mix(in oklab, var(--brand) 78%, var(--foreground));
        text-decoration: underline;
        text-underline-offset: 4px;
      }
    }

    /* Square icon button: no label, centered glyph. */
    &[data-icon-only] {
      width: 2.25rem;
      padding: 0;

      & svg {
        width: 1.25rem;
        height: 1.25rem;
      }
    }

    /* -- Sizes ----------------------------------------------- */
    &[data-size="xs"] {
      height: 1.75rem;
      padding: 0 0.5rem;
      font-size: 0.75rem;
      border-radius: var(--radius-sm);
    }
    &[data-size="sm"] {
      height: 2rem;
      padding: 0 0.75rem;
      font-size: 0.8125rem;
    }
    &[data-size="lg"] {
      height: 2.75rem;
      padding: 0 2rem;
      font-size: 1rem;
    }
    &[data-size="icon"] {
      height: 2.25rem;
      width: 2.25rem;
      padding: 0;
    }
    &[data-size="icon-xs"] {
      height: 1.75rem;
      width: 1.75rem;
      padding: 0;
      border-radius: var(--radius-sm);
    }
    &[data-size="icon-sm"] {
      height: 2rem;
      width: 2rem;
      padding: 0;
    }
    &[data-size="icon-lg"] {
      height: 2.75rem;
      width: 2.75rem;
      padding: 0;
    }

    /* Fork: pressed/selected pill; after variants so it wins the cascade. */
    &[data-active="true"] {
      background-color: var(--primary);
      color: var(--primary-foreground);
      border-color: var(--primary);
      box-shadow: none;

      &:hover {
        background-color: color-mix(in oklab, var(--primary) 88%, black);
        color: var(--primary-foreground);
      }
    }
  }

  /* -- Accessibility ------------------------------------------ */

  @media (prefers-reduced-motion: reduce) {
    .btn {
      transition: none;
    }
  }

  @media (prefers-contrast: more) {
    .btn {
      border: 2px solid transparent;

      &[data-variant="default"],
      &[data-variant="secondary"],
      &[data-variant="destructive"] {
        border-color: currentColor;
      }

      &[data-variant="outline"],
      &[data-variant="ghost"] {
        border-color: var(--foreground);
      }
    }
  }

  @media (forced-colors: active) {
    .btn {
      border: 1px solid ButtonText;

      &:disabled,
      &[aria-disabled="true"] {
        border-color: GrayText;
        color: GrayText;
      }
    }
  }

  /* Fork: fetch-submit spinner (api.js toggles .hidden); legacy svg spinners animate themselves. */
  .btn .btn-spinner:not(svg) {
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 9999px;
    animation: btn-spin 600ms linear infinite;
  }

  /* Fork: in-place refresh — the button's own glyph spins instead of adding
     a spinner, so an icon-only action keeps its footprint. */
  .btn[data-loading="true"] svg {
    animation: btn-spin 900ms linear infinite;
  }

  @media (prefers-reduced-motion: reduce) {
    .btn[data-loading="true"] svg {
      animation: none;
    }
  }
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

/* -- Card component -------------------------------------------- */

@layer components {
  .card {
    background-color: var(--card);
    color: var(--card-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    container-type: inline-size;
  }

  .card-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1.5rem;
    padding-bottom: 0;
  }

  .card-title {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.015em;
    margin: 0;
  }

  .card-description {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin: 0;
    line-height: 1.6;
  }

  .card-content {
    padding: 1.5rem;
  }

  /* -- Stat card ------------------------------------------------ */
  .stat-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1.25rem;
    color: inherit;
    text-decoration: none;
    transition:
      border-color 150ms ease,
      box-shadow 150ms ease,
      transform 150ms ease;
  }

  a.stat-card:hover {
    border-color: color-mix(in oklab, var(--brand) 35%, var(--border));
    box-shadow: var(--shadow-sm);
  }

  .stat-icon {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    background: color-mix(in oklab, var(--brand) 10%, transparent);
    color: var(--brand);
  }

  .stat-icon svg {
    width: 1.125rem;
    height: 1.125rem;
  }

  .stat-body {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.125rem;
  }

  .stat-label {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted-foreground);
  }

  .stat-value {
    margin: 0;
    overflow: hidden;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stat-hint {
    margin: 0;
    font-size: 0.75rem;
    color: var(--muted-foreground);
  }

  .stat-arrow {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    margin-left: auto;
    color: var(--muted-foreground);
    opacity: 0.6;
    transition:
      opacity 150ms ease,
      translate 150ms ease;
  }

  a.stat-card:hover .stat-arrow {
    opacity: 1;
    translate: 2px 0;
  }

  @media (prefers-reduced-motion: reduce) {
    .stat-card,
    .stat-arrow {
      transition: none;
    }
    a.stat-card:hover .stat-arrow {
      translate: none;
    }
  }

  /* -- Quick links: 2x2 tiles styled like the overview stat cards -- */
  .quick-links-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  @media (min-width: 480px) {
    .quick-links-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .quick-link {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.25rem;
    color: inherit;
    text-decoration: none;
    transition:
      border-color 150ms ease,
      box-shadow 150ms ease,
      transform 150ms ease;
  }

  a.quick-link:hover {
    border-color: color-mix(in oklab, var(--brand) 35%, var(--border));
    box-shadow: var(--shadow-sm);
  }

  .quick-link-body {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.25rem;
  }

  .quick-link-title {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--foreground);
  }

  .quick-link-hint {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--muted-foreground);
  }

  .quick-link-arrow {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    width: 1.25rem;
    height: 1.25rem;
    color: var(--muted-foreground);
    opacity: 0.6;
    transition:
      opacity 150ms ease,
      translate 150ms ease;
  }

  a.quick-link:hover .quick-link-arrow {
    opacity: 1;
    translate: 2px 0;
  }

  @media (prefers-reduced-motion: reduce) {
    .quick-link,
    .quick-link-arrow {
      transition: none;
    }
    a.quick-link:hover .quick-link-arrow {
      translate: none;
    }
  }

  /* -- Container query: compact card in narrow containers -- */
  @container (max-width: 280px) {
    .card-header {
      padding: 1rem;
      padding-bottom: 0;
    }
    .card-content {
      padding: 1rem;
    }
    .card-title {
      font-size: 1rem;
    }
  }
}

/* -- Page-level composition ------------------------------------ */

@layer components {
  .page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem 1rem;
  }

  .page-heading {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
  }

  .page-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.025em;
    text-wrap: balance;
  }

  .page-description {
    margin: 0;
    max-width: 65ch;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--muted-foreground);
  }

  .page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }

  /* -- Empty states -------------------------------------------- */
  .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 3rem 1.5rem;
    text-align: center;
  }

  .empty-state-icon {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    margin-bottom: 0.375rem;
    border-radius: 9999px;
    background: color-mix(in oklab, var(--brand) 10%, transparent);
    color: var(--brand);
  }

  .empty-state-icon svg {
    width: 1.25rem;
    height: 1.25rem;
  }

  .empty-state-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--foreground);
  }

  .empty-state-description {
    margin: 0;
    max-width: 36ch;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--muted-foreground);
  }

  .empty-state-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
  }

  /* -- Ordered steps ------------------------------------------- */
  .step-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .step {
    display: flex;
    gap: 0.75rem;
  }

  .step-number {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background: color-mix(in oklab, var(--brand) 10%, transparent);
    color: var(--brand);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
  }

  .step-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
  }

  .step-description {
    margin: 0.125rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--muted-foreground);
  }
}

@layer components {
  .limit-row {
    padding-block: 0.75rem;
    border-top: 1px solid var(--border);
  }

  .limit-row:first-child {
    border-top: 0;
  }

  .meter {
    display: block;
    width: 100%;
    height: 0.375rem;
    margin-top: 0.5rem;
    overflow: hidden;
    border: none;
    border-radius: 9999px;
    appearance: none;
    background: var(--muted);
  }

  .meter::-webkit-meter-bar {
    border: none;
    border-radius: 9999px;
    background: var(--muted);
  }

  .meter::-webkit-meter-optimum-value {
    border-radius: 9999px;
    background: var(--brand);
  }

  .meter::-webkit-meter-suboptimum-value {
    border-radius: 9999px;
    background: var(--warning);
  }

  .meter::-webkit-meter-even-less-good-value {
    border-radius: 9999px;
    background: var(--destructive);
  }

  .meter::-moz-meter-bar {
    border-radius: 9999px;
    background: var(--brand);
  }
}

/* -- Application chrome: topbar, account menu, avatar ---------- */

@layer components {
  .skip-link {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 100;
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    translate: 0 -150%;
    transition: translate 150ms ease;
  }

  .skip-link:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
    translate: 0 0;
  }

  .app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid var(--border);
    background: color-mix(in oklab, var(--background) 82%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }

  .app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: 4rem;
    padding-inline: 1rem;
  }

  @media (min-width: 768px) {
    .app-header-inner {
      padding-inline: 1.5rem;
    }
  }

  .app-header-left,
  .app-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
  }

  .app-header-title {
    overflow: hidden;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .app-header-divider {
    width: 1px;
    height: 1.25rem;
    background: var(--border);
  }

  .app-header-logo {
    display: none;
    align-items: center;
    border-radius: var(--radius-md);
    outline: none;
  }

  @media (max-width: 767px) {
    .app-header-logo {
      display: flex;
    }
  }

  .app-header-logo img {
    width: 1.75rem;
    height: 1.75rem;
  }

  .app-header-logo:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
  }

  .page-container {
    width: 100%;
    max-width: 90rem;
    margin-inline: auto;
  }

  /* -- Account menu -------------------------------------------- */
  .user-menu-trigger {
    gap: 0.5rem;
    max-width: 20rem;
    height: 2.5rem;
    padding: 0 0.5rem 0 0.5rem;
    border-radius: 9999px;
  }

  .user-menu-trigger[data-variant="outline"]:hover {
    background-color: var(--accent);
    border-color: color-mix(in oklab, var(--border) 60%, var(--foreground));
  }

  .avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background: linear-gradient(
      140deg,
      var(--brand),
      color-mix(in oklab, var(--brand) 55%, oklch(0.55 0.21 300))
    );
    color: var(--brand-foreground);
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
  }

  .user-menu-name {
    max-width: 12rem;
    overflow: hidden;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-menu-head {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.5rem 0.5rem 0.375rem;
  }

  .user-menu-head strong {
    overflow: hidden;
    font-size: 0.875rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-menu-head span {
    overflow: hidden;
    font-size: 0.75rem;
    color: var(--muted-foreground);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  @media (prefers-reduced-motion: reduce) {
    .app-header {
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }
}

/* -- Auth shell ------------------------------------------------ */

@layer components {
  .auth-brand-panel {
    position: relative;
    display: none;
    isolation: isolate;
    overflow: hidden;
    background:
      radial-gradient(
        90% 70% at 82% 12%,
        color-mix(in oklab, var(--brand) 22%, transparent) 0%,
        transparent 60%
      ),
      radial-gradient(
        70% 60% at 12% 88%,
        color-mix(in oklab, oklch(0.62 0.18 300) 16%, transparent) 0%,
        transparent 62%
      ),
      linear-gradient(150deg, oklch(0.975 0.01 264), oklch(0.935 0.028 264));
  }

  .dark .auth-brand-panel {
    background:
      radial-gradient(
        90% 70% at 82% 12%,
        color-mix(in oklab, var(--brand) 30%, transparent) 0%,
        transparent 62%
      ),
      radial-gradient(
        70% 60% at 12% 88%,
        color-mix(in oklab, oklch(0.6 0.2 300) 22%, transparent) 0%,
        transparent 64%
      ),
      linear-gradient(150deg, oklch(0.2 0.02 264), oklch(0.14 0.012 264));
  }

  .auth-brand-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image:
      linear-gradient(
        to right,
        color-mix(in oklab, var(--foreground) 6%, transparent) 1px,
        transparent 1px
      ),
      linear-gradient(
        to bottom,
        color-mix(in oklab, var(--foreground) 6%, transparent) 1px,
        transparent 1px
      );
    background-size: 44px 44px;
    mask-image: radial-gradient(70% 70% at 50% 50%, #000 20%, transparent 100%);
  }

  .auth-brand-content {
    position: relative;
    z-index: 1;
    display: flex;
    max-width: 22rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 2rem;
  }

  .auth-brand-content img {
    height: 2rem;
    width: auto;
    margin-bottom: 0.5rem;
  }

  .auth-brand-tagline {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: color-mix(in oklab, var(--foreground) 78%, transparent);
  }

  .auth-brand-points {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
  }

  .auth-brand-points li {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.875rem;
    color: var(--foreground);
  }

  .auth-brand-points svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    color: var(--brand);
  }

  @media (min-width: 1024px) {
    .auth-brand-panel {
      display: flex;
    }
  }

  .auth-form-column {
    display: flex;
    width: 100%;
    flex: 1 1 0%;
    flex-direction: column;
    padding: 1.5rem;
  }

  @media (min-width: 640px) {
    @media (min-width: 1024px) {
      .auth-brand-panel {
        display: flex;
      }
    }

    .auth-form-column {
      padding: 2.5rem;
    }
  }

  @media (min-width: 1024px) {
    @media (min-width: 1024px) {
      .auth-brand-panel {
        display: flex;
      }
    }

    .auth-form-column {
      width: 50%;
      padding: 3rem;
    }
  }

  .auth-mobile-logo {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin-bottom: auto;
    border-radius: var(--radius-md);
    outline: none;
  }

  .auth-mobile-logo img {
    height: 1.75rem;
    width: auto;
  }

  .auth-mobile-logo:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
  }

  @media (min-width: 1024px) {
    .auth-mobile-logo {
      display: none;
    }
  }

  @media (prefers-reduced-motion: no-preference) and (prefers-reduced-transparency: reduce) {
    .auth-brand-panel::before {
      display: none;
    }
  }
}

/* -- Input component ------------------------------------------- */

@layer components {
  .input {
    height: 2.5rem;
    width: 100%;
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    background: var(--background);
    padding: 0 0.75rem;
    font-size: 0.875rem;
    font-family: var(--font-sans);
    color: var(--foreground);
    outline: none;
    box-shadow: var(--shadow-xs);
    transition:
      border-color 150ms,
      box-shadow 150ms;

    &:focus {
      border-color: var(--ring);
      box-shadow: 0 0 0 2px oklch(from var(--ring) l c h / 0.2);
    }

    &::placeholder {
      color: var(--muted-foreground);
    }

    &:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    /* -- Readonly state -------------------------------------- */
    &:read-only:not([type="file"]) {
      background: var(--muted);
      cursor: default;
      opacity: 0.7;

      &:focus {
        border-color: var(--input);
        box-shadow: var(--shadow-xs);
      }
    }

    /* -- Invalid state --------------------------------------- */
    &:is([aria-invalid="true"], :user-invalid) {
      border-color: var(--destructive);

      &:focus {
        border-color: var(--destructive);
        box-shadow: 0 0 0 2px oklch(from var(--destructive) l c h / 0.2);
      }
    }

    /* -- File input ------------------------------------------ */
    &[type="file"] {
      padding: 0;
      font-size: 0.875rem;

      &::file-selector-button {
        height: 100%;
        border: none;
        border-right: 1px solid var(--input);
        background: var(--muted);
        color: var(--foreground);
        font-size: 0.875rem;
        font-weight: 500;
        font-family: var(--font-sans);
        padding: 0 0.75rem;
        margin-right: 0.75rem;
        cursor: pointer;
        transition: background 150ms;

        &:hover {
          background: var(--accent);
        }
      }
    }

    /* -- Sizes ----------------------------------------------- */
    &[data-size="sm"] {
      height: 2rem;
      padding: 0 0.625rem;
      font-size: 0.8125rem;
    }
    &[data-size="lg"] {
      height: 2.75rem;
      padding: 0 1rem;
      font-size: 1rem;
    }
  }

  /* -- Field error ------------------------------------------- */
  .field-error {
    font-size: 0.8125rem;
    color: var(--destructive);
    margin: 0.375rem 0 0;
  }

  /* -- Accessibility ---------------------------------------- */
  @media (prefers-reduced-motion: reduce) {
    .input {
      transition: none;
    }

    .input[type="file"]::file-selector-button {
      transition: none;
    }
  }

  @media (prefers-contrast: more) {
    .input {
      border-width: 2px;
    }

    .input:disabled {
      opacity: 0.7;
    }
  }

  @media (forced-colors: active) {
    .input {
      border-color: ButtonBorder;
      color: ButtonText;
      background: Field;
    }

    .input:focus {
      outline: 2px solid Highlight;
      outline-offset: 1px;
    }

    .input:disabled {
      opacity: 1;
      color: GrayText;
      border-color: GrayText;
    }

    .input:is([aria-invalid="true"], :user-invalid) {
      border-color: LinkText;
    }

    .field-error {
      color: LinkText;
    }
  }
}

/* -- Label component -------------------------------------------- */

@layer components {
  .label {
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-sans);
    line-height: 1;
    color: var(--foreground);
    display: block;
    margin-bottom: 0.375rem;
    cursor: default;

    /* Disabled — explicit attribute */
    &[data-disabled] {
      opacity: 0.7;
      cursor: not-allowed;
    }

    /* Disabled — auto-detect via adjacent disabled control */
    &:has(+ :disabled),
    &:has(+ [data-disabled]) {
      opacity: 0.7;
      cursor: not-allowed;
    }
  }

  /* -- Accessibility ---------------------------------------- */
  @media (prefers-contrast: more) {
    .label[data-disabled],
    .label:has(+ :disabled),
    .label:has(+ [data-disabled]) {
      opacity: 0.85;
    }
  }

  @media (forced-colors: active) {
    .label {
      color: LinkText;
    }

    .label[data-disabled],
    .label:has(+ :disabled),
    .label:has(+ [data-disabled]) {
      opacity: 1;
      color: GrayText;
    }
  }
}

/* -- Select component ------------------------------------------- */

@layer components {
  .select {
    appearance: none;
    height: 2.5rem;
    width: 100%;
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    background: var(--background);
    padding: 0 2rem 0 0.75rem;
    font-size: 0.875rem;
    font-family: var(--font-sans);
    color: var(--foreground);
    outline: none;
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    transition:
      border-color 150ms,
      box-shadow 150ms;

    /* Custom chevron */
    background-image: var(--icon-select-chevron);
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;

    &:focus {
      border-color: var(--ring);
      box-shadow: 0 0 0 2px oklch(from var(--ring) l c h / 0.2);
    }

    &:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    &:is([aria-invalid="true"], :user-invalid) {
      border-color: var(--destructive);

      &:focus {
        border-color: var(--destructive);
        box-shadow: 0 0 0 2px oklch(from var(--destructive) l c h / 0.2);
      }
    }

    /* -- Sizes ----------------------------------------------- */
    &[data-size="sm"] {
      height: 2rem;
      padding-left: 0.625rem;
      font-size: 0.8125rem;
    }
    &[data-size="lg"] {
      height: 2.75rem;
      padding-left: 1rem;
      font-size: 1rem;
    }
  }
}

/* -- Badge component ------------------------------------------- */

@layer components {
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border: 1px solid transparent;
    border-radius: 9999px;
    padding: 0.125rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.375rem;
    text-transform: capitalize;
    white-space: nowrap;

    &[data-variant="outline"] {
      border-color: var(--border);
      color: var(--muted-foreground);
    }

    &[data-variant="secondary"] {
      background: var(--secondary);
      color: var(--secondary-foreground);
    }

    &[data-variant="default"] {
      background: var(--primary);
      color: var(--primary-foreground);
    }

    /* Fork: tinted status variants — solid pills overpower dense tables. */
    &[data-variant="destructive"] {
      border-color: color-mix(in oklab, var(--destructive) 28%, transparent);
      background: color-mix(in oklab, var(--destructive) 12%, transparent);
      color: color-mix(in oklab, var(--destructive) 68%, var(--foreground));
    }

    &[data-variant="success"] {
      border-color: color-mix(in oklab, var(--success) 28%, transparent);
      background: color-mix(in oklab, var(--success) 12%, transparent);
      color: color-mix(in oklab, var(--success) 62%, var(--foreground));
    }

    &[data-variant="warning"] {
      border-color: color-mix(in oklab, var(--warning) 32%, transparent);
      background: color-mix(in oklab, var(--warning) 14%, transparent);
      color: color-mix(in oklab, var(--warning) 52%, var(--foreground));
    }
  }

  @media (forced-colors: active) {
    .badge {
      border-color: CanvasText;
    }
  }
}

@layer components {
  .alert {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
    color: var(--foreground);
    background-color: var(--background);

    /* Fork: tinted status surfaces (badge.css token pattern). */
    &[data-variant="destructive"] {
      border-color: color-mix(in oklab, var(--destructive) 24%, transparent);
      background: color-mix(in oklab, var(--destructive) 7%, transparent);

      & .alert-title,
      & .alert-icon {
        color: color-mix(in oklab, var(--destructive) 68%, var(--foreground));
      }

      & .alert-description {
        color: color-mix(
          in oklab,
          var(--destructive) 42%,
          var(--muted-foreground)
        );
      }
    }

    &[data-variant="success"] {
      border-color: color-mix(in oklab, var(--success) 24%, transparent);
      background: color-mix(in oklab, var(--success) 7%, transparent);

      & .alert-title,
      & .alert-icon {
        color: color-mix(in oklab, var(--success) 62%, var(--foreground));
      }
    }

    &[data-variant="warning"] {
      border-color: color-mix(in oklab, var(--warning) 28%, transparent);
      background: color-mix(in oklab, var(--warning) 8%, transparent);

      & .alert-title,
      & .alert-icon {
        color: color-mix(in oklab, var(--warning) 52%, var(--foreground));
      }
    }

    &[data-variant="info"] {
      border-color: color-mix(in oklab, var(--ring) 22%, transparent);
      background: color-mix(in oklab, var(--ring) 6%, transparent);

      & .alert-title,
      & .alert-icon {
        color: var(--foreground);
      }
    }
  }

  .alert-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    margin-top: 0.125rem;
    color: var(--foreground);
  }

  .alert-content {
    flex: 1;
    min-width: 0;
  }

  .alert-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: -0.01em;
    color: var(--foreground);
  }

  .alert-description {
    margin: 0.25rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--muted-foreground);
  }

  .alert-action {
    flex-shrink: 0;
    margin-left: auto;
    align-self: center;
  }
}

/* -- JSON payload view ------------------------------------------- */

@layer components {
  .json {
    --json-key: var(--brand);
    --json-str: var(--success);
    --json-num: oklch(0.55 0.14 65);
    --json-lit: oklch(0.55 0.18 305);

    color: var(--foreground);

    & .json-key {
      color: var(--json-key);
    }
    & .json-str {
      color: var(--json-str);
    }
    & .json-num {
      color: var(--json-num);
    }
    & .json-lit {
      color: var(--json-lit);
      font-style: italic;
    }
  }

  .dark .json {
    --json-key: oklch(0.75 0.13 264);
    --json-str: oklch(0.76 0.16 155);
    --json-num: oklch(0.78 0.13 70);
    --json-lit: oklch(0.74 0.16 310);
  }
}

@layer components {
  .table-container {
    position: relative;
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--card);
    box-shadow: var(--shadow-xs);
    container-type: inline-size;
  }

  .table-plain {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    text-align: left;
  }

  .table-head {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border);
    background-color: color-mix(in oklab, var(--muted) 55%, transparent);
    color: var(--muted-foreground);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.045em;
    text-transform: uppercase;
    white-space: nowrap;

    &:first-child {
      border-top-left-radius: var(--radius-lg);
    }

    &:last-child {
      border-top-right-radius: var(--radius-lg);
    }
  }

  .table-row {
    border-bottom: 1px solid var(--border);
    transition: background-color 150ms ease;

    &:last-child {
      border-bottom: none;
    }

    tbody &:hover {
      background-color: color-mix(in oklab, var(--muted) 55%, transparent);
    }
  }

  .table-cell {
    padding: 0.8125rem 1rem;
    vertical-align: middle;
    color: var(--foreground);
  }

  tfoot .table-row {
    background-color: var(--muted);
    border-top: 1px solid var(--border);
    font-weight: 500;
  }

  tfoot .table-cell:first-child {
    border-bottom-left-radius: var(--radius-lg);
  }

  tfoot .table-cell:last-child {
    border-bottom-right-radius: var(--radius-lg);
  }

  /* -- Container query: compact table in narrow containers -- */
  @container (max-width: 480px) {
    .table-head,
    .table-cell {
      padding: 0.5rem 0.75rem;
      font-size: 0.8125rem;
    }
  }
}

/* -- Dialog component ------------------------------------------ */

@layer components {
  dialog.dialog {
    border: none;
    border-radius: var(--radius-xl);
    background-color: var(--popover);
    color: var(--popover-foreground);
    padding: 0;
    margin: auto;
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    max-width: 28rem;
    width: calc(100vw - 2rem);
    max-height: calc(100vh - 2rem);
    box-shadow:
      0 25px 80px oklch(0 0 0 / 0.25),
      0 0 0 1px var(--border);
    opacity: 0;
    transform: translateY(-0.5rem) scale(0.98);
    transition:
      opacity 200ms ease,
      transform 200ms ease,
      display 200ms allow-discrete;

    &[open] {
      opacity: 1;
      transform: translateY(0) scale(1);
    }

    /* The flex above outranks the UA's closed-dialog rule. */
    &:not([open]) {
      display: none;
    }

    /* -- Sizes ------------------------------------------------ */
    &[data-size="sm"] {
      max-width: 24rem;
    }
    &[data-size="lg"] {
      max-width: 32rem;
    }
    &[data-size="xl"] {
      max-width: 40rem;
    }
    &[data-size="full"] {
      max-width: calc(100vw - 2rem);
    }

    /* -- Backdrop --------------------------------------------- */
    &::backdrop {
      background: oklch(0 0 0 / 0);
      backdrop-filter: blur(0px);
      transition:
        all 200ms ease,
        display 200ms allow-discrete;
    }

    &[open]::backdrop {
      background: oklch(0 0 0 / 0.45);
      backdrop-filter: blur(3px);
    }
  }

  @starting-style {
    dialog.dialog[open] {
      opacity: 0;
      transform: translateY(-0.5rem) scale(0.98);
    }

    dialog.dialog[open]::backdrop {
      background: oklch(0 0 0 / 0);
      backdrop-filter: blur(0px);
    }
  }

  /* -- Content sections ------------------------------------- */
  .dialog-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.5rem;
  }
  .dialog-header {
    margin-bottom: 1rem;
  }
  .dialog-title {
    font-size: 1.0625rem;
    font-weight: 600;
    margin: 0 0 0.375rem;
    letter-spacing: -0.01em;
  }
  .dialog-description {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin: 0;
    line-height: 1.6;
  }
  .dialog-body {
    margin-top: 1rem;
  }
  .dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
  }

  /* -- Wide batch dialog: the footer stays reachable while rows scroll */
  dialog.dialog[data-size="xl"] .dialog-footer {
    position: sticky;
    bottom: 0;
    z-index: 1;
    margin: 1.5rem -1.5rem -1.5rem;
    padding: 1.25rem 1.5rem;
    background: var(--popover);
    border-top: 1px solid var(--border);
  }

  /* -- Batch entry rows (add addresses) --------------------- */
  .address-row {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--background);
    transition:
      border-color 150ms ease,
      box-shadow 150ms ease;
  }

  .address-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .address-row-index {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted-foreground);
  }

  .address-row-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    align-items: start;

    & > div {
      min-width: 0;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .address-row {
      transition: none;
    }
  }
}

@layer components {
  dialog.alert-dialog {
    border: none;
    border-radius: var(--radius-xl);
    background: var(--background);
    color: var(--foreground);
    padding: 0;
    max-width: 28rem;
    width: calc(100% - 2rem);
    box-shadow: var(--shadow-lg);
    margin: auto;
    position: fixed;
    inset: 0;

    /* Entry/exit animation */
    opacity: 0;
    transform: translateY(-0.5rem) scale(0.98);
    transition:
      opacity 200ms ease,
      transform 200ms ease,
      display 200ms allow-discrete;

    &[open] {
      opacity: 1;
      transform: translateY(0) scale(1);
    }

    &::backdrop {
      background: oklch(0 0 0 / 0);
      backdrop-filter: blur(0px);
      transition:
        all 200ms ease,
        display 200ms allow-discrete;
    }

    &[open]::backdrop {
      background: oklch(0 0 0 / 0.45);
      backdrop-filter: blur(3px);
    }

    /* Block Escape key — user must choose an action */
    &::backdrop {
      pointer-events: auto;
    }
  }

  @starting-style {
    dialog.alert-dialog[open] {
      opacity: 0;
      transform: translateY(-0.5rem) scale(0.98);
    }
    dialog.alert-dialog[open]::backdrop {
      background: oklch(0 0 0 / 0);
      backdrop-filter: blur(0px);
    }
  }

  .alert-dialog-content {
    padding: 1.5rem;
  }

  .alert-dialog-header {
    margin-bottom: 1.25rem;
  }

  .alert-dialog-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
  }

  .alert-dialog-description {
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
    color: var(--muted-foreground);
    line-height: 1.5;
  }

  .alert-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
  }
}

/* -- Dropdown component ---------------------------------------- */

@layer components {
  .dropdown-content {
    background-color: var(--popover);
    color: var(--popover-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.25rem;
    min-width: 8rem;
    box-shadow:
      0 8px 24px oklch(0 0 0 / 0.1),
      0 0 0 1px color-mix(in oklab, var(--border) 60%, transparent);

    &[data-size="wide"] {
      min-width: 14rem;
      max-width: calc(100vw - 1rem);
    }

    /* -- Anchor positioning ------------------------------------ */
    position: fixed;
    inset: auto;
    top: anchor(bottom);
    left: anchor(left);
    margin: 0;
    margin-top: 4px;
    position-try-fallbacks: flip-block, flip-inline;

    /* -- Animation --------------------------------------------- */
    opacity: 0;
    transform: scale(0.96) translateY(-0.25rem);
    transition:
      opacity 150ms ease,
      transform 150ms ease,
      display 150ms allow-discrete;

    &:popover-open {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  @starting-style {
    .dropdown-content:popover-open {
      opacity: 0;
      transform: scale(0.96) translateY(-0.25rem);
    }
  }

  .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.375rem 0.5rem;
    /* Fork: menu items can be <a>; drop the UA underline. */
    text-decoration: none;
    border-radius: calc(var(--radius) * 0.6);
    font-size: 0.875rem;
    border: none;
    background: transparent;
    color: var(--foreground);
    cursor: pointer;
    outline: none;
    text-align: left;

    & svg {
      width: 1rem;
      height: 1rem;
      flex-shrink: 0;
      color: var(--muted-foreground);
    }

    &:hover,
    &[data-highlighted] {
      background-color: var(--accent);
      color: var(--accent-foreground);

      & svg {
        color: currentColor;
      }
    }

    &[data-variant="destructive"] {
      color: var(--destructive);

      &:hover,
      &[data-highlighted] {
        background-color: color-mix(
          in oklab,
          var(--destructive) 12%,
          transparent
        );
        color: var(--destructive);

        & svg {
          color: currentColor;
        }
      }
    }

    &:disabled {
      pointer-events: none;
      opacity: 0.5;
    }
  }

  .dropdown-separator {
    height: 1px;
    background: var(--border);
    margin: 0.25rem -0.25rem;
  }

  /* -- Accessibility ------------------------------------------ */

  @media (prefers-reduced-motion: reduce) {
    .dropdown-content {
      transition: none;
    }
    .dropdown-item {
      transition: none;
    }
  }

  @media (forced-colors: active) {
    .dropdown-content {
      border-color: ButtonText;
    }
    .dropdown-item {
      &:hover,
      &[data-highlighted] {
        forced-color-adjust: none;
        background: Highlight;
        color: HighlightText;
      }
    }
  }
}

@layer components {
  .pagination {
    display: flex;
    justify-content: center;
  }
  .pagination-list {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
  }
  .pagination-link,
  .pagination-prev,
  .pagination-next {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding-inline: 0.5rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--foreground);
    text-decoration: none;
    cursor: pointer;
    outline: none;
    transition:
      background-color 150ms ease,
      border-color 150ms ease;
    gap: 0.25rem;
    &:hover {
      background-color: var(--accent);
    }
    &:focus-visible {
      outline: 2px solid var(--ring);
      outline-offset: 2px;
    }
    & svg {
      width: 1rem;
      height: 1rem;
      flex-shrink: 0;
    }

    /* Disabled state for prev/next at boundaries */
    &[aria-disabled="true"],
    &.disabled {
      pointer-events: none;
      opacity: 0.5;
    }
  }
  .pagination-prev,
  .pagination-next {
    padding-inline: 0.75rem;
    gap: 0.375rem;
  }
  /* -- Accessibility ------------------------------------------ */

  @media (prefers-reduced-motion: reduce) {
    .pagination-link,
    .pagination-prev,
    .pagination-next {
      transition: none;
    }
  }

  @media (prefers-contrast: more) {
    .pagination-link,
    .pagination-prev,
    .pagination-next {
      border-color: var(--border);
      &:hover {
        border-color: var(--foreground);
      }
    }
  }

  @media (forced-colors: active) {
    .pagination-link,
    .pagination-prev,
    .pagination-next {
      &:hover {
        forced-color-adjust: none;
        background: Highlight;
        color: HighlightText;
      }
    }
  }
}

@layer components {
  /* Minimal scrollbar for tall inner lists (e.g. Stacked plans). Firefox
     gets the native thin scrollbar; WebKit gets a slim rounded thumb that
     only appears on hover so short lists look unscrollable. */
  .stack-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }

  .stack-scroll::-webkit-scrollbar {
    width: 6px;
  }

  .stack-scroll::-webkit-scrollbar-track {
    background: transparent;
  }

  .stack-scroll::-webkit-scrollbar-thumb {
    border-radius: 9999px;
    background: transparent;
  }

  .stack-scroll:hover::-webkit-scrollbar-thumb {
    background: var(--border);
  }
}

/* -- Sidebar component ------------------------------------------ */
/* Application sidebar: collapsible rail and mobile sheet overlay.   */

@layer components {
  /* ── Shell layout ─────────────────────────────────────────── */
  .sidebar-layout {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
  }

  /* ── Sidebar panel ────────────────────────────────────────── */
  .app-sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width, 16rem);
    height: 100vh;
    height: 100dvh;
    position: sticky;
    top: 0;
    background-color: var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    transition: width 200ms ease;
    overflow: hidden;
    z-index: 30;

    /* Right side */
    &[data-side="right"] {
      border-right: none;
      border-left: 1px solid var(--sidebar-border);
      order: 1;
    }

    /* Hidden on mobile by default — shown via dialog */
    @media (max-width: 767px) {
      display: none;
    }
  }

  /* Collapsed — icon-only rail. The html-level attribute is what the
     pre-paint restore sets (sidebar-boot.js); the aside-level one is the
     JS-off / server default and is kept in step by sidebar-state.js, so a
     collapse never flashes the expanded state on navigation. */
  .app-sidebar[data-state="collapsed"],
  :root[data-sidebar-state="collapsed"] .app-sidebar {
    width: var(--sidebar-width-collapsed, 3.75rem);

    & .sidebar-link span,
    & .sidebar-section-title,
    & .sidebar-logo-wordmark {
      display: none;
    }

    & .sidebar-logo-mark {
      display: block;
    }
    & .sidebar-link {
      justify-content: center;
      padding: 0.5rem;
    }
    & .sidebar-header {
      justify-content: center;
      padding-inline: 0.5rem;
    }
  }

  /* ── Sidebar header ───────────────────────────────────────── */
  .sidebar-header {
    display: flex;
    align-items: center;
    /* The header's border sits below its 4rem inner row; match that edge. */
    min-height: calc(4rem + 1px);
    padding-inline: 1.25rem;
    gap: 0.5rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
  }

  .sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: var(--radius-md);
    color: var(--sidebar-foreground);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    outline: none;
  }

  .sidebar-logo:focus-visible {
    outline: 2px solid var(--sidebar-ring);
    outline-offset: 2px;
  }

  .sidebar-logo img {
    height: 2rem;
    width: auto;
  }

  .sidebar-logo-wordmark {
    display: flex;
    align-items: center;
  }

  .sidebar-logo img.sidebar-logo-mark {
    display: none;
    height: 1.75rem;
    width: 1.75rem;
  }

  /* ── Sidebar content (scrollable area) ────────────────────── */
  .sidebar-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.5rem;
    gap: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-border) transparent;
  }

  /* ── Sidebar nav ──────────────────────────────────────────── */
  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
  }

  /* ── Nav links ────────────────────────────────────────────── */
  .sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--sidebar-foreground);
    font-size: 0.875rem;
    font-weight: 450;
    text-decoration: none;
    transition:
      background-color 150ms ease,
      color 150ms ease;

    &:hover {
      background-color: var(--sidebar-accent);
      color: var(--sidebar-accent-foreground);
    }

    &[data-active="true"],
    &[aria-current="page"] {
      background-color: color-mix(in oklab, var(--brand) 10%, transparent);
      color: var(--brand);
      font-weight: 500;
    }

    &[data-active="true"]::before,
    &[aria-current="page"]::before {
      content: "";
      position: absolute;
      inset-block: 0.5rem;
      inset-inline-start: -0.5rem;
      width: 2px;
      border-radius: 9999px;
      background: var(--brand);
    }

    &:focus-visible {
      outline: 2px solid var(--sidebar-ring);
      outline-offset: -2px;
    }

    & svg {
      width: 1.0625rem;
      height: 1.0625rem;
      flex-shrink: 0;
    }
  }

  /* ── Section title ────────────────────────────────────────── */
  .sidebar-section-title {
    padding: 0.75rem 0.75rem 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
  }

  /* ── Mobile sidebar (<dialog> sheet overlay) ──────────────── */
  .sidebar-mobile {
    border: none;
    padding: 0;
    margin: 0;
    position: fixed;
    inset: 0;
    width: var(--sidebar-width, 16rem);
    max-width: 80vw;
    height: 100%;
    background-color: var(--sidebar);
    color: var(--sidebar-foreground);
    z-index: 50;
    overflow: hidden;
    display: flex;
    flex-direction: column;

    opacity: 0;
    translate: -100% 0;
    transition:
      opacity 200ms ease,
      translate 200ms ease,
      display 200ms allow-discrete;

    &[open] {
      opacity: 1;
      translate: 0 0;
    }

    &[data-side="right"] {
      right: 0;
      left: auto;
      translate: 100% 0;
      &[open] {
        translate: 0 0;
      }
    }

    &::backdrop {
      background: oklch(0 0 0 / 0.5);
      opacity: 0;
      transition:
        opacity 200ms ease,
        display 200ms allow-discrete;
    }

    &[open]::backdrop {
      opacity: 1;
    }

    & .sidebar-mobile-close {
      position: absolute;
      top: 0.75rem;
      right: 0.75rem;
      width: 1.5rem;
      height: 1.5rem;
      border: none;
      background: transparent;
      color: var(--sidebar-foreground);
      cursor: pointer;
      border-radius: var(--radius-sm);
      display: flex;
      align-items: center;
      justify-content: center;

      &:hover {
        background-color: var(--sidebar-accent);
      }
      & svg {
        width: 0.875rem;
        height: 0.875rem;
      }
    }

    @media (min-width: 768px) {
      display: none;
    }
  }

  @starting-style {
    .sidebar-mobile[open] {
      opacity: 0;
      translate: -100% 0;
    }
    .sidebar-mobile[open]::backdrop {
      opacity: 0;
    }
    .sidebar-mobile[data-side="right"][open] {
      opacity: 0;
      translate: 100% 0;
    }
  }

  /* ── Reduced motion ───────────────────────────────────────── */
  @media (prefers-reduced-motion: reduce) {
    .app-sidebar {
      transition: none;
    }
    .sidebar-link {
      transition: none;
    }
    .sidebar-mobile {
      transition: none;
    }
    .sidebar-mobile::backdrop {
      transition: none;
    }
  }
}

/* -- Scanner status page ---------------------------------------- */

@layer components {
  /* Overall health banner: one glanceable strip above the chain cards. */
  .scanner-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.5rem;
    padding: 1rem 1.25rem;
  }

  .scanner-hero-state {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
  }

  /* Pulsing liveness dot: solid core + expanding ring. Paused/error freeze
     the pulse — a still dot reads as "not moving" without animation noise. */
  .scanner-dot {
    position: relative;
    width: 0.625rem;
    height: 0.625rem;
    flex-shrink: 0;
    border-radius: 9999px;
  }

  .scanner-dot::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    background: currentColor;
  }

  .scanner-dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    background: currentColor;
    animation: scanner-ping 2.4s cubic-bezier(0, 0, 0.2, 1) infinite;
  }

  .scanner-dot[data-still="true"]::after {
    animation: none;
    opacity: 0;
  }

  .scanner-dot[data-state="healthy"] {
    color: var(--success);
  }

  .scanner-dot[data-state="error"] {
    color: var(--destructive);
  }

  .scanner-dot[data-state="catching-up"],
  .scanner-dot[data-state="initializing"] {
    color: var(--warning);
  }

  .scanner-dot[data-state="paused"] {
    color: var(--muted-foreground);
  }

  @keyframes scanner-ping {
    0% {
      transform: scale(1);
      opacity: 0.6;
    }

    75%,
    100% {
      transform: scale(2.4);
      opacity: 0;
    }
  }

  /* Per-chain card hook for the poller's state sync. */
  .scanner-card {
    container-type: inline-size;
  }

  /* Metric cell: label / big number / hint, hairline between cells. */
  .scanner-metric {
    display: flex;
    flex-direction: column;
    gap: 0.1875rem;
    padding: 0.75rem 1rem;
    background: color-mix(in oklab, var(--muted-foreground) 5%, transparent);
    border-radius: var(--radius-lg);
  }

  .scanner-metric-label {
    margin: 0;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted-foreground);
  }

  .scanner-metric-value {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .scanner-metric-hint {
    margin: 0;
    font-size: 0.6875rem;
    color: var(--muted-foreground);
  }

  /* Stale tile: last scanned block older than the threshold — amber tint so
     "the scanner has not committed in a while" is visible per-tile. */
  .scanner-metric[data-stale="true"] {
    border: 1px solid color-mix(in oklab, var(--warning) 32%, transparent);
    background: color-mix(in oklab, var(--warning) 12%, transparent);
  }

  .scanner-metric[data-stale="true"] .scanner-metric-value {
    color: color-mix(in oklab, var(--warning) 60%, var(--foreground));
  }

  /* Error strip: tinted panel, icon + monospace message. */
  .scanner-error {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid color-mix(in oklab, var(--destructive) 28%, transparent);
    background: color-mix(in oklab, var(--destructive) 7%, transparent);
  }

  .scanner-error svg {
    width: 0.9375rem;
    height: 0.9375rem;
    flex-shrink: 0;
    margin-top: 0.0625rem;
    color: var(--destructive);
  }

  .scanner-error p {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    word-break: break-all;
    color: color-mix(in oklab, var(--destructive) 72%, var(--foreground));
  }

  @media (prefers-reduced-motion: reduce) {
    .scanner-dot::after {
      animation: none;
      opacity: 0;
    }
  }
}

/* Opt-in utilities, Tailwind-named, token-based. One line per utility.
   Append new utilities at the end of their section; never reformat. */

/* Layout */
.space-y-2 > :not([hidden]) ~ :not([hidden]) {
  margin-top: 0.5rem;
}
.space-y-4 > :not([hidden]) ~ :not([hidden]) {
  margin-top: 1rem;
}
.space-y-5 > :not([hidden]) ~ :not([hidden]) {
  margin-top: 1.25rem;
}
.flex {
  display: flex;
}
.grid {
  display: grid;
}
.hidden {
  display: none;
}
.block {
  display: block;
}
.flex-col {
  flex-direction: column;
}
.flex-wrap {
  flex-wrap: wrap;
}
.flex-1 {
  flex: 1 1 0%;
}
.items-center {
  align-items: center;
}
.items-start {
  align-items: flex-start;
}
.items-baseline {
  align-items: baseline;
}
.justify-between {
  justify-content: space-between;
}
.justify-center {
  justify-content: center;
}
.justify-end {
  justify-content: flex-end;
}
.items-end {
  align-items: flex-end;
}

/* Grid columns */
.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}
.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Gap (1 = 0.25rem) */
.gap-1 {
  gap: 0.25rem;
}
.gap-1\.5 {
  gap: 0.375rem;
}
.gap-2 {
  gap: 0.5rem;
}
.gap-2\.5 {
  gap: 0.625rem;
}
.gap-3 {
  gap: 0.75rem;
}
.gap-4 {
  gap: 1rem;
}
.gap-5 {
  gap: 1.25rem;
}
.gap-6 {
  gap: 1.5rem;
}
/* Margin */
.mx-auto {
  margin-inline: auto;
}
.ml-auto {
  margin-left: auto;
}
.mt-1 {
  margin-top: 0.25rem;
}
.mt-2 {
  margin-top: 0.5rem;
}
.mt-3 {
  margin-top: 0.75rem;
}
.mt-4 {
  margin-top: 1rem;
}
.mt-5 {
  margin-top: 1.25rem;
}
.mt-6 {
  margin-top: 1.5rem;
}
.mb-2 {
  margin-bottom: 0.5rem;
}
.mb-4 {
  margin-bottom: 1rem;
}
.mb-6 {
  margin-bottom: 1.5rem;
}
.mb-8 {
  margin-bottom: 2rem;
}

/* Padding (1 = 0.25rem) */
.p-4 {
  padding: 1rem;
}
.p-6 {
  padding: 1.5rem;
}
.py-3 {
  padding-block: 0.75rem;
}
/* Sizing */
.w-full {
  width: 100%;
}
.min-w-0 {
  min-width: 0;
}
.max-w-md {
  max-width: 28rem;
}
.max-w-lg {
  max-width: 32rem;
}
.max-w-3xl {
  max-width: 48rem;
}
.min-h-screen {
  min-height: 100vh;
}
.max-w-xs {
  max-width: 20rem;
}
.w-48 {
  width: 12rem;
}
/* Typography */
.text-xs {
  font-size: 0.75rem;
  line-height: 1rem;
}
.text-sm {
  font-size: 0.875rem;
  line-height: 1.25rem;
}
.text-2xl {
  font-size: 1.5rem;
  line-height: 2rem;
}
.font-medium {
  font-weight: 500;
}
.font-semibold {
  font-weight: 600;
}
.font-mono {
  font-family: var(--font-mono);
}
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}
.text-muted-foreground {
  color: var(--muted-foreground);
}
.text-destructive {
  color: var(--destructive);
}
.break-all {
  word-break: break-all;
}
.whitespace-nowrap {
  white-space: nowrap;
}
.uppercase {
  text-transform: uppercase;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Misc */
.col-span-2 {
  grid-column: span 2 / span 2;
}
.cursor-not-allowed {
  cursor: not-allowed;
}
.opacity-50 {
  opacity: 0.5;
}
.relative {
  position: relative;
}
.border-b {
  border-bottom: 1px solid var(--border);
}
.bg-background {
  background-color: var(--background);
}
.bg-muted {
  background-color: var(--muted);
}
.p-3 {
  padding: 0.75rem;
}
.pb-20 {
  padding-bottom: 5rem;
}
.theme-light-only {
  display: block;
}
.dark .theme-light-only {
  display: none;
}
.theme-dark-only {
  display: none;
}
.dark .theme-dark-only {
  display: block;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.z-1 {
  z-index: 1;
}
.overflow-x-auto {
  overflow-x: auto;
}

/* Responsive variants. Plain CSS here outranks Tailwind's @layer utilities,
   so every breakpoint override lives in this one block, after its base
   utility — order inside the block decides ties. */
@media (min-width: 640px) {
  .sm\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sm\:inline {
    display: inline;
  }
  .sm\:space-y-6 > :not([hidden]) ~ :not([hidden]) {
    margin-top: 1.5rem;
  }
  .sm\:text-start {
    text-align: start;
  }
  .sm\:w-48 {
    width: 12rem;
  }
  .sm\:w-64 {
    width: 16rem;
  }
}
@media (min-width: 768px) {
  .md\:gap-6 {
    gap: 1.5rem;
  }
  .md\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .md\:grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .md\:p-6 {
    padding: 1.5rem;
  }
}
@media (min-width: 1024px) {
  .lg\:flex-row {
    flex-direction: row;
  }
  .lg\:grid {
    display: grid;
  }
  .lg\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .lg\:w-1\/2 {
    width: 50%;
  }
}
@media (min-width: 1280px) {
  .xl\:grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .xl\:grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
