:root {
  color-scheme: dark;
  --bg: #070a09;
  --panel: #101512;
  --panel-2: #151b17;
  --text: #f7f4ec;
  --muted: #b9b5aa;
  --line: rgba(222, 232, 211, 0.14);
  --green: #9bef74;
  --mint: #70e2b6;
  --gold: #f0c766;
  --red: #ff806e;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
}

body.light-theme {
  color-scheme: light;
  --bg: #f7f8f4;
  --panel: #ffffff;
  --panel-2: #eef4ea;
  --text: #172016;
  --muted: #5f685b;
  --line: rgba(25, 49, 23, 0.16);
  --green: #247a2f;
  --mint: #168b74;
  --gold: #9d7417;
  --red: #b43f32;
  --shadow: 0 18px 42px rgba(33, 55, 30, 0.12);
  background: #f7f8f4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(rgba(155, 239, 116, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(155, 239, 116, 0.03) 1px, transparent 1px),
    linear-gradient(145deg, #070a09, #0e1411 58%, #17130b);
  background-size: 38px 38px, 38px 38px, auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.gate-open {
  height: 100vh;
  height: 100svh;
  max-height: 100vh;
  max-height: 100svh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #090d12;
}

button, input, textarea, select { font: inherit; }

button, .top-actions a {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid rgba(155, 239, 116, 0.34);
  border-radius: 7px;
  color: #071008;
  background: linear-gradient(135deg, var(--green), var(--mint));
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
}

button:hover, .top-actions a:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
}

button:active, .top-actions a:active {
  transform: translateY(0);
}

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: 0%;
  height: 4px;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.hidden { display: none !important; }

.app {
  width: min(1260px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

body.gate-open .app {
  width: 100%;
  height: 100vh;
  height: 100svh;
  max-height: 100vh;
  max-height: 100svh;
  padding: 0;
  overflow: hidden;
}

.gate {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  height: 100vh;
  height: 100svh;
  max-height: 100vh;
  max-height: 100svh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(14px, 3vw, 34px);
  overflow: hidden;
}

body.gate-open .gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
}

.gate .access-card {
  width: min(100%, 448px);
  max-height: calc(100svh - 32px);
  overflow-y: auto;
  padding: 36px 32px 30px;
  border: 1px solid rgba(222, 232, 211, 0.14);
  border-radius: 8px;
  background: #121923;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

.auth-stage { display: grid; gap: 14px; }
.auth-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-form-grid label:nth-child(5), .auth-form-grid label:nth-child(6) { grid-column: 1 / -1; }
.business-type-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 7px; }
.business-type-picker legend { padding: 0 6px; color: var(--muted); font-size: 0.86rem; font-weight: 800; }
.business-type-picker label, .privilege-grid label { display: flex; align-items: center; gap: 7px; }
.business-type-picker input, .privilege-grid input { width: 17px; min-height: 17px; }
button.secondary { color: var(--text); background: transparent; border-color: var(--line); }

.cockpit { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; align-items: start; }
.cockpit > .topbar, .cockpit > .site-search-results { grid-column: 1 / -1; }
.left-rail { position: sticky; top: 112px; z-index: 20; align-self: start; width: 230px; max-height: calc(100vh - 128px); overflow-y: auto; overscroll-behavior: contain; padding: 0 6px 18px 0; scrollbar-gutter: stable; }
.left-rail .page-tabs { display: grid; gap: 6px; overflow: visible; padding: 0 0 10px; }
.left-rail .page-tabs button { width: 100%; min-height: 38px; text-align: left; }
.cockpit > .page { grid-column: 2; min-width: 0; margin-left: 0; }
.owner-account-panel { position: static; width: 100%; max-height: none; overflow: visible; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(16, 21, 18, 0.98); box-shadow: var(--shadow); }
.owner-account-panel.collapsed { width: 48px; overflow: hidden; }
.owner-account-panel.collapsed #ownerPanelBody { display: none; }
.owner-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.owner-panel-head button { width: 32px; min-width: 32px; min-height: 32px; padding: 0; }
.owner-account-panel h3 { margin: 16px 0 8px; font-size: 0.9rem; }
.owner-account-summary, .owner-account-panel .mini-list { color: var(--muted); font-size: 0.8rem; line-height: 1.45; }
.owner-account-summary > * { display: block; margin-bottom: 3px; }
.owner-account-panel .mini-list { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; overflow-wrap: anywhere; }
.owner-account-panel .mini-item { padding: 8px 0; border-bottom: 1px solid var(--line); }
#renameLocationButton { display: block; max-width: 100%; color: var(--text); background: transparent; border: 0; text-align: left; padding: 4px 0; overflow-wrap: anywhere; }
.intelligence-tools { margin: 18px 0; min-width: 0; }
.owner-account-panel .mini-item strong, .owner-account-panel .mini-item span { display: block; }
.owner-account-panel .mini-item button { width: 100%; min-height: 32px; margin-top: 7px; padding: 0 9px; }
.admin-create-box { margin-top: 10px; }
.admin-create-box summary { cursor: pointer; font-weight: 850; }
.admin-create-box label { margin-top: 9px; }
.privilege-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 9px; }

.gate-brand {
  margin-bottom: 30px;
  color: #f7f4ec;
  font-size: 1.04rem;
  font-weight: 900;
  text-align: center;
}

.gate .access-card .gate-brand span {
  display: inline;
  color: var(--mint);
  font-size: inherit;
}

.gate-heading h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  letter-spacing: 0;
}

.gate-heading p {
  margin: 0 0 24px;
  color: #98a1ae;
  line-height: 1.45;
}

.gate .access-card label {
  display: grid;
  gap: 7px;
  color: #aeb6c1;
  font-size: 0.9rem;
}

.gate .password-row input {
  min-height: 46px;
  border-color: #8993a1;
  background: #151d28;
}

.gate .password-row {
  position: relative;
  display: block;
}

.gate .password-row button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 54px;
  min-width: 54px;
  min-height: 38px;
  padding: 0 6px;
  border: 0;
  color: #aeb6c1;
  background: transparent;
  font-size: 0.8rem;
}

.gate .password-row input { padding-right: 62px; }

.gate .access-card > button[type="submit"] {
  width: 100%;
  margin-top: 13px;
  background: #5f8ff4;
  border-color: #5f8ff4;
  color: #fff;
}

.gate .access-card small {
  display: block;
  margin-top: 18px;
  color: #8f98a5;
  line-height: 1.45;
  text-align: center;
}

.brand-block h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(2.2rem, 5.4vw, 5.1rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.brand-block p:not(.eyebrow), .hero-panel p, .panel-head p, .page-title p {
  color: var(--muted);
  line-height: 1.55;
}

.brand-block p:not(.eyebrow) {
  max-width: 720px;
  font-size: 1.12rem;
}

.front-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.front-points span {
  padding: 8px 10px;
  border: 1px solid rgba(155, 239, 116, 0.24);
  border-radius: 7px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.86rem;
  font-weight: 800;
}

.front-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 900px;
  margin-top: 18px;
}

.front-grid article {
  min-height: 92px;
  padding: 12px;
  border: 1px solid rgba(247, 244, 236, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.front-grid strong,
.front-grid span {
  display: block;
}

.front-faq {
  max-width: 720px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(155, 239, 116, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.front-faq summary {
  color: var(--green);
  font-weight: 900;
  cursor: pointer;
}

.front-faq p { margin-bottom: 0; }

.front-grid strong {
  color: var(--green);
  font-size: 0.9rem;
}

.front-grid span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.access-card, .panel, .hero-panel, .metrics article {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 21, 18, 0.96), rgba(21, 27, 23, 0.94));
  box-shadow: var(--shadow);
}

.access-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

input, textarea, select {
  width: 100%;
  border: 1px solid rgba(247, 244, 236, 0.14);
  border-radius: 7px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.28);
  outline: none;
}

input, select {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

.access-card button { width: 100%; }

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.password-row button {
  width: auto;
  min-width: 74px;
}

.access-card span, .status-line {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.status-line.error { color: var(--red); }
.status-line.good { color: var(--green); }

.topbar {
  position: sticky;
  top: 4px;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 8px 0 14px;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 76%, transparent);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.4rem);
  letter-spacing: 0;
}

.top-left-stack {
  display: grid;
  gap: 8px;
}

.location-switcher {
  display: inline-grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  align-items: center;
  gap: 8px;
  max-width: 360px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.location-switcher > div { min-width: 0; }

.location-switcher .store-code-chip {
  display: inline-block;
  width: fit-content;
  margin-bottom: 3px;
  padding: 3px 7px;
  border: 1px solid rgba(155, 239, 116, 0.36);
  border-radius: 5px;
  color: var(--green);
  background: rgba(155, 239, 116, 0.08);
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.location-switcher button {
  min-width: 38px;
  min-height: 34px;
  padding: 0 8px;
}

.location-switcher strong,
.location-switcher span,
.location-switcher small {
  display: block;
}

.location-switcher span,
.location-switcher small {
  color: var(--muted);
  font-size: 0.78rem;
}

.location-switcher #activeLocationName { font-size: 0.9rem; }
.location-switcher #activeLocationPosition { margin-top: 2px; }
.location-switcher button:disabled { opacity: 0.36; cursor: default; transform: none; filter: none; }

.top-actions, .button-row, .mini-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.site-search-label {
  min-width: min(260px, 100%);
  color: var(--muted);
  font-size: 0.76rem;
}

.site-search-label input {
  min-height: 42px;
}

.site-search-results {
  position: fixed;
  top: 94px;
  right: max(14px, calc((100vw - 1260px) / 2));
  z-index: 45;
  width: min(720px, calc(100vw - 28px));
  max-height: min(72vh, 680px);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 0 12px auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.site-search-results .list-item {
  margin-top: 8px;
}

.search-results-head { display: grid; gap: 3px; padding: 4px 4px 8px; color: var(--muted); font-size: 0.82rem; }
.search-results-head strong { color: var(--text); }
.search-result-item { position: relative; }
.search-result-item button, .record-search-result button { position: relative; z-index: 1; }

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.top-actions button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

#accountQuickButton { border-color: rgba(155, 239, 116, 0.42); }

.page-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 16px;
  scroll-padding-left: 8px;
}

.page-tabs button {
  flex: 0 0 auto;
  min-height: 38px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(247, 244, 236, 0.12);
}

.page-tabs button.active {
  color: #071008;
  border-color: rgba(155, 239, 116, 0.5);
  background: linear-gradient(135deg, var(--green), var(--mint));
}

.page { display: none; }
.page.active { display: block; }

.page-title {
  max-width: 780px;
  margin: 18px 0 18px;
}

.page-title h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  letter-spacing: 0;
}

.page-title p { margin: 10px 0 0; }

.dashboard-search {
  max-width: 520px;
  margin-top: 14px;
}

.hero-panel {
  min-height: 230px;
  display: grid;
  align-items: center;
  padding: 26px;
  border-radius: 8px;
  overflow: hidden;
}

.compact-hero h2 {
  max-width: 850px;
  margin: 12px 0 0;
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.signal {
  color: var(--gold);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.metrics article {
  min-height: 104px;
  padding: 15px;
  border-radius: 8px;
}

.metrics article[data-control-jump] {
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.metrics article[data-control-jump]:hover,
.metrics article[data-control-jump]:focus-visible {
  border-color: rgba(91, 141, 239, 0.65);
  background: rgba(91, 141, 239, 0.1);
  outline: none;
  transform: translateY(-1px);
}

.metrics span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.metrics strong {
  display: block;
  margin-top: 16px;
  font-size: clamp(1.22rem, 2.2vw, 2rem);
}

.mini-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mini-metrics article {
  min-height: 78px;
  padding: 12px;
}

.mini-metrics strong {
  margin-top: 8px;
  font-size: 1.25rem;
}

.overview-grid, .two-column, .ranking-grid, .trade-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.section-divider {
  margin: 26px 0 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.section-divider h2 {
  margin: 0;
  font-size: 1.05rem;
}

.section-divider p {
  margin: 5px 0 0;
  color: var(--muted);
  max-width: 780px;
}

.nexus-inbox-panel {
  margin: 14px 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.segmented-control button {
  min-height: 38px;
  padding: 0 10px;
  border-color: rgba(247, 244, 236, 0.16);
  background: rgba(247, 244, 236, 0.055);
  color: var(--muted);
  font-size: 0.76rem;
}

.segmented-control button.active {
  border-color: rgba(155, 239, 116, 0.72);
  color: var(--text);
  background: rgba(155, 239, 116, 0.1);
}

.product-mix-row {
  padding: 11px 0;
  border-bottom: 1px solid rgba(247, 244, 236, 0.08);
}

.product-mix-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
}

.product-mix-top strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.product-mix-top i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.product-mix-top span {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}

.product-mix-bar {
  height: 9px;
  border-radius: 999px;
  background: rgba(247, 244, 236, 0.08);
  overflow: hidden;
}

.product-mix-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.scan-action-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(110, 231, 183, 0.24);
  border-radius: 8px;
  background: rgba(110, 231, 183, 0.08);
}

.scan-action-panel strong,
.scan-action-panel p {
  margin: 0;
}

.scan-action-panel p {
  color: var(--muted);
  line-height: 1.4;
}

.trade-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.trade-grid.slim {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.trade-grid > .panel {
  min-height: 0;
  height: auto;
}

.trade-grid textarea {
  min-height: 104px;
}

.weight-panel {
  margin-bottom: 14px;
}

.weight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.hub-section {
  margin-top: 14px;
}

.ranking-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 14px 0;
}

.records-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.record-folder-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.record-folder-card {
  align-items: flex-start;
  background: rgba(247, 244, 236, 0.045);
  border: 1px solid rgba(247, 244, 236, 0.14);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 112px;
  padding: 14px;
  text-align: left;
}

.record-folder-card:hover,
.record-folder-card:focus-visible {
  background: rgba(91, 141, 239, 0.1);
  border-color: rgba(91, 141, 239, 0.62);
  outline: none;
}

.record-folder-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.record-folder-card strong {
  font-size: 1.8rem;
}

.record-folder-card small {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}

.lower-grid { margin-top: 14px; }

.panel {
  padding: 20px;
  border-radius: 8px;
  overflow: hidden;
}

.form-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-content: start;
  overflow: auto;
}

.overview-grid > .panel {
  height: 340px;
}

.ranking-grid > .panel {
  display: flex;
  flex-direction: column;
  height: 310px;
}

.records-grid > .panel {
  display: flex;
  flex-direction: column;
  height: 390px;
}

.two-column > .panel {
  display: flex;
  flex-direction: column;
  height: min(620px, calc(100vh - 220px));
  min-height: 390px;
}

.page[data-page="imports"] .two-column > .panel,
.page[data-page="files"] .two-column > .panel,
.page[data-page="snapshots"] .two-column > .panel,
.page[data-page="decisions"] .two-column > .panel {
  height: 560px;
  min-height: 460px;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.12rem;
  letter-spacing: 0;
}

.panel-head p {
  margin: 6px 0 0;
  font-size: 0.91rem;
}

.split {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.chart-panel {
  min-height: 300px;
}

.chart-panel canvas {
  width: 100%;
  height: 210px;
}

.list {
  display: grid;
  gap: 10px;
  max-height: 100%;
  overflow: auto;
  min-height: 0;
  padding-right: 4px;
}

.overview-grid .list {
  max-height: 232px;
}

.two-column .list {
  flex: 1;
}

.records-grid .list {
  flex: 1;
}

.ranking-grid .list {
  flex: 1;
}

.mini-list {
  margin-top: 12px;
  max-height: 180px;
}

.form-divider {
  height: 1px;
  margin: 2px 0;
  background: rgba(247, 244, 236, 0.12);
}

.empty {
  color: var(--muted);
  padding: 12px;
  border: 1px dashed rgba(247, 244, 236, 0.14);
  border-radius: 7px;
}

.list-item {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(247, 244, 236, 0.12);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.18);
}

.list-item strong, .list-item span { display: block; }
.list-item span, .list-item p { color: var(--muted); }
.list-item p {
  margin: 6px 0 0;
  line-height: 1.42;
}

.list-item.high { border-color: rgba(255, 128, 110, 0.46); }
.list-item.medium { border-color: rgba(240, 199, 102, 0.42); }
.list-item.critical { border-color: rgba(255, 128, 110, 0.72); background: rgba(255, 128, 110, 0.08); }
.list-item.low { border-color: rgba(110, 231, 183, 0.28); }

.list-item button {
  min-height: 36px;
  margin-top: 10px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.preview-box {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(110, 231, 183, 0.28);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.2);
  max-height: 130px;
  overflow: auto;
}

.preview-box strong, .preview-box span { display: block; }
.preview-box span, .preview-box p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.badge {
  height: fit-content;
  padding: 7px 10px;
  border: 1px solid rgba(247, 244, 236, 0.15);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.badge.good {
  color: var(--green);
  border-color: rgba(155, 239, 116, 0.36);
}

.badge.warn {
  color: var(--gold);
  border-color: rgba(240, 199, 102, 0.36);
}

.answer {
  flex: 1;
  min-height: 0;
  margin: 12px 0 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid rgba(247, 244, 236, 0.12);
  border-radius: 7px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.28);
  white-space: pre-wrap;
}

.scroll-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  min-width: 62px;
  box-shadow: var(--shadow);
}

.loading-overlay {
  position: fixed;
  inset: auto 18px 18px auto;
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
  font-weight: 850;
}

.loading-overlay span {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(155, 239, 116, 0.22);
  border-top-color: var(--green);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.table-wrap { overflow: auto; }

.page[data-page="passports"] > .panel {
  max-height: 430px;
}

.utility-page {
  display: none !important;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(247, 244, 236, 0.1);
  text-align: left;
}

th {
  color: var(--green);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td { color: var(--muted); }

@media (max-width: 980px) {
  .cockpit { display: block; }
  .auth-form-grid, .business-type-picker { grid-template-columns: 1fr; }
  .auth-form-grid label:nth-child(5), .auth-form-grid label:nth-child(6) { grid-column: auto; }
  .left-rail { position: static; display: none; width: 100%; max-height: none; overflow: visible; padding: 0; }
  body.mobile-nav-open .left-rail { display: block; }
  .left-rail .page-tabs { display: none; }
  body.mobile-nav-open .left-rail .page-tabs { display: flex; }
  .owner-account-panel { position: static; width: 100%; max-height: none; margin: 10px 0; }
  .cockpit > .page { margin-left: 0; }

  .gate, .overview-grid, .two-column, .records-grid, .record-folder-grid, .ranking-grid, .trade-grid, .trade-grid.slim, .front-grid, .weight-grid {
    grid-template-columns: 1fr;
  }

  .gate {
    align-content: center;
    justify-content: stretch;
    gap: 14px;
    padding: 14px;
  }

  .brand-block h1 {
    font-size: clamp(2rem, 9vw, 3.65rem);
    line-height: 0.98;
  }

  .brand-block p:not(.eyebrow) {
    font-size: 0.96rem;
    line-height: 1.42;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segmented-control {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions > button,
  .site-search-label {
    flex: 1 1 140px;
  }

  .site-search-results {
    top: 154px;
    right: 14px;
    width: calc(100vw - 28px);
    max-height: calc(100svh - 170px);
  }

  .page-tabs {
    display: none;
    flex-direction: column;
    overflow: visible;
  }

  body.mobile-nav-open .page-tabs {
    display: flex;
  }

  .overview-grid > .panel,
  .two-column > .panel,
  .records-grid > .panel,
  .ranking-grid > .panel {
    height: 430px;
    min-height: 0;
  }
}

@media (min-width: 981px) and (max-width: 1180px) {
  .ranking-grid, .trade-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 981px) and (max-width: 1180px) {
  .metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Narrow screens: give every label, action, and record room to breathe. */
@media (max-width: 600px) {
  html, body { overflow-x: hidden; }

  .app {
    width: calc(100% - 20px);
    padding: 14px 0 34px;
  }

  button {
    min-height: 44px;
    padding: 8px 11px;
    line-height: 1.18;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  input, select { min-height: 44px; }

  .gate { padding: 10px; }
  .gate .access-card {
    max-height: calc(100svh - 20px);
    padding: 24px 18px 20px;
  }
  .gate-brand { margin-bottom: 22px; }
  .auth-form-grid, .business-type-picker { grid-template-columns: 1fr; }

  .topbar {
    align-items: stretch;
    position: relative;
    gap: 10px;
    padding: 4px 0 12px;
  }
  .top-left-stack { min-width: 0; width: 100%; }
  .topbar h1 {
    font-size: 1.7rem;
    line-height: 1.08;
    overflow-wrap: anywhere;
  }

  .location-switcher {
    width: 100%;
    max-width: none;
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    gap: 6px;
    padding: 7px;
  }
  .location-switcher button { min-width: 34px; padding: 4px; }
  .location-switcher #activeLocationName,
  .location-switcher #activeLocationType,
  .location-switcher #activeLocationPosition,
  .location-switcher #activeLocationId { overflow-wrap: anywhere; }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }
  .top-actions > button,
  .site-search-label {
    width: 100%;
    min-width: 0;
  }
  .site-search-label { grid-column: 1 / -1; }
  .site-search-label input { min-width: 0; }

  .site-search-results {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: calc(100svh - 20px);
    margin: 0;
  }

  .page { min-width: 0; }
  .hero-panel, .panel { padding: 16px; }
  .compact-hero h2 {
    font-size: 1.85rem;
    line-height: 1.04;
    overflow-wrap: anywhere;
  }
  .hero-panel p, .panel-head p, .page-title p { overflow-wrap: anywhere; }

  .hero-actions, .button-row, .mini-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .hero-actions > button, .button-row > button, .mini-actions > button { width: 100%; }

  .metrics, .mini-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metrics article { min-height: 88px; padding: 10px; }
  .metrics span { line-height: 1.25; overflow-wrap: anywhere; }
  .metrics strong { margin-top: 10px; font-size: 1.18rem; overflow-wrap: anywhere; }

  .panel-head.split {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .panel-head.split > button { width: 100%; }

  .segmented-control { grid-template-columns: 1fr; }
  .product-mix-top {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }
  .product-mix-top span { text-align: left; overflow-wrap: anywhere; }

  .list-item, .empty, .record-folder-card, .scan-action-panel { overflow-wrap: anywhere; }
  .list-item button { width: 100%; }
  table { display: block; max-width: 100%; overflow-x: auto; }

  .owner-account-panel { padding: 12px; }
  .privilege-grid { grid-template-columns: 1fr; }
  .left-rail .page-tabs button { text-align: left; }
}

@media (max-width: 390px) {
  .app { width: calc(100% - 16px); }
  .gate .access-card { padding-inline: 14px; }
  .metrics, .mini-metrics { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 1.52rem; }
  .compact-hero h2 { font-size: 1.68rem; }
}
