/* ============================================================================
   ComDir — Material 3 (Material You) UI, dependency-free
   All colors flow through theme tokens; [data-theme] swaps light/dark.
   ========================================================================== */

/* ------------------------------- tokens ---------------------------------- */
:root {
  color-scheme: light;

  /* type & shape */
  --font: Roboto, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "Roboto Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;

  /* light palette */
  --primary: #4655c6;
  --on-primary: #ffffff;
  --primary-hover: #3a48ad;
  --primary-container: #e4e7ff;
  --on-primary-container: #151f56;

  --sf-page: #f2f3f8;
  --sf-card: #ffffff;
  --sf-inset: #f1f2f7;
  --sf-inset2: #e9eaf1;
  --on-surface: #1d1e24;
  --on-surface-var: #4b4c58;

  --outline: #74757f;
  --outline-variant: #dcdee8;

  --ok: #1e7040;
  --ok-soft: #d7f0e0;
  --warn: #7a5800;
  --warn-soft: #ffedc4;
  --warn-text: #5f4a00;
  --bad: #b3261e;
  --bad-soft: #ffdad6;
  --bad-text: #7c1622;
  --neutral-soft: #ececf2;

  --snack-bg: #313033;
  --snack-fg: #f4eff6;

  --scrim: rgba(15, 18, 28, .42);

  --e1: 0 1px 2px rgba(15, 18, 30, .10), 0 1px 3px rgba(15, 18, 30, .07);
  --e2: 0 2px 6px rgba(15, 18, 30, .10), 0 1px 2px rgba(15, 18, 30, .06);
  --e3: 0 8px 22px rgba(15, 18, 30, .16), 0 2px 6px rgba(15, 18, 30, .08);
  --e-drawer: 0 12px 48px rgba(15, 18, 30, .32);
}

html[data-theme="dark"] {
  color-scheme: dark;

  --primary: #b8c2ff;
  --on-primary: #1b2364;
  --primary-hover: #c9d1ff;
  --primary-container: #2c3581;
  --on-primary-container: #dfe3ff;

  --sf-page: #101014;
  --sf-card: #1a1a21;
  --sf-inset: #23232c;
  --sf-inset2: #2b2b35;
  --on-surface: #e4e3ea;
  --on-surface-var: #c0c0cc;

  --outline: #91919e;
  --outline-variant: #3a3a45;

  --ok: #7cd49b;
  --ok-soft: #1c3b28;
  --warn: #efcb6f;
  --warn-soft: #463808;
  --warn-text: #f5d48f;
  --bad: #ffb4ab;
  --bad-soft: #5c1512;
  --bad-text: #ffd7d3;
  --neutral-soft: #2b2b35;

  --snack-bg: #e6e1e5;
  --snack-fg: #333238;

  --scrim: rgba(0, 0, 0, .55);

  --e1: 0 1px 2px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .35);
  --e2: 0 2px 8px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
  --e3: 0 10px 28px rgba(0, 0, 0, .6), 0 3px 8px rgba(0, 0, 0, .45);
  --e-drawer: 0 16px 56px rgba(0, 0, 0, .7);
}

/* ------------------------------ base ------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* Respect the `hidden` attribute even where a component sets its own display
   (banner/drawer use display:flex). */
[hidden] { display: none !important; }

/* Smooth cross-fade when the theme is toggled (class is removed after the
   transition window, so hover states stay snappy the rest of the time). */
html.theme-anim,
html.theme-anim *,
html.theme-anim *::before,
html.theme-anim *::after {
  transition: background-color .3s ease, border-color .3s ease, color .3s ease,
              box-shadow .3s ease, fill .3s ease, stroke .3s ease,
              background .3s ease, outline-color .3s ease !important;
}

body {
  margin: 0;
  background: var(--sf-page);
  color: var(--on-surface);
  font: 14.5px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--primary) 25%, transparent); }

/* --------------------------- top app bar --------------------------------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--sf-card) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--outline-variant);
}
.appbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  flex: none; width: 42px; height: 42px; border-radius: 14px;
  background: var(--primary-container); color: var(--on-primary-container);
  display: grid; place-items: center; box-shadow: var(--e1);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-text { min-width: 0; }
.brand h1 {
  margin: 0; font-size: 20px; font-weight: 600; letter-spacing: .1px;
  line-height: 1.2; white-space: nowrap;
}
.tagline { margin: 1px 0 0; color: var(--on-surface-var); font-size: 12px; font-weight: 500; white-space: nowrap; }
.appbar-actions { display: flex; align-items: center; gap: 10px; }

/* status chip */
.badge {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 13px 0 11px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 600; letter-spacing: .1px;
  background: var(--warn-soft); color: var(--warn);
  white-space: nowrap; cursor: default;
  transition: background-color .2s, color .2s;
}
.badge::before {
  content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

/* icon buttons */
.icon-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  border: none; background: transparent; color: var(--on-surface-var);
  display: grid; place-items: center; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: color-mix(in srgb, var(--on-surface) 9%, transparent); color: var(--on-surface); }
.icon-btn:active { background: color-mix(in srgb, var(--on-surface) 14%, transparent); }
.icon-btn svg { width: 21px; height: 21px; }
#themeToggle .ic-sun { display: none; }
html[data-theme="dark"] #themeToggle .ic-sun { display: block; }
html[data-theme="dark"] #themeToggle .ic-moon { display: none; }

/* G5: the app-bar "3D map" restore button — a tonal pill (icon + label).
   app.js gates the `hidden` attribute (visible once a map has been opened
   and closed, hidden while a map is open) — [hidden] must beat display. */
.map-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 14px;
  border: none; border-radius: var(--r-pill);
  background: var(--primary-container); color: var(--on-primary-container);
  font-size: 12.5px; font-weight: 600; letter-spacing: .1px; white-space: nowrap;
  cursor: pointer;
  transition: box-shadow .15s, filter .15s;
}
.map-btn:hover { filter: brightness(1.06); box-shadow: var(--e1); }
.map-btn:active { box-shadow: var(--e2); }
.map-btn svg { width: 17px; height: 17px; flex: none; }
.map-btn[hidden] { display: none; }

/* ------------------------------ layout ----------------------------------- */
.wrap { max-width: 1280px; margin: 20px auto 40px; padding: 0 20px; display: grid; gap: 16px; }
.card {
  background: var(--sf-card);
  border: 1px solid var(--outline-variant);
  border-radius: var(--r-lg);
  box-shadow: var(--e1);
}
.foot { color: var(--on-surface-var); font-size: 12.5px; text-align: center; padding: 4px 0 12px; }

/* --------------------------- outlined fields ----------------------------- */
.filters { padding: 16px 18px 14px; }

/* P2: Companies | People search-mode toggle */
.mode-toggle {
  display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 12px;
  border: 1px solid var(--outline); border-radius: var(--r-pill);
}
.mode-btn {
  appearance: none; border: 0; background: none; padding: 6px 18px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--on-surface-var);
  border-radius: var(--r-pill); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.mode-btn:hover { color: var(--on-surface); }
.mode-btn.active { background: var(--primary); color: var(--on-primary); }
/* company-specific filters disappear in People mode */
.filters[mode="people"] .co-only { display: none !important; }
.filters[mode="people"] .grid { grid-template-columns: minmax(0, 480px); }
.filters[mode="people"] .sector-row { display: none; }

/* People-mode results (thead is hidden; one card per row) */
body.people-mode .tbl thead { display: none; }
.person-td { display: flex !important; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px !important; }
.person-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.person-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.person-addr { font-size: 12.5px; color: var(--on-surface-var); overflow-wrap: anywhere; }
.person-appt { white-space: nowrap; }

.grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.1fr 1.1fr .9fr 1.1fr 1.1fr;
  gap: 10px;
}
.m-field { position: relative; min-width: 0; }
.m-field input,
.m-field select {
  width: 100%; height: 48px;
  padding: 13px 12px;
  font: inherit; font-size: 14.5px; color: var(--on-surface);
  background: transparent;
  border: 1px solid var(--outline);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
  min-width: 0;
}
.m-field input::placeholder { color: transparent; }
/* Chromium: the native "mm/dd/yyyy" hint would sit under the resting label —
   hide it while the label occupies the field. On focus the label floats up, so
   the hint shows then (and the entered value always shows). */
.m-field:not(.filled):not(:focus-within) input[type="date"]::-webkit-datetime-edit { color: transparent; }
.m-field input:hover, .m-field select:hover { border-color: var(--on-surface-var); }
.m-field input:focus, .m-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.m-field select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; }
.m-field select:disabled { opacity: .5; cursor: default; }

.m-label {
  position: absolute; left: 9px; top: 50%;
  transform: translateY(-50%);
  font-size: 14.5px; font-weight: 400; color: var(--on-surface-var);
  padding: 0 5px;
  background: var(--sf-card); /* mask the border line where the label sits */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: calc(100% - 18px);
  pointer-events: none;
  transform-origin: left center;
  transition: top .16s cubic-bezier(.2, 0, 0, 1), font-size .16s cubic-bezier(.2, 0, 0, 1),
              color .16s ease;
}
.m-label em { font-style: normal; opacity: .72; }
.m-field:focus-within > .m-label,
.m-field.filled > .m-label,
.m-field.select > .m-label {
  top: 0;
  font-size: 11.5px;
  font-weight: 500;
}
.m-field.filled > .m-label, .m-field.select > .m-label { color: var(--on-surface-var); }
.m-field:focus-within > .m-label { color: var(--primary); }

.sel-caret {
  position: absolute; right: 11px; top: 50%;
  width: 17px; height: 17px;
  transform: translateY(-50%);
  color: var(--on-surface-var);
  pointer-events: none;
  transition: transform .18s cubic-bezier(.2, 0, 0, 1), color .15s;
}
.m-field.select:focus-within .sel-caret { color: var(--primary); transform: translateY(-50%) rotate(180deg); }

/* compact field (pager "rows") */
.m-field.compact { width: 118px; }
.m-field.compact select { height: 38px; padding: 10px 32px 10px 11px; font-size: 13.5px; border-radius: 9px; }
.m-field.compact > .m-label { left: 8px; font-size: 13px; }
.m-field.compact.select > .m-label { top: 0; font-size: 10.5px; }
.m-field.compact .sel-caret { right: 9px; width: 15px; height: 15px; }

/* sector row */
.sector-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--outline-variant);
}
.sector-label {
  font-size: 12px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
  color: var(--on-surface-var); padding-right: 4px;
}
.sector-label em { font-style: normal; font-weight: 400; text-transform: none; letter-spacing: 0; opacity: .75; }
.w-250 { width: 250px; }
.w-240 { width: 240px; }

/* chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 32px; padding: 0 7px 0 12px;
  border-radius: 9px;
  background: var(--primary-container); color: var(--on-primary-container);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
}
.chip-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 360px;
}
.chip button {
  all: unset; cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  color: inherit;
  font-size: 15px; font-weight: 700; line-height: 1;
  transition: background-color .15s;
}
.chip button:hover { background: color-mix(in srgb, var(--on-primary-container) 14%, transparent); }
.chip-n { opacity: .7; font-size: 12px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 18px;
  border: none; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 600; letter-spacing: .2px;
  cursor: pointer; position: relative; overflow: hidden;
  transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s;
}
.btn svg { width: 17px; height: 17px; }
.btn.filled { background: var(--primary); color: var(--on-primary); box-shadow: var(--e1); }
.btn.filled:hover { background: var(--primary-hover); box-shadow: var(--e2); }
.btn.outlined { background: transparent; color: var(--primary); border: 1px solid var(--outline); }
.btn.outlined:hover { background: color-mix(in srgb, var(--primary) 9%, transparent); }
.btn.outlined:active { background: color-mix(in srgb, var(--primary) 16%, transparent); }
.btn:disabled { opacity: .38; cursor: default; box-shadow: none; }

/* ripple */
.ripple { position: relative; overflow: hidden; }
.ink {
  position: absolute; border-radius: 50%;
  background: currentColor; opacity: .22;
  transform: scale(0); pointer-events: none;
  animation: ink .55s ease-out forwards;
}
@keyframes ink { to { transform: scale(1); opacity: 0; } }

/* ------------------------------ banner ----------------------------------- */
.banner {
  display: flex; align-items: flex-start; gap: 12px;
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 14px; line-height: 1.55;
  border: 1px solid var(--outline-variant);
  background: var(--sf-card);
  box-shadow: var(--e1);
}
.banner .b-ico { flex: none; display: grid; place-items: center; margin-top: 1px; }
.banner .b-ico svg { width: 21px; height: 21px; }
.banner .b-msg { min-width: 0; }
.banner .b-msg code {
  font-family: var(--mono); font-size: 12.5px;
  background: color-mix(in srgb, var(--on-surface) 8%, transparent);
  padding: 1px 6px; border-radius: 5px;
}
.banner.err { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad-text); }
.banner.err .b-ico { color: var(--bad); }
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn-text); }
.banner.warn .b-ico { color: var(--warn); }
.banner a { color: inherit; text-decoration: underline; }

/* ------------------------------ toolbar ---------------------------------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--outline-variant);
}
.count { font-size: 14px; color: var(--on-surface-var); }
.count b { color: var(--on-surface); font-weight: 700; font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; gap: 8px; }
.pager .btn { height: 34px; padding: 0 14px; font-size: 13.5px; }
.pginfo {
  font-size: 13px; color: var(--on-surface-var);
  font-variant-numeric: tabular-nums;
  min-width: 86px; text-align: center;
}

/* ------------------------------- table ----------------------------------- */
.tablewrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--sf-inset);
  text-align: left;
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .55px;
  color: var(--on-surface-var);
  padding: 11px 14px;
  border-bottom: 1px solid var(--outline-variant);
  white-space: nowrap; user-select: none;
  transition: background-color .15s, color .15s;
}
.tbl thead th[data-k] { cursor: pointer; }
.tbl thead th[data-k]:hover { color: var(--on-surface); }
.tbl thead th .sort { display: inline-grid; place-items: center; margin-left: 4px; color: var(--primary); }
.tbl thead th .sort svg { width: 13px; height: 13px; }
.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--outline-variant); vertical-align: middle; }
.tbl tbody tr { cursor: pointer; transition: background-color .12s; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.tbl tbody tr.cur {
  background: color-mix(in srgb, var(--primary-container) 65%, transparent);
  box-shadow: inset 3px 0 0 var(--primary);
}
.tbl td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.co-no { font-family: var(--mono); font-size: 12.5px; color: var(--on-surface-var); white-space: nowrap; }
.co-name { font-weight: 600; }
.sic-chip {
  display: inline-block;
  font-family: var(--mono); font-size: 11.5px;
  background: var(--sf-inset);
  border: 1px solid var(--outline-variant);
  color: var(--on-surface-var);
  padding: 1.5px 7px; border-radius: 6px;
  margin: 1.5px 4px 1.5px 0; cursor: help;
}
.loc { color: var(--on-surface-var); font-size: 13px; white-space: nowrap; }
.dissolved-note { color: var(--bad); font-size: 12px; font-weight: 600; }

/* status pills */
.pill {
  display: inline-block;
  font-size: 11.5px; font-weight: 600; letter-spacing: .25px;
  padding: 3px 10px; border-radius: var(--r-pill);
  white-space: nowrap;
}
.pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.dissolved, .pill.closed, .pill.removed, .pill.converted-closed { background: var(--bad-soft); color: var(--bad); }
.pill.liquidation, .pill.administration, .pill.receivership, .pill.insolvency-proceedings { background: var(--warn-soft); color: var(--warn); }
.pill.other { background: var(--neutral-soft); color: var(--on-surface-var); }

/* empty states */
.placeholder { padding: 60px 20px; text-align: center; color: var(--on-surface-var); display: none; }
.ph-icon {
  width: 76px; height: 76px; margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--sf-inset);
  color: var(--primary);
  display: grid; place-items: center;
}
.ph-icon svg { width: 32px; height: 32px; }
.placeholder p { font-size: 15px; margin: 4px 0; color: var(--on-surface); }
.ph-hint { font-size: 12.5px !important; color: var(--on-surface-var) !important; opacity: .85; margin-top: 12px !important; }
kbd {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--sf-inset);
  border: 1px solid var(--outline-variant); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px;
  color: var(--on-surface);
}

/* skeleton rows */
.skeleton td { padding: 13px 14px; }
.skel {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--sf-inset) 25%, var(--sf-inset2) 50%, var(--sf-inset) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.1s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------- drawer ---------------------------------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 460px; max-width: 94vw;
  background: var(--sf-card);
  border-left: 1px solid var(--outline-variant);
  z-index: 50;
  box-shadow: var(--e-drawer);
  transform: translateX(103%);
  transition: transform .22s cubic-bezier(.2, 0, 0, 1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-close { position: absolute; top: 10px; right: 10px; z-index: 2; }
.drawer-body { padding: 18px 24px 34px; padding-top: 58px; overflow-y: auto; flex: 1; }
/* G4: docked mode — while the 3D map is open the drawer is a fixed part of
   the map view: no slide (the content just swaps in place) and no elevation
   shadow (it is a panel of the view, not an overlay). The canvas / bar /
   loading overlay insets live in the graph section below. */
.drawer.docked { transition: none; box-shadow: none; }
.d-empty { padding-top: 96px; text-align: center; color: var(--on-surface-var); }
.d-empty-title { font-size: 15px; font-weight: 600; }
.d-empty-sub { margin-top: 6px; font-size: 13px; }

.d-name { font-size: 22px; font-weight: 600; line-height: 1.3; margin: 10px 0 2px; letter-spacing: .1px; }
.d-no { font-family: var(--mono); font-size: 12.5px; color: var(--on-surface-var); }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.d-item {
  background: var(--sf-inset);
  border: 1px solid var(--outline-variant);
  border-radius: var(--r-md);
  padding: 10px 12px;
  min-width: 0;
}
.d-item .k {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--on-surface-var);
}
.d-item .v { font-size: 13.5px; margin-top: 4px; overflow-wrap: anywhere; }
.d-sec { margin-top: 20px; }
.d-sec h3 {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--on-surface-var); margin: 0 0 10px;
}
.d-addr { font-size: 14px; line-height: 1.6; }
.d-sic li { font-size: 13.5px; margin: 6px 0; }
.d-sic .code {
  font-family: var(--mono); font-size: 12px;
  background: var(--sf-inset);
  border: 1px solid var(--outline-variant);
  padding: 1.5px 7px; border-radius: 6px; margin-right: 8px;
  color: var(--on-surface-var);
}
.d-link {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 24px; padding: 11px 20px;
  border-radius: var(--r-pill);
  background: var(--primary); color: var(--on-primary);
  font-weight: 600; font-size: 14px;
  box-shadow: var(--e1);
  transition: background-color .15s, box-shadow .15s;
}
.d-link:hover { background: var(--primary-hover); box-shadow: var(--e2); text-decoration: none; }
.d-link svg { width: 16px; height: 16px; }
.d-loading { color: var(--on-surface-var); padding: 20px 0; font-size: 14px; }

/* drawer tabs (Profile / Officers / Filings) */
.d-tabs { display: flex; gap: 2px; margin-top: 18px; border-bottom: 1px solid var(--outline-variant); }
.d-tab {
  appearance: none; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--on-surface-var);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 13px; position: relative;
  transition: color .15s, background-color .15s;
}
.d-tab:hover { background: var(--sf-inset); color: var(--on-surface); }
.d-tab.active { color: var(--primary); }
.d-tab.active::after {
  content: ""; position: absolute; left: 9px; right: 9px; bottom: -1px;
  height: 2.5px; border-radius: 2px; background: var(--primary);
}
.tab-n {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  background: var(--sf-inset); border: 1px solid var(--outline-variant);
  color: var(--on-surface-var);
  border-radius: var(--r-pill); padding: 0 7px; line-height: 16px;
}
.d-tab.active .tab-n {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
  color: var(--primary);
}
.d-pane { padding-top: 14px; }
.d-subsum { font-size: 12.5px; color: var(--on-surface-var); margin-bottom: 10px; }
.d-empty { color: var(--on-surface-var); font-size: 13.5px; padding: 8px 0 16px; }
.d-err { color: var(--bad-text); font-size: 13.5px; padding: 8px 0 16px; }
/* P7: name-mismatch note — a register entry (corporate PSC / corporate
   officer / appointment-history row) whose recorded company name differs from
   the company's current registered name, plus its similar-name suggestions. */
.d-note { margin-top: 16px; padding: 10px 12px; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }
.d-note-t, .d-note-s { font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--warn-text); }
.d-note-t { margin-bottom: 6px; }
.d-note-s { margin: 10px 0 4px; }
.d-note-b { font-size: 13px; line-height: 1.5; }
.d-note-sug { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font: inherit; color: var(--primary); }
.d-note-sug:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }
/* P10: the name column stacks the flag pill 4px below the name (flex
   baseline alignment left an awkward gap once the second line appeared) */
.d-note-sug-n { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-weight: 500; }
.d-note-sug-m { font-size: 12px; color: var(--on-surface-var); white-space: nowrap; }
/* P10: "likely the intended company" flag — a similar-name candidate whose
   registered office matches the address declared in the register entry */
.d-note-sug-flag { display: inline-block; padding: 1px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--ok); background: var(--ok-soft); }
.d-note-dim { font-size: 12px; line-height: 1.45; color: var(--on-surface-var); margin: 0 0 6px; }

/* officer cards */
.off-card {
  border: 1px solid var(--outline-variant); background: var(--sf-inset);
  border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 8px;
}
.off-card.off-resigned { opacity: .62; }
.off-name { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.off-meta { font-size: 12.5px; margin-top: 3px; }
.off-sub { font-size: 12px; color: var(--on-surface-var); margin-top: 3px; }
.off-addr {
  font-size: 11.5px; color: var(--on-surface-var); opacity: .85;
  margin-top: 3px; overflow-wrap: anywhere;
}
/* corporate officer -> jump to that company; P5: person names -> the
   person's appointment history (officer cards) or a People search (PSCs) */
.off-corp, .off-person, .psc-person {
  appearance: none; border: 0; background: none; padding: 0; margin: 0;
  font: inherit; color: var(--primary); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere;
}
.off-corp:hover, .off-person:hover, .psc-person:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); border-radius: 4px; }

/* cross-company appointment history (expandable in an officer card) */
.off-hist-toggle {
  appearance: none; border: 0; background: none; padding: 6px 0 0; margin: 0;
  font: inherit; font-size: 12px; color: var(--primary); cursor: pointer;
}
.off-hist-toggle:hover { text-decoration: underline; text-underline-offset: 2px; }
.off-hist { margin-top: 8px; border-top: 1px dashed var(--outline-variant); padding-top: 8px; }
.off-hist-full { margin-top: 0; border-top: 0; padding-top: 0; }
.off-hist-sum { font-size: 12px; color: var(--on-surface-var); margin-bottom: 4px; }
.off-hist-row { padding: 7px 0; border-bottom: 1px solid var(--outline-variant); }
.off-hist-row:last-of-type { border-bottom: 0; }
.off-hist-co {
  appearance: none; border: 0; background: none; padding: 0; margin: 0;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--on-surface); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere;
}
.off-hist-cur { font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere; }
.off-hist-curchip {
  display: inline-block; font-size: 9.5px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--on-surface-var);
  border: 1px solid var(--outline-variant); border-radius: var(--r-pill);
  padding: 1px 7px; margin-left: 6px; vertical-align: 1px;
}
.off-hist-meta { font-size: 11.5px; color: var(--on-surface-var); margin-top: 2px; }
.off-hist-note { font-size: 12px; color: var(--on-surface-var); padding: 4px 0; }
.off-hist-err { font-size: 12px; color: var(--bad-text); padding: 4px 0; }
.off-hist-morewrap { margin-top: 8px; }

/* P4: officer list controls (filter chips / role select / sort / CSV) */
.off-ctrl {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.off-fchips { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--outline); border-radius: var(--r-pill); }
.off-fchip {
  appearance: none; border: 0; background: none; padding: 4px 12px;
  font: inherit; font-size: 12px; font-weight: 600; color: var(--on-surface-var);
  border-radius: var(--r-pill); cursor: pointer; transition: background-color .15s, color .15s;
}
.off-fchip:hover { color: var(--on-surface); }
.off-fchip.on { background: var(--primary); color: var(--on-primary); }
/* Role filter: a MenuSelect (menu.js) rendered as a compact pill so it sits
   with the neighbour chips (the native <select> popup is OS-drawn and can't
   be themed — the same fix the main-search selects got). */
.off-ctrl .off-role { width: auto; min-width: 122px; }
.off-ctrl .off-role .ms-trigger {
  height: 30px; padding: 5px 28px 5px 12px;
  font-size: 12px; font-weight: 600; border-radius: var(--r-pill);
}
.off-ctrl .off-role .sel-caret { right: 10px; width: 14px; height: 14px; }
.off-csv {
  appearance: none; border: 1px solid var(--outline-variant); background: none; padding: 4px 14px;
  font: inherit; font-size: 12px; font-weight: 600; color: var(--on-surface-var);
  border-radius: var(--r-pill); cursor: pointer; margin-left: auto;
  transition: border-color .15s, color .15s;
}
.off-csv:hover { border-color: var(--primary); color: var(--primary); }

/* P3: PSC / ownership cards */
.psc-card {
  border: 1px solid var(--outline-variant); background: var(--sf-inset);
  border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 8px;
}
.psc-card.psc-ceased { opacity: .62; }
.psc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.psc-chip {
  font-size: 11px; font-weight: 600; color: var(--on-primary-container);
  background: var(--primary-container); border-radius: var(--r-pill);
  padding: 2px 9px;
}
.psc-statement { font-size: 13px; padding: 8px 0; color: var(--on-surface); }
.psc-stmt-date { font-size: 11.5px; color: var(--on-surface-var); margin-top: 2px; }

/* filing history rows */
.fil-row {
  display: grid; grid-template-columns: 74px 1fr auto; gap: 10px;
  align-items: start; padding: 9px 2px; border-bottom: 1px solid var(--outline-variant);
}
.fil-row:last-child { border-bottom: none; }
.fil-date { font-family: var(--mono); font-size: 11.5px; color: var(--on-surface-var); padding-top: 2px; }
.fil-pages { display: block; font-size: 10.5px; margin-top: 2px; opacity: .8; }
.fil-type {
  font-family: var(--mono); font-size: 11.5px; font-weight: 700; color: var(--primary);
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}
.cat-chip {
  font-family: inherit; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
  background: var(--sf-inset); border: 1px solid var(--outline-variant);
  color: var(--on-surface-var); border-radius: var(--r-pill); padding: 1px 8px;
}
.fil-desc { font-size: 12.5px; margin-top: 3px; color: var(--on-surface); }
.fil-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: var(--r-sm);
  color: var(--on-surface-var);
  transition: background-color .15s, color .15s;
}
.fil-link:hover { background: var(--sf-inset); color: var(--primary); }
.fil-link svg { width: 14px; height: 14px; }

/* drawer pagination (Showing X of Y + Load more) */
.d-pager {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 12px; font-size: 12.5px; color: var(--on-surface-var);
}
.d-pager:empty { display: none; }
.d-pager-side { display: inline-flex; align-items: center; gap: 12px; }
.d-sublink {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--on-surface-var);
  transition: color .15s;
}
.d-sublink:hover { color: var(--primary); text-decoration: none; }
.d-sublink svg { width: 13px; height: 13px; }
.d-loadmore {
  appearance: none; border: 1px solid var(--primary); background: none; color: var(--primary);
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 18px; border-radius: var(--r-pill); cursor: pointer;
  transition: background-color .15s;
}
.d-loadmore:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }

/* ------------------------------ snackbar --------------------------------- */
.snack {
  position: fixed; left: 50%; bottom: 26px;
  transform: translate(-50%, 16px);
  opacity: 0;
  z-index: 60;
  background: var(--snack-bg); color: var(--snack-fg);
  font-size: 14px; font-weight: 500;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: var(--e3);
  max-width: min(560px, 90vw);
  pointer-events: none;
  transition: transform .22s cubic-bezier(.2, 0, 0, 1), opacity .22s ease;
}
.snack.show { transform: translate(-50%, 0); opacity: 1; }

/* ------------------------ M3 menu select (menu.js) ----------------------- */
/* The native <select> stays in the DOM as the source of truth but is invisible;
   the themed .ms-trigger button + .ms-menu listbox are what the user sees. */
.m-field .ms-src {
  position: absolute !important; top: 0; left: 0;
  width: 1px !important; height: 1px !important;
  opacity: 0 !important; pointer-events: none !important;
}
.ms-trigger {
  width: 100%; height: 48px;
  display: flex; align-items: center;
  padding: 13px 34px 13px 12px;
  font: inherit; font-size: 14.5px; color: var(--on-surface);
  background: transparent;
  border: 1px solid var(--outline); border-radius: 10px;
  cursor: pointer; position: relative; overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
  text-align: left;
}
.ms-trigger:hover:not(:disabled) { border-color: var(--on-surface-var); }
.m-field.select:focus-within .ms-trigger,
.ms-trigger:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  outline: none;
}
.ms-trigger:disabled { opacity: .5; cursor: default; }
.ms-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-field.compact .ms-trigger { height: 38px; padding: 10px 32px 10px 11px; font-size: 13.5px; border-radius: 9px; }

.ms-menu {
  position: absolute; top: calc(100% - 6px); left: 0; z-index: 40;
  width: max-content; min-width: 100%; max-width: min(440px, calc(100vw - 32px));
  background: var(--sf-card);
  border: 1px solid var(--outline-variant);
  border-radius: 12px;
  box-shadow: var(--e3);
  padding: 6px;
  max-height: min(320px, 62vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  /* theme the scrollbar too — the OS default would leak light into dark mode */
  scrollbar-width: thin;
  scrollbar-color: var(--outline) transparent;
}
.ms-menu::-webkit-scrollbar { width: 12px; }
.ms-menu::-webkit-scrollbar-track { background: transparent; }
.ms-menu::-webkit-scrollbar-thumb {
  background: var(--outline); border-radius: 999px;
  border: 4px solid var(--sf-card);
}
.ms-menu.up { top: auto; bottom: calc(100% - 6px); }
.ms-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 38px; padding: 0 10px; margin: 1px 0;
  border-radius: 9px;
  font-size: 14px; line-height: 1.3;
  white-space: nowrap;
  cursor: pointer; user-select: none;
  color: var(--on-surface);
  transition: background-color .1s;
}
.ms-opt-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ms-opt:hover { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.ms-opt.active { background: var(--neutral-soft); }
.ms-check { flex: none; width: 16px; height: 16px; color: var(--primary); opacity: 0; }
.ms-opt[aria-selected="true"] .ms-check { opacity: 1; }
/* Multi-select rows: a real checkbox box (the "Any …" row has none — it clears). */
.ms-cb {
  flex: none; width: 18px; height: 18px; position: relative;
  border: 2px solid var(--outline); border-radius: 4px;
  transition: border-color .12s, background-color .12s;
}
.ms-opt[aria-selected="true"] .ms-cb { background: var(--primary); border-color: var(--primary); }
.ms-opt[aria-selected="true"] .ms-cb::after {
  content: ""; position: absolute; left: 4.5px; top: 1.5px;
  width: 5px; height: 9px;
  border: 2px solid var(--on-primary);
  border-top: 0; border-left: 0;
  transform: rotate(45deg);
}
.ms-opt-any { opacity: .7; }
.ms-menu.compact .ms-opt { min-height: 32px; font-size: 13.5px; }
.m-field.select.open .sel-caret { color: var(--primary); transform: translateY(-50%) rotate(180deg); }

/* --------------------- G1: 3D connection map overlay ----------------------
   Full-screen force-directed graph (3d-force-graph in lib/). z 35: above the
   sticky app bar (30), BELOW the scrim (40) and drawer (50) — a node click
   layers the drawer on top and the graph stays open behind it. */
.graph-overlay { position: fixed; inset: 0; z-index: 35; background: var(--sf-page); }
.graph-canvas { position: absolute; inset: 0; }
.graph-canvas canvas { display: block; }
/* G4: docked info panel — while the map is open the drawer (460px, capped at
   94vw, same as .drawer) is a fixed part of the view, so the canvas, the top
   bar and the loading overlay take only the remaining width (the drawer
   covers the rest; its z 50 > overlay z 35). */
body.graph-docked .graph-canvas { right: min(460px, 94vw); }
body.graph-docked .graph-bar { right: min(460px, 94vw); }
body.graph-docked .graph-msg { right: min(460px, 94vw); }
.graph-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--sf-card) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--outline-variant);
}
.graph-close { flex: none; }
.graph-root { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.graph-root #graphRootName {
  font-weight: 600; font-size: .95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 38vw;
}
.graph-root-no { font-size: .78rem; font-family: var(--mono); color: var(--on-surface-var); }
.graph-depth { margin-left: auto; }
.graph-legend {
  display: flex; gap: 12px; align-items: center;
  font-size: .78rem; color: var(--on-surface-var); white-space: nowrap;
  /* G6: with the two dead entries the bar can wrap (flex-wrap) — when a
     single row still gets tight, the legend tail clips instead of pushing
     the stats off the bar (the dead reasons stay readable on the link
     labels themselves). */
  min-width: 0; overflow: hidden;
}
.gl { display: inline-flex; align-items: center; gap: 5px; }
.gl-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.gl-line { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.graph-stats {
  font-size: .8rem; color: var(--on-surface-var); white-space: nowrap;
  /* G6: the full stats string (… · N dead (hidden)) is in the title —
     ellipsize instead of overrunning the bar / drawer edge. */
  min-width: 0; max-width: 40vw; overflow: hidden; text-overflow: ellipsis;
}
/* G6: the "Hide dead links" top-bar toggle (a plain labelled checkbox — the
   dead links are a view preference, not a search filter). */
.graph-deadchk {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--on-surface-var);
  white-space: nowrap; cursor: pointer; user-select: none;
}
.graph-deadchk input {
  margin: 0; width: 15px; height: 15px;
  accent-color: var(--primary); cursor: pointer;
}
/* G6 legend: the dead-link swatch (a fainter, dashed-ish grey line) */
.gl-line-dead {
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--outline) 0 4px, transparent 4px 7px);
}
/* G2: the top-bar focus section (the focused node's name + Expand/Reset).
   Sits between the seed name and the depth select; wraps below the bar on
   narrow screens. */
.graph-focus {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 10px;
  background: color-mix(in srgb, var(--sf-card) 70%, transparent);
  border: 1px solid var(--outline-variant);
  border-radius: 999px;
  min-width: 0;
}
.graph-focus-name {
  font-size: .8rem; font-weight: 600;
  max-width: 200px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.graph-focus-btn {
  padding: 4px 10px;
  font-size: .75rem;
  white-space: nowrap;
}
/* G2: the always-visible label for the focused node. app.js sets left/top
   from graph2ScreenCoords every frame (the transform keeps the pill BELOW
   the node's projected point, centred on it). */
.graph-focus-label {
  position: absolute; z-index: 2; left: 0; top: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  max-width: 260px;
  padding: 4px 10px;
  background: var(--sf-card);
  color: var(--on-surface);
  border: 1px solid var(--outline);
  border-radius: var(--r-md);
  box-shadow: var(--e-drawer);
  font-size: .78rem; line-height: 1.3; text-align: center;
}
.graph-focus-label .gfl-name { font-weight: 600; }
.graph-focus-label .gfl-sub { color: var(--on-surface-var); font-size: .68rem; margin-top: 1px; }
.graph-msg {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.gm-loading, .gm-err {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  background: var(--sf-card);
  border: 1px solid var(--outline-variant);
  border-radius: var(--r-md);
  box-shadow: var(--e-drawer);
  font-size: .9rem;
  max-width: 80vw;
}
.gm-err { border-color: var(--bad); color: var(--bad-text); }
.gm-spin {
  flex: none; width: 14px; height: 14px;
  border: 2px solid var(--outline); border-top-color: var(--primary);
  border-radius: 50%;
  animation: gspin .8s linear infinite;
}
@keyframes gspin { to { transform: rotate(360deg); } }
/* 3d-force-graph renders node/link tooltips as a positioned div — style it
   (the library sets position/pointer-events/font-size on the wrapper itself). */
.graph-tip {
  font-size: 12px; line-height: 1.4;
  padding: 6px 10px;
  background: var(--sf-card);
  border: 1px solid var(--outline-variant);
  border-radius: var(--r-sm);
  box-shadow: var(--e-drawer);
}
.graph-tip .gt-sub { color: var(--on-surface-var); font-size: 11px; margin-top: 2px; }
/* the drawer's "3D connection map" action (company drawers only) */
.d-graphrow { padding: 10px 20px 0; }
.d-graphrow .btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }

/* ----------------------------- responsive -------------------------------- */
@media (max-width: 1080px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .grid .grow { grid-column: 1 / -1; }
  .sector-row .m-field { width: 100%; }
}
@media (max-width: 620px) {
  .grid { grid-template-columns: 1fr; }
  .appbar-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .d-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: flex-start; }
}

/* ---------------------------- reduced motion ----------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
