/**
 * NShine ERP Design System — shareable App UI theme
 * ─────────────────────────────────────────────────────────────────────────────
 * Single source for new UI styling. Load after style.css in App.razor.
 *
 * Extend this file with reusable ns-* patterns. Do not add per-module CSS for
 * buttons, cards, dials, segmented controls, or settings dialogs.
 * Inbox keeps .cai-* class names in markup; those are aliases of ns-* here.
 * Module CSS (chat-agent-inbox.css, ai-assistant-chat.css) = layout shells only.
 *
 * Token naming follows shadcn/ui conventions (--background, --primary, etc.)
 * mapped to existing NShine brand variables from style.css (:root --ns-color-*).
 */

/* ═══════════════════════════════════════════════════════════════════════════
   1. Semantic design tokens
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    /* Surfaces */
    --background: #F7F8FB;
    --foreground: var(--ns-color-blue, #212B36);
    --card: var(--ns-color-white, #ffffff);
    --card-foreground: var(--foreground);
    --popover: var(--card);
    --popover-foreground: var(--foreground);
    /* Brand */
    --primary: var(--ns-color-primary, #ff6821);
    --primary-foreground: var(--ns-color-white, #ffffff);
    --secondary: var(--ns-color-secondary, #3068A4);
    --secondary-foreground: var(--ns-color-white, #ffffff);
    /* Muted / accent */
    --muted: var(--ns-color-bg-light, #f8f9fa);
    --muted-foreground: var(--ns-color-gray, #637381);
    --accent: var(--ns-color-light-orange, #ffded9);
    --accent-foreground: var(--ns-color-blue, #212B36);
    /* Feedback */
    --destructive: var(--ns-color-red, #F14B5B);
    --destructive-foreground: var(--ns-color-white, #ffffff);
    --warning: var(--ns-color-yellow, #ffc107);
    --warning-foreground: #664d03;
    --warning-subtle: #fff3cd;
    --success: var(--ns-color-green, #1EB386);
    --success-foreground: var(--ns-color-white, #ffffff);
    /* Borders & focus */
    --border: var(--ns-color-border-light, #e0e0e0);
    --input: var(--border);
    --ring: var(--primary);
    /* Radius */
    --radius-sm: 0.25rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    /* Spacing scale */
    --ns-space-1: 0.25rem;
    --ns-space-2: 0.5rem;
    --ns-space-3: 0.75rem;
    --ns-space-4: 1rem;
    --ns-space-5: 1.25rem;
    --ns-space-6: 1.5rem;
    /* Typography helpers */
    --ns-text-xs: 0.75rem;
    --ns-text-sm: 0.875rem;
    --ns-text-base: 1rem;
}

/* Dark theme hook — extend when app-wide dark mode ships */
[data-bs-theme="dark"],
[data-theme="dark"] {
    --background: #1a1d21;
    --foreground: #e8eaed;
    --card: #212529;
    --card-foreground: var(--foreground);
    --muted: #2d3238;
    --muted-foreground: #9aa0a6;
    --border: #3c4043;
    --accent: rgba(255, 104, 33, 0.15);
    --warning-subtle: rgba(255, 193, 7, 0.15);
}

/* ═══════════════════════════════════════════════════════════════════════════
   2. Layout primitives
   ═══════════════════════════════════════════════════════════════════════════ */

.ns-ops-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ns-space-4);
    margin-bottom: var(--ns-space-4);
}

.ns-slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--ns-space-3);
}

/* ═══════════════════════════════════════════════════════════════════════════
   3. Interactive components
   ═══════════════════════════════════════════════════════════════════════════ */

/* Page / card action buttons — brand orange primary, calm secondary.
   Inbox (.cai-btn*) aliases the same recipe so AI surfaces share one theme. */
.ns-page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--ns-space-2);
}

.ns-btn,
.cai-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: var(--ns-text-sm);
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
    background: transparent;
    color: var(--foreground);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.ns-btn:disabled,
.cai-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ns-btn--primary,
.cai-btn--primary {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.ns-btn--primary:hover:not(:disabled),
.cai-btn--primary:hover:not(:disabled) {
    background: var(--ns-color-primary-2, #e05c1d);
    border-color: var(--ns-color-primary-2, #e05c1d);
    color: var(--primary-foreground);
}

.ns-btn--secondary,
.cai-btn--outline {
    background: var(--card);
    color: var(--foreground);
    border-color: var(--border);
}

.ns-btn--secondary:hover:not(:disabled),
.cai-btn--outline:hover:not(:disabled) {
    background: var(--muted);
    border-color: color-mix(in srgb, var(--muted-foreground) 25%, var(--border));
}

.ns-btn--ghost,
.cai-btn--ghost {
    background: transparent;
    color: var(--muted-foreground);
    border-color: transparent;
}

.ns-btn--ghost:hover:not(:disabled),
.cai-btn--ghost:hover:not(:disabled) {
    background: var(--muted);
    color: var(--foreground);
}

.ns-btn--destructive,
.cai-btn--destructive {
    background: var(--card);
    color: var(--destructive);
    border-color: color-mix(in srgb, var(--destructive) 28%, var(--border));
}

.ns-btn--destructive:hover:not(:disabled),
.cai-btn--destructive:hover:not(:disabled) {
    background: color-mix(in srgb, var(--destructive) 8%, var(--card));
}

.ns-btn--success,
.cai-btn--approve {
    background: var(--success);
    color: var(--success-foreground);
    border-color: var(--success);
    margin-left: auto;
    min-height: 28px;
    padding: 4px 10px;
    font-size: 0.6875rem;
}

.ns-btn--success:hover:not(:disabled),
.cai-btn--approve:hover:not(:disabled) {
    background: var(--ns-color-green-dark, #1A9F78);
    border-color: var(--ns-color-green-dark, #1A9F78);
}

.ns-btn--sm,
.cai-btn--sm {
    min-height: 32px;
    padding: 0 10px;
    font-size: 0.8125rem;
}

.ns-btn--icon,
.cai-btn--icon {
    width: 36px;
    padding: 0;
}

.ns-btn--block,
.cai-btn--block {
    width: 100%;
}

.cai-btn--muted {
    color: var(--muted-foreground);
}

.ns-btn .rz-icon,
.cai-btn .rz-icon {
    font-size: 1.1rem;
}

.cai-btn__spinner {
    width: 14px;
    height: 14px;
    border: 2px solid color-mix(in srgb, var(--primary-foreground) 35%, transparent);
    border-top-color: var(--primary-foreground);
    border-radius: var(--radius-full);
    animation: ns-spin 0.7s linear infinite;
}

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

/* Collapsible briefing / settings panel */
.ns-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--card-foreground);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--ns-space-3);
}

.ns-panel--compact {
    box-shadow: none;
}

.ns-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--ns-space-2);
    padding: var(--ns-space-3) var(--ns-space-4);
}

.ns-panel--compact .ns-panel__header {
    padding: var(--ns-space-2) var(--ns-space-3) 0;
}

.ns-panel__body {
    padding: 0 var(--ns-space-4) var(--ns-space-4);
}

.ns-panel--compact .ns-panel__body {
    padding: 0 var(--ns-space-3) var(--ns-space-3);
}

.ns-panel__body--solo {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ns-space-2);
    padding: var(--ns-space-3);
}

.ns-panel__title {
    font-weight: 600;
    color: var(--foreground);
}

.ns-panel--compact .ns-panel__title {
    font-size: var(--ns-text-sm);
}

.ns-panel__meta {
    font-size: var(--ns-text-sm);
    color: var(--muted-foreground);
    white-space: nowrap;
}

.ns-panel--compact .ns-panel__meta {
    font-size: var(--ns-text-xs);
}

.ns-summary-line {
    margin: 0;
    font-size: var(--ns-text-sm);
    line-height: 1.45;
    color: var(--foreground);
}

.ns-summary-line--strong {
    font-weight: 600;
}

.ns-summary-line + .ns-summary-line {
    margin-top: var(--ns-space-1);
}

.ns-priority-list {
    margin: var(--ns-space-2) 0 0;
    padding-left: 1.15rem;
    font-size: var(--ns-text-sm);
    color: var(--muted-foreground);
    line-height: 1.45;
}

.ns-priority-list li + li {
    margin-top: 0.2rem;
}

/* Digest / attention cards */
.ns-digest-card {
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--ns-space-3) var(--ns-space-4);
    min-width: 220px;
    background: var(--card);
    color: var(--card-foreground);
    transition: box-shadow 0.15s ease;
}

.ns-digest-card:hover {
    box-shadow: var(--shadow);
}

.ns-digest-card.is-read {
    opacity: 0.65;
}

.ns-digest-card__title {
    font-weight: 600;
}

.ns-digest-card__sub {
    font-size: var(--ns-text-sm);
    color: var(--muted-foreground);
}

.ns-section-label {
    font-size: var(--ns-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted-foreground);
    margin: var(--ns-space-3) 0 var(--ns-space-2);
}

/* Segmented filters (Inbox + future App UI) */
.ns-segmented,
.cai-segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: var(--radius);
    background: var(--muted);
    border: 1px solid var(--border);
    gap: 2px;
}

.ns-segmented__item,
.cai-segmented__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.ns-segmented__item:hover,
.cai-segmented__item:hover {
    color: var(--foreground);
}

.ns-segmented__item.is-active,
.cai-segmented__item.is-active {
    background: var(--card);
    color: var(--foreground);
    box-shadow: var(--shadow-sm);
}

.ns-segmented__dot,
.cai-segmented__dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 4px;
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--primary);
    color: var(--primary-foreground);
}

/* Trust dial (Off / Suggest / Auto) — three equal segments */
.ns-dial,
.cai-dial {
    display: flex;
    width: 100%;
    max-width: 22rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--card);
}

.ns-dial__item,
.cai-dial__item {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 0;
    background: transparent;
    padding: 8px 10px;
    min-width: 0;
    min-height: 44px;
    font-size: 0.85rem;
    color: var(--muted-foreground);
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    text-align: center;
}

.ns-dial__item + .ns-dial__item,
.cai-dial__item + .cai-dial__item {
    border-left: 1px solid var(--border);
}

.ns-dial__item.is-active,
.cai-dial__item.is-active {
    background: var(--accent);
    color: var(--foreground);
    font-weight: 600;
}

.ns-dial__item:disabled,
.cai-dial__item:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.ns-dial__desc,
.cai-dial-desc {
    margin: 6px 0 0;
    font-size: 0.82rem;
    color: var(--muted-foreground);
}

.ns-dial__accuracy,
.cai-dial-accuracy {
    margin: 4px 0 0;
    font-size: 0.82rem;
    color: var(--success);
}

/* Settings / form dialog shell */
.ns-dialog--lg.rz-dialog,
.cai-settings-dialog.rz-dialog {
    width: min(960px, 94vw) !important;
    max-width: 960px !important;
    height: min(88vh, 820px) !important;
    max-height: min(88vh, 820px) !important;
    display: flex;
    flex-direction: column;
}

.ns-dialog--lg .rz-dialog-content,
.cai-settings-dialog .rz-dialog-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
}

.ns-settings-sheet {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    max-width: 100%;
}

.ns-settings-sheet__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
}

.ns-settings-sheet__footer {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 0.85rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--card);
}

/* Selectable list rows (Rules page, etc.) */
.ns-list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--ns-space-2);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.ns-list-row:hover {
    background: var(--muted);
}

.ns-list-row.is-selected {
    background: var(--muted);
}

.ns-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--ns-space-2);
    padding: var(--ns-space-6) var(--ns-space-4);
    text-align: center;
    color: var(--muted-foreground);
}

.ns-empty__title {
    margin: 0;
    font-size: var(--ns-text-sm);
    font-weight: 600;
    color: var(--foreground);
}

.ns-muted {
    color: var(--muted-foreground);
    font-size: var(--ns-text-sm);
}

/* Decision feed (Autopilot approval queue — dense list, not tall card stack) */
.ns-decision-feed {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    overflow: hidden;
    margin-bottom: var(--ns-space-3);
}

.ns-decision-section + .ns-decision-section {
    border-top: 1px solid var(--border);
}

.ns-decision-feed .ns-section-label {
    display: flex;
    align-items: center;
    gap: var(--ns-space-2);
    width: 100%;
    margin: 0;
    padding: var(--ns-space-2) var(--ns-space-3);
    background: var(--muted);
    border: none;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.ns-section-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    padding: 0 0.35rem;
    border-radius: var(--radius-full);
    background: var(--card);
    border: 1px solid var(--border);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: none;
    letter-spacing: 0;
}

.ns-section-chevron {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--muted-foreground);
}

.ns-decision-card {
    padding: var(--ns-space-3) var(--ns-space-3);
    background: var(--card);
    color: var(--card-foreground);
    border-bottom: 1px solid var(--border);
}

.ns-decision-card:last-child {
    border-bottom: none;
}

.ns-decision-card:hover {
    background: var(--muted);
}

.ns-decision-card.is-handled {
    opacity: 0.65;
}

.ns-decision-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ns-space-2);
    margin-bottom: 0.2rem;
}

.ns-decision-card__when {
    font-size: var(--ns-text-xs);
    color: var(--muted-foreground);
    white-space: nowrap;
}

/* Attribution chip — ghost pill in the feed meta row (rules-as-live-agents). */
.ns-rule-chip {
    display: inline-block;
    max-width: 100%;
    margin-left: auto;
    padding: 0.1rem 0.45rem;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--muted-foreground);
    text-decoration: none;
    background: transparent;
    border: 1px solid var(--ns-color-lightgray2, #e5e7eb);
    border-radius: 999px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.ns-rule-chip:hover {
    color: var(--foreground);
    border-color: var(--ns-color-secondary, #64748b);
}

/* Agent cards grid on Autopilot Rules page. */
.ns-agent-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

@media (min-width: 992px) {
    .ns-agent-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.ns-agent-card {
    cursor: pointer;
    transition: box-shadow 0.15s ease, opacity 0.15s ease;
}

.ns-agent-card:hover {
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.ns-agent-card.is-off {
    opacity: 0.65;
}

.ns-agent-card__title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
    margin: 0;
}

.ns-agent-card__when {
    font-size: 0.8125rem;
    color: var(--foreground);
    margin: 0.35rem 0 0;
}

.ns-agent-card__stats {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin: 0.35rem 0 0;
}

.ns-agent-card__stats a {
    color: var(--ns-color-secondary, #0f766e);
    text-decoration: none;
    font-weight: 600;
}

.ns-agent-card__stats a:hover {
    text-decoration: underline;
}

.ns-agent-card--skeleton {
    min-height: 6.5rem;
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: ns-agent-skeleton 1.2s ease-in-out infinite;
    border-radius: 8px;
    border: 1px solid var(--ns-color-lightgray2, #e5e7eb);
}

@keyframes ns-agent-skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.ns-decision-card__headline {
    font-weight: 600;
    font-size: var(--ns-text-sm);
    line-height: 1.35;
    color: var(--foreground);
}

.ns-decision-card__ask {
    margin: 0.25rem 0 0;
    font-size: var(--ns-text-sm);
    line-height: 1.4;
    color: var(--muted-foreground);
}

.ns-decision-card__facts {
    margin: 0.15rem 0 0;
    font-size: var(--ns-text-xs);
    line-height: 1.4;
    color: var(--muted-foreground);
}

.ns-decision-card__done {
    margin: 0.2rem 0 0;
    font-size: var(--ns-text-xs);
    color: var(--ns-color-green-text, #1F4F2E);
}

.ns-decision-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ns-space-1);
    align-items: center;
    margin-top: var(--ns-space-2);
}

.ns-decision-card__actions .ns-btn--sm {
    min-height: 28px;
    padding: 0 8px;
    font-size: 0.75rem;
}

.ns-section-toggle {
    cursor: pointer;
    user-select: none;
}

button.ns-section-toggle {
    appearance: none;
    font: inherit;
}

button.ns-section-toggle:hover {
    color: var(--foreground);
}

.ns-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: var(--ns-space-3);
}

.ns-skeleton {
    height: 96px;
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--muted) 25%, var(--border) 50%, var(--muted) 75%);
    background-size: 200% 100%;
    animation: ns-shimmer 1.2s infinite;
    margin-bottom: var(--ns-space-3);
}

.ns-skeleton--row {
    height: 64px;
    margin: 0;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
}

.ns-skeleton--row:last-child {
    border-bottom: none;
}

@keyframes ns-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.ns-slot {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--ns-space-3);
    min-height: 100px;
    background: var(--card);
    color: var(--card-foreground);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .ns-slot:hover {
        border-color: var(--primary);
        box-shadow: var(--shadow);
    }

.ns-slot--filled {
    background: color-mix(in srgb, var(--success) 9%, var(--card));
    border-color: color-mix(in srgb, var(--success) 36%, var(--border));
    border-style: solid;
}

.ns-slot--empty {
    border-style: dashed;
    background: var(--background);
    border-color: color-mix(in srgb, var(--muted-foreground) 18%, var(--border));
}

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

/* Chip / pill selector (reason codes, filters, tags) */
.ns-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ns-space-2);
}

.ns-chip {
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: var(--ns-space-1) var(--ns-space-3);
    background: var(--card);
    color: var(--foreground);
    cursor: pointer;
    font-size: var(--ns-text-sm);
    line-height: 1.4;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

    .ns-chip:hover {
        border-color: var(--primary);
        background: var(--accent);
    }

.ns-chip--selected {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-foreground);
}

    .ns-chip--selected:hover {
        background: var(--ns-color-primary-2, #e05c1d);
        border-color: var(--ns-color-primary-2, #e05c1d);
        color: var(--primary-foreground);
    }

/* Suggestion bar — simple muted chips (shadcn-like) */
.ns-suggestion-bar .ns-chip-group {
    gap: 0.375rem;
    align-items: center;
}

.ns-suggestion-bar .ns-suggestion-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    height: 1.375rem; /* 22px */
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--muted);
    color: var(--muted-foreground);
    overflow: hidden;
}

.ns-suggestion-bar .ns-suggestion-chip:hover {
    background: color-mix(in srgb, var(--muted-foreground) 8%, var(--muted));
}

/* Prefill ("Use last trip") — same pill shape, soft brand orange so it reads as the primary action */
.ns-suggestion-bar .ns-suggestion-chip--prefill {
    background: var(--accent);
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
    color: var(--ns-color-primary-2, #e05c1d);
}

.ns-suggestion-bar .ns-suggestion-chip--prefill:hover {
    background: color-mix(in srgb, var(--primary) 12%, var(--accent));
    border-color: color-mix(in srgb, var(--primary) 50%, var(--border));
}

.ns-suggestion-bar .ns-suggestion-chip--flash {
    border-color: var(--success);
    color: var(--success);
}

.ns-suggestion-bar .ns-suggestion-chip__apply,
.ns-suggestion-bar .ns-suggestion-chip__dismiss,
.ns-suggestion-bar .ns-suggestion-chip--bulk,
.ns-suggestion-bar .ns-suggestion-more {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    text-decoration: none !important;
    font-family: inherit;
    cursor: pointer;
    color: inherit;
}

.ns-suggestion-bar .ns-suggestion-chip__apply {
    height: 100%;
    max-width: 16rem;
    padding: 0 0.375rem 0 0.5rem;
    display: inline-flex;
    align-items: center;
    font-size: 0.6875rem;
    font-weight: 500;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ns-suggestion-bar .ns-suggestion-chip__apply.is-busy {
    opacity: 0.5;
}

.ns-suggestion-bar .ns-suggestion-chip__apply:focus-visible,
.ns-suggestion-bar .ns-suggestion-chip__dismiss:focus-visible,
.ns-suggestion-bar .ns-suggestion-chip--bulk:focus-visible,
.ns-suggestion-bar .ns-suggestion-more:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 1px;
}

.ns-suggestion-bar .ns-suggestion-chip__dismiss {
    flex: 0 0 auto;
    width: 1.25rem;
    height: 100%;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.65;
}

.ns-suggestion-bar .ns-suggestion-chip__dismiss:hover:not(:disabled) {
    opacity: 1;
    color: var(--foreground);
}

.ns-suggestion-bar .ns-suggestion-chip__dismiss:disabled,
.ns-suggestion-bar .ns-suggestion-chip__apply:disabled,
.ns-suggestion-bar .ns-suggestion-chip--bulk:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ns-suggestion-bar .ns-suggestion-chip--bulk {
    height: 1.375rem;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--muted);
    color: var(--muted-foreground);
    font-size: 0.6875rem;
    font-weight: 500;
    line-height: 1;
}

.ns-suggestion-bar .ns-suggestion-chip--bulk:hover:not(:disabled) {
    background: color-mix(in srgb, var(--muted-foreground) 8%, var(--muted));
}

.ns-suggestion-bar .ns-suggestion-more {
    height: 1.375rem;
    padding: 0 0.25rem;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--muted-foreground);
}

.ns-suggestion-bar .ns-suggestion-more:hover {
    color: var(--foreground);
}

.ns-suggestion-bar .ns-suggestion-skeleton {
    display: inline-block;
    width: 4.5rem;
    height: 1.375rem;
    border-radius: var(--radius-sm);
    background: var(--muted);
    animation: ns-suggestion-pulse 1.2s ease-in-out infinite;
}

@keyframes ns-suggestion-pulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 0.85; }
}

/* Badges & status pills */
.ns-badge {
    display: inline-flex;
    align-items: center;
    font-size: var(--ns-text-sm);
    padding: var(--ns-space-1) 0.625rem;
    border-radius: var(--radius-full);
    font-weight: 500;
    line-height: 1.4;
}

.ns-decision-card .ns-badge {
    font-size: 0.6875rem;
    padding: 0.1rem 0.45rem;
    font-weight: 600;
    line-height: 1.35;
}

.ns-badge--warning {
    background: var(--warning-subtle);
    color: var(--warning-foreground);
}

.ns-badge--danger {
    background: rgba(241, 75, 91, 0.12);
    color: var(--destructive);
}

.ns-badge--success {
    background: rgba(30, 179, 134, 0.15);
    color: var(--ns-color-green-text, #1F4F2E);
}

.ns-badge--muted {
    background: var(--muted);
    color: var(--muted-foreground);
}

/* ═══════════════════════════════════════════════════════════════════════════
   4. Surface helpers (optional card-in-card patterns)
   ═══════════════════════════════════════════════════════════════════════════ */

.ns-surface {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.ns-surface--muted {
    background: var(--muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   5. Vehicle assets — stacked category sections + axle diagram
   ═══════════════════════════════════════════════════════════════════════════ */

.ns-vehicle-assets {
    display: flex;
    flex-direction: column;
    gap: var(--ns-space-5);
}

.ns-asset-section {
    display: flex;
    flex-direction: column;
    gap: var(--ns-space-3);
}

.ns-asset-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ns-space-3);
    flex-wrap: wrap;
}

.ns-asset-section__title {
    margin: 0;
    font-size: var(--ns-text-base);
    font-weight: 600;
}

.ns-asset-section__meta {
    display: block;
    font-size: var(--ns-text-xs);
    color: var(--muted-foreground);
}

.ns-asset-empty {
    padding: var(--ns-space-4);
    font-size: var(--ns-text-sm);
    color: var(--muted-foreground);
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.ns-axle-diagram {
    display: flex;
    flex-direction: column;
    gap: var(--ns-space-6);
    padding: var(--ns-space-5);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.ns-axle-row__label {
    font-size: var(--ns-text-xs);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted-foreground);
    text-align: center;
    margin-bottom: var(--ns-space-3);
}

.ns-axle-row__track {
    display: grid;
    grid-template-columns: 1fr minmax(56px, 96px) 1fr;
    align-items: center;
    gap: var(--ns-space-3);
}

.ns-axle-row__wheels {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ns-space-2);
    align-items: stretch;
}

.ns-axle-row__wheels--left {
    justify-content: flex-end;
}

.ns-axle-row__wheels--right {
    justify-content: flex-start;
}

.ns-axle-row__center {
    align-self: center;
    width: 100%;
    height: 10px;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--border), var(--muted-foreground), var(--border));
    opacity: 0.35;
}

.ns-axle-slot {
    display: flex;
    flex-direction: column;
    flex: 0 1 132px;
    min-width: 112px;
    max-width: 148px;
    min-height: 128px;
    padding: var(--ns-space-3);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

    .ns-axle-slot:hover {
        border-color: var(--primary);
        box-shadow: var(--shadow);
    }

.ns-axle-slot--empty {
    border-style: dashed;
    background: var(--background);
    border-color: color-mix(in srgb, var(--muted-foreground) 18%, var(--border));
    min-height: 136px;
}

    .ns-axle-slot--empty:hover {
        background: var(--accent);
        border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
    }

.ns-axle-slot--filled {
    background: color-mix(in srgb, var(--success) 9%, var(--card));
    border-color: color-mix(in srgb, var(--success) 36%, var(--border));
    border-style: solid;
}

.ns-axle-slot--selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--ns-color-primary-rgb, 255, 104, 33), 0.2);
}

.ns-axle-mobile-row--selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--ns-color-primary-rgb, 255, 104, 33), 0.2);
}

.ns-vehicle-assets--readonly .ns-axle-slot,
.ns-vehicle-assets--readonly .ns-axle-mobile-row {
    cursor: default;
}

.ns-vehicle-assets--readonly .ns-axle-slot--filled,
.ns-vehicle-assets--readonly .ns-axle-mobile-row--filled {
    cursor: pointer;
}

.ns-vehicle-assets--readonly .ns-axle-slot a,
.ns-vehicle-assets--readonly .ns-axle-mobile-row a {
    pointer-events: auto;
    cursor: pointer;
}

.ns-axle-slot__label {
    font-weight: 700;
    font-size: var(--ns-text-sm);
    line-height: 1.2;
}

.ns-axle-slot__code {
    font-size: var(--ns-text-xs);
    color: var(--muted-foreground);
}

.ns-axle-slot__body {
    flex: 1;
    margin-top: var(--ns-space-2);
    font-size: var(--ns-text-xs);
    line-height: 1.35;
}

.ns-axle-slot__cta {
    margin-top: var(--ns-space-2);
    font-size: var(--ns-text-sm);
    font-weight: 600;
    color: var(--muted-foreground);
}

.ns-axle-slot--empty:hover .ns-axle-slot__cta {
    color: var(--primary);
}

.ns-axle-slot__actions {
    display: flex;
    gap: var(--ns-space-1);
    margin-top: var(--ns-space-2);
    padding-top: var(--ns-space-2);
    border-top: 1px solid var(--border);
}

.ns-axle-slot__action-btn {
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    font-size: var(--ns-text-xs);
    line-height: 1.4;
    cursor: pointer;
    color: var(--foreground);
}

    .ns-axle-slot__action-btn:hover {
        border-color: var(--primary);
        color: var(--primary);
    }

.ns-axle-slot__action-btn--danger:hover {
    border-color: var(--destructive);
    color: var(--destructive);
}

/* Mobile: list instead of diagram */
.ns-axle-diagram--desktop {
    display: flex;
}

.ns-axle-mobile-list {
    display: none;
}

@media (max-width: 991.98px) {
    .ns-axle-diagram--desktop {
        display: none;
    }

    .ns-axle-mobile-list {
        display: block;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        overflow: hidden;
    }

    .ns-axle-mobile-row {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: var(--ns-space-3);
        align-items: center;
        padding: var(--ns-space-3) var(--ns-space-4);
        border-bottom: 1px solid var(--border);
        min-height: 52px;
    }

    .ns-axle-mobile-row--filled {
        background: color-mix(in srgb, var(--success) 7%, var(--card));
    }

    .ns-axle-mobile-row--empty {
        background: var(--background);
    }

        .ns-axle-mobile-row--empty:active {
            background: var(--accent);
        }

    .ns-axle-mobile-row:last-child {
        border-bottom: none;
    }

    .ns-axle-mobile-row--filled:active {
        background: color-mix(in srgb, var(--success) 12%, var(--card));
    }
}

/* Non-axle positional layouts render as a simple wrap of slot cards */
.ns-slot-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ns-space-3);
    padding: var(--ns-space-5);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

/* Non-positional categories render as a flat installed list */
.ns-asset-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.ns-asset-list__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ns-space-3);
    padding: var(--ns-space-3) var(--ns-space-4);
    background: var(--card);
}

    .ns-asset-list__row:not(:last-child) {
        border-bottom: 1px solid var(--border);
    }

/* Dialog footers */
.dialog-footer.ns-dialog-footer,
.ns-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--ns-space-2);
    width: 100%;
    margin-top: var(--ns-space-3);
    padding-top: var(--ns-space-3);
    border-top: 1px solid var(--border);
}

/* Slot-assign dialog */
.ns-slot-assign {
    display: flex;
    flex-direction: column;
    gap: var(--ns-space-3);
}

    .ns-slot-assign .dialog-footer,
    .ns-slot-assign .ns-dialog-footer {
        margin-top: auto;
    }

.ns-slot-assign__odo {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

    .ns-slot-assign__odo > label {
        font-size: var(--ns-text-xs);
        font-weight: 600;
        color: var(--muted-foreground);
    }

.ns-slot-assign__list {
    display: flex;
    flex-direction: column;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.ns-slot-assign__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ns-space-3);
    width: 100%;
    padding: var(--ns-space-3) var(--ns-space-4);
    border: none;
    border-bottom: 1px solid var(--border);
    background: var(--card);
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease;
}

    .ns-slot-assign__item:last-child {
        border-bottom: none;
    }

    .ns-slot-assign__item:hover:not(:disabled) {
        background: var(--accent);
    }

    .ns-slot-assign__item:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

.ns-slot-assign__item-main {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.ns-slot-assign__item-code {
    font-weight: 600;
    font-size: var(--ns-text-sm);
}

.ns-slot-assign__item-serial {
    font-size: var(--ns-text-xs);
    color: var(--muted-foreground);
}

.ns-slot-assign__item-cta {
    font-size: var(--ns-text-sm);
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

.ns-slot-assign__item:disabled .ns-slot-assign__item-cta {
    color: var(--muted-foreground);
}

.ns-slot-assign__empty {
    text-align: center;
    padding: var(--ns-space-5) var(--ns-space-3);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.ns-slot-assign__tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--muted);
    border-radius: var(--radius);
}

.ns-slot-assign__tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 6px 10px;
    border-radius: calc(var(--radius) - 2px);
    font-size: var(--ns-text-sm);
    font-weight: 600;
    color: var(--muted-foreground);
    cursor: pointer;
}

.ns-slot-assign__tab--active {
    background: var(--card);
    color: var(--foreground);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
}

.ns-slot-assign__field-label {
    display: block;
    font-size: var(--ns-text-xs);
    font-weight: 600;
    color: var(--muted-foreground);
    margin-bottom: 4px;
}

.ns-slot-assign__serial-grid {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 280px;
    overflow-y: auto;
}

.ns-slot-assign__serial-head,
.ns-slot-assign__serial-row {
    display: grid;
    grid-template-columns: minmax(88px, 1fr) 2fr;
    gap: var(--ns-space-2);
    align-items: center;
    padding: 8px 12px;
}

.ns-slot-assign__serial-head {
    font-size: var(--ns-text-xs);
    font-weight: 600;
    color: var(--muted-foreground);
    background: var(--muted);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}

.ns-slot-assign__serial-row:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.ns-slot-assign__serial-pos {
    font-size: var(--ns-text-sm);
    font-weight: 600;
}

.ns-slot-assign__serial-input {
    display: flex;
    align-items: center;
    min-width: 0;
}

    .ns-slot-assign__serial-input .custom-w-90 {
        flex: 1;
        min-width: 0;
    }

.ns-asset-bulk-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--ns-space-2);
    margin-bottom: var(--ns-space-3);
    padding: var(--ns-space-3) var(--ns-space-4);
    background: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--ns-text-sm);
}

/* ═══════════════════════════════════════════════════════════════════════════
   6. Generic layout builder (Settings > Position Layouts)
   Domain-agnostic: driven by the LayoutProfile (row/lane/slot nouns + render style).
   ═══════════════════════════════════════════════════════════════════════════ */

.ns-layout-builder {
    display: flex;
    flex-direction: column;
    gap: var(--ns-space-4);
}

.ns-layout-builder__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--ns-space-3);
    padding: var(--ns-space-4);
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.ns-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 220px;
    min-width: 160px;
}

.ns-field--sm {
    flex: 0 1 170px;
}

.ns-field > label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-foreground);
}

.ns-layout-builder__count {
    display: flex;
    gap: var(--ns-space-2);
    margin-left: auto;
    align-self: center;
}

.ns-layout-builder__canvas {
    display: flex;
    flex-direction: column;
    gap: var(--ns-space-4);
    padding: var(--ns-space-4);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-height: 55vh;
    overflow-y: auto;
}

.ns-layout-builder__empty {
    text-align: center;
    color: var(--muted-foreground);
    padding: var(--ns-space-5);
}

.ns-builder-row {
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: var(--ns-space-3) var(--ns-space-4);
    background: var(--background);
}

.ns-builder-row__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ns-space-3);
    margin-bottom: var(--ns-space-3);
}

.ns-builder-row__title {
    font-weight: 600;
    color: var(--foreground);
}

.ns-builder-row__tools {
    display: flex;
    gap: var(--ns-space-2);
    align-items: center;
}

.ns-builder-row__remove {
    border: none;
    background: transparent;
    color: var(--destructive);
    font-size: 0.9rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 6px;
    border-radius: var(--radius);
}

    .ns-builder-row__remove:hover {
        background: color-mix(in srgb, var(--destructive) 12%, transparent);
    }

.ns-slot--edit {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 118px;
    padding: var(--ns-space-3);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.05));
}

.ns-slot__remove {
    position: absolute;
    top: 4px;
    right: 4px;
    border: none;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: var(--radius);
}

    .ns-slot__remove:hover {
        color: var(--destructive);
        background: color-mix(in srgb, var(--destructive) 12%, transparent);
    }

.ns-slot__input {
    width: 100%;
    font-size: 0.8rem;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--foreground);
}

.ns-slot__toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--muted-foreground);
    margin: 0;
}

.ns-builder-add-row {
    align-self: flex-start;
    border: 1px dashed var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    color: var(--primary);
    font-weight: 600;
    padding: var(--ns-space-2) var(--ns-space-4);
    border-radius: var(--radius);
    cursor: pointer;
}

    .ns-builder-add-row:hover {
        background: color-mix(in srgb, var(--primary) 16%, transparent);
    }
