/* Native Stack — component stylesheet. Tokens only; no literal colours below except via var(). */
:root { --ns-tnum: "tnum" 1, "lnum" 1; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-sans); font-size: 14px; line-height: 20px; -webkit-font-smoothing: antialiased; }
* { box-sizing: border-box; }
.ns-num { font-feature-settings: var(--ns-tnum); font-variant-numeric: tabular-nums lining-nums; }
.ns-preview { padding: var(--space-5); background: var(--tracing); }
.ns-row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.ns-stack { display: flex; flex-direction: column; gap: var(--space-4); }
.ns-display { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.01em; }
.ns-label { font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.ns-small { font-size: 12px; line-height: 16px; color: var(--ink-mute); }
.ns-dense { font-size: 13px; line-height: 18px; }
.ns-legal { font-weight: 600; color: var(--ink); }
.ns-dba { color: var(--ink-soft); font-weight: 400; }
.ns-money { font-feature-settings: var(--ns-tnum); font-variant-numeric: tabular-nums; font-weight: 500; text-align: right; white-space: nowrap; }
.ns-money-lg { font-size: 22px; line-height: 26px; font-weight: 600; letter-spacing: -0.01em; }
.ns-jobno { font-feature-settings: var(--ns-tnum); font-weight: 600; font-size: 13px; line-height: 16px; letter-spacing: 0.04em; white-space: nowrap; }
a.ns-link, .ns-link { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }

/* focus: every interactive element */
.ns-btn:focus-visible, .ns-input:focus-visible, .ns-select:focus-visible, .ns-filter:focus-visible, .ns-switch:focus-visible, .ns-app:focus-visible, .ns-chip-btn:focus-visible, .ns-row-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Buttons */
.ns-btn { font: inherit; font-weight: 500; height: 36px; padding: 0 var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--dust); box-shadow: var(--shadow-card); background: var(--paper); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.ns-btn:hover { background: var(--tracing); }
.ns-btn-primary { background: var(--clay); border-color: var(--clay); color: var(--on-clay); }
.ns-btn-primary:hover { background: var(--clay-deep); border-color: var(--clay-deep); }
.ns-btn-quiet { border-color: transparent; box-shadow: none; }
.ns-btn-quiet:hover { background: var(--tracing); border-color: var(--dust); }
.ns-btn-blocked { background: var(--tracing); border-color: var(--status-draft-line); color: var(--status-draft); cursor: not-allowed; border-style: dashed; box-shadow: none; }
.ns-btn-sm { height: 28px; padding: 0 var(--space-3); font-size: 13px; }
.ns-btn-phone { min-height: 44px; }
.ns-btn .ns-count { color: inherit; opacity: .8; }

/* Inputs, selects, filters */
.ns-field { display: flex; flex-direction: column; gap: var(--space-1); }
.ns-field > .ns-label { color: var(--ink-soft); }
.ns-input, .ns-select { font: inherit; height: 38px; padding: 0 var(--space-3); border: 1px solid var(--dust-deep); border-radius: var(--radius-md); background: var(--paper); color: var(--ink); width: 100%; }
.ns-input::placeholder { color: var(--ink-mute); }
.ns-input-money { text-align: right; font-feature-settings: var(--ns-tnum); font-weight: 500; }
.ns-select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.ns-help { font-size: 12px; line-height: 16px; color: var(--ink-mute); }
.ns-filter { font: inherit; font-size: 13px; height: 30px; padding: 0 var(--space-3); border: 1px solid var(--dust-deep); border-radius: var(--radius-pill); background: var(--paper); color: var(--ink); cursor: pointer; }
.ns-filter[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.ns-switch { width: 40px; height: 22px; border-radius: var(--radius-pill); border: 1px solid var(--dust-deep); background: var(--paper); position: relative; cursor: pointer; padding: 0; }
.ns-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; background: var(--ink-soft); border-radius: var(--radius-pill); transition: left .12s; }
.ns-switch[aria-checked="true"] { background: var(--ink); border-color: var(--ink); }
.ns-switch[aria-checked="true"]::after { left: 21px; background: var(--on-ink); }

/* Status chip — every state carries a word */
.ns-status { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 10px; font-size: 12px; line-height: 16px; font-weight: 600; border-radius: var(--radius-pill); white-space: nowrap; }
.ns-status-draft { color: var(--status-draft); border: 1px dashed var(--status-draft-line); background: var(--paper); }
.ns-status-ready { color: var(--ink); border: 1px solid var(--ink); background: var(--paper); }
.ns-status-sent { color: var(--on-clay); background: var(--status-sent); }
.ns-status-blocked { color: var(--status-blocked); background: var(--clay-tint); border: 1px solid var(--status-blocked); }
.ns-status-complete, .ns-status-awarded { color: var(--on-topsoil); background: var(--status-complete); }
.ns-status-attention { color: var(--status-attention); background: var(--sand-tint); }
.ns-status-prospective { color: var(--ink-soft); border: 1px solid var(--dust-deep); background: var(--paper); }
.ns-status-current { color: var(--ink); background: var(--aggregate-tint); }
.ns-status-unknown { color: var(--status-unknown); background: var(--tracing); font-weight: 400; }
.ns-stamp { display: inline-flex; align-items: center; height: 26px; padding: 0 var(--space-3); border: 2px solid var(--status-complete); color: var(--status-complete); border-radius: var(--radius-pill); font-family: var(--font-display); font-weight: 800; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; transform: rotate(-3deg); background: var(--paper); }

/* Unknown vs zero */
.ns-unknown { color: var(--status-unknown); font-weight: 400; }
.ns-unknown::before { content: "—"; margin-right: 6px; }
.ns-zero { color: var(--ink); font-feature-settings: var(--ns-tnum); }

/* Actor chip: a person or an agent, same shape */
.ns-actor { white-space: nowrap; display: inline-flex; align-items: center; gap: var(--space-2); height: 28px; padding: 0 var(--space-3) 0 4px; border: 1px solid var(--dust); border-radius: var(--radius-pill); background: var(--paper); font-size: 13px; color: var(--ink); }
.ns-actor-avatar { width: 20px; height: 20px; border-radius: var(--radius-pill); background: var(--ink); color: var(--on-ink); display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; letter-spacing: .02em; }
.ns-actor-agent { background: var(--actor-agent); }
.ns-actor-agent .ns-actor-avatar { background: var(--topsoil); border-radius: var(--radius-sm); }
.ns-actor-kind { font-size: 11px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* App bar — one per app. Each app is its own window; the family is a menu, not a tab row. */
.ns-shell { background: var(--tracing); min-height: 100%; }
.ns-bar { height: 52px; background: var(--paper); border-bottom: 1px solid var(--dust); box-shadow: var(--shadow-card); display: flex; align-items: center; padding: 0 var(--space-4); gap: var(--space-4); position: relative; z-index: var(--z-chrome, 10); }
.ns-bar-app { display: flex; align-items: center; gap: var(--space-2); height: 52px; padding-right: var(--space-4); border-right: 1px solid var(--dust); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.ns-bar-app svg, .ns-bar-app img { width: 24px; height: 24px; display: block; border-radius: var(--radius-md); }
.ns-bar-app .ns-app-name { font-family: var(--font-display); font-weight: 800; font-size: 16px; line-height: 20px; letter-spacing: -0.01em; white-space: nowrap; }
.ns-bar-app[data-app="preconstruction"] { border-bottom-color: var(--app-preconstruction); }
.ns-bar-app[data-app="construction"] { border-bottom-color: var(--app-construction); }
.ns-bar-app[data-app="accounting"] { border-bottom-color: var(--app-accounting); }
.ns-bar-app[data-app="closeout"] { border-bottom-color: var(--app-closeout); }
.ns-bar-app[data-app="admin"] { border-bottom-color: var(--app-admin); }
.ns-family { position: relative; }
.ns-family-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--space-2); border: 1px solid transparent; border-radius: var(--radius-md); background: none; cursor: pointer; font: inherit; font-size: 12px; color: var(--ink-mute); }
.ns-family-btn svg { width: 20px; height: 20px; display: block; }
.ns-family-btn:hover { background: var(--tracing); border-color: var(--dust); }
.ns-family-menu { position: absolute; top: 42px; left: 0; width: 280px; background: var(--paper); border: 1px solid var(--dust); border-radius: var(--radius-lg); box-shadow: var(--shadow-toast); padding: var(--space-2); z-index: var(--z-sheet, 20); }
.ns-family-menu .ns-label { display: block; padding: var(--space-1) var(--space-3); }
.ns-family-menu a { display: grid; grid-template-columns: 24px 1fr auto; gap: var(--space-2); align-items: center; padding: 8px var(--space-2); border-radius: var(--radius-md); color: var(--ink); text-decoration: none; font-size: 13px; }
.ns-family-menu a:hover { background: var(--tracing); }
.ns-family-menu a svg, .ns-family-menu a img { width: 24px; height: 24px; border-radius: var(--radius-sm); display: block; }
.ns-family-menu a .ns-small { color: var(--ink-mute); }
.ns-family-menu a[aria-current="page"] { color: var(--ink-mute); cursor: default; }
.ns-bar-project { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; padding-left: var(--space-4); border-left: 1px solid var(--dust); }
.ns-bar-project .ns-jobno { color: var(--ink-soft); }
.ns-bar-project .ns-select { height: 30px; width: auto; min-width: 200px; font-size: 13px; background-color: var(--paper); }
.ns-bar-tools { display: flex; align-items: center; gap: var(--space-2); }
.ns-crosslink { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.ns-crosslink::after { content: "\2192"; text-decoration: none; }
.ns-page { padding: var(--space-6); background: var(--tracing); }
@media (max-width: 720px) { .ns-page { padding: var(--space-4); } .ns-bar-app .ns-app-name { display: none; } .ns-bar-project .ns-select { min-width: 0; } }

/* Page header */
.ns-pagehead { display: flex; align-items: flex-end; gap: var(--space-4); padding: var(--space-2) 0 var(--space-5); margin-bottom: var(--space-2); flex-wrap: wrap; }
.ns-pagehead-eyebrow { display: flex; gap: var(--space-2); align-items: center; margin-bottom: 4px; }
.ns-pagehead h1 { font-family: var(--font-display); font-size: 26px; line-height: 30px; font-weight: 800; letter-spacing: -0.01em; margin: 2px 0 0; }
.ns-pagehead .ns-legal-line { color: var(--ink-soft); font-size: 13px; line-height: 18px; margin-top: 2px; }
.ns-pagehead-actions { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; }

/* Record header + provenance */
.ns-record { border: 1px solid var(--dust); background: var(--paper); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }
.ns-record-head { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2) var(--space-4); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--dust); }
.ns-record-title { font-weight: 600; }
.ns-record-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0; }
.ns-record-field { padding: var(--space-3) var(--space-5); border-right: 1px solid var(--dust); border-bottom: 1px solid var(--dust); margin-bottom: -1px; }
.ns-record-field:last-child { border-right: 0; }
.ns-record-field .ns-value { font-size: 14px; line-height: 20px; color: var(--ink); font-weight: 500; }
.ns-record-field .ns-value.ns-num { font-weight: 500; }
.ns-prov { font-size: 12px; line-height: 16px; color: var(--ink-mute); display: inline-flex; align-items: center; gap: 6px; margin-top: 2px; }
.ns-prov::before { content: ""; width: 8px; height: 8px; border: 1px solid var(--dust-deep); background: var(--paper); flex: none; border-radius: 2px; }
.ns-prov[data-source="typed"]::before { border-style: dashed; }
.ns-prov[data-source="exhibit"]::before { background: var(--aggregate); border-color: var(--aggregate); }
.ns-prov[data-source="contract"]::before { background: var(--topsoil); border-color: var(--topsoil); }
.ns-prov[data-source="quickbooks"]::before { background: var(--sand); border-color: var(--sand); }
.ns-prov[data-source="license"]::before { background: var(--clay); border-color: var(--clay); }
.ns-prov[data-source="agent"]::before { background: var(--actor-agent); border-color: var(--topsoil); border-style: dashed; }

/* Dense table */
.ns-table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 18px; background: var(--paper); }
.ns-table th { text-align: left; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-soft); padding: var(--space-3) var(--space-3); background: var(--tracing); border-bottom: 1px solid var(--dust); white-space: nowrap; }
.ns-table td { padding: var(--space-3) var(--space-3); border-bottom: 1px solid var(--dust); vertical-align: top; }
.ns-table tbody tr:hover td { background: var(--tracing); }
.ns-table tbody tr:last-child td { border-bottom: 0; }
.ns-table th.ns-money, .ns-table td.ns-money { text-align: right; }
.ns-table tr.ns-row-draft td { border-bottom: 1px dashed var(--status-draft-line); color: var(--status-draft); }
.ns-table tr.ns-row-blocked td:first-child { box-shadow: inset 3px 0 0 var(--status-blocked); }
.ns-table tfoot td { border-top: 1px solid var(--dust-deep); border-bottom: 0; font-weight: 600; background: var(--paper); }
.ns-table .ns-cell-sub { display: block; color: var(--ink-mute); font-size: 12px; line-height: 16px; }
.ns-table-wrap { border: 1px solid var(--dust); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); background: var(--paper); overflow-x: auto; }
/* phone: rows become field-ticket cards with the same labels */
@media (max-width: 720px) {
  .ns-table.ns-table-phone thead { display: none; }
  .ns-table.ns-table-phone tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--dust); }
  .ns-table.ns-table-phone td { display: block; border: 0; padding: 2px 0; background: none !important; }
  .ns-table.ns-table-phone td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
  .ns-table.ns-table-phone td.ns-cell-primary { grid-column: 1 / -1; }
}

/* Document chip — evidence, not the row */
.ns-doc { display: inline-flex; align-items: center; gap: var(--space-2); height: 28px; padding: 0 var(--space-3) 0 6px; background: var(--aggregate-tint); border: 1px solid var(--aggregate); border-radius: var(--radius-md); font-size: 12px; line-height: 16px; color: var(--ink); max-width: 100%; }
.ns-doc-kind { font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--ink-soft); border: 1px solid var(--dust-deep); padding: 0 4px; line-height: 16px; background: var(--paper); border-radius: var(--radius-sm); }
.ns-doc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.ns-doc-meta { color: var(--ink-mute); white-space: nowrap; }
.ns-doc-photo { width: 18px; height: 18px; background: var(--sand); border: 1px solid var(--dust-deep); flex: none; border-radius: var(--radius-sm); }
.ns-doc-unlinked { border-style: dashed; background: var(--paper); color: var(--status-draft); }

/* Permission */
.ns-perm { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-4); border: 1px solid var(--dust); background: var(--paper); font-size: 13px; border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.ns-perm-cap { display: inline-flex; align-items: center; gap: 6px; }

.ns-perm-verb { color: var(--ink-soft); }
.ns-perm-note { grid-column: 1 / -1; font-size: 12px; line-height: 16px; color: var(--ink-mute); }
.ns-perm-blocked { box-shadow: inset 3px 0 0 var(--status-blocked), var(--shadow-card); }
.ns-perm-blocked .ns-perm-note { color: var(--status-blocked); }
.ns-perm-toggle { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 13px; }

/* Agent draft: queue item + inline diff */
.ns-draft { border: 1px dashed var(--status-draft-line); background: var(--paper); border-radius: var(--radius-lg); overflow: hidden; }
.ns-draft-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px dashed var(--status-draft-line); flex-wrap: wrap; }
.ns-draft-head .ns-app-tag { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.ns-draft-title { font-weight: 600; color: var(--ink); }
.ns-draft-body { padding: var(--space-4); display: grid; gap: var(--space-3); font-size: 13px; line-height: 18px; }
.ns-diff { display: grid; grid-template-columns: 140px 1fr 1fr; gap: 0; border: 1px solid var(--dust); background: var(--paper); font-size: 13px; border-radius: var(--radius-md); overflow: hidden; }
.ns-diff > div { padding: 8px var(--space-3); border-bottom: 1px solid var(--dust); }
.ns-diff > div:nth-last-child(-n+3) { border-bottom: 0; }
.ns-diff-label { color: var(--ink-soft); font-size: 12px; font-weight: 600; padding-top: 9px !important; }
.ns-diff-was { color: var(--ink-mute); text-decoration: line-through; text-decoration-color: var(--dust-deep); }
.ns-diff-now { color: var(--status-draft); border-left: 1px dashed var(--status-draft-line); }
.ns-diff-head { background: var(--tracing); color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.ns-draft-actions { display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px dashed var(--status-draft-line); align-items: center; flex-wrap: wrap; }
.ns-draft-actions .ns-small { margin-left: auto; }
.ns-banner-draft { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px dashed var(--status-draft-line); background: var(--paper); border-radius: var(--radius-lg); color: var(--status-draft); font-size: 13px; }

/* Field ticket form */
.ns-ticket { border: 1px solid var(--dust); background: var(--paper); max-width: 640px; border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }
.ns-ticket-head { display: flex; justify-content: space-between; align-items: baseline; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--dust); }
.ns-ticket-head .ns-display { font-size: 18px; line-height: 22px; }
.ns-ticket-grid { display: grid; grid-template-columns: repeat(12, 1fr); }
.ns-ticket-cell { padding: var(--space-3) var(--space-5); border-right: 1px solid var(--dust); border-bottom: 1px solid var(--dust); grid-column: span 6; }
.ns-ticket-cell.c4 { grid-column: span 4; } .ns-ticket-cell.c3 { grid-column: span 3; } .ns-ticket-cell.c12 { grid-column: span 12; border-right: 0; }
.ns-ticket-cell:nth-child(2n) { border-right: 0; }
.ns-ticket-cell .ns-label { display: block; margin-bottom: 2px; }
.ns-ticket-cell .ns-input, .ns-ticket-cell .ns-select { border-color: transparent; border-bottom: 1px solid var(--dust-deep); border-radius: 0; height: 32px; padding: 0 2px; }
.ns-ticket-cell .ns-input:focus-visible, .ns-ticket-cell .ns-select:focus-visible { border-bottom-color: var(--clay); box-shadow: none; outline: none; }
.ns-ticket-cell textarea.ns-input { height: auto; min-height: 72px; padding: 4px 2px; resize: vertical; font-family: inherit; }
.ns-ticket-foot { display: flex; gap: var(--space-2); padding: var(--space-4) var(--space-5); align-items: center; background: var(--tracing); }
.ns-ticket-foot .ns-small { margin-left: auto; }
@media (max-width: 720px) { .ns-ticket-cell, .ns-ticket-cell.c4, .ns-ticket-cell.c3 { grid-column: span 12; border-right: 0; } .ns-ticket-cell .ns-input, .ns-ticket-cell .ns-select { height: 44px; } }

/* Toast */
.ns-toast { display: inline-flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--paper); border: 1px solid var(--dust); border-left: 3px solid var(--ink); border-radius: var(--radius-lg); box-shadow: var(--shadow-toast); font-size: 13px; max-width: 480px; }
.ns-toast-sent { border-left-color: var(--status-sent); }
.ns-toast-blocked { border-left-color: var(--status-blocked); }
.ns-toast-draft { border-left-color: var(--status-draft-line); border-left-style: dashed; }
.ns-toast .ns-btn { margin-left: auto; }

/* Directory peek (slide-over) */
.ns-sheet { width: 360px; max-width: 100%; background: var(--paper); box-shadow: var(--shadow-sheet); min-height: 100%; border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
.ns-sheet-head { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--dust); display: flex; align-items: baseline; gap: var(--space-2); }
.ns-sheet-head .ns-display { font-size: 18px; line-height: 22px; }
.ns-sheet-section { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--dust); }
.ns-sheet-section .ns-label { display: block; margin-bottom: var(--space-1); }
.ns-sheet-jobs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.ns-sheet-jobs li { display: flex; gap: var(--space-2); align-items: center; }
.ns-sheet-jobs .ns-jobno { color: var(--ink-soft); width: 64px; }

/* App icon tile (family home) */
.ns-tile { display: grid; grid-template-columns: 64px 1fr; gap: var(--space-4); align-items: center; padding: var(--space-4); border: 1px solid var(--dust); background: var(--paper); text-decoration: none; color: var(--ink); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.ns-tile:hover { border-color: var(--dust-deep); }
.ns-tile img, .ns-tile svg { width: 64px; height: 64px; display: block; border-radius: 12px; }
.ns-tile .ns-display { font-size: 18px; line-height: 22px; }
.ns-tile .ns-small { display: block; }
