/* ==========================================================================
   Northstar Capital — Component library  (.ns-*)
   Shared by the marketing site, the product dashboard and the case study.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
.ns-root, .ns-root * { -webkit-font-smoothing: antialiased; }

.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.i--sm { width: 16px; height: 16px; }
.i--lg { width: 24px; height: 24px; }
.ns-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Eyebrow / mono label — the "north wedge" is the bullet ---------- */
.ns-eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font: 500 var(--fs-mono)/1 var(--font-mono); letter-spacing: var(--tracking-mono); text-transform: uppercase;
  color: var(--text-3);
}
.ns-eyebrow::before {
  content: ""; width: 8px; height: 9px; flex: none; background: var(--mark-accent);
  clip-path: polygon(0 0, 0 100%, 100% 100%);
}
.ns-eyebrow--plain::before { display: none; }
.ns-mono { font-family: var(--font-mono); letter-spacing: .02em; }
.ns-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ---------- Buttons ---------- */
.ns-btn {
  --h: 40px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 16px; border-radius: var(--r-md);
  font: 500 .9375rem/1 var(--font-sans); letter-spacing: -.006em; white-space: nowrap; text-decoration: none;
  border: 1px solid transparent; background: transparent; color: var(--text); cursor: pointer;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.ns-btn .i { width: 18px; height: 18px; transition: transform var(--dur-2) var(--ease); }
.ns-btn:active { transform: translateY(.5px); }
.ns-btn:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.ns-btn[disabled], .ns-btn[aria-disabled="true"] { opacity: .42; pointer-events: none; }

.ns-btn--primary { background: var(--accent); color: var(--accent-contrast); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(20,50,170,.35); }
.ns-btn--primary:hover { background: var(--accent-hover); }
.ns-btn--dark { background: var(--text); color: var(--bg); box-shadow: inset 0 1px 0 rgba(255,255,255,.12); }
.ns-btn--dark:hover { background: color-mix(in srgb, var(--text) 86%, var(--accent)); }
.ns-btn--outline { background: var(--surface); border-color: var(--line-strong); color: var(--text); box-shadow: var(--shadow-1); }
.ns-btn--outline:hover { border-color: var(--text-3); }
.ns-btn--ghost:hover { background: var(--line-soft); }
.ns-btn--link { height: auto; padding: 0; border-radius: 0; color: var(--accent-ink); }
.ns-btn--link:hover { text-decoration: underline; text-underline-offset: 4px; }
.ns-btn--sm { --h: 32px; padding: 0 12px; font-size: .8125rem; border-radius: 8px; gap: 6px; }
.ns-btn--sm .i { width: 16px; height: 16px; }
.ns-btn--lg { --h: 52px; padding: 0 24px; font-size: 1rem; border-radius: 12px; }
.ns-btn--icon { width: var(--h); padding: 0; }
.ns-btn--block { width: 100%; }
.ns-btn:hover .i-arrow { transform: translateX(3px); }
.ns-btn:hover .i-arrow-ur { transform: translate(2px, -2px); }

/* ---------- Form controls ---------- */
.ns-field { display: grid; gap: 8px; }
.ns-label { font: 500 .8125rem/1.2 var(--font-sans); color: var(--text); letter-spacing: -.003em; }
.ns-hint { font-size: .8125rem; color: var(--text-3); line-height: 1.4; }
.ns-input, .ns-select, .ns-textarea {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r-md);
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong);
  font: 400 .9375rem/1.2 var(--font-sans); letter-spacing: -.004em; outline: none;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.ns-textarea { height: auto; min-height: 112px; padding: 12px 14px; line-height: 1.5; resize: vertical; }
.ns-input::placeholder, .ns-textarea::placeholder { color: var(--text-3); opacity: .8; }
.ns-input:hover, .ns-select:hover, .ns-textarea:hover { border-color: var(--text-3); }
.ns-input:focus, .ns-select:focus, .ns-textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
.ns-input[aria-invalid="true"] { border-color: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }
.ns-input--sm, .ns-select--sm { height: 34px; font-size: .8125rem; padding: 0 10px; border-radius: 8px; }
.ns-select {
  appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23858FA0' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
}
.ns-input-wrap { position: relative; display: flex; align-items: center; }
.ns-input-wrap > .i { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; width: 18px; height: 18px; }
.ns-input-wrap > .ns-input { padding-left: 38px; }
.ns-input-prefix { position: absolute; left: 14px; color: var(--text-3); font-size: .9375rem; pointer-events: none; }
.ns-input-wrap > .ns-input.has-prefix { padding-left: 28px; }

.ns-switch { position: relative; display: inline-block; width: 40px; height: 24px; flex: none; }
.ns-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.ns-switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background var(--dur-2) var(--ease); }
.ns-switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform var(--dur-2) var(--ease); }
.ns-switch input:checked + span { background: var(--accent); }
.ns-switch input:checked + span::after { transform: translateX(16px); }
.ns-switch input:focus-visible + span { box-shadow: var(--ring); }

.ns-check { display: inline-flex; align-items: center; gap: 10px; font-size: .9375rem; cursor: pointer; }
.ns-check input { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin: 0; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--surface); display: grid; place-content: center; cursor: pointer; transition: all var(--dur-1) var(--ease); }
.ns-check input::after { content: ""; width: 10px; height: 10px; transform: scale(0); background: #fff; clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 8%, 38% 72%); transition: transform var(--dur-1) var(--ease); }
.ns-check input:checked { background: var(--accent); border-color: var(--accent); }
.ns-check input:checked::after { transform: scale(1); }
.ns-check input:focus-visible { box-shadow: var(--ring); }

/* ---------- Segmented control & tabs ---------- */
.ns-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--bg-sunken); border: 1px solid var(--line-soft); }
.ns-seg button { height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); font: 500 .8125rem/1 var(--font-sans); cursor: pointer; transition: all var(--dur-2) var(--ease); white-space: nowrap; }
.ns-seg button:hover { color: var(--text); }
.ns-seg button[aria-pressed="true"], .ns-seg button[aria-selected="true"], .ns-seg button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), 0 0 0 1px var(--line-soft); }
.ns-seg button:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 1px; }

.ns-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.ns-tabs::-webkit-scrollbar { display: none; }
.ns-tabs button, .ns-tabs a { position: relative; flex: none; padding: 0 0 12px; border: 0; background: none; color: var(--text-3); font: 500 .9375rem/1 var(--font-sans); letter-spacing: -.006em; cursor: pointer; text-decoration: none; display: inline-flex; gap: 8px; align-items: center; transition: color var(--dur-2) var(--ease); }
.ns-tabs button:hover, .ns-tabs a:hover { color: var(--text); }
.ns-tabs [aria-selected="true"], .ns-tabs .is-active { color: var(--text); }
.ns-tabs [aria-selected="true"]::after, .ns-tabs .is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text); border-radius: 2px; }
.ns-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--line-soft); color: var(--text-2); font: 500 .6875rem/1 var(--font-mono); }

/* ---------- Chips & badges ---------- */
.ns-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font: 500 .8125rem/1 var(--font-sans); cursor: pointer; transition: all var(--dur-2) var(--ease); }
.ns-chip:hover { color: var(--text); border-color: var(--text-3); }
.ns-chip[aria-pressed="true"], .ns-chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }

.ns-badge { --b: var(--text-2); --bg-b: var(--line-soft); display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--bg-b); color: var(--b); font: 500 .75rem/1 var(--font-sans); letter-spacing: -.003em; white-space: nowrap; }
.ns-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.ns-badge--plain::before { display: none; }
.ns-badge--accent { --b: var(--accent-ink); --bg-b: var(--accent-soft); }
.ns-badge--pos { --b: var(--pos); --bg-b: var(--pos-soft); }
.ns-badge--neg { --b: var(--neg); --bg-b: var(--neg-soft); }
.ns-badge--warn { --b: var(--warn); --bg-b: var(--warn-soft); }
.ns-badge--ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }

.ns-kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; background: var(--surface); color: var(--text-2); font: 500 .6875rem/1 var(--font-mono); }

/* ---------- Surfaces ---------- */
.ns-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.ns-card--flat { box-shadow: none; }
.ns-card--sunken { background: var(--surface-2); box-shadow: none; }
.ns-divider { height: 1px; background: var(--line); border: 0; margin: 0; }

.ns-avatar { --s: 32px; display: inline-grid; place-items: center; width: var(--s); height: var(--s); flex: none; border-radius: 50%; background: var(--bg-sunken); color: var(--text-2); font: 600 calc(var(--s) * .36)/1 var(--font-sans); letter-spacing: 0; box-shadow: inset 0 0 0 1px var(--line); }
.ns-avatar--sq { border-radius: 9px; }
.ns-avatar--accent { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent-line); }
.ns-avatar--ink { background: var(--ink-900); color: var(--paper-100); box-shadow: none; }

/* ---------- Stat ---------- */
.ns-stat { display: grid; gap: 6px; }
.ns-stat__label { font-size: .8125rem; color: var(--text-3); letter-spacing: -.003em; }
.ns-stat__value { font: 600 1.75rem/1.05 var(--font-sans); letter-spacing: -.035em; color: var(--text); }
.ns-delta { display: inline-flex; align-items: center; gap: 4px; font: 500 .75rem/1 var(--font-sans); color: var(--text-3); }
.ns-delta--pos { color: var(--pos); }
.ns-delta--neg { color: var(--neg); }
.ns-delta .i { width: 14px; height: 14px; }

/* ---------- Table ---------- */
.ns-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.ns-table th { text-align: left; padding: 10px 16px; font: 500 var(--fs-mono)/1 var(--font-mono); letter-spacing: var(--tracking-mono); text-transform: uppercase; color: var(--text-3); border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.ns-table td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); color: var(--text); vertical-align: middle; }
.ns-table tbody tr { transition: background var(--dur-1) var(--ease); }
.ns-table tbody tr:hover { background: var(--surface-2); }
.ns-table .r { text-align: right; }
.ns-amt-pos { color: var(--pos); }
.ns-amt-neg { color: var(--text); }

/* ---------- Meter ---------- */
.ns-meter { height: 6px; border-radius: 6px; background: var(--accent-soft); overflow: hidden; }
.ns-meter > i { display: block; height: 100%; border-radius: 6px; background: var(--accent); }
.ns-meter--pos { background: var(--pos-soft); } .ns-meter--pos > i { background: var(--pos-fill); }
.ns-meter--warn { background: var(--warn-soft); } .ns-meter--warn > i { background: var(--warn-fill); }

/* ---------- Toast ---------- */
.ns-toast-host { position: fixed; z-index: 1000; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: min(92vw, 420px); }
.ns-toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; background: var(--ink-900); color: var(--paper-100); border: 1px solid rgba(255,255,255,.1); box-shadow: var(--shadow-3); font-size: .875rem; line-height: 1.35; pointer-events: auto; animation: ns-toast-in var(--dur-3) var(--ease) both; }
.ns-toast .i { width: 18px; height: 18px; color: #6A8AFF; }
.ns-toast.is-out { animation: ns-toast-out var(--dur-2) var(--ease) both; }
@keyframes ns-toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes ns-toast-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ---------- Tooltip (CSS) ---------- */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translate(-50%, 4px); padding: 6px 9px; border-radius: 7px; background: var(--ink-900); color: var(--paper-100); font: 500 .75rem/1.2 var(--font-sans); white-space: nowrap; pointer-events: none; opacity: 0; transition: all var(--dur-2) var(--ease); z-index: 20; box-shadow: var(--shadow-2); }
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Brand graphic language ---------- */
/* Meridian grid: hairline columns with registration crosses at the intersections */
.ns-meridian { background-image: linear-gradient(to right, var(--line-soft) 1px, transparent 1px); background-size: calc(100% / 12) 100%; }
.ns-cross { position: relative; }
.ns-cross::before, .ns-cross::after { content: ""; position: absolute; width: 11px; height: 11px; background:
  linear-gradient(var(--text-3), var(--text-3)) center / 100% 1px no-repeat,
  linear-gradient(var(--text-3), var(--text-3)) center / 1px 100% no-repeat; opacity: .55; }
.ns-cross::before { top: -5px; left: -5px; } .ns-cross::after { bottom: -5px; right: -5px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
