/* =====================================================================
   modules/base/assets/styles.css — Securily visual layer
   Part 1: generic widget styles (from the AtomMarkets design).
   Part 2: app shell + generic List / Form view chrome.
   Font: Proxima Nova (self-hosted in ./fonts/).
   ===================================================================== */

:root {
  /* Brand / action (semantic — not tied to a hue) */
  --action: #1665d8;
  --action-hover: #0f54bd;
  --action-active: #0c469e;
  --action-strong: #1763cf;
  --action-fg: #ffffff;
  --focus-ring: 0 0 0 2px rgba(22, 101, 216, .15);
  --focus-ring-soft: 0 0 0 2px rgba(22, 101, 216, .12);
  --link: #1a6dff;
  --link-hover: #0a52d4;
  --accent: #9a6434;
  --accent-fg: #ffffff;

  /* Financial signals */
  --gain: #1aa34a;
  --gain-bg: #e8f6ee;
  --loss: #e0392b;
  --loss-bg: #fcebed;

  /* Neutral scale */
  --ink: #1c1f23;
  --ink-2: #4a4f55;
  --ink-3: #7b8085;
  --ink-4: #a7adb3;
  --line: #e9ebee;
  --line-2: #eef0f2;
  --border: #d3d7dc;
  --border-strong: #b4b9bf;

  /* Surfaces */
  --bg: #efefef;
  --bg-subtle: #f1f2f4;
  --bg-hover: #f5f8ff;
  --bg-selected: #eaf1ff;
  --bg-info: #eef4fe;
  --bg-zebra: #f8f9fa;
  --sidenav-bg: #F2F2F2;
  --sidenav-border: #e6e6e6;
  --sidenav-active: #ede7de;

  /* Status */
  --warning: #b9770a;
  --warning-bg: #fef6e7;

  /* Radii */
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-pop: 0 2px 10px rgba(20, 28, 40, .12);
  --shadow-modal: 0 10px 34px rgba(15, 23, 38, .22);
  --shadow-card: 0 1px 2px rgba(20, 28, 40, .06);
  --shadow-knob: 0 1px 3px rgba(0, 0, 0, .28);
  --menu-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);

  /* Typography */
  --font-sans: 'Proxima Nova', 'proxima-nova', 'Helvetica Neue', Helvetica, Arial, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Spacing */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
}

/*
 * Theme tokens: source of truth is modules/base/views/themes.js (`tokens`).
 * applyTheme() writes them onto <html>. :root above is the pre-JS fallback.
 */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.4;
}

h1, h2, h3 { margin: 0; font-weight: 600; color: var(--ink); }

.num,
.value-num,
.kv-value,
.td-right,
.stepper-input,
.th-right { font-variant-numeric: tabular-nums; }

/* ---------- Icons ---------- */
.icon-wrap { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.icon { display: block; }

/* ---------- Links ---------- */
.link {
  color: var(--link);
  text-decoration: none;
  cursor: pointer;
  transition: color 120ms ease;
}
.link:hover { color: var(--link-hover); text-decoration: underline; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.btn-label { display: inline-flex; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* sizes */
.btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn-md { height: 40px; padding: 0 18px; font-size: 14px; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 16px; }

/* primary */
.btn-primary { background: var(--action); color: var(--action-fg); }
.btn-primary:hover { background: var(--action-hover); }
.btn-primary:active { background: var(--action-active); }

/* secondary — pill outline */
.btn-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--ink);
  border-radius: var(--radius-pill);
}
.btn-secondary:hover { border-color: var(--border-strong); background: #fafafa; }

/* tertiary / ghost text */
.btn-ghost { background: transparent; color: var(--link); }
.btn-ghost:hover { background: var(--bg-subtle); }

/* subtle (light grey fill, e.g. download / Vorschau) */
.btn-subtle { background: var(--bg-subtle); border-color: var(--border); color: var(--ink-2); }
.btn-subtle:hover { background: #e9ebee; }

/* danger */
.btn-danger { background: var(--loss); color: #fff; }
.btn-danger:hover { background: #c22f23; }

.btn-block { width: 100%; }
.btn-caret { margin-left: 2px; opacity: .9; }

/* ---------- Icon buttons ---------- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.icon-btn-sm { width: 30px; height: 30px; }
.icon-btn-md { width: 36px; height: 36px; }
.icon-btn-lg { width: 44px; height: 44px; }
.icon-btn-ghost:hover { background: var(--bg-subtle); color: var(--ink); }
.icon-btn-bare { color: var(--ink); }
.icon-btn-bare:hover { color: var(--ink); background: transparent; }
.icon-btn-outline { border-color: var(--border); color: var(--ink-2); }
.icon-btn-outline:hover { border-color: var(--border-strong); background: #fafafa; }
.icon-btn-primary { background: var(--action); color: var(--action-fg); border-radius: var(--radius-sm); }
.icon-btn-primary:hover { background: var(--action-hover); }
.icon-btn-filled { background: var(--bg-subtle); color: var(--ink-2); }
.icon-btn-filled:hover { background: #e3e6ea; color: var(--ink); }
.icon-btn-info-solid { color: var(--action); }
.icon-btn-on-blue { color: #fff; }
.icon-btn-on-blue:hover { background: rgba(255,255,255,.16); color: #fff; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-inline { flex-direction: row; align-items: center; justify-content: space-between; }
.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.field-hint { font-size: 12px; color: var(--ink-3); }
.field-error { font-size: 12px; color: var(--loss); }

/* ---------- Inputs ---------- */
.input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input::placeholder { color: var(--ink-4); }
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--action); box-shadow: var(--focus-ring); }
.input:disabled { background: var(--bg-subtle); color: var(--ink-4); }
.input-invalid { border-color: var(--loss); }
.input-invalid:focus { box-shadow: 0 0 0 2px rgba(224, 57, 43, .15); }

/* input shell with leading icon cell / trailing affix */
.input-shell {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input-shell:hover { border-color: var(--border-strong); }
.input-shell:focus-within { border-color: var(--action); box-shadow: var(--focus-ring); }
.input-shell.input-invalid { border-color: var(--loss); }
.input-shell .input { border: none; box-shadow: none; }
.input-shell .input:focus { box-shadow: none; }
.input-affix { display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); }
.input-affix-lead { width: 56px; border-right: 1px solid var(--line); color: var(--ink-2); }
.input-affix-trail { width: 48px; }

/* ---------- Search ---------- */
.search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  min-width: 260px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.search:focus-within { border-color: var(--action); box-shadow: var(--focus-ring-soft); }
.search-icon { color: var(--ink-4); flex: none; }
.search-input { flex: 1; border: none; outline: none; background: transparent; font-family: inherit; font-size: 14px; color: var(--ink); min-width: 0; }
.search-input::placeholder { color: var(--ink-4); }
.kbd {
  font-family: inherit;
  font-size: 12px;
  color: var(--ink-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  background: var(--bg-subtle);
}

/* ---------- Stepper ---------- */
.stepper {
  display: flex;
  align-items: center;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.stepper:focus-within { border-color: var(--action); box-shadow: var(--focus-ring); }
.stepper-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  padding: 0 14px;
}
.stepper-ctrls { display: flex; align-items: center; padding-right: 8px; gap: 2px; }
.stepper-sep { width: 1px; height: 22px; background: var(--line); }
.stepper-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border: none; background: transparent;
  color: var(--action); cursor: pointer; border-radius: var(--radius-sm);
  transition: background 120ms ease;
}
.stepper-btn:hover { background: var(--bg-subtle); }

/* ---------- Select ---------- */
.select-shell { position: relative; display: block; }
.select {
  width: 100%;
  height: 48px;
  padding: 0 40px 0 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.select:hover { border-color: var(--border-strong); }
.select:focus { outline: none; border-color: var(--action); box-shadow: var(--focus-ring); }
.select-caret { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.select-invalid { border-color: var(--loss); }

/* ---------- Toggle / Switch ----------
   Full override of the atom.gui.js Switch component. Root selector must
   match what Switch() actually renders (Switch / Switch.checked /
   Switch .thumb / Switch .label) — the bundler (scripts/build-client-css.js)
   matches on this per selector and drops the corresponding atom.gui.css
   block in favor of these. */
Switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  flex: none;
}
Switch .thumb {
  position: relative;
  width: 52px;
  height: 28px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: #e6e9ed;
  transition: background 140ms ease, border-color 140ms ease;
  flex: none;
}
Switch .thumb::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: var(--shadow-knob);
  transition: transform 160ms cubic-bezier(.4,.1,.2,1);
}
Switch.checked .thumb { background: var(--action); border-color: var(--action); }
Switch.checked .thumb::after { transform: translateX(24px); }
Switch:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
Switch:disabled { opacity: 0.5; cursor: not-allowed; }
Switch .label { font-size: 14px; color: var(--ink); }

/* ---------- Checkbox ---------- */
.checkbox { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.checkbox input.checkbox-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: none;
}
.checkbox input.checkbox-input::after { content: none; display: none; }
.checkbox-box {
  position: relative;
  width: 18px; height: 18px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: #fff;
  transition: background 120ms ease, border-color 120ms ease;
  flex: none;
}
.checkbox input.checkbox-input:hover + .checkbox-box { border-color: var(--border-strong); }
.checkbox input.checkbox-input:checked + .checkbox-box { background: var(--action); border-color: var(--action); }
.checkbox input.checkbox-input:checked + .checkbox-box::after {
  content: ""; position: absolute; left: 5px; top: 1.5px;
  width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.checkbox input.checkbox-input:indeterminate + .checkbox-box { background: var(--action); border-color: var(--action); }
.checkbox input.checkbox-input:indeterminate + .checkbox-box::after {
  content: ""; position: absolute; left: 3px; top: 7px; width: 10px; height: 2px; background: #fff;
}
.checkbox input.checkbox-input:focus-visible + .checkbox-box { box-shadow: 0 0 0 2px rgba(22,101,216,.3); }
.checkbox-label { font-size: 14px; color: var(--ink); }

/* ---------- Radio ---------- */
.radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.radio-input { position: absolute; opacity: 0; width: 0; height: 0; }
.radio-dot {
  position: relative; width: 18px; height: 18px;
  border: 1px solid var(--border); border-radius: 50%; background: #fff; flex: none;
  transition: border-color 120ms ease;
}
.radio-input:checked + .radio-dot { border-color: var(--action); }
.radio-input:checked + .radio-dot::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px;
  background: var(--action); border-radius: 50%; transform: translate(-50%, -50%);
}
.radio-label { font-size: 14px; color: var(--ink); }

/* ---------- Segmented control / range pills ---------- */
.segmented { display: inline-flex; align-items: center; gap: 22px; }
.segmented-item {
  border: none; background: transparent; padding: 0; cursor: pointer;
  font-family: inherit; font-size: 14px; color: var(--ink-3); font-weight: 400;
  transition: color 120ms ease;
}
.segmented-item:hover { color: var(--ink-2); }
.segmented-item-active { color: var(--ink); font-weight: 600; }

/* ---------- Tabs (underline) ---------- */
.tabs-list { display: flex; align-items: center; gap: 28px; border-bottom: 1px solid var(--line); }
.tab {
  position: relative;
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 15px; color: var(--ink-3);
  padding: 14px 0; display: inline-flex; align-items: center; gap: 8px;
  transition: color 120ms ease;
  text-decoration: none;
}
.tab:hover { color: var(--ink-2); }
.tab-active { color: var(--ink); font-weight: 500; }
.tab-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--action); border-radius: 2px;
}
.tab-badge { font-size: 12px; color: var(--link); font-weight: 600; }
.tabs-panel { padding-top: 20px; }

/* ---------- Chip / Badge ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 18px;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: #fff; color: var(--ink); font-family: inherit; font-size: 14px;
  cursor: pointer; white-space: nowrap;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}
button.chip:hover { border-color: var(--border-strong); background: #fafafa; }
.chip-filter { height: 30px; padding: 0 14px; border-color: transparent; color: var(--ink-3); font-size: 13px; }
.chip-filter.chip-active { background: var(--bg-selected); color: var(--link); }
.chip-account {
  height: 26px; padding: 0 12px; background: var(--bg-info); border-color: transparent;
  color: var(--link); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; line-height: 1;
}
.badge-neutral { background: var(--bg-subtle); color: var(--ink-3); }
.badge-success { background: var(--gain-bg); color: var(--gain); }
.badge-warning { background: #fdf1dd; color: var(--warning); }
.badge-notif { background: var(--loss); color: #fff; }
.badge-count { background: transparent; color: var(--link); font-weight: 600; }

/* ---------- Info dot / tooltip ---------- */
.infodot { position: relative; display: inline-flex; align-items: center; cursor: help; }
.infodot-muted { color: var(--ink-4); }
.infodot-solid .icon { color: var(--action-fg); }
.infodot-solid {
  width: 20px; height: 20px; border-radius: 50%; background: var(--action);
  align-items: center; justify-content: center; color: var(--action-fg);
}
.infodot-solid .icon-wrap { color: var(--action-fg); }
.tooltip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: var(--ink); color: #fff; font-size: 12px; line-height: 1.4;
  padding: 8px 10px; border-radius: var(--radius-md); white-space: normal; width: max-content; max-width: 260px;
  box-shadow: var(--shadow-pop); opacity: 0; pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease; z-index: 50;
}
.infodot:hover .tooltip, .infodot:focus .tooltip { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Value (signed financial) ---------- */
.value { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.value-num { font-variant-numeric: tabular-nums; }
.value-ccy { font-size: 11px; color: var(--ink-3); letter-spacing: .02em; }
.value-gain .value-num, .value-gain { color: var(--gain); }
.value-loss .value-num, .value-loss { color: var(--loss); }
.value-link .value-num, .value-link { color: var(--link); }
.value-neutral .value-num { color: var(--ink); }
.value-muted .value-num { color: var(--ink-3); }

/* ---------- Table ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.th {
  text-align: left; padding: 10px 16px 12px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-3); border-bottom: 1px solid var(--line); vertical-align: bottom; white-space: nowrap;
}
.th-right { text-align: right; }
.th-center { text-align: center; }
.th-inner { display: inline-flex; align-items: center; gap: 4px; }
.th-right .th-inner { flex-direction: row; }
.th-sort { color: var(--ink-4); }
.th-sortable { cursor: pointer; }
.th-sorted { color: var(--ink); }

.tr { border-bottom: 1px solid var(--line); transition: background 100ms ease; }
.tr:hover { background: var(--bg-hover); }
.tr-selected { background: var(--bg-selected); }
.td {
  padding: 14px 16px; color: var(--ink); vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.td-right { text-align: right; }
.td-center { text-align: center; }
.table-compact .td { padding: 9px 16px; }
.table-spacious .td { padding: 18px 16px; }

/* primary cell — ticker + company */
.cell-symbol { display: flex; flex-direction: column; gap: 2px; }
.cell-ticker { font-size: 15px; font-weight: 600; color: var(--ink); }
.cell-sub { font-size: 12px; color: var(--ink-3); letter-spacing: .02em; }
.cell-ccy { display: block; font-size: 11px; color: var(--ink-3); margin-top: 1px; }

/* ---------- Card ---------- */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); }
.card-accent { box-shadow: var(--shadow-card); border-top: 3px solid var(--action); }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 24px; border-bottom: 1px solid var(--line);
}
.card-heading { display: flex; align-items: center; gap: 10px; }
.card-title { font-size: 20px; font-weight: 600; }
.card-subtitle { font-size: 13px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.card-actions { display: flex; align-items: center; gap: 10px; }
.card-body { padding: 24px; }

/* ---------- Section header (hairline style, no box) ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.section-heading { display: flex; align-items: center; gap: 10px; flex: none; }
.section-title { font-size: 24px; font-weight: 600; white-space: nowrap; }
.section-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Info box (accent) ---------- */
.infobox {
  background: var(--bg-info);
  border-left: 3px solid var(--action);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 16px 18px; color: var(--ink-2); font-size: 14px; line-height: 1.5;
}

/* ---------- Key/value list ---------- */
.kv { display: flex; flex-direction: column; }
.kv-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 32px; }
.kv-row-divider { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.kv-label { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 14px; white-space: nowrap; }
.kv-value { color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------- Modal / panel ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 28, 40, .4); display: flex; z-index: 100; }
.modal-backdrop-center { align-items: center; justify-content: center; }
.modal-backdrop-panel { align-items: stretch; justify-content: flex-end; }
.modal { background: #fff; box-shadow: var(--shadow-modal); display: flex; flex-direction: column; overflow: hidden; }
.modal-center { width: min(560px, 92vw); max-height: 88vh; border-radius: var(--radius-md); }
.modal-panel { width: min(460px, 100vw); height: 100%; }
.modal-header {
  display: flex; align-items: center; gap: 12px;
  background: var(--action); color: var(--action-fg); padding: 14px 18px;
}
.modal-title { flex: 1; font-size: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); }
.modal-footer > * { flex: 1; }

/* ---------- Nav bar ---------- */
.nav {
  display: flex; align-items: center; gap: 22px;
  height: 64px; padding: 0 22px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.nav-brand { display: flex; align-items: center; flex: none; }
.nav-links { display: flex; align-items: center; gap: 26px; flex: 1; min-width: 0; }
.nav-link {
  font-size: 17px; color: var(--ink-3); text-decoration: none; white-space: nowrap;
  transition: color 120ms ease;
}
.nav-link:hover { color: var(--ink-2); }
.nav-link-active {
  color: var(--action-active); font-weight: 600;
}
.nav-link-active:hover { color: var(--action-active); }
.nav-right { display: flex; align-items: center; gap: 14px; flex: none; }

/* ---------- Spinner ---------- */
.spinner {
  display: inline-block; border: 2px solid var(--line); border-top-color: var(--action);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 1.6s; } }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 24px; text-align: center; }
.empty-icon { color: var(--ink-4); }
.empty-title { font-size: 16px; font-weight: 600; }
.empty-text { margin: 0; color: var(--ink-3); font-size: 14px; }

/* =====================================================================
   Part 2 — Securily app shell + generic List / Form views
   ===================================================================== */

html, body, #app, #root { height: 100%; }
body { overflow: hidden; }            /* SPA shell: only inner regions scroll, never the page */

/* ---------- Sidenav shell ---------- */
Sidenav {
  display: block;
  position: relative;
  min-height: 100%;
  height: 100%;
  color: var(--ink);
  overflow: hidden;

  > aside {
    position: absolute;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    width: 250px;
    background: var(--sidenav-bg);
    border-right: 1px solid var(--sidenav-border);
    overflow: hidden;
    /* Fixed chrome size — must not inherit leaked mail/editor font rules. */
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.3;

    /* Inset-Schatten über Header, Body und Footer (nicht vom Content verdeckt). */
    &::after {
      content: '';
      position: absolute;
      inset: 0 0 0 auto;
      width: 12px;
      pointer-events: none;
      z-index: 5;
      box-shadow: inset -6px 0 10px -6px rgba(0, 0, 0, 0.1);
    }
  }

  .header,
  .footer {
    flex-shrink: 0;
  }

  .body {
    flex: 1;
    min-height: 0;
    overflow: auto;
  }

  /* Nur der Shell-Main — nicht verschachtelte <main> in Editoren. */
  > main {
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    height: 100%;
    min-width: 0;
    margin-left: 250px;
    background: var(--bg-subtle);
    overflow: auto;
    transition: margin-left 0.25s ease;
  }

  &.collapsed > main {
    margin-left: 0;
  }
}

/* ---------- PaneStack (list + detail inside an editor) ----------
   Unknown tags are inline by default; the split itself (columns, sizing) is the
   consuming editor's business. */
PaneStack {
  display: flex;
  min-width: 0;
  min-height: 0;
}

/* ---------- Editorhead (shared editor chrome) ---------- */
Editorhead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  box-sizing: border-box;
  height: 40px;
  padding: 0 10px 0 6px;
  border-bottom: 1px solid var(--sidenav-border, #e6e6e6);
  flex: 0 0 40px;
  background: #fff;
  z-index: 3;
  min-width: 0;
  user-select: none;

  .eh-left,
  .eh-center,
  .eh-right,
  .eh-tools {
    display: flex;
    align-items: center;
    min-width: 0;
  }

  .eh-left {
    grid-column: 1;
    gap: 8px;
    justify-self: start;
  }

  .eh-left-extra {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: none;
    margin-left: 4px;
  }

  .eh-center {
    grid-column: 2;
    gap: 8px;
    justify-self: center;
  }

  .eh-right {
    grid-column: 3;
    gap: 8px;
    justify-content: flex-end;
    justify-self: end;
  }

  .eh-sidenav {
    flex: none;
    width: 28px;
    height: 28px;

    img {
      width: 18px;
      height: 18px;
      display: block;
    }
  }

  .eh-type-icon {
    flex: none;
    width: 16px;
    height: 16px;
    display: block;
  }

  .eh-filepath {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    color: var(--ink, #1f2328);
  }

  .eh-pathdir {
    font-weight: 400;
    color: var(--ink-2, #4a4f55);
  }

  .eh-filename {
    font-weight: 700;
    color: var(--ink, #1f2328);
  }

  .eh-dirty {
    flex: none;
    color: var(--action, #2563eb);
    font-size: 18px;
    line-height: 1;
  }

  .eh-tools {
    gap: 4px;
  }

  .eh-zoom {
    flex: none;
    font-variant-numeric: tabular-nums;
  }

  /* Slot-Hülle bleibt ein reiner Flex-Container für den Beitrag. */
  .eh-info {
    flex: none;
    display: flex;
    align-items: center;
  }

  .eh-close {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    color: var(--ink-2, #605e5c);

    img {
      width: 16px;
      height: 16px;
      display: block;
      opacity: 0.7;
    }

    &:hover {
      background: rgba(0, 0, 0, 0.05);
      color: var(--ink, #1f2328);

      img { opacity: 1; }
    }
  }
}

/* ---------- Sidenav footer ---------- */
SidenavFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  box-sizing: border-box;
  height: 36px;
  padding: 0 8px;
  background: var(--sidenav-bg);
  border-top: 1px solid var(--sidenav-border);
  font-size: 12px;
  color: var(--ink-3);
  user-select: none;

  .user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 2px 4px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-align: left;

    &:hover {
      background: rgba(0, 0, 0, 0.05);
      color: var(--ink);
    }
  }

  .avatar {
    flex: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-fg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
  }

  .avatar::after { content: none; }

  .name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-2);
  }

  .role {
    flex: none;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
  }

  .caret {
    flex: none;
    width: 12px;
    height: 12px;
    opacity: 0.55;
  }

  .actions {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 2px;
  }

  .ws-status {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;

    img {
      width: 16px;
      height: 16px;
      display: block;
      /* hellgrau wenn getrennt */
      opacity: 0.45;
      filter: grayscale(1) brightness(1.35);
    }

    &:hover { background: rgba(0, 0, 0, 0.05); }

    &.connected {
      cursor: default;
      img {
        opacity: 1;
        /* grün wenn verbunden */
        filter: invert(48%) sepia(72%) saturate(480%) hue-rotate(95deg) brightness(95%) contrast(92%);
      }
      &:hover { background: transparent; }
    }
  }

  .cog {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;

    img {
      width: 16px;
      height: 16px;
      display: block;
      opacity: 0.55;
    }

    &:hover,
    &.active {
      background: rgba(0, 0, 0, 0.05);
      img { opacity: 0.9; }
    }
  }
}

.user-menu {
  position: fixed;
  z-index: 1000;
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--sidenav-border);
  border-radius: 6px;
  box-shadow: var(--menu-shadow);
  padding: 4px 0;
  font-size: 13px;
}

.user-menu-empty {
  padding: 8px 12px;
  color: var(--ink-3);
}

.user-menu-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.user-menu-item:hover {
  background: var(--bg-subtle, rgba(0, 0, 0, 0.05));
}

/* Login gate */
.login-boot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-size: 14px;
  color: var(--ink-3);
  background: var(--bg);
}

LoginPage {
  display: block;
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 28px 24px;
  border: 1px solid var(--border, var(--sidenav-border));
  border-radius: 12px;
  background: var(--bg);
  box-shadow: var(--shadow-card, 0 8px 28px rgb(0 0 0 / 0.08));
}

.login-brand {
  display: flex;
  justify-content: center;
}

/* Das Logo bringt rundum einen durchsichtigen Rand mit (gut ein Sechstel der
   Kantenlänge). Die negativen Ränder holen ihn zurück, damit der Abstand zum
   Kartenrand und zum Text so groß wirkt wie überall sonst. */
.login-logo {
  width: 200px;
  height: auto;
  margin: -18px 0 -14px;
  user-select: none;
}

.login-lead {
  margin: -4px 0 4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-3);
  text-align: center;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}

.login-input {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong, var(--border, var(--sidenav-border)));
  border-radius: 8px;
  background: var(--sidenav-bg, var(--bg-subtle, var(--bg)));
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.login-input:focus {
  border-color: var(--accent, var(--action));
  box-shadow: var(--focus-ring, 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent));
}

.login-error {
  margin: 0;
  font-size: 13px;
  color: var(--loss, #b42318);
}

.login-submit {
  margin-top: 4px;
  padding: 11px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent, var(--action));
  color: var(--accent-fg, var(--action-fg, #fff));
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.login-submit:hover:not(:disabled) {
  filter: brightness(1.05);
}

.login-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

.app { display: flex; flex-direction: column; height: 100%; overflow: hidden; background: var(--bg); }
/* Fixed chrome — the main nav and the app's sub-tab row never scroll away. */
.nav, .tabs-links { flex: none; }

/* brand mark in the nav bar */
.brand { display: inline-flex; align-items: center; gap: 9px; font-size: 23px; letter-spacing: -.01em; }
.brand-mark { width: 26px; height: 28px; }
.brand-a { font-weight: 700; color: var(--action-hover); }
.brand-b { font-weight: 500; color: var(--ink); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: conic-gradient(from 210deg, #1763cf, #19b3c4, #1763cf);
  display: inline-flex; align-items: center; justify-content: center;
}
.avatar::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 3px #1763cf; }
.bell-wrap { position: relative; display: inline-flex; }
.bell-wrap .badge { position: absolute; top: -4px; right: -5px; }

/* ---------- Securily header: search + trade CTA ---------- */
.pp-navsearch {
  display: inline-flex; align-items: center; gap: 4px;
  height: 32px; padding: 0 8px 0 4px;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--bg-subtle); color: var(--ink-3);
  transition: border-color 120ms ease, background 120ms ease;
}
.pp-navsearch:focus-within { border-color: var(--action); background: #fff; }
.pp-navsearch-input {
  border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 13px; color: var(--ink); width: 200px;
}
.pp-navsearch-input::placeholder { color: var(--ink-4); }
.pp-trade-cta { text-decoration: none; }
@media (max-width: 900px) { .pp-navsearch-input { width: 110px; } }

/* link-mode tab row (router navigation under main nav or in-page) */
.tabs-links {
  display: flex; align-items: center;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.tabs-links .tabs-list {
  display: flex; align-items: center; gap: 28px;
  border-bottom: none; background: transparent;
  border-radius: 0; padding: 0;
}
.tabs-links .tab {
  position: relative;
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 15px; color: var(--ink-3);
  padding: 14px 0; display: inline-flex; align-items: center; gap: 8px;
  transition: color 120ms ease;
  text-decoration: none;
  box-shadow: none;
}
.tabs-links .tab:hover { color: var(--ink-2); }
.tabs-links .tab-active {
  color: var(--ink); font-weight: 500;
  background: transparent; box-shadow: none;
}
.tabs-links .tab-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--action); border-radius: 2px;
}

/* main view area */
.app-main { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 24px 32px 64px; min-width: 0; }
.app-main-bare { padding: 0; }
.app-view-transition {
  opacity: 1;
  transition: opacity 140ms ease;
  will-change: opacity;
}
.app-view-leaving,
.app-view-entering {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .app-view-transition {
    transition: none;
  }
}

.empty-state { padding: 64px 32px; text-align: center; color: var(--ink-3); font-size: 15px; }

/* ---------- generic list view ---------- */
.portfolio-list { padding-top: 4px; }
.portfolio-list-head { margin-bottom: 12px; }
.portfolio-list-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.portfolio-list-search { min-width: 260px; height: 36px; }
.portfolio-list-pagination { margin-left: 2px; }
.portfolio-list-table-wrap { margin-top: 12px; }
.portfolio-list-table .th:first-child,
.portfolio-list-table .td:first-child { padding-left: 6px; }
.portfolio-row-checkbox { height: 18px; }
.portfolio-list .cell-symbol { min-width: 150px; }

.view-list .toolbar,
.view-form .toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar-title { font-size: 24px; font-weight: 600; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.pagination { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 13px; }
.pagination-input {
  width: 52px; height: 32px; text-align: right;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; color: var(--ink); padding: 0 8px;
  font-variant-numeric: tabular-nums;
}
.pagination-input:focus { outline: none; border-color: var(--action); }
.pagination-sep { color: var(--ink-4); }
.pagination-total { font-variant-numeric: tabular-nums; white-space: nowrap; }

.th-checkbox { width: 36px; padding-right: 0 !important; }

.td .empty, td.empty { padding: 40px 16px; text-align: center; color: var(--ink-3); }

.banner { padding: 10px 16px; border-radius: var(--radius-sm); background: var(--bg-info); color: var(--ink-2); margin-bottom: 12px; }
.banner-error { background: var(--loss-bg); color: var(--loss); }

/* ---------- generic form view ---------- */
.form-body { display: flex; flex-direction: column; gap: 28px; max-width: 880px; }
.form-group-title {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.form-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px 28px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-3);
}
.form-label .required { color: var(--loss); }
.form-input.readonly { opacity: .65; pointer-events: none; }
.btn-group { display: inline-flex; gap: 0; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }

/* ---------- datafields ---------- */
.df-input {
  width: 100%; height: 40px; padding: 0 12px;
  font-family: inherit; font-size: 14px; color: var(--ink);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.df-input::placeholder { color: var(--ink-4); }
.df-input:hover { border-color: var(--border-strong); }
.df-input:focus { outline: none; border-color: var(--action); box-shadow: var(--focus-ring); }
.df-textarea { height: auto; padding: 10px 12px; resize: vertical; }
.df-num { font-variant-numeric: tabular-nums; }
.df-link { color: var(--link); text-decoration: none; }
.df-link:hover { color: var(--link-hover); text-decoration: underline; }
.df-truncate { display: inline-block; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.df-badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 10px;
  border-radius: var(--radius-pill); font-size: 12px; font-weight: 600;
  background: var(--bg-subtle); color: var(--ink-2);
}
.df-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  color: #fff; font-size: 13px; font-weight: 600;
}

/* tone helpers for money / percent cells */
.tone-gain { color: var(--gain); font-variant-numeric: tabular-nums; }
.tone-loss { color: var(--loss); font-variant-numeric: tabular-nums; }

/* =====================================================================
   ModelView — reusable model editor (header + swappable List/Form/Kanban)
   Adapted from atom.gui.css to the Securily design tokens so the
   component matches the rest of the app. Layout-only; reuses table /
   card / btn etc. The few standard primitives styles.css did not
   yet cover (segmented switcher, dropdown menu, textarea) are styled here
   scoped under .mv so the rest of the app is unaffected.
   ===================================================================== */
.mv {
  display: flex;
  flex-direction: column;
  gap: 20px;
  color: var(--ink);
}

/* ---------- constant header ---------- */
.mv-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.mv-title { justify-self: start; min-width: 0; font-size: 24px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }

/* search — pill, centered in header */
.mv-search { position: relative; width: min(340px, 100%); justify-self: center; }
.mv-search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  display: inline-flex; color: var(--ink-4); pointer-events: none;
}
.mv-search-input {
  width: 100%; height: 38px; padding: 0 16px 0 38px;
  font-family: inherit; font-size: 14px; color: var(--ink);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-pill);
  outline: none; transition: border-color 120ms ease, box-shadow 120ms ease;
}
.mv-search-input::placeholder { color: var(--ink-4); }
.mv-search-input:hover { border-color: var(--border-strong); }
.mv-search-input:focus { border-color: var(--action); box-shadow: var(--focus-ring-soft); }

.mv-actions { display: flex; align-items: center; gap: 12px; justify-self: end; }
.mv-range {
  font-size: 13px; font-variant-numeric: tabular-nums;
  color: var(--ink-3); white-space: nowrap;
}
.mv-pager { display: inline-flex; gap: 4px; }

/* icon buttons — borderless, matching .icon-btn-ghost (md) */
.mv-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  color: var(--ink-2); background: transparent;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 120ms ease, color 120ms ease;
}
.mv-icon-btn:hover { background: var(--bg-subtle); color: var(--ink); }

/* view switcher — scoped restyle of atom.gui SegmentedButton inside ModelView */
.mv SegmentedButton { display: inline-flex; align-items: center; gap: 4px; }
.mv SegmentedButton .item {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 12px;
  border: 1px solid transparent; background: transparent;
  color: var(--ink-3); font-family: inherit; font-size: 14px; font-weight: 500;
  border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.mv SegmentedButton .item:hover:not(.active) { background: var(--bg-subtle); color: var(--ink); }
.mv SegmentedButton .item.active { background: var(--bg-selected); border-color: transparent; color: var(--link); }

/* settings dropdown — scoped restyle of atom.gui DropdownMenu inside ModelView */
.mv DropdownMenu { position: relative; display: inline-block; }
.mv DropdownMenu .content {
  position: absolute; z-index: 50; top: calc(100% + 6px); min-width: 200px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop); padding: 6px;
}
.mv DropdownMenu .content.align-end { left: auto; right: 0; }
.mv DropdownMenu .content.align-start { left: 0; right: auto; }
.mv DropdownMenu .item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; font-family: inherit; font-size: 14px; color: var(--ink);
  background: none; border: none; text-align: left; cursor: pointer;
  border-radius: var(--radius-sm); transition: background 120ms ease;
}
.mv DropdownMenu .item:hover, .mv DropdownMenu .item:focus { background: var(--bg-subtle); outline: none; }
.mv DropdownMenu .item.destructive { color: var(--loss); }
.mv DropdownMenu .item.destructive:hover { background: var(--loss-bg); }
.mv DropdownMenu .separator { height: 1px; background: var(--line); margin: 4px 0; }

/* ---------- body / views ---------- */
.mv-body { min-height: 180px; }
.mv-empty,
.mv-form-loading { padding: 48px 24px; text-align: center; color: var(--ink-3); font-size: 14px; }
.mv-cell-empty { color: var(--ink-4); }

/* identity cell — primary value + muted subtitle (mirrors .cell-symbol) */
.mv-cell-identity { display: flex; flex-direction: column; gap: 2px; min-width: 150px; }
.mv-id-main { font-size: 15px; font-weight: 600; color: var(--ink); }
.mv-id-sub { font-size: 12px; color: var(--ink-3); letter-spacing: .02em; }

/* list view — pointer on clickable data rows (excludes loading/empty placeholder) */
.mv-table tbody .tr:has(.td) { cursor: pointer; }

/* ---------- form view ---------- */
.mv-form { display: flex; flex-direction: column; gap: 20px; }
.mv-form-bar { display: flex; align-items: center; gap: 16px; }
.mv-form-heading { font-size: 16px; font-weight: 600; color: var(--ink); }
.mv-form-bar > :last-child { margin-left: auto; }
.mv-form-error {
  padding: 12px 16px; font-size: 14px;
  color: var(--loss); background: var(--loss-bg);
  border: 1px solid color-mix(in srgb, var(--loss) 25%, transparent);
  border-radius: var(--radius-sm);
}
/* grouped layout (app.json layout: groups) — mirrors .form-body / .form-group-title */
.mv-form-groups {
  display: flex; flex-direction: column; gap: 28px; max-width: 880px;
  opacity: 1; transition: opacity 120ms ease;
}
/* Paging to another record while the current one is still on screen: dim
   instead of unmounting, so prev/next never flashes the loading fallback. */
.mv-form-groups-switching { opacity: .45; pointer-events: none; }
.mv-form-group { display: flex; flex-direction: column; }
.mv-form-group-title {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.mv-form-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px 28px;
}
.mv-field { display: flex; align-items: center; min-height: 44px; }
.mv-form .textarea {
  width: 100%; min-height: 88px; padding: 10px 12px;
  font-family: inherit; font-size: 14px; color: var(--ink);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  resize: vertical; transition: border-color 120ms ease, box-shadow 120ms ease;
}
.mv-form .textarea::placeholder { color: var(--ink-4); }
.mv-form .textarea:hover { border-color: var(--border-strong); }
.mv-form .textarea:focus { outline: none; border-color: var(--action); box-shadow: var(--focus-ring); }

/* ---------- kanban view ---------- */
.mv-kanban {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px;
}
.mv-kanban-card { cursor: pointer; }
.mv-kanban-card .card {
  height: 100%; box-shadow: var(--shadow-card);
  transition: box-shadow 120ms ease, transform 120ms ease, border-color 120ms ease;
}
.mv-kanban-card:hover .card { box-shadow: var(--shadow-pop); border-color: var(--border-strong); transform: translateY(-2px); }
.mv-kanban-fields {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13px;
}
.mv-kanban-fields dt { color: var(--ink-3); }
.mv-kanban-fields dd { margin: 0; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Datatable (schema-driven) ---------- */
Datatable {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0 4px 8px;

  .dt-loading,
  .dt-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    font-size: 13px;
    color: var(--ink-3);
  }

  .dt-table {
    display: table;
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    box-sizing: border-box;
  }

  .dt-table TableHead,
  .dt-table TableCell {
    box-sizing: border-box;
  }

  .dt-table TableBody TableRow {
    border-bottom: 1px solid var(--line, var(--border));
  }

  .dt-table TableBody TableRow:last-child {
    border-bottom: none;
  }

  .dt-table TableBody TableCell {
    border-bottom: none;
  }

  .dt-col-primary .dt-input,
  .dt-col-primary .dt-colorlabel-text {
    font-weight: 600;
    color: var(--ink);
  }

  .dt-input {
    display: block;
    width: 100%;
    min-width: 0;
    height: 28px;
    padding: 4px 8px;
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    box-shadow: none;
    outline: none;

    &::placeholder { color: var(--ink-3); }

    &:hover { border-color: var(--line, #e6e6e6); }

    &:focus {
      border-color: var(--action);
      background: var(--bg);
      box-shadow: var(--focus-ring, 0 0 0 2px color-mix(in srgb, var(--action) 18%, transparent));
    }
  }

  .dt-input-number {
    font-variant-numeric: tabular-nums;
    text-align: right;
  }

  .dt-input-secret {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
  }

  .dt-imagefield {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
  }

  .dt-imagefield-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px dashed var(--border-strong, #c8c8c8);
    background: var(--bg-subtle, #f4f4f5);
    cursor: pointer;
    overflow: hidden;
    flex: 0 0 auto;
  }

  .dt-imagefield-preview.has-image {
    border-style: solid;
    border-color: var(--border, #e6e6e6);
    background: #fff;
  }

  .dt-imagefield-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .dt-imagefield-placeholder {
    font-size: 16px;
    line-height: 1;
    color: var(--ink-3);
    font-weight: 500;
  }

  .dt-imagefield-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
  }

  .dt-imagefield-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-3);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
  }

  .dt-imagefield-clear:hover {
    color: var(--ink);
    background: var(--bg-subtle, #f0f0f0);
  }

  .dt-cell-text,
  .dt-cell-string {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Width tiers (table-layout: fixed): narrow < text < wide */
  .dt-col-narrow {
    width: 5%;
    max-width: 5.5rem;
    white-space: nowrap;
    overflow: visible;
  }

  .dt-col-text {
    width: 12%;
  }

  .dt-col-wide {
    width: 22%;
  }

  .dt-col-control {
    text-align: right;
  }

  .dt-col-actions {
    width: 3%;
    max-width: 2.5rem;
    padding-left: 2px;
    padding-right: 4px;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    overflow: visible;
  }

  .dt-add,
  .dt-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    color: var(--ink-3);

    img {
      width: 16px;
      height: 16px;
      display: block;
      opacity: 0.7;
    }

    &:hover:not(:disabled) {
      background: var(--bg-subtle);
      img { opacity: 1; }
    }

    &:disabled {
      opacity: 0.35;
      cursor: default;
    }
  }

  .dt-add img {
    filter: none;
  }

  /* Trash only visible on row hover */
  .dt-remove {
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease;
  }

  .dt-table TableBody TableRow:hover .dt-remove:not(:disabled) {
    opacity: 1;
    pointer-events: auto;
  }

  .dt-remove img {
    /* tint icon red via CSS filter where SVG is monochrome */
    filter: invert(27%) sepia(86%) saturate(2840%) hue-rotate(346deg) brightness(90%) contrast(95%);
    opacity: 0.9;
  }

  .dt-remove:hover:not(:disabled) {
    background: color-mix(in srgb, var(--loss, #b42318) 12%, transparent);
  }

  .dt-empty-cell {
    color: var(--ink-3);
    font-size: 13px;
    padding: 16px;
  }

  /* Half-size toggles in cells (global Switch is 52×28). */
  Switch.dt-toggle .thumb {
    width: 26px;
    height: 14px;
  }

  Switch.dt-toggle .thumb::after {
    top: 1.5px;
    left: 1.5px;
    width: 11px;
    height: 11px;
  }

  Switch.dt-toggle.checked .thumb::after {
    transform: translateX(12px);
  }

  /* Colorfield */
  .dt-colorfield {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    flex: none;
    cursor: pointer;
    position: relative;
  }

  .dt-colorfield-input {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--ink) 20%, transparent);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    overflow: hidden;

    &::-webkit-color-swatch-wrapper { padding: 0; }
    &::-webkit-color-swatch { border: none; border-radius: 50%; }
    &::-moz-color-swatch { border: none; border-radius: 50%; }
  }

  .dt-colorlabel {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    width: 100%;
  }

  .dt-colorlabel-text {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
    color: var(--ink);
  }

  /* Multiselect / tags pills */
  .dt-col-pills {
    overflow: visible;
  }

  .dt-multiselect,
  .dt-tags {
    position: relative;
    display: block;
    min-width: 0;
    width: 100%;
  }

  .dt-multiselect-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 4px 8px;
    box-sizing: border-box;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    cursor: text;

    &:focus-within,
    &.open {
      border-color: var(--action);
      background: var(--bg);
      box-shadow: var(--focus-ring, 0 0 0 2px color-mix(in srgb, var(--action) 18%, transparent));
    }
  }

  .dt-pill {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 1px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    outline: none;

    &.focused {
      outline: 2px solid var(--pill-color, var(--action));
      outline-offset: 1px;
    }
  }

  .dt-pill-option {
    pointer-events: none;
  }

  .dt-pill-neutral {
    background: var(--bg-subtle, #f0f0f0);
    color: var(--ink-2);
    border-color: var(--border-strong, color-mix(in srgb, var(--ink) 28%, var(--border)));
  }

  .dt-multiselect-input,
  .dt-tags-input {
    flex: 1 1 4rem;
    min-width: 4rem;
    height: 22px;
    margin: 0;
    padding: 0 2px;
    border: none;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    outline: none;
  }

  .dt-multiselect-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    min-width: 140px;
    max-height: 220px;
    overflow: auto;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    box-shadow: var(--shadow-card, 0 4px 16px rgba(0,0,0,.12));
  }

  .dt-multiselect-empty {
    padding: 8px 10px;
    font-size: 12px;
    color: var(--ink-3);
  }

  .dt-multiselect-option {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 4px 6px;
    border: none;
    border-radius: 6px;
    background: transparent;
    text-align: left;
    cursor: pointer;

    &:hover,
    &.active { background: var(--bg-subtle); }
  }

  .dt-tags-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 4px 8px;
    box-sizing: border-box;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    cursor: text;

    &:focus-within,
    &.open {
      border-color: var(--action);
      background: var(--bg);
      box-shadow: var(--focus-ring, 0 0 0 2px color-mix(in srgb, var(--action) 18%, transparent));
    }
  }

  Select.dt-select,
  .dt-select {
    max-width: 100%;
    height: auto;
    min-height: 28px;
    padding: 4px 1.75rem 4px 8px;
    font-size: 13px;
    border: 1px solid transparent;
    background-color: transparent;
    box-shadow: none;

    &:focus {
      border-color: var(--action);
      background-color: var(--bg);
      box-shadow: var(--focus-ring, 0 0 0 2px color-mix(in srgb, var(--action) 18%, transparent));
    }
  }

  .dt-cell-secret {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--ink-3);
  }

  .dt-password {
    width: 100%;
    min-width: 0;
    height: 28px;
    padding: 4px 8px;
    font-size: 13px;
    color: var(--ink);
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    box-shadow: none;
    outline: none;

    &::placeholder {
      color: var(--ink-3);
    }

    &:focus {
      border-color: var(--action);
      background: var(--bg);
      box-shadow: var(--focus-ring, 0 0 0 2px color-mix(in srgb, var(--action) 18%, transparent));
    }
  }
}
