/*
 * Nouvia Pane Design System — components v2.0.0
 * Requires tokens/nv-tokens.css. Every value is a token; no raw hex.
 */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--nv-surface); color: var(--nv-ink); font: var(--nv-text-body); -webkit-font-smoothing: antialiased; }
a { color: var(--nv-accent); text-underline-offset: 2px; }
a:hover { color: var(--nv-ink); }
:focus-visible { outline: none; box-shadow: var(--nv-focus-ring); }
.nv-icon { font-family: var(--nv-font-icon); font-size: 20px; line-height: 1; font-weight: 400; user-select: none; }
.nv-num { font-variant-numeric: tabular-nums; }

/* ── Pane shell ─────────────────────────────────────────── */
.nv-pane { position: relative; display: flex; flex-direction: column; height: 100vh; min-width: var(--nv-pane-narrow); background: var(--nv-surface); overflow: hidden; }
.nv-pane__header { flex: none; height: var(--nv-pane-header); display: flex; align-items: center; gap: var(--nv-space-1); padding: 0 var(--nv-space-2) 0 var(--nv-pane-margin); }
.nv-pane__title { flex: 1; min-width: 0; font: var(--nv-text-headline); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nv-pane__toolbar { flex: none; display: flex; flex-direction: column; gap: var(--nv-space-3); padding: 0 var(--nv-pane-margin) var(--nv-space-3); }
.nv-pane__content { flex: 1; min-height: 0; overflow: auto; padding: var(--nv-space-1) var(--nv-pane-margin) var(--nv-space-4); display: flex; flex-direction: column; gap: var(--nv-space-4); }
.nv-pane__actions { flex: none; height: var(--nv-pane-actions); display: flex; align-items: center; justify-content: flex-end; gap: var(--nv-space-2); padding: 0 var(--nv-space-4); background: var(--nv-surface); border-top: 1px solid var(--nv-outline); }
.nv-list-detail { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0,1fr); gap: var(--nv-space-3); padding: 0 var(--nv-space-3) var(--nv-space-3); }
@media (max-width: 599px) { .nv-list-detail { grid-template-columns: 1fr; } }

/* ── Buttons ────────────────────────────────────────────── */
.nv-btn { font: inherit; font-weight: 600; height: var(--nv-control); padding: 0 20px; border-radius: var(--nv-radius-full); border: 0; display: inline-flex; align-items: center; gap: var(--nv-space-2); cursor: pointer; transition: box-shadow var(--nv-dur-1) var(--nv-ease), background var(--nv-dur-1) var(--nv-ease); }
.nv-btn .nv-icon { font-size: 18px; }
.nv-btn--filled { background: var(--nv-accent); color: var(--nv-on-accent); }
.nv-btn--filled:hover { box-shadow: var(--nv-elev-1); filter: brightness(1.08); }
.nv-btn--tonal { background: var(--nv-accent-container); color: var(--nv-on-accent-container); }
.nv-btn--tonal:hover { box-shadow: var(--nv-elev-1); }
.nv-btn--outlined { background: transparent; color: var(--nv-ink); font-weight: 500; border: 1px solid var(--nv-outline-strong); padding: 0 16px; }
.nv-btn--outlined:hover, .nv-btn--text:hover { background: var(--nv-hover); }
.nv-btn--text { background: transparent; color: var(--nv-accent); padding: 0 12px; }
.nv-btn--danger { background: var(--nv-danger); color: var(--nv-surface); }
.nv-btn--sm { height: var(--nv-control-sm); padding: 0 14px; font-size: 13px; }
.nv-btn:active { background-image: linear-gradient(var(--nv-press), var(--nv-press)); }
.nv-btn:disabled { background: var(--nv-press); color: var(--nv-ink-3); border-color: transparent; box-shadow: none; filter: none; opacity: .7; cursor: default; }
.nv-btn:focus-visible { box-shadow: var(--nv-focus-ring); }
.nv-icon-btn { width: var(--nv-control); height: var(--nv-control); border-radius: var(--nv-radius-full); border: 0; background: transparent; color: var(--nv-ink-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.nv-icon-btn:hover { background: var(--nv-hover); }
.nv-icon-btn--tonal { background: var(--nv-surface-2); }
.nv-icon-btn--outlined { border: 1px solid var(--nv-outline-strong); }

/* Create button (extended FAB) — queue/list panes only */
.nv-fab { position: absolute; right: var(--nv-space-4); bottom: var(--nv-space-4); height: var(--nv-fab); min-width: var(--nv-fab); padding: 0 16px; border-radius: var(--nv-radius-fab); border: 0; background: var(--nv-accent-container); color: var(--nv-on-accent-container); box-shadow: var(--nv-elev-3); font: inherit; font-weight: 600; display: inline-flex; align-items: center; overflow: hidden; white-space: nowrap; cursor: pointer; transition: box-shadow var(--nv-dur-1) var(--nv-ease); }
.nv-fab .nv-icon { font-size: 24px; width: 24px; flex: none; }
.nv-fab__label { max-width: 160px; margin-left: 12px; padding-right: 4px; overflow: hidden; transition: max-width var(--nv-dur-2) var(--nv-ease), margin var(--nv-dur-2) var(--nv-ease), padding var(--nv-dur-2) var(--nv-ease), opacity var(--nv-dur-1); }
.nv-fab:hover { box-shadow: 0 6px 16px 4px rgba(0,0,0,.12), 0 2px 4px rgba(0,0,0,.12); }
.nv-fab:active { box-shadow: var(--nv-elev-1); }
.nv-fab--collapsed .nv-fab__label { max-width: 0; margin-left: 0; padding-right: 0; opacity: 0; }

/* ── Chips, badges, status ──────────────────────────────── */
.nv-chip { height: var(--nv-control-sm); padding: 0 12px; border-radius: var(--nv-radius-sm); border: 1px solid var(--nv-outline-strong); background: transparent; color: var(--nv-ink); font: inherit; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.nv-chip:hover { background: var(--nv-hover); }
.nv-chip[aria-pressed="true"], .nv-chip--selected { border-color: transparent; background: var(--nv-accent-container); color: var(--nv-on-accent-container); padding-left: 8px; }
.nv-chip--input { border: 0; background: var(--nv-surface-2); padding: 0 6px 0 10px; }
.nv-badge { height: 22px; padding: 0 8px; border-radius: var(--nv-radius-xs); display: inline-flex; align-items: center; gap: 4px; font: var(--nv-text-label); background: var(--nv-surface-3); color: var(--nv-ink-2); }
.nv-badge .nv-icon { font-size: 14px; }
.nv-badge--success { background: var(--nv-success-bg); color: var(--nv-success); }
.nv-badge--warning { background: var(--nv-warning-bg); color: var(--nv-warning); }
.nv-badge--danger  { background: var(--nv-danger-bg);  color: var(--nv-danger); }
.nv-badge--info    { background: var(--nv-info-bg);    color: var(--nv-info); }
.nv-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--nv-ink-3); }
.nv-dot--success { background: var(--nv-success); } .nv-dot--warning { background: var(--nv-warning); } .nv-dot--danger { background: var(--nv-danger); }
.nv-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--nv-radius-full); background: var(--nv-danger); color: var(--nv-surface); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

/* ── Inputs ─────────────────────────────────────────────── */
.nv-field { display: flex; flex-direction: column; gap: 6px; }
.nv-field__label { font: var(--nv-text-label); color: var(--nv-ink-2); }
.nv-field__help { font-size: 12px; color: var(--nv-ink-3); }
.nv-input, .nv-select, .nv-textarea { font: inherit; width: 100%; height: var(--nv-control); padding: 0 12px; border-radius: var(--nv-radius-sm); border: 1px solid var(--nv-outline-strong); background: var(--nv-surface); color: var(--nv-ink); outline: none; transition: border-color var(--nv-dur-1) var(--nv-ease); }
.nv-textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.nv-input:hover, .nv-select:hover, .nv-textarea:hover { border-color: var(--nv-ink-3); }
.nv-input:focus, .nv-select:focus, .nv-textarea:focus { border: 2px solid var(--nv-accent); padding-left: 11px; box-shadow: none; }
.nv-input:disabled, .nv-select:disabled, .nv-textarea:disabled { background: var(--nv-surface-2); color: var(--nv-ink-3); border-color: var(--nv-outline); cursor: not-allowed; }
.nv-input[aria-invalid="true"], .nv-textarea[aria-invalid="true"] { border: 2px solid var(--nv-danger); padding-left: 11px; }
.nv-field:focus-within .nv-field__label { color: var(--nv-accent); }
.nv-field--error .nv-field__label, .nv-field--error .nv-field__help { color: var(--nv-danger); }
.nv-search { height: 44px; border-radius: var(--nv-radius-full); background: var(--nv-surface-2); display: flex; align-items: center; gap: var(--nv-space-2); padding: 0 6px 0 14px; }
.nv-search input { flex: 1; min-width: 0; font: inherit; border: 0; background: none; color: var(--nv-ink); outline: none; }
.nv-search input::placeholder { color: var(--nv-ink-3); }
.nv-search:focus-within { box-shadow: var(--nv-focus-ring); }
.nv-check { appearance: none; width: 18px; height: 18px; border-radius: var(--nv-radius-xs); border: 2px solid var(--nv-ink-3); margin: 0; display: inline-grid; place-content: center; cursor: pointer; }
.nv-check:checked { background: var(--nv-accent); border-color: var(--nv-accent); }
.nv-check:checked::after { content: "check"; font-family: var(--nv-font-icon); font-size: 16px; color: var(--nv-on-accent); }
.nv-radio { appearance: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--nv-ink-3); margin: 0; display: inline-grid; place-content: center; cursor: pointer; }
.nv-radio:checked { border-color: var(--nv-accent); }
.nv-radio:checked::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--nv-accent); }
.nv-switch { appearance: none; width: 44px; height: 24px; border-radius: var(--nv-radius-full); border: 2px solid var(--nv-ink-3); background: var(--nv-surface-3); margin: 0; position: relative; cursor: pointer; transition: background var(--nv-dur-1) var(--nv-ease); }
.nv-switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--nv-ink-3); transition: all var(--nv-dur-1) var(--nv-ease); }
.nv-switch:checked { background: var(--nv-accent); border-color: var(--nv-accent); }
.nv-switch:checked::after { top: 2px; left: 22px; width: 16px; height: 16px; background: var(--nv-on-accent); }

/* ── Navigation ─────────────────────────────────────────── */
.nv-tabs { display: flex; border-bottom: 1px solid var(--nv-outline); }
.nv-tab { font: inherit; font-weight: 500; height: 44px; padding: 0 16px; background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; color: var(--nv-ink-2); cursor: pointer; }
.nv-tab:hover { background: var(--nv-hover); }
.nv-tab[aria-selected="true"] { font-weight: 600; color: var(--nv-ink); border-bottom-color: var(--nv-accent); }
.nv-seg { display: inline-flex; border: 1px solid var(--nv-outline-strong); border-radius: var(--nv-radius-full); overflow: hidden; }
.nv-seg > button { font: inherit; font-size: 13px; font-weight: 500; height: 36px; padding: 0 16px; border: 0; border-right: 1px solid var(--nv-outline-strong); background: transparent; color: var(--nv-ink); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.nv-seg > button:last-child { border-right: 0; }
.nv-seg > button[aria-pressed="true"] { background: var(--nv-accent-container); color: var(--nv-on-accent-container); }

/* ── Lists & tables ─────────────────────────────────────── */
.nv-section-label { font: var(--nv-text-label); color: var(--nv-ink-2); padding: var(--nv-space-2) var(--nv-space-2) var(--nv-space-1); }
.nv-row { display: flex; align-items: center; gap: var(--nv-space-3); padding: 10px var(--nv-space-2); min-height: var(--nv-row); border-radius: var(--nv-radius-md); cursor: pointer; }
.nv-row:hover { background: var(--nv-hover); }
.nv-row[aria-selected="true"] { background: var(--nv-accent-container); }
.nv-row__avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--nv-accent-container); color: var(--nv-on-accent-container); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.nv-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nv-row__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nv-row__meta { font: var(--nv-text-sm); color: var(--nv-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nv-row__trail { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--nv-ink-3); }
.nv-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; border: 1px solid var(--nv-outline); border-radius: var(--nv-radius-md); overflow: hidden; }
.nv-table th { height: 36px; padding: 0 12px; text-align: left; font: var(--nv-text-label); color: var(--nv-ink-2); background: var(--nv-surface-2); }
.nv-table td { height: var(--nv-row); padding: 0 12px; border-top: 1px solid var(--nv-outline); }
.nv-table tr:hover td { background: var(--nv-hover); }
.nv-table .nv-num, .nv-table th.nv-num { text-align: right; }
.nv-table tfoot td { font-weight: 600; border-top: 1px solid var(--nv-outline-strong); }
.nv-kv { display: grid; grid-template-columns: minmax(88px, 120px) minmax(0, 1fr); background: var(--nv-surface); border-radius: var(--nv-radius-md); }
.nv-kv dd, .nv-kv dt { overflow-wrap: anywhere; }
.nv-kv > * { padding: 10px 14px; border-bottom: 1px solid var(--nv-outline); }
.nv-kv > :nth-last-child(-n+2) { border-bottom: 0; }
.nv-kv dt { color: var(--nv-ink-2); }
.nv-kv dd { margin: 0; }

/* ── Feedback ───────────────────────────────────────────── */
.nv-card { background: var(--nv-surface-2); border-radius: var(--nv-radius-md); padding: var(--nv-space-5); }
.nv-banner { display: flex; gap: var(--nv-space-3); align-items: flex-start; padding: 12px 16px; border-radius: var(--nv-radius-md); font: var(--nv-text-sm); color: var(--nv-ink); }
.nv-banner--info { background: var(--nv-info-bg); } .nv-banner--info .nv-icon { color: var(--nv-info); }
.nv-banner--warning { background: var(--nv-warning-bg); } .nv-banner--warning .nv-icon { color: var(--nv-warning); }
.nv-banner--danger { background: var(--nv-danger-bg); } .nv-banner--danger .nv-icon { color: var(--nv-danger); }
.nv-banner--success { background: var(--nv-success-bg); } .nv-banner--success .nv-icon { color: var(--nv-success); }
.nv-snackbar { position: absolute; left: var(--nv-space-4); right: var(--nv-space-4); bottom: calc(var(--nv-pane-actions) + var(--nv-space-2)); display: flex; align-items: center; gap: var(--nv-space-3); min-height: 48px; padding: 0 8px 0 16px; border-radius: var(--nv-radius-sm); background: var(--nv-ink); color: var(--nv-bg); box-shadow: var(--nv-elev-3); }
.nv-snackbar__action { font: inherit; font-weight: 600; height: 36px; padding: 0 12px; border: 0; border-radius: var(--nv-radius-full); background: none; color: var(--nv-accent-container); cursor: pointer; }
.nv-progress { height: 4px; border-radius: var(--nv-radius-full); background: var(--nv-surface-3); overflow: hidden; }
.nv-progress > i { display: block; height: 100%; width: 40%; background: var(--nv-accent); border-radius: inherit; animation: nv-indeterminate 1.4s var(--nv-ease) infinite; }
@keyframes nv-indeterminate { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.nv-skeleton { background: var(--nv-surface-3); border-radius: var(--nv-radius-xs); animation: nv-pulse 1.6s ease-in-out infinite; }
@keyframes nv-pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.nv-tooltip { padding: 4px 8px; border-radius: var(--nv-radius-xs); background: var(--nv-ink); color: var(--nv-bg); font-size: 12px; }
.nv-scrim { position: absolute; inset: 0; background: var(--nv-scrim); display: flex; align-items: center; justify-content: center; padding: var(--nv-space-4); }
.nv-dialog { background: var(--nv-surface); border-radius: var(--nv-radius-lg); box-shadow: var(--nv-elev-3); padding: var(--nv-space-6); max-width: 320px; display: flex; flex-direction: column; gap: var(--nv-space-3); }
.nv-dialog__title { font: var(--nv-text-headline); }
.nv-dialog__body { color: var(--nv-ink-2); }
.nv-dialog__actions { display: flex; justify-content: flex-end; gap: var(--nv-space-2); margin-top: var(--nv-space-1); }
.nv-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--nv-space-2); padding: var(--nv-space-6); text-align: center; }
.nv-empty__icon { width: 56px; height: 56px; border-radius: 50%; background: var(--nv-surface-2); display: flex; align-items: center; justify-content: center; }
.nv-empty__icon .nv-icon { font-size: 28px; color: var(--nv-ink-2); }
.nv-empty--error .nv-empty__icon { background: var(--nv-danger-bg); } .nv-empty--error .nv-icon { color: var(--nv-danger); }
.nv-empty__title { font: var(--nv-text-title); }
.nv-empty__body { font: var(--nv-text-sm); color: var(--nv-ink-2); max-width: 320px; }

/* ── Pane ↔ chat handoff ────────────────────────────────── */
.nv-handoff-working { border-radius: var(--nv-radius-md); background: var(--nv-accent-container); color: var(--nv-on-accent-container); overflow: hidden; }
.nv-handoff-working__row { display: flex; gap: 10px; align-items: center; padding: 12px 14px; font: var(--nv-text-sm); font-weight: 500; }
.nv-handoff-working .nv-progress { height: 3px; border-radius: 0; background: rgba(0,0,0,.08); }
.nv-from-chat { box-shadow: inset 3px 0 0 var(--nv-accent); }
.nv-from-chat__tag { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--nv-accent); }
.nv-from-chat__tag .nv-icon { font-size: 14px; }
.nv-from-chat__old { text-decoration: line-through; color: var(--nv-ink-3); font: var(--nv-text-sm); }
.nv-locked { pointer-events: none; opacity: .6; }
.nv-waiting { display: flex; gap: var(--nv-space-3); align-items: center; padding: 12px 14px; border-radius: var(--nv-radius-md); border: 1px solid var(--nv-outline-strong); }
.nv-diff { display: flex; flex-direction: column; gap: 4px; font-variant-numeric: tabular-nums; }
.nv-diff__del, .nv-diff__add { display: flex; gap: 8px; padding: 4px 8px; border-radius: var(--nv-radius-xs); font: var(--nv-text-sm); }
.nv-diff__del { background: var(--nv-danger-bg); } .nv-diff__del s { color: var(--nv-ink-2); }
.nv-diff__add { background: var(--nv-success-bg); font-weight: 600; }

/* ---- Stepper (lifecycle strip): where this record is in its life, e.g. Scope ● → Estimate ○ → Quote ○. One line, no card. */
.nv-stepper { display: flex; align-items: center; gap: var(--nv-space-2); font: var(--nv-text-meta); color: var(--nv-ink-2); min-height: 20px; flex-wrap: wrap; }
.nv-stepper__step { display: inline-flex; align-items: center; gap: 6px; }
.nv-stepper__step[aria-current="step"] { color: var(--nv-ink); font-weight: 600; }
.nv-stepper__step[data-state="done"] .nv-stepper__dot { background: var(--nv-success); border-color: var(--nv-success); }
.nv-stepper__step[aria-current="step"] .nv-stepper__dot { background: var(--nv-accent); border-color: var(--nv-accent); }
.nv-stepper__dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--nv-ink-3); background: transparent; display: inline-block; }
.nv-stepper__line { width: 16px; height: 1px; background: var(--nv-outline); display: inline-block; }
.nv-stepper__meta { margin-left: var(--nv-space-1); color: var(--nv-ink-3); }

/* ---- Side sheet: a second level that opens over the pane (History, a record section, a file list). One at a time; × and Esc close it; the pane keeps its scroll. */
.nv-sheet { position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--nv-surface); box-shadow: var(--nv-elev-3); display: flex; flex-direction: column; }
.nv-sheet__header { flex: none; height: var(--nv-pane-header); display: flex; align-items: center; gap: var(--nv-space-2); padding: 0 var(--nv-space-2) 0 var(--nv-space-4); border-bottom: 1px solid var(--nv-outline); }
.nv-sheet__title { font: var(--nv-text-title); color: var(--nv-ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv-sheet__content { flex: 1; min-height: 0; overflow: auto; padding: var(--nv-space-4); display: flex; flex-direction: column; gap: var(--nv-space-3); }
.nv-scrim--sheet { justify-content: flex-end; align-items: stretch; padding: 0; }
