/* ==========================================================================
   meshbook — component styles
   --------------------------------------------------------------------------
   File:      components.css
   Purpose:   Every reusable UI component's CSS lives here. Components
              reference theme tokens from themes/*.css via var(--nv-*) and
              never hard-code colours. Keeping it all in one file (rather
              than per-component files) is a deliberate PoC-era choice —
              easier to grep, easier to read whole-thing in one screen.
              If this file grows past ~1500 lines we'll split it per-
              component.

   Layout:    Split into clearly-marked sections.
                - App shell    (body layout, sidebar, top bar, main)
                - Login        (centred card, form)
                - Primitives   (buttons, inputs, labels, kbd, chips)
                - Data         (tables, cards, badges)
                - Overlays     (toasts, modals, command palette)
                - Pages        (small per-page helpers, keyed by page class)
   ========================================================================== */


/* ==========================================================================
   APP SHELL
   ========================================================================== */

/* The outer grid for the whole logged-in app. Two columns (sidebar + main),
   two rows (top bar + main content). The grid-template-areas syntax makes
   the layout legible at a glance. */
.nv-app {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: 64px 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}


/* -- Sidebar ------------------------------------------------------------- */

.nv-sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    width: 240px;
    padding: 1rem 0.75rem;
    background-color: var(--nv-bg-elevated);
    border-right: 1px solid var(--nv-border);
    transition: width var(--nv-duration-medium) var(--nv-ease-spring);
    overflow-y: auto;
    overflow-x: hidden;
}

.nv-sidebar--collapsed {
    width: 64px;
}

.nv-sidebar--collapsed .nv-sidebar__name,
.nv-sidebar--collapsed .nv-sidebar__link span,
.nv-sidebar--collapsed .nv-sidebar__group-label {
    display: none;
}

.nv-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.5rem 1rem 0.5rem;
    border-bottom: 1px solid var(--nv-border);
    margin-bottom: 0.5rem;
}

.nv-sidebar__logo {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.nv-sidebar__name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--nv-text);
    white-space: nowrap;
}

.nv-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    flex: 1;
}

.nv-sidebar__group-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--nv-text-tertiary);
    padding: 0.75rem 0.75rem 0.25rem;
}

.nv-sidebar__divider {
    height: 1px;
    background-color: var(--nv-border);
    margin: 0.75rem 0.5rem;
}

.nv-sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--nv-radius-md);
    color: var(--nv-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color var(--nv-duration-fast) var(--nv-ease-spring),
                color var(--nv-duration-fast) var(--nv-ease-spring);
    white-space: nowrap;
    /* The sidebar is a flex column; without an explicit no-shrink the
       links squish vertically once content height exceeds the viewport
       — the `i` icons keep their declared 18×18 but the link's flex
       padding compresses, so they suddenly look "almost invisible".
       Sidebar's own `overflow-y:auto` is the right escape valve; pin
       link height first and let the parent scroll. */
    flex-shrink: 0;
}

.nv-sidebar__link:hover {
    background-color: var(--nv-surface-hover);
    color: var(--nv-text);
}

.nv-sidebar__link.is-active {
    background-color: var(--nv-surface-active);
    color: var(--nv-text);
    box-shadow: inset 2px 0 0 var(--nv-accent);
}

.nv-sidebar__link i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nv-sidebar__collapse {
    margin-top: auto;
    padding: 0.5rem;
    border: 1px solid var(--nv-border);
    background: transparent;
    color: var(--nv-text-secondary);
    border-radius: var(--nv-radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--nv-duration-fast);
}
.nv-sidebar__collapse:hover {
    background-color: var(--nv-surface-hover);
    color: var(--nv-text);
}


/* -- Top bar ------------------------------------------------------------- */

.nv-topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1rem;
    border-bottom: 1px solid var(--nv-border);
    background-color: var(--nv-surface);
    backdrop-filter: blur(var(--nv-glass-blur));
    -webkit-backdrop-filter: blur(var(--nv-glass-blur));
}

.nv-topbar__search {
    flex: 1;
    max-width: 560px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--nv-bg);
    border: 1px solid var(--nv-border);
    border-radius: var(--nv-radius-lg);
    transition: border-color var(--nv-duration-fast);
    cursor: text;
}
.nv-topbar__search:hover,
.nv-topbar__search:focus-within {
    border-color: var(--nv-border-strong);
}

.nv-topbar__search i {
    color: var(--nv-text-tertiary);
    width: 16px;
    height: 16px;
}

.nv-topbar__search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--nv-text);
    font-size: 0.875rem;
}
.nv-topbar__search-input::placeholder {
    color: var(--nv-text-tertiary);
}

.nv-topbar__kbd {
    font-family: var(--nv-font-mono);
    font-size: 0.6875rem;
    color: var(--nv-text-tertiary);
    background: var(--nv-surface-solid);
    border: 1px solid var(--nv-border);
    padding: 0.125rem 0.375rem;
    border-radius: var(--nv-radius-sm);
}

.nv-topbar__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}


/* -- User chip ----------------------------------------------------------- */

.nv-user-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    background-color: var(--nv-surface);
    border: 1px solid var(--nv-border);
    border-radius: var(--nv-radius-pill);
    /* Don't let the topbar's flex layout crush the chip — without
       flex-shrink:0 the name silently truncates because the chip
       collapses to fit-content of just the avatar before the ellipsis
       rule on __name even gets a chance to apply. */
    flex-shrink: 0;
}

.nv-user-chip__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-image: var(--nv-gradient-accent);
    color: var(--nv-text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.nv-user-chip__text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    min-width: 0;
}
.nv-user-chip__name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--nv-text);
    /* Roomy ~20+ visible glyphs before ellipsis. Sized in `rem` rather
       than `ch` because Inter's `1ch` is ~0.5em and yields a tighter
       visible cap than the count suggests; 14rem reliably shows
       "Christopher Tyl" + buffer. */
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nv-user-chip__role {
    font-size: 0.6875rem;
    color: var(--nv-text-tertiary);
    font-family: var(--nv-font-mono);
}


/* -- Main content area --------------------------------------------------- */

.nv-main {
    grid-area: main;
    overflow-y: auto;
    padding: 2rem 2.5rem;
    background-color: transparent;           /* let body gradient show through */
    position: relative;
}


/* ==========================================================================
   LOGIN
   ========================================================================== */

.nv-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
}

.nv-login__theme-corner {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nv-login__card {
    width: min(440px, 100%);
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.nv-login__brand {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.nv-login__logo {
    width: 56px;
    height: 56px;
}

.nv-login__title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Brand wordmark gradient overrides — pulled from the hexagon logo's own
   colour stops so the brand reads as one piece. Only dark + light themes
   are overridden; california + retro keep the theme accent gradient from
   .nv-gradient-text. The selector is more specific than .nv-gradient-text
   (0,2,0 vs 0,1,0) so source order doesn't matter. */
[data-theme="dark"] .nv-login__title.nv-gradient-text {
    background-image: linear-gradient(135deg, #b0f1ff 0%, #5fdcff 100%);
}
[data-theme="light"] .nv-login__title.nv-gradient-text {
    background-image: linear-gradient(135deg, #04124e 0%, #1976d2 100%);
}

.nv-login__subtitle {
    color: var(--nv-text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.nv-login__au-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding: 0.25rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--nv-text-secondary);
    background: var(--nv-surface-2);
    border: 1px solid var(--nv-border);
    border-radius: 999px;
    letter-spacing: 0.01em;
}
.nv-login__au-badge-flag {
    width: 18px;
    height: 11px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.06);
    display: block;
}

.nv-login__form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nv-login__hint {
    font-size: 0.75rem;
    color: var(--nv-text-tertiary);
    margin: 0.25rem 0 1rem;
    line-height: 1.5;
}
.nv-login__hint code {
    font-size: 0.6875rem;
    padding: 0.0625rem 0.25rem;
    background: var(--nv-surface-solid);
    border: 1px solid var(--nv-border);
    border-radius: var(--nv-radius-sm);
}
.nv-login__hint--cta {
    text-align: center;
    margin-top: 0.25rem;
    margin-bottom: 0;
}
.nv-login__hint--cta a {
    font-weight: 600;
}
.nv-login__sso-btn.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.4);
}
.nv-login__sso-btn.is-disabled:hover {
    transform: none;
    border-color: var(--nv-border);
}
.nv-login__sso-soon {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--nv-text-tertiary);
    margin-left: 0.35em;
    letter-spacing: 0.01em;
}

.nv-login__submit {
    width: 100%;
    margin-top: 0.25rem;
}

/* SSO sign-in stack — Google + Microsoft pills with their brand glyphs.
   Order: Google first (most users), Microsoft second. Both anchor tags so
   the OAuth round-trip is a normal full-page navigation; no JS needed. */
.nv-login__sso {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}
.nv-login__sso-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.6875rem 1rem;
    text-decoration: none;
    font-weight: 600;
    border-radius: var(--nv-radius-md);
    border: 1px solid var(--nv-border);
    transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.nv-login__sso-btn:hover {
    transform: translateY(-1px);
    border-color: var(--nv-border-strong);
}
.nv-login__sso-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.nv-login__sso-stack {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.15;
}
.nv-login__sso-label {
    font-weight: 600;
}
.nv-login__sso-suffix {
    font-size: 0.6875rem;
    font-weight: 400;
    opacity: 0.65;
    margin-top: 2px;
    letter-spacing: 0.02em;
}
.nv-login__sso-btn--primary {
    background: var(--nv-accent);
    color: var(--nv-accent-contrast, #fff);
    border-color: var(--nv-accent);
}
.nv-login__sso-btn--primary:hover {
    background: var(--nv-accent-hover, var(--nv-accent));
    border-color: var(--nv-accent-hover, var(--nv-accent));
}
.nv-login__sso-btn--google {
    background: var(--nv-surface-solid);
    color: var(--nv-text);
}
.nv-login__sso-btn--google:hover {
    background: var(--nv-surface-elevated);
}
.nv-login__sso-btn--google.nv-login__sso-btn--primary {
    background: var(--nv-accent);
    color: var(--nv-accent-contrast, #fff);
}
/* Dark + light themes get the logo-blue gradient on the primary Google
   button so it harmonises with the cyan/navy "meshbook" wordmark above
   it. California + retro keep their --nv-accent treatment. */
[data-theme="dark"] .nv-login__sso-btn--google.nv-login__sso-btn--primary,
[data-theme="light"] .nv-login__sso-btn--google.nv-login__sso-btn--primary {
    background: linear-gradient(135deg, #1976d2 0%, #04124e 100%);
    color: #ffffff;
    border-color: transparent;
}
[data-theme="dark"] .nv-login__sso-btn--google.nv-login__sso-btn--primary:hover,
[data-theme="light"] .nv-login__sso-btn--google.nv-login__sso-btn--primary:hover {
    background: linear-gradient(135deg, #1565c0 0%, #020c38 100%);
    color: #ffffff;
    border-color: transparent;
}
.nv-login__sso-btn--microsoft {
    background: var(--nv-surface);
    color: var(--nv-text);
}
.nv-login__sso-btn--microsoft:hover {
    background: var(--nv-surface-elevated);
}
.nv-login__sso-btn--moltbook {
    background: var(--nv-surface);
    color: var(--nv-text);
}
.nv-login__sso-btn--moltbook:hover {
    background: var(--nv-surface-elevated);
}

/* Warm-up progress list under the sign-in form. Footnote-styled rows,
   one per cached entity. Tick / dot / bang prefix animates between
   states with a subtle opacity. */
.nv-login__warmup {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.75rem;
    color: var(--nv-text-tertiary);
    line-height: 1.5;
}
.nv-login__warmup-row {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    transition: color 0.18s ease;
}
.nv-login__warmup-row[data-status="loading"] {
    opacity: 0.7;
}
.nv-login__warmup-row[data-status="done"] {
    color: var(--nv-text-secondary);
    opacity: 1;
}
.nv-login__warmup-row[data-status="error"] {
    color: var(--nv-danger, #f87171);
    opacity: 1;
}
.nv-login__warmup-icon {
    width: 0.9rem;
    text-align: center;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.nv-login__warmup-row[data-status="done"] .nv-login__warmup-icon {
    color: var(--nv-accent);
}
.nv-login__warmup-count {
    font-variant-numeric: tabular-nums;
    color: var(--nv-text-tertiary);
}

.nv-login__footer {
    position: absolute;
    bottom: 1.5rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--nv-text-tertiary);
}


/* ==========================================================================
   PRIMITIVES
   ========================================================================== */

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

.nv-card {
    background-color: var(--nv-surface);
    backdrop-filter: blur(var(--nv-glass-blur));
    -webkit-backdrop-filter: blur(var(--nv-glass-blur));
    border: 1px solid var(--nv-border);
    border-radius: var(--nv-radius-xl);
    box-shadow: var(--nv-shadow-card);
}

.nv-card--hover {
    transition: box-shadow var(--nv-duration-medium) var(--nv-ease-spring),
                transform var(--nv-duration-medium) var(--nv-ease-spring);
}
.nv-card--hover:hover {
    box-shadow: var(--nv-shadow-card), var(--nv-glow-accent);
    transform: translateY(-1px);
}


/* -- Buttons ------------------------------------------------------------- */

.nv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: var(--nv-radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color var(--nv-duration-fast),
                border-color var(--nv-duration-fast),
                box-shadow var(--nv-duration-fast),
                transform var(--nv-duration-fast);
    white-space: nowrap;
}
.nv-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.nv-btn:focus-visible {
    outline: 2px solid var(--nv-accent);
    outline-offset: 2px;
}

.nv-btn--primary {
    background-color: var(--nv-accent);
    color: var(--nv-text-inverse);
    box-shadow: 0 6px 16px -6px rgba(0,0,0,0.35);
}
.nv-btn--primary:hover:not(:disabled) {
    background-color: var(--nv-accent-hover);
    box-shadow: var(--nv-glow-accent);
}

.nv-btn--secondary {
    background-color: var(--nv-surface);
    color: var(--nv-text);
    border-color: var(--nv-border);
}
.nv-btn--secondary:hover:not(:disabled) {
    background-color: var(--nv-surface-hover);
    border-color: var(--nv-border-strong);
}

.nv-btn--ghost {
    background: transparent;
    color: var(--nv-text-secondary);
}
.nv-btn--ghost:hover:not(:disabled) {
    background-color: var(--nv-surface-hover);
    color: var(--nv-text);
}

.nv-btn--danger {
    background-color: var(--nv-danger);
    color: #ffffff;
}
.nv-btn--danger:hover:not(:disabled) {
    filter: brightness(1.1);
}


/* -- Icon button --------------------------------------------------------- */

.nv-icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--nv-radius-md);
    background: transparent;
    color: var(--nv-text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color var(--nv-duration-fast),
                color var(--nv-duration-fast);
}
.nv-icon-btn:hover {
    background-color: var(--nv-surface-hover);
    color: var(--nv-text);
}
.nv-icon-btn i {
    width: 18px;
    height: 18px;
}


/* Spin animation for the topbar "Sync now" button. Applied by Alpine
   while the refreshAll() promise is in flight. Respects
   prefers-reduced-motion for users who disable UI animation. */
@keyframes nv-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.nv-icon-btn.is-spinning i {
    animation: nv-spin 900ms linear infinite;
    transform-origin: 50% 50%;
}

.nv-icon-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

@media (prefers-reduced-motion: reduce) {
    .nv-icon-btn.is-spinning i {
        animation: none;
        opacity: 0.6;
    }
}


/* -- Inputs / labels ----------------------------------------------------- */

.nv-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--nv-text-secondary);
    margin-bottom: 0.25rem;
    display: block;
}

/*
 * Input / select / textarea styles.
 * --------------------------------------------------------------------
 * We deliberately use a doubled-class selector (`.nv-input.nv-input`)
 * to bump specificity from (0, 0, 1, 0) to (0, 0, 2, 0). This beats
 * Tailwind's @tailwindcss/forms plugin, which styles inputs with
 * attribute selectors like `input[type='email']` (0, 0, 1, 1) and
 * otherwise overrides our background / text colours — producing the
 * infamous "white text on white background" bug in dark theme. Using
 * the doubled-class idiom here lets us leave the component class name
 * unchanged in markup.
 */
.nv-input.nv-input,
.nv-select.nv-select,
.nv-textarea.nv-textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    color: var(--nv-text);
    background-color: var(--nv-bg-elevated);
    border: 1px solid var(--nv-border);
    border-radius: var(--nv-radius-md);
    transition: border-color var(--nv-duration-fast),
                box-shadow var(--nv-duration-fast);
    outline: none;
    /* Ensure caret is also readable against the input background. */
    caret-color: var(--nv-text);
}
.nv-input.nv-input::placeholder,
.nv-textarea.nv-textarea::placeholder {
    color: var(--nv-text-tertiary);
}
.nv-input.nv-input:focus,
.nv-select.nv-select:focus,
.nv-textarea.nv-textarea:focus {
    border-color: var(--nv-accent);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--nv-accent) 20%, transparent);
}

/* Autofill (Chrome, Edge) overrides the background with a yellow-ish
   hue and sets text colour via -webkit-text-fill-color. Force both
   back to our theme tokens. Safari handles this differently; we'll
   address when someone actually uses Safari against this app. */
.nv-input.nv-input:-webkit-autofill,
.nv-input.nv-input:-webkit-autofill:hover,
.nv-input.nv-input:-webkit-autofill:focus,
.nv-input.nv-input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--nv-text);
    -webkit-box-shadow: 0 0 0 1000px var(--nv-bg-elevated) inset;
    caret-color: var(--nv-text);
    transition: background-color 5000s ease-in-out 0s;
}


/* -- Badges / chips ------------------------------------------------------ */

.nv-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 500;
    border-radius: var(--nv-radius-pill);
    line-height: 1.5;
}
.nv-badge--success { background-color: var(--nv-success-bg); color: var(--nv-success); }
.nv-badge--warning { background-color: var(--nv-warning-bg); color: var(--nv-warning); }
.nv-badge--danger  { background-color: var(--nv-danger-bg);  color: var(--nv-danger);  }
.nv-badge--info    { background-color: var(--nv-info-bg);    color: var(--nv-info);    }
.nv-badge--accent  {
    background-color: color-mix(in oklab, var(--nv-accent) 18%, transparent);
    color: var(--nv-accent);
}

.nv-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background-color: var(--nv-surface-hover);
    border: 1px solid var(--nv-border);
    border-radius: var(--nv-radius-pill);
    font-size: 0.75rem;
    color: var(--nv-text-secondary);
}


/* ==========================================================================
   DATA DISPLAY
   ========================================================================== */

/* -- Page header --------------------------------------------------------- */

.nv-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.nv-page-header__title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.nv-page-header__subtitle {
    color: var(--nv-text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}
.nv-page-header__actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}


/* -- Table --------------------------------------------------------------- */

.nv-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}
.nv-table thead th {
    text-align: left;
    font-weight: 600;
    color: var(--nv-text-tertiary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--nv-border);
    background-color: transparent;
    position: sticky;
    top: 0;
}
.nv-table tbody td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--nv-border);
    color: var(--nv-text);
    vertical-align: middle;
}
.nv-table tbody tr {
    transition: background-color var(--nv-duration-fast);
}
.nv-table tbody tr:hover {
    background-color: var(--nv-surface-hover);
}
.nv-table__mono {
    font-family: var(--nv-font-mono);
    font-size: 0.8125rem;
    color: var(--nv-text-secondary);
}


/* -- Empty state --------------------------------------------------------- */

.nv-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--nv-text-tertiary);
}
.nv-empty__icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.75rem;
    color: var(--nv-text-muted);
}


/* ==========================================================================
   OVERLAYS
   ========================================================================== */

/* -- Toast stack --------------------------------------------------------- */

.nv-toast-stack {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10000;
    pointer-events: none;
}

.nv-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    min-width: 280px;
    max-width: 420px;
    background-color: var(--nv-surface);
    backdrop-filter: blur(var(--nv-glass-blur));
    -webkit-backdrop-filter: blur(var(--nv-glass-blur));
    border: 1px solid var(--nv-border);
    border-radius: var(--nv-radius-lg);
    box-shadow: var(--nv-shadow-card);
    color: var(--nv-text);
    font-size: 0.875rem;
    animation: nv-toast-in var(--nv-duration-medium) var(--nv-ease-spring);
}
.nv-toast--success { border-left: 3px solid var(--nv-success); }
.nv-toast--error   { border-left: 3px solid var(--nv-danger);  }
.nv-toast--info    { border-left: 3px solid var(--nv-info);    }
.nv-toast--warning { border-left: 3px solid var(--nv-warning); }

.nv-toast__icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px;
}
.nv-toast__body { flex: 1; }
.nv-toast__title {
    font-weight: 600;
    margin-bottom: 0.125rem;
}
.nv-toast__message {
    color: var(--nv-text-secondary);
    line-height: 1.45;
}
.nv-toast__close {
    background: transparent;
    border: none;
    color: var(--nv-text-tertiary);
    cursor: pointer;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes nv-toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0);   }
}


/* -- Command palette ----------------------------------------------------- */

.nv-palette-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}
.nv-palette {
    width: min(600px, 92vw);
    background-color: var(--nv-surface);
    backdrop-filter: blur(var(--nv-glass-blur));
    -webkit-backdrop-filter: blur(var(--nv-glass-blur));
    border: 1px solid var(--nv-border-strong);
    border-radius: var(--nv-radius-xl);
    box-shadow: var(--nv-shadow-window);
    overflow: hidden;
}
.nv-palette__input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: none;
    background: transparent;
    outline: none;
    color: var(--nv-text);
    font-size: 1rem;
    border-bottom: 1px solid var(--nv-border);
}
.nv-palette__results {
    max-height: 360px;
    overflow-y: auto;
    padding: 0.5rem;
}
.nv-palette__item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--nv-radius-md);
    color: var(--nv-text);
    font-size: 0.875rem;
    cursor: pointer;
}
.nv-palette__item:hover,
.nv-palette__item.is-active {
    background-color: var(--nv-surface-hover);
}
.nv-palette__item i {
    width: 16px;
    height: 16px;
    color: var(--nv-text-secondary);
}


/* ==========================================================================
   THEME SWITCH (component)
   ========================================================================== */

.nv-theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background-color: var(--nv-surface);
    border: 1px solid var(--nv-border);
    border-radius: var(--nv-radius-pill);
}
.nv-theme-switch__btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--nv-duration-fast),
                transform var(--nv-duration-fast);
    padding: 0;
}
.nv-theme-switch__btn:hover {
    border-color: var(--nv-border-strong);
    transform: translateY(-1px);
}
.nv-theme-switch__btn.is-active {
    border-color: var(--nv-accent);
    box-shadow: var(--nv-glow-accent);
}
.nv-theme-switch__swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: block;
}


/* ==========================================================================
   LANGUAGE SWITCH (component)
   Mirrors the theme-switch container (pill, surface, border) but with
   text labels (EN / PL / ZH) instead of swatches. Sized so EN/PL/ZH all
   fit inside a uniform-width chip.
   ========================================================================== */

.nv-lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.2rem;
    background-color: var(--nv-surface);
    border: 1px solid var(--nv-border);
    border-radius: var(--nv-radius-pill);
}
.nv-lang-switch__btn {
    min-width: 32px;
    height: 26px;
    padding: 0 0.5rem;
    border-radius: var(--nv-radius-pill);
    border: 1px solid transparent;
    background: transparent;
    color: var(--nv-text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: color var(--nv-duration-fast),
                background-color var(--nv-duration-fast),
                border-color var(--nv-duration-fast),
                transform var(--nv-duration-fast);
}
.nv-lang-switch__btn:hover {
    color: var(--nv-text);
    border-color: var(--nv-border-strong);
    transform: translateY(-1px);
}
.nv-lang-switch__btn.is-active {
    color: var(--nv-text);
    background-color: var(--nv-surface-2);
    border-color: var(--nv-accent);
    box-shadow: var(--nv-glow-accent);
}


/* ==========================================================================
   PAGE-SPECIFIC helpers
   ========================================================================== */

/* Dashboard placeholder */
.nv-dashboard__hero {
    padding: 3rem 2rem;
    text-align: center;
    border-radius: var(--nv-radius-xl);
    background-color: var(--nv-surface);
    backdrop-filter: blur(var(--nv-glass-blur));
    -webkit-backdrop-filter: blur(var(--nv-glass-blur));
    border: 1px solid var(--nv-border);
}
.nv-dashboard__hero h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.nv-dashboard__hero p {
    color: var(--nv-text-secondary);
    max-width: 620px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Activity log row styling */
.nv-log-row__ts {
    font-family: var(--nv-font-mono);
    font-size: 0.75rem;
    color: var(--nv-text-tertiary);
}
.nv-log-row__actor {
    font-weight: 500;
}
.nv-log-row__diff {
    font-family: var(--nv-font-mono);
    font-size: 0.75rem;
    color: var(--nv-text-tertiary);
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ==========================================================================
   PHASE 1: list-page scaffolding
   --------------------------------------------------------------------------
   Shared by contacts / companies / leads list pages:
     .nv-page               outer wrapper (margin / padding)
     .nv-page__header       page title + toolbar row
     .nv-toolbar            right-side filter/search cluster on the header
     .nv-search-inline      magnifier + input chip
     .nv-table              clean borderless data table
     .nv-table__row--clickable  hover lift + cursor pointer
     .nv-pagination         footer with page counts
   ========================================================================== */

.nv-page {
    padding: 1.25rem 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.nv-page__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.nv-page__header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.nv-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Filter selects inside the toolbar — desktop layout.
   `.nv-select { width: 100% }` is the right default for form fields
   (where each label/input stacks), but it forces every toolbar
   filter onto its own row. Override to auto-width here so filters
   flow horizontally and only wrap when the row genuinely runs out
   of space. (Chris feedback 2026-05-09 PM.) */
.nv-toolbar .nv-select,
.nv-toolbar .nv-input {
    width: auto;
    flex: 0 0 auto;
}

/* Height parity: native <select> filters and the <details> summary chips
   share .nv-select, so one min-height keeps the whole toolbar row even. */
.nv-toolbar .nv-select {
    box-sizing: border-box;
    min-height: 2.25rem;
}

/* Multi-select filter dropdown (<details>) — hide the native disclosure
   triangle so the <summary> reads as a plain select-style chip, and
   vertically centre its label to match the native selects. */
.nv-msdd > summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
}
.nv-msdd > summary::-webkit-details-marker { display: none; }
.nv-msdd > summary::marker { content: ""; }

/* Predictive multi-select panel. Double the old 240px so the
   "Name — Company" rows have room; max-width:90vw keeps it inside the
   viewport on mobile without a separate breakpoint. */
.nv-msdd__panel {
    position: absolute;
    z-index: 50;
    top: calc(100% + 4px);
    left: 0;
    width: 480px;
    max-width: 90vw;
    background: var(--nv-bg-elevated);
    border: 1px solid var(--nv-border);
    border-radius: var(--nv-radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    padding: 0.5rem;
}

/* Mobile breakpoint — flip the toolbar back to a vertical stack with
   full-width controls. 768px matches the "tablet portrait / phone
   landscape" boundary that the rest of the app's responsive cuts
   target. The same media query lets the page__header stop pushing the
   toolbar to the right edge and lets it sit naturally below the title.
   Full mobile pass is post-launch DEV-DEBT (2026-05-09); this much
   keeps the toolbar usable on phones today. */
@media (max-width: 768px) {
    .nv-page__header {
        align-items: flex-start;
    }
    .nv-toolbar {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    .nv-toolbar .nv-select,
    .nv-toolbar .nv-input,
    .nv-toolbar .nv-btn {
        width: 100%;
    }
    .nv-toolbar .nv-viewswitch {
        align-self: stretch;
    }
}

.nv-search-inline {
    position: relative;
    display: flex;
    align-items: center;
}

.nv-search-inline > i[data-lucide] {
    position: absolute;
    left: 0.625rem;
    width: 16px;
    height: 16px;
    color: var(--nv-text-tertiary);
    pointer-events: none;
}

.nv-search-inline > input {
    padding-left: 2.1rem;
    min-width: 280px;
}

.nv-table-wrap {
    overflow-x: auto;
}

.nv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.nv-table thead th {
    text-align: left;
    padding: 0.625rem 0.9rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--nv-text-tertiary);
    border-bottom: 1px solid var(--nv-border);
    background: var(--nv-surface-elevated);
    position: sticky;
    top: 0;
}

.nv-table tbody td {
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--nv-border);
    vertical-align: middle;
}

.nv-table__row--clickable {
    transition: background-color 120ms ease;
}
.nv-table__row--clickable:hover td {
    background-color: var(--nv-surface-elevated);
    cursor: pointer;
}

.nv-pagination {
    margin-top: 0.75rem;
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}


/* ==========================================================================
   PHASE 1: detail drawer (slide-in from right)
   ========================================================================== */

.nv-drawer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 80;
}
.nv-drawer--open {
    pointer-events: auto;
}

.nv-drawer__scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 200ms ease;
}
.nv-drawer--open .nv-drawer__scrim {
    opacity: 1;
}

.nv-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(560px, 94vw);
    background: var(--nv-bg-elevated);
    border-left: 1px solid var(--nv-border);
    box-shadow: -20px 0 40px rgba(0, 0, 0, 0.35);
    transform: translateX(100%);
    transition: transform 240ms cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.nv-drawer--open .nv-drawer__panel {
    transform: translateX(0);
}

.nv-drawer__header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--nv-border);
    background: var(--nv-surface);
}

.nv-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem 1.5rem;
}

.nv-drawer__section-title {
    margin: 0 0 0.5rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--nv-text-tertiary);
}


/* ==========================================================================
   PHASE 1: leads kanban board
   --------------------------------------------------------------------------
   Each column is a flex-column with its own dropzone that accepts dragged
   cards. .is-dragging drops the card's opacity; .nv-kcol--drop-target ring
   calls out the active target column while dragging. .is-moving tints a
   card while the API round-trip is in flight.
   ========================================================================== */

.nv-kanban {
    padding-bottom: 1rem;
}

.nv-kcol {
    background: var(--nv-surface);
    border: 1px solid var(--nv-border);
    border-radius: 14px;
    padding: 0.85rem 0.75rem 1rem;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    transition: border-color 140ms ease, background-color 140ms ease;
}
.nv-kcol--drop-target {
    border-color: var(--nv-accent);
    background: color-mix(in srgb, var(--nv-accent) 8%, var(--nv-surface));
}

.nv-kcol__dropzone {
    flex: 1;
}

.nv-kcard {
    user-select: none;
}
.nv-kcard:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    border-color: color-mix(in srgb, var(--nv-accent) 25%, var(--nv-border));
}
.nv-kcard.is-dragging {
    opacity: 0.45;
    cursor: grabbing;
}
.nv-kcard.is-moving {
    opacity: 0.6;
    pointer-events: none;
}


/* ==========================================================================
   PHASE 1: dashboard funnel bars
   ========================================================================== */

.nv-funnel__rows {
    font-size: 0.875rem;
}


/* ==========================================================================
   Misc additions used across Phase 1 pages
   ========================================================================== */

.nv-chip--accent {
    background: color-mix(in srgb, var(--nv-accent) 14%, transparent);
    color: var(--nv-accent);
    border-color: color-mix(in srgb, var(--nv-accent) 30%, transparent);
}


/* ==========================================================================
   PHASE 2: modal overlay + form primitives
   --------------------------------------------------------------------------
   Modals sit above drawers (z-index 100 vs drawer's 80) because an "Edit"
   button inside a drawer pops a modal on top. Background scrim darkens the
   whole viewport including any open drawer. Panel is centered, capped at
   ~640px wide, scrolls internally when content is tall.
   ========================================================================== */

.nv-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.nv-modal--open {
    pointer-events: auto;
}

.nv-modal__scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 200ms ease;
}
.nv-modal--open .nv-modal__scrim {
    opacity: 1;
}

.nv-modal__panel {
    position: relative;
    width: min(640px, 100%);
    max-height: calc(100vh - 3rem);
    background: var(--nv-bg-elevated);
    border: 1px solid var(--nv-border);
    border-radius: var(--nv-radius-lg, 14px);
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);
    transform: translateY(12px) scale(0.98);
    opacity: 0;
    transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1),
                opacity 220ms cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.nv-modal--open .nv-modal__panel {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.nv-modal__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--nv-border);
    background: var(--nv-surface);
}
.nv-modal__header h2 {
    flex: 1;
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
}
.nv-modal__header > i {
    width: 18px;
    height: 18px;
    color: var(--nv-accent);
}

.nv-modal__form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.nv-modal__body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.nv-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--nv-border);
    background: var(--nv-surface);
}


/* -- Form layout primitives --------------------------------------------- */

.nv-form__row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}
.nv-form__row > * {
    flex: 1;
    min-width: 0;
}

.nv-form__field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nv-form__help {
    font-size: 0.75rem;
    color: var(--nv-text-tertiary);
    margin-top: 0.125rem;
}

.nv-form__error {
    font-size: 0.8125rem;
    color: var(--nv-danger);
    padding: 0.5rem 0.75rem;
    background: color-mix(in srgb, var(--nv-danger) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--nv-danger) 30%, transparent);
    border-radius: var(--nv-radius-md);
}

/* Tight two-column row for the date-range / mini-pair fields. */
@media (max-width: 520px) {
    .nv-form__row {
        flex-direction: column;
    }
}


/* -- Toolbar "+ New" primary button alignment helper -------------------- */

.nv-toolbar .nv-btn--primary {
    padding: 0.5rem 0.85rem;
}


/* -- Cross-nav linkrow (drawer lists + kv pairs) ------------------------ */

/* Clickable rows inside drawers gain a subtle hover lift + accent border
   so users discover they can jump to the linked entity. */
.nv-linkrow {
    transition: border-color var(--nv-duration-fast),
                background-color var(--nv-duration-fast),
                transform var(--nv-duration-fast);
}
.nv-linkrow:hover {
    border-color: color-mix(in srgb, var(--nv-accent) 40%, var(--nv-border)) !important;
    background-color: color-mix(in srgb, var(--nv-accent) 6%, var(--nv-surface-elevated)) !important;
    transform: translateX(1px);
}
.nv-linkrow:hover i[data-lucide="arrow-up-right"] {
    color: var(--nv-accent) !important;
}


/* -- Form checkbox (renders inline label next to the box) --------------
 * We paint a custom control because @tailwindcss/forms sets
 * `appearance: none` on every `input[type='checkbox']` via an attribute
 * selector (specificity 0,0,1,1), which on its own would strip the
 * native box and leave only a thin accent bar visible next to the label.
 *
 * Rather than restore `appearance: auto` (which looks different on
 * every OS/browser and won't honour our theme tokens), we lean into the
 * plugin's `appearance: none` and paint our own box with a pseudo-check.
 * The doubled-class selector `.nv-form__checkbox.nv-form__checkbox …`
 * bumps specificity to (0,0,3,1) so the plugin can't beat us on
 * background-color / border-color / border-radius either.
 * ---------------------------------------------------------------------- */

.nv-form__checkbox {
    /* Without `display: flex` the row's other flex properties below are
       no-ops and the label collapses to inline — the checkbox renders
       as a tiny dot with the label text running into adjacent layout.
       NVITAFE-source CSS shipped without this; meshbook-port repro. */
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    flex-wrap: wrap;
}

.nv-form__checkbox.nv-form__checkbox input[type="checkbox"] {
    /* Custom control — beats Tailwind forms plugin on every axis. */
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;                                   /* flex-shrink guard  */
    margin: 0;                                         /* beat browser UA    */
    padding: 0;
    border: 1.5px solid var(--nv-border-strong);
    border-radius: var(--nv-radius-sm, 4px);
    background-color: var(--nv-bg-elevated);
    background-image: none;                            /* clobber plugin bg  */
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background-color var(--nv-duration-fast),
                border-color var(--nv-duration-fast),
                box-shadow var(--nv-duration-fast);
}

.nv-form__checkbox.nv-form__checkbox input[type="checkbox"]:hover {
    border-color: var(--nv-accent);
}

.nv-form__checkbox.nv-form__checkbox input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--nv-accent);
    outline-offset: 2px;
}

.nv-form__checkbox.nv-form__checkbox input[type="checkbox"]:checked {
    background-color: var(--nv-accent);
    border-color: var(--nv-accent);
}

/* The tick itself — drawn via two borders on a rotated pseudo element,
   which scales cleanly at any theme accent and doesn't need SVG. */
.nv-form__checkbox.nv-form__checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid var(--nv-text-inverse, #ffffff);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* -- Form radio (mirrors the checkbox pattern; native is also stripped
 *    by tailwindcss-forms so we paint a circle with a centre dot). ---- */
.nv-form__radio {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    flex-wrap: wrap;
}
.nv-form__radio.nv-form__radio input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin: 0;
    padding: 0;
    border: 1.5px solid var(--nv-border-strong);
    border-radius: 50%;
    background-color: var(--nv-bg-elevated);
    background-image: none;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background-color var(--nv-duration-fast),
                border-color var(--nv-duration-fast),
                box-shadow var(--nv-duration-fast);
}
.nv-form__radio.nv-form__radio input[type="radio"]:hover {
    border-color: var(--nv-accent);
}
.nv-form__radio.nv-form__radio input[type="radio"]:focus-visible {
    outline: 2px solid var(--nv-accent);
    outline-offset: 2px;
}
.nv-form__radio.nv-form__radio input[type="radio"]:checked {
    border-color: var(--nv-accent);
}
.nv-form__radio.nv-form__radio input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--nv-accent);
}

/* Label text sits beside the box, not under it. The help row below
   wraps to a new line thanks to `flex-wrap: wrap` on the container. */
.nv-form__checkbox .nv-label {
    display: inline;
    margin-bottom: 0;
    cursor: pointer;
    user-select: none;
}

.nv-form__checkbox .nv-form__help {
    flex-basis: 100%;
    margin-left: calc(18px + 0.5rem);                  /* align under label  */
    margin-top: 0.125rem;
}


/* -- Tag editor -------------------------------------------------------- */

.nv-tag-row .nv-chip {
    padding-right: 0.3rem;
}
.nv-tag-detach:hover {
    color: var(--nv-danger) !important;
}


/* ==========================================================================
   §22.x — MOBILE RESPONSIVE PASS
   --------------------------------------------------------------------------
   Comprehensive mobile-first additions on top of the desktop baseline.
   Two breakpoints:
     - 768px: tablet portrait + phone landscape — sidebar collapses to
       overlay drawer, drawer/modal go full-screen, kanban gets snap-
       scroll, touch targets bumped to ≥ 44px.
     - 480px: phone portrait — form rows stack, list-tables hide low-
       priority columns, topbar slim, body padding tightens.

   Safe-area insets honour iPhone notch + home-indicator (the index.html
   viewport meta sets `viewport-fit=cover` so env(safe-area-inset-*)
   becomes non-zero on devices that have them).

   The hamburger button in .nv-topbar is gated to `display:none` on
   desktop and revealed below 768px. Mobile sidebar uses
   `transform: translateX(-100%)` and slides in when
   .nv-sidebar--mobile-open is applied (Alpine `mobileNavOpen` state).

   This is the "Phase 2" pass — not a complete redesign. The desktop
   experience is untouched.
   ========================================================================== */

/* Hamburger is hidden on desktop. */
.nv-topbar__hamburger {
    display: none !important;
}

/* Mobile sidebar backdrop is hidden on desktop. */
.nv-sidebar__backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    animation: nv-fade-in 200ms ease;
}

@keyframes nv-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---- 768px ---- */
@media (max-width: 768px) {
    /* App shell — drop the sidebar column from the grid; topbar + main
       become a single column. The sidebar still exists in the DOM but
       slides in as an overlay rather than taking grid space. */
    .nv-app {
        grid-template-columns: 1fr;
        grid-template-rows: 56px 1fr;
        grid-template-areas:
            "topbar"
            "main";
    }

    /* Sidebar becomes a fixed overlay drawer, off-screen by default.
       Position over everything, slide in on .nv-sidebar--mobile-open. */
    .nv-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 80vw;
        max-width: 320px;
        z-index: 95;
        transform: translateX(-100%);
        transition: transform 240ms cubic-bezier(0.4, 0, 0.2, 1);
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-left: max(0.75rem, env(safe-area-inset-left));
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }
    .nv-sidebar--mobile-open {
        transform: translateX(0);
    }

    /* The desktop "collapse to icon-only" affordance has no meaning on
       mobile — always show full labels in the overlay. */
    .nv-sidebar--collapsed .nv-sidebar__name,
    .nv-sidebar--collapsed .nv-sidebar__link span,
    .nv-sidebar--collapsed .nv-sidebar__group-label {
        display: revert;
    }
    .nv-sidebar__collapse {
        display: none;
    }

    .nv-sidebar__backdrop {
        display: block;
    }

    /* Topbar slim down. Show the hamburger. Search loses its kbd hint
       and tightens to fit. */
    .nv-topbar {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
        padding-top: max(0.4rem, env(safe-area-inset-top));
        gap: 0.5rem;
    }
    .nv-topbar__hamburger {
        display: inline-flex !important;
        margin-right: 0.25rem;
    }
    .nv-topbar__search {
        flex: 1;
        min-width: 0;
    }
    .nv-topbar__kbd {
        display: none;
    }
    .nv-topbar__search-input {
        font-size: 16px;  /* prevents iOS zoom-on-focus */
    }
    /* Mesh picker compresses; theme + language switches become icon-only
       in their respective component selectors. */
    .nv-mesh-picker {
        max-width: 9rem;
    }

    /* Drawer goes full-screen on phones. */
    .nv-drawer__panel {
        width: 100vw;
        border-left: 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Modal goes full-screen on phones with safe-area padding. */
    .nv-modal {
        padding: 0;
    }
    .nv-modal__panel {
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: 0;
    }
    .nv-modal__body {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    .nv-modal__header {
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    /* Kanban — column min-width is the screen width minus a peek so the
       next column shows ~30px to hint horizontal scroll. Snap-scroll on
       column boundary so swipes settle cleanly. */
    .nv-kanban__row {
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scroll-padding: 1rem;
    }
    .nv-kcol {
        scroll-snap-align: start;
        min-width: calc(100vw - 2.5rem);
    }
    /* Cards have native draggable=true on desktop; on touch we make
       tap-targets larger and the drag-handle area more obvious. */
    .nv-kcard {
        padding: 1rem;
        min-height: 64px;
    }

    /* Touch targets — every clickable bumps to ≥ 44px (Apple HIG) /
       48px (Material) so they're actually hittable with a thumb. */
    .nv-btn,
    .nv-icon-btn,
    .nv-sidebar__link,
    .nv-table__row--clickable td {
        min-height: 44px;
    }
    .nv-icon-btn {
        min-width: 44px;
    }

    /* Table → cards on the smaller screens. We keep the table semantics
       (good for screen readers + crawlers) but visually re-flow rows
       into stacked cards via display:block on the row + each cell. */
    .nv-table-wrap {
        border-radius: 0;
        background: transparent;
        border: 0;
    }
    .nv-table,
    .nv-table tbody,
    .nv-table thead,
    .nv-table tr,
    .nv-table td {
        display: block;
        width: 100%;
    }
    .nv-table thead {
        /* Visually-hidden but still in a11y tree. */
        position: absolute;
        clip-path: inset(50%);
        height: 1px;
        width: 1px;
        overflow: hidden;
        white-space: nowrap;
    }
    .nv-table tr {
        margin-bottom: 0.6rem;
        padding: 0.85rem 1rem;
        background: var(--nv-surface);
        border: 1px solid var(--nv-border);
        border-radius: 12px;
    }
    .nv-table td {
        padding: 0.25rem 0;
        border: 0;
        font-size: 0.9rem;
    }
    /* First cell (the "Name" column in every list) gets bumped to read
       as the card title. */
    .nv-table tbody td:first-child {
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: 0.25rem;
    }

    /* Chat composer — sticks to the bottom with safe-area honoured so the
       text input isn't behind the iPhone home indicator. */
    .chat-composer,
    .nv-chat-composer {
        position: sticky;
        bottom: 0;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
        background: var(--nv-bg);
        border-top: 1px solid var(--nv-border);
    }

    /* Page padding tightens to use screen real estate. */
    .nv-page {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }

    /* Form rows already stack at 520px, but bump the input font to 16px
       to prevent iOS auto-zoom on focus. */
    .nv-input,
    .nv-select,
    .nv-form__field input,
    .nv-form__field select,
    .nv-form__field textarea {
        font-size: 16px;
    }
}

/* ---- 480px (phone portrait) — finer-grain tweaks ---- */
@media (max-width: 480px) {
    .nv-page__header h1 {
        font-size: 1.25rem;
    }
    .nv-toolbar {
        gap: 0.4rem;
    }
    /* Hide the user-chip text — keep only the avatar to save horizontal
       space in the topbar. */
    .nv-user-chip span,
    .nv-user-chip .nv-user-chip__name {
        display: none;
    }
    /* Mesh picker truncates aggressively. */
    .nv-mesh-picker {
        max-width: 7rem;
    }
}

/* ---- pointer-coarse (any size) ---- */
/* Dedicated rule for touch screens regardless of width — desktops with
   touchscreens get the same touch-target bump. */
@media (pointer: coarse) {
    .nv-btn,
    .nv-icon-btn {
        min-height: 44px;
    }
    .nv-icon-btn {
        min-width: 44px;
    }
}
