/* Base styles, components, layout — extracted verbatim from prototype/conduit-proto.html. */
  /* ============================= RESET / BASE ============================= */
  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    margin: 0; background: var(--surface); color: var(--ink);
    font-family: var(--font-sans); font-size: 14px; line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }
  h1, h2, h3, h4 { font-family: var(--font-sans); font-weight: 600; margin: 0; text-wrap: balance; }
  p { margin: 0; }
  button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
  button { cursor: pointer; }
  a { color: var(--accent); }
  code, .mono { font-family: var(--font-mono); }
  ::selection { background: var(--accent-soft); }
  :focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  }
  .scrollx { overflow-x: auto; }

  /* ============================= APP SHELL ============================= */
  #app {
    display: grid; grid-template-columns: 224px 1fr; grid-template-rows: 56px 1fr;
    grid-template-areas: "brand topbar" "rail main"; height: 100vh; min-height: 560px;
  }
  .brand { grid-area: brand; display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); background: var(--surface-raised); }
  .brand__mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .brand__mark svg { width: 16px; height: 16px; }
  .brand__name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }

  .topbar { grid-area: topbar; display: flex; align-items: center; gap: 14px; padding: 0 20px; background: var(--surface-raised); border-bottom: 1px solid var(--border); min-width: 0; }
  .topbar__spacer { flex: 1; }
  .topbar__note { font-size: 11.5px; color: var(--muted); }
  .env-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

  .rail { grid-area: rail; background: var(--surface-raised); border-right: 1px solid var(--border); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
  .rail__section-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 10px 10px 6px; }
  .navitem { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-m); background: transparent; border: none; color: var(--ink-2); font-weight: 500; text-align: left; width: 100%; }
  .navitem svg { width: 17px; height: 17px; flex-shrink: 0; }
  .navitem:hover { background: var(--surface-sunken); color: var(--ink); }
  .navitem.active { background: var(--accent); color: var(--accent-contrast); font-weight: 700; }
  .navitem .count { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .navitem.active .count { color: var(--accent-contrast); opacity: 0.65; }
  .rail__foot { margin-top: auto; padding: 10px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border); }

  main.view { grid-area: main; overflow-y: auto; padding: 22px 26px 60px; }
  .view__header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
  .view__title { font-size: 20px; }
  .view__subtitle { color: var(--ink-2); font-size: 13px; margin-top: 4px; max-width: 62ch; }

  .breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
  .breadcrumb button { background: none; border: none; color: var(--accent); font-weight: 600; padding: 0; font-size: 12.5px; }
  .breadcrumb button:hover { text-decoration: underline; }
  .breadcrumb .sep { color: var(--border-strong); }
  .breadcrumb .current { color: var(--ink); font-weight: 600; }

  /* ============================= CONTROLS ============================= */
  .btn { display: inline-flex; align-items: center; gap: 6px; border-radius: var(--radius-m); border: 1px solid var(--border); background: var(--surface-raised); color: var(--ink); padding: 8px 13px; font-weight: 600; font-size: 13px; white-space: nowrap; }
  .btn:hover { border-color: var(--border-strong); }
  .btn svg { width: 15px; height: 15px; }
  .btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
  .btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
  .btn-ghost { background: transparent; border-color: transparent; }
  .btn-ghost:hover { background: var(--surface-sunken); border-color: transparent; }
  .btn-danger { color: var(--critical-ink); }
  .btn:disabled { opacity: 0.45; cursor: not-allowed; }
  .btn.small { padding: 5px 9px; font-size: 12px; }

  .field { display: flex; flex-direction: column; gap: 5px; }
  .field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
  .field .hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
  .input, select.input, textarea.input { border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); padding: 8px 10px; width: 100%; }
  textarea.input { resize: vertical; min-height: 64px; }
  .search { display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--surface); padding: 7px 11px; min-width: 220px; }
  .search svg { width: 15px; height: 15px; color: var(--muted); flex-shrink: 0; }
  .search input { border: none; background: transparent; width: 100%; outline: none; }
  .toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
  .toolbar__filters { display: flex; gap: 8px; flex-wrap: wrap; }
  select.chipselect { border: 1px solid var(--border); background: var(--surface-raised); border-radius: 999px; padding: 6px 10px; font-size: 12.5px; color: var(--ink-2); }

  /* ============================= PILLS / BADGES ============================= */
  .pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
  .pill .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
  .pill-good { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good-ink); }
  .pill-good .dot { background: var(--good); }
  .pill-neutral { background: var(--surface-sunken); color: var(--ink-2); }

  .env-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 6px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-sunken); color: var(--ink-2); white-space: nowrap; }
  .env-chips { display: flex; gap: 4px; flex-wrap: wrap; }
  .type-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent-strong); white-space: nowrap; }

  /* ============================= TABLE ============================= */
  table.grid { width: 100%; border-collapse: collapse; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-m); overflow: hidden; }
  table.grid th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-sunken); white-space: nowrap; }
  table.grid td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  table.grid tbody tr:last-child td { border-bottom: none; }
  table.grid tbody tr.clickable:hover { background: var(--accent-soft); cursor: pointer; }
  .cell-name { font-weight: 600; }
  .cell-sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
  .empty-row td { text-align: center; color: var(--muted); padding: 34px 14px; }

  /* ============================= CARD / DASH ============================= */
  .stat-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
  .stat-tile { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 14px 16px; }
  .stat-tile__label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
  .stat-tile__value { font-family: var(--font-mono); font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
  .stat-tile__sub { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }

  /* ============================= DETAIL HEADER (system / environment) ============================= */
  .detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
  .detail-head__desc { color: var(--ink-2); font-size: 13px; margin-top: 6px; max-width: 68ch; }
  .detail-head__actions { display: flex; gap: 4px; flex-shrink: 0; }

  /* ============================= DRAWER ============================= */
  .backdrop { position: fixed; inset: 0; background: rgba(8, 14, 17, 0.42); display: flex; justify-content: flex-end; z-index: 40; }
  .drawer { width: min(560px, 94vw); height: 100%; background: var(--surface-raised); box-shadow: var(--shadow-drawer); display: flex; flex-direction: column; animation: slidein 0.18s ease; }
  @keyframes slidein { from { transform: translateX(24px); opacity: 0.6; } to { transform: translateX(0); opacity: 1; } }
  .drawer__head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .drawer__title { font-size: 18px; }
  .drawer__meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
  .drawer__body { padding: 18px 22px; overflow-y: auto; flex: 1; }
  .drawer__foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
  .icon-btn { background: transparent; border: none; padding: 6px; border-radius: 8px; color: var(--muted); }
  .icon-btn:hover { background: var(--surface-sunken); color: var(--ink); }
  .icon-btn svg { width: 17px; height: 17px; display: block; }
  .icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
  .icon-btn:disabled:hover { background: transparent; color: var(--muted); }

  .kv-grid { display: grid; grid-template-columns: 150px 1fr; gap: 11px 14px; font-size: 13px; }
  .kv-grid dt { color: var(--muted); }
  .kv-grid dd { margin: 0; }
  .section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; margin: 22px 0 10px; }
  .section-title:first-child { margin-top: 0; }
  .section-title-row { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 10px; }
  .section-title-row:first-child { margin-top: 0; }

  .attr-table { width: 100%; border-collapse: collapse; }
  .attr-table td { padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
  .attr-table tr:last-child td { border-bottom: none; }
  .attr-table .attr-name { font-weight: 600; width: 38%; }
  .attr-table .attr-type { color: var(--muted); font-size: 11px; font-family: var(--font-mono); }

  /* ============================= MODAL ============================= */
  .modal-backdrop { position: fixed; inset: 0; background: rgba(8, 14, 17, 0.5); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
  .modal { width: min(620px, 100%); max-height: 88vh; display: flex; flex-direction: column; background: var(--surface-raised); border-radius: var(--radius-l); box-shadow: var(--shadow-drawer); animation: popin 0.14s ease; }
  @keyframes popin { from { transform: scale(0.98); opacity: 0; } to { transform: scale(1); opacity: 1; } }
  .modal.wide { width: min(760px, 100%); }
  .modal__head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
  .modal__body { padding: 20px 22px; overflow-y: auto; }
  .modal__foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .form-grid .span2 { grid-column: 1 / -1; }
  .add-row-btn { font-size: 12.5px; }
  .checklist { display: flex; flex-wrap: wrap; gap: 8px; }
  .check-chip { display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px 6px 8px; font-size: 12.5px; font-weight: 600; cursor: pointer; background: var(--surface); }
  .check-chip input { accent-color: var(--accent); }
  .check-chip.checked { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
  .form-error { color: var(--critical-ink); font-size: 12px; margin-top: 6px; }
  .attr-def-row { border: 1px solid var(--border); border-radius: var(--radius-m); padding: 10px 12px; margin-bottom: 8px; background: var(--surface); }
  .attr-def-row .row1 { display: flex; gap: 8px; align-items: flex-end; }
  .attr-def-row .row1 .field { flex: 1; }
  .attr-def-row .row1 .field.type-field { max-width: 160px; }

  /* ============================= ENV ADMIN ============================= */
  .env-admin-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--surface-raised); margin-bottom: 8px; }
  .env-admin-row.clickable { cursor: pointer; }
  .env-admin-row.clickable:hover { border-color: var(--border-strong); background: var(--accent-soft); }
  .env-admin-row .swatch { width: 16px; height: 16px; border-radius: 5px; flex-shrink: 0; }
  .env-admin-row .name { font-weight: 600; flex: 1; }
  .env-admin-row .usage { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }

  /* ============================= LIST CARD (links, etc.) ============================= */
  .list-card { border: 1px solid var(--border); border-radius: var(--radius-m); padding: 11px 13px; margin-bottom: 8px; background: var(--surface); }
  .list-card.linkable { cursor: pointer; }
  .list-card.linkable:hover { border-color: var(--border-strong); background: var(--accent-soft); }
  .list-card__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .list-card__title { font-weight: 600; font-size: 13px; }
  .list-card__desc { color: var(--ink-2); font-size: 12.5px; margin-top: 3px; }
  .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink-2); }

  /* ============================= MAP ============================= */
  .map-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
  .map-wrap {
    position: relative; border: 1px solid var(--border); border-radius: var(--radius-l);
    background: radial-gradient(var(--border) 1px, transparent 1px) 0 0/22px 22px, var(--surface-raised);
    height: calc(100vh - 300px); min-height: 420px; overflow: hidden;
  }
  .map-wrap svg { width: 100%; height: 100%; display: block; }
  .map-hint { position: absolute; left: 16px; bottom: 14px; font-size: 11.5px; color: var(--muted); background: color-mix(in srgb, var(--surface-raised) 88%, transparent); padding: 5px 9px; border-radius: 999px; }
  .map-legend { position: absolute; right: 16px; top: 14px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 10px 12px; font-size: 11.5px; box-shadow: var(--shadow-pop); max-width: 200px; }
  .map-legend__title { font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; font-size: 10px; color: var(--muted); margin-bottom: 7px; }
  .map-legend__row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
  .map-legend__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .node { cursor: grab; }
  .node:active { cursor: grabbing; }
  .node.dim { opacity: 0.28; }
  .node-label { font-size: 10.5px; font-weight: 600; fill: var(--ink); pointer-events: none; }
  .node-sub { font-size: 9px; fill: var(--muted); pointer-events: none; }
  .edge { stroke: var(--border-strong); stroke-width: 1.6; fill: none; }
  .edge.dim { opacity: 0.15; }
  .edge.active { stroke: var(--accent); stroke-width: 2.2; }
  .edge-hit { stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }

  .popover { position: absolute; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-m); box-shadow: var(--shadow-pop); padding: 12px 14px; width: 260px; font-size: 12.5px; z-index: 30; }
  .popover__title { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
  .popover__row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; color: var(--ink-2); }

  /* ============================= TYPE / SYSTEM CARD ============================= */
  .type-card { border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--surface-raised); padding: 14px 16px; margin-bottom: 10px; }
  .type-card__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .type-card__name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
  .type-card__swatch { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
  .type-card__desc { color: var(--ink-2); font-size: 12.5px; margin-top: 3px; max-width: 60ch; }
  .type-card__attrs { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
  .attr-tag { font-size: 11px; font-family: var(--font-mono); background: var(--surface-sunken); color: var(--ink-2); padding: 3px 8px; border-radius: 6px; }
  .type-card__meta { font-size: 11.5px; color: var(--muted); margin-top: 10px; }

  /* ============================= TOAST ============================= */
  .toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
  .toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: var(--radius-m); font-size: 13px; box-shadow: var(--shadow-pop); animation: toastin 0.15s ease; display: flex; align-items: center; gap: 8px; }
  @keyframes toastin { from { transform: translateY(6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--border); } }
  :root[data-theme="dark"] .toast { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--border); }

  @media (max-width: 880px) {
    #app { grid-template-columns: 64px 1fr; }
    .navitem span:not(.count) { display: none; }
    .brand__name { display: none; }
    .stat-row { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
  }

/* ============================= AUTH SCREENS (new — login, invite accept, forgot/reset password) ============================= */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--surface); padding: 20px; }
.auth-card { width: min(400px, 100%); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-pop); padding: 28px 26px; }
.auth-card__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth-card__brand .brand__mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.auth-card__brand .brand__mark svg { width: 16px; height: 16px; }
.auth-card__brand .brand__name { font-weight: 700; font-size: 16px; }
.auth-card h1 { font-size: 18px; margin-bottom: 6px; }
.auth-card__sub { color: var(--ink-2); font-size: 13px; margin-bottom: 18px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn-primary { width: 100%; justify-content: center; margin-top: 4px; }
.auth-card__switch { margin-top: 16px; font-size: 12.5px; color: var(--ink-2); text-align: center; }
.auth-card__switch button { background: none; border: none; color: var(--accent-strong); font-weight: 600; padding: 0; font-size: 12.5px; cursor: pointer; }
.auth-card__switch button:hover { text-decoration: underline; }
.auth-card__message { font-size: 13px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--accent-soft); color: var(--accent-strong); margin-bottom: 14px; }
.auth-card__spinner { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 0; }
