:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(11, 24, 41, 0.82);
  --panel-strong: rgba(15, 33, 54, 0.92);
  --line: rgba(67, 103, 136, 0.34);
  --text: #e7f2ff;
  --muted: #8da5ba;
  --cyan: #38d5e6;
  --teal: #1fbfa5;
  --green: #37d67a;
  --red: #ff6473;
  --gold: #e8c56c;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 213, 230, 0.15), transparent 30rem),
    radial-gradient(circle at 78% 8%, rgba(31, 191, 165, 0.1), transparent 24rem),
    linear-gradient(135deg, #050b14 0%, var(--bg) 52%, #081827 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 42px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0 26px;
}

.hero-actions {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.api-key-switcher {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  max-width: 720px;
  padding: 10px;
  border: 1px solid rgba(141, 165, 186, 0.18);
  border-radius: 8px;
  background: rgba(4, 11, 20, 0.5);
}

.api-key-switcher label {
  display: grid;
  gap: 5px;
  min-width: min(340px, 100%);
}

.api-key-switcher span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.api-key-switcher input {
  min-height: 34px;
  border: 1px solid rgba(141, 165, 186, 0.2);
  border-radius: 6px;
  color: var(--text);
  background: rgba(7, 17, 31, 0.88);
  font: inherit;
  font-size: 12px;
  outline: none;
  padding: 0 10px;
}

.api-key-switcher input:focus {
  border-color: rgba(56, 213, 230, 0.6);
  box-shadow: 0 0 0 3px rgba(56, 213, 230, 0.12);
}

.identity-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(56, 213, 230, 0.34);
  border-radius: 999px;
  color: #bdf8ff;
  background: rgba(56, 213, 230, 0.1);
  font-size: 12px;
}

.identity-badge.user-mode {
  border-color: rgba(31, 191, 165, 0.36);
  color: #bff9eb;
  background: rgba(31, 191, 165, 0.1);
}

.tabs {
  display: inline-flex;
  padding: 4px;
  border: 1px solid rgba(141, 165, 186, 0.22);
  border-radius: 8px;
  background: rgba(4, 11, 20, 0.62);
}

.tab-button {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.tab-button[hidden],
#adminTabButton[hidden],
#settingsTabButton[hidden],
#adminView[hidden],
#settingsView[hidden] {
  display: none !important;
}

.tab-button.active {
  color: #03131a;
  background: linear-gradient(135deg, var(--cyan), var(--teal));
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 4.6vw, 58px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.subtitle {
  max-width: 640px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 16px;
}

.refresh-button {
  min-width: 150px;
  min-height: 44px;
  border: 1px solid rgba(56, 213, 230, 0.45);
  border-radius: 6px;
  color: #03131a;
  background: linear-gradient(135deg, var(--cyan), var(--teal));
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(31, 191, 165, 0.2);
}

.secondary-button,
.inline-action-button {
  min-height: 34px;
  border: 1px solid rgba(56, 213, 230, 0.34);
  border-radius: 6px;
  color: var(--cyan);
  background: rgba(56, 213, 230, 0.08);
  font: inherit;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.secondary-button {
  padding: 0 12px;
}

.inline-action-button {
  min-height: 30px;
  padding: 0 10px;
}

.secondary-button:disabled,
.inline-action-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.refresh-button:disabled {
  cursor: default;
  filter: grayscale(0.45);
  opacity: 0.7;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.metric-card,
.table-panel,
.detail-panel {
  border: 1px solid rgba(141, 165, 186, 0.2);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(15, 33, 54, 0.86), rgba(11, 24, 41, 0.78));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.metric-card {
  min-height: 100px;
  padding: 18px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 16px;
  font-size: 24px;
  line-height: 1;
}

.journal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
  margin-top: 18px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
  align-items: start;
}

.table-panel,
.detail-panel {
  overflow: hidden;
}

.panel-header,
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 31, 0.42);
}

#statusText,
#detailStatus {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1.4fr;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 31, 0.24);
}

.admin-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 31, 0.24);
}

.admin-form.stacked {
  grid-template-columns: 1fr;
  padding: 0;
  border-bottom: 0;
  background: transparent;
}

.admin-form label {
  display: grid;
  gap: 7px;
}

.filters label {
  display: grid;
  gap: 7px;
}

.filters span,
.admin-form span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid rgba(141, 165, 186, 0.24);
  border-radius: 6px;
  color: var(--text);
  background: rgba(4, 11, 20, 0.74);
  font: inherit;
  font-size: 13px;
  outline: none;
}

select {
  min-height: 38px;
  padding: 0 10px;
}

input {
  min-height: 38px;
  padding: 0 12px;
}

textarea {
  min-height: 82px;
  padding: 10px 12px;
  resize: vertical;
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(56, 213, 230, 0.72);
  box-shadow: 0 0 0 3px rgba(56, 213, 230, 0.12);
}

.table-wrap {
  overflow-x: auto;
}

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

.admin-table {
  min-width: 980px;
}

.api-key-table {
  min-width: 720px;
}

.account-table {
  min-width: 900px;
}

.user-trades-table {
  min-width: 980px;
}

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

.compact-metric {
  min-height: 82px;
  padding: 13px;
}

.compact-metric strong {
  margin-top: 12px;
  font-size: 18px;
}

.admin-mini-filters {
  margin-bottom: 12px;
  max-width: 300px;
}

.admin-mini-filters label {
  display: grid;
  gap: 7px;
}

.admin-mini-filters span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-trade-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(141, 165, 186, 0.16);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(7, 17, 31, 0.28);
}

.empty-table-row td {
  padding: 24px 14px;
  color: var(--muted);
  text-align: center;
  background: rgba(7, 17, 31, 0.22);
}

.onboarding-section {
  border-color: rgba(56, 213, 230, 0.22);
  background:
    linear-gradient(135deg, rgba(56, 213, 230, 0.08), transparent 38%),
    rgba(8, 20, 35, 0.72);
}

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

.onboarding-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: onboarding-step;
}

.onboarding-steps li {
  counter-increment: onboarding-step;
  display: grid;
  gap: 3px;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid rgba(56, 213, 230, 0.18);
  border-radius: 7px;
  color: #c8f7fb;
  background: rgba(56, 213, 230, 0.06);
  font-size: 11px;
  font-weight: 850;
}

.onboarding-steps li::before {
  content: none;
}

.onboarding-steps li span {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.onboarding-generate-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(141, 165, 186, 0.16);
  border-radius: 8px;
  background: rgba(4, 11, 20, 0.38);
}

.onboarding-field,
.onboarding-setup {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(141, 165, 186, 0.16);
  border-radius: 8px;
  background: rgba(4, 11, 20, 0.48);
}

.onboarding-field span,
.onboarding-setup span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.onboarding-field code,
.onboarding-setup pre {
  margin: 0;
  overflow-wrap: anywhere;
  color: #dffbff;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.onboarding-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.helper-text {
  margin: 0;
  color: #9fb5c9;
  font-size: 12px;
  line-height: 1.5;
}

.onboarding-warning {
  margin-bottom: 0;
}

.settings-panel {
  display: grid;
  gap: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(141, 165, 186, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(56, 213, 230, 0.08), transparent 42%),
    rgba(8, 20, 35, 0.72);
  box-shadow: var(--shadow);
}

.settings-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-card code {
  overflow-wrap: anywhere;
  color: #dffbff;
  font-size: 13px;
  line-height: 1.5;
}

.settings-card p {
  color: #9fb5c9;
  font-size: 12px;
  line-height: 1.5;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.setup-steps-card {
  grid-column: 1 / -1;
}

.portal-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: #dcecff;
  font-size: 13px;
  line-height: 1.5;
}

.selected-user-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid rgba(141, 165, 186, 0.18);
  border-radius: 999px;
  background: rgba(5, 14, 25, 0.62);
  color: #c9d8e6;
  font-size: 12px;
  font-weight: 700;
}

.meta-chip .review-badge {
  margin: -2px -5px;
}

.compact-wrap {
  border: 1px solid rgba(141, 165, 186, 0.14);
  border-radius: 8px;
}

.analytics-panel {
  display: grid;
  gap: 18px;
}

.analytics-card-grid {
  margin: 0;
}

.analytics-filters {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.analytics-filters input {
  min-height: 42px;
  border: 1px solid rgba(141, 165, 186, 0.2);
  border-radius: 6px;
  color: var(--text);
  background: rgba(7, 17, 31, 0.88);
  font: inherit;
  font-size: 13px;
  outline: none;
  padding: 0 10px;
}

.analytics-filters input:focus {
  border-color: rgba(56, 213, 230, 0.6);
  box-shadow: 0 0 0 3px rgba(56, 213, 230, 0.12);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.chart-card {
  min-height: unset;
  padding: 16px;
  border: 1px solid rgba(141, 165, 186, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(56, 213, 230, 0.06), transparent 40%),
    rgba(8, 20, 35, 0.7);
  box-shadow: var(--shadow);
}

.chart-card-wide {
  grid-column: 1 / -1;
}

.chart-box {
  position: relative;
  height: 280px;
  max-height: 320px;
  overflow: hidden;
}

.chart-box.large {
  height: 320px;
}

.chart-box.compact {
  height: 260px;
}

.chart-box canvas {
  width: 100%;
  height: 100%;
  max-height: 100%;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  display: block;
}

.chart-message {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 18px;
  border: 1px dashed rgba(141, 165, 186, 0.22);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(4, 11, 20, 0.42);
  font-size: 13px;
  text-align: center;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(29, 52, 77, 0.72);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: rgba(7, 17, 31, 0.36);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  color: #d7e7f5;
  font-size: 13px;
}

tbody tr {
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease;
}

tbody tr:hover,
tbody tr:focus {
  background: rgba(56, 213, 230, 0.075);
  outline: none;
}

.selected-row {
  background: rgba(56, 213, 230, 0.13);
  box-shadow: inset 3px 0 0 var(--cyan);
}

.admin-table .current-user-row,
.admin-table .selected-row {
  background:
    linear-gradient(90deg, rgba(56, 213, 230, 0.18), rgba(56, 213, 230, 0.045)),
    rgba(7, 17, 31, 0.72);
  box-shadow:
    inset 3px 0 0 var(--cyan),
    inset 0 0 0 1px rgba(56, 213, 230, 0.14);
}

.admin-table .current-user-row td,
.admin-table .selected-row td {
  border-bottom-color: rgba(56, 213, 230, 0.18);
}

.positive {
  color: var(--green) !important;
}

.negative {
  color: var(--red) !important;
}

.buy {
  color: var(--teal);
  font-weight: 800;
}

.sell {
  color: var(--gold);
  font-weight: 800;
}

.review-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(141, 165, 186, 0.24);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.review-badge.reviewed {
  border-color: rgba(55, 214, 122, 0.38);
  color: var(--green);
  background: rgba(55, 214, 122, 0.1);
}

.review-badge.needs-review {
  border-color: rgba(232, 197, 108, 0.36);
  color: var(--gold);
  background: rgba(232, 197, 108, 0.1);
}

.empty-state,
.detail-empty {
  margin: 20px;
  padding: 34px 18px;
  border: 1px dashed rgba(141, 165, 186, 0.32);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: rgba(7, 17, 31, 0.36);
}

.detail-panel {
  position: sticky;
  top: 16px;
}

.admin-detail-panel {
  position: sticky;
  top: 16px;
}

.detail-content {
  padding: 16px;
}

.detail-item {
  min-height: 70px;
  padding: 12px;
  border: 1px solid rgba(141, 165, 186, 0.16);
  border-radius: 8px;
  background: rgba(7, 17, 31, 0.42);
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-item strong {
  display: block;
  margin-top: 10px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
}

.raw-payload {
  margin-top: 14px;
  border: 1px solid rgba(141, 165, 186, 0.16);
  border-radius: 8px;
  background: rgba(7, 17, 31, 0.42);
}

.raw-payload summary {
  padding: 13px 14px;
  color: var(--cyan);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.raw-payload pre {
  max-height: 280px;
  margin: 0;
  padding: 0 14px 14px;
  overflow: auto;
  color: #cfe0ed;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.review-form {
  display: grid;
  gap: 12px;
}

.detail-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(141, 165, 186, 0.16);
  border-radius: 8px;
  background: rgba(7, 17, 31, 0.42);
}

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

.review-form-header,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.review-form h3,
.section-heading h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0;
}

#reviewSaveStatus {
  min-height: 18px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.review-form label {
  display: grid;
  gap: 7px;
}

.review-form label span,
.reviewed-check span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reviewed-check {
  display: inline-flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(56, 213, 230, 0.25);
  border-radius: 999px;
  background: rgba(56, 213, 230, 0.08);
  cursor: pointer;
  white-space: nowrap;
}

.reviewed-check input {
  width: 14px;
  min-height: 14px;
  accent-color: var(--cyan);
}

.save-review-button {
  min-height: 40px;
  border: 1px solid rgba(56, 213, 230, 0.45);
  border-radius: 6px;
  color: #03131a;
  background: linear-gradient(135deg, var(--cyan), var(--teal));
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.save-review-button:disabled {
  cursor: default;
  opacity: 0.72;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

.field-warning {
  color: var(--gold);
  font-size: 12px;
  line-height: 1.35;
}

.evidence-empty {
  padding: 22px 14px;
  border: 1px dashed rgba(141, 165, 186, 0.32);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: rgba(4, 11, 20, 0.36);
  font-size: 13px;
}

.screenshot-preview-card {
  overflow: hidden;
  border: 1px solid rgba(56, 213, 230, 0.24);
  border-radius: 8px;
  background: rgba(4, 11, 20, 0.58);
}

.screenshot-preview-card img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
}

.open-screenshot-button {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(56, 213, 230, 0.38);
  border-radius: 999px;
  color: var(--cyan);
  background: rgba(56, 213, 230, 0.08);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.generated-key-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(56, 213, 230, 0.3);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(56, 213, 230, 0.1), rgba(4, 11, 20, 0.42)),
    rgba(4, 11, 20, 0.72);
}

.generated-key-box p {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.generated-key-box code {
  display: block;
  padding: 12px;
  overflow-wrap: anywhere;
  border: 1px solid rgba(141, 165, 186, 0.18);
  border-radius: 6px;
  color: #dffbff;
  background: rgba(0, 0, 0, 0.26);
  font-size: 12px;
  line-height: 1.45;
}

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

  .journal-layout {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel,
  .admin-detail-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  .hero {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions {
    justify-items: stretch;
  }

  .api-key-switcher {
    justify-content: stretch;
  }

  .api-key-switcher label,
  .api-key-switcher button,
  .identity-badge {
    width: 100%;
  }

  .tabs {
    width: 100%;
  }

  .tab-button {
    flex: 1;
  }

  .refresh-button {
    width: 100%;
  }

  .metrics,
  .filters,
  .admin-form,
  .admin-summary-grid,
  .analytics-filters,
  .onboarding-grid,
  .onboarding-generate-form,
  .onboarding-steps,
  .settings-grid,
  .admin-trade-detail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .chart-box,
  .chart-box.large,
  .chart-box.compact {
    height: 260px;
    max-height: 260px;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding-top: 18px;
  }

  .metrics,
  .filters,
  .admin-form,
  .admin-summary-grid,
  .analytics-filters,
  .onboarding-grid,
  .admin-trade-detail,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 92px;
  }
}

/* B3.9 SaaS polish layer */
:root {
  --bg: #060b12;
  --panel: rgba(10, 18, 30, 0.78);
  --panel-strong: rgba(12, 22, 36, 0.92);
  --line: rgba(112, 142, 171, 0.2);
  --line-strong: rgba(56, 213, 230, 0.24);
  --text: #eaf4ff;
  --muted: #8b9db1;
  --cyan: #39d9e8;
  --teal: #20bea7;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.34);
  --soft-glow: 0 0 0 1px rgba(56, 213, 230, 0.05), 0 18px 46px rgba(0, 0, 0, 0.28);
}

body {
  background:
    linear-gradient(180deg, rgba(56, 213, 230, 0.05), transparent 260px),
    linear-gradient(135deg, #04070c 0%, #07111f 52%, #08131f 100%);
}

.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 18px;
  width: min(1560px, calc(100% - 28px));
  min-height: 100vh;
  padding: 14px 0 26px;
}

.sidebar {
  position: sticky;
  top: 14px;
  display: grid;
  align-self: start;
  min-height: calc(100vh - 28px);
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  padding: 16px;
  border: 1px solid rgba(141, 165, 186, 0.16);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(16, 30, 48, 0.86), rgba(7, 14, 24, 0.78)),
    rgba(5, 11, 19, 0.86);
  box-shadow: var(--soft-glow);
  backdrop-filter: blur(18px);
}

.brand-block {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(56, 213, 230, 0.34);
  border-radius: 9px;
  color: #dffcff;
  background:
    linear-gradient(135deg, rgba(56, 213, 230, 0.18), rgba(31, 191, 165, 0.08)),
    rgba(6, 17, 28, 0.82);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.brand-block .eyebrow {
  margin-bottom: 4px;
  font-size: 9px;
  letter-spacing: 0.12em;
}

.brand-block strong {
  display: block;
  overflow: hidden;
  color: #f2fbff;
  font-size: 14px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(141, 165, 186, 0.14);
  color: var(--muted);
  font-size: 11px;
}

.sidebar-footer strong {
  color: #c9d8e6;
  font-size: 11px;
}

.workspace {
  min-width: 0;
}

.hero {
  align-items: center;
  min-height: 82px;
  margin-bottom: 12px;
  padding: 16px 18px;
  border: 1px solid rgba(141, 165, 186, 0.14);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(56, 213, 230, 0.07), transparent 42%),
    rgba(7, 15, 25, 0.68);
  box-shadow: var(--soft-glow);
}

.hero .eyebrow {
  margin-bottom: 6px;
  font-size: 10px;
}

h1 {
  font-size: clamp(24px, 2.4vw, 34px);
  line-height: 1.08;
}

.subtitle {
  max-width: 760px;
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.45;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.topbar {
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid rgba(141, 165, 186, 0.14);
  border-radius: 10px;
  background: rgba(4, 9, 16, 0.56);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18);
}

.api-key-switcher {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: end;
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
}

.api-key-switcher label {
  min-width: 0;
}

.api-key-switcher input,
select,
input,
textarea {
  border-color: rgba(141, 165, 186, 0.18);
  background: rgba(3, 9, 17, 0.78);
}

.tabs {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
}

.tab-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #9fb1c4;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.tab-button:hover {
  border-color: rgba(141, 165, 186, 0.14);
  color: #d9e9f8;
  background: rgba(141, 165, 186, 0.06);
}

.tab-button.active {
  border-color: rgba(56, 213, 230, 0.28);
  color: #dffcff;
  background:
    linear-gradient(90deg, rgba(56, 213, 230, 0.16), rgba(56, 213, 230, 0.04)),
    rgba(7, 17, 31, 0.7);
  box-shadow: inset 3px 0 0 var(--cyan);
}

.tab-icon {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(141, 165, 186, 0.18);
  border-radius: 6px;
  color: #c8d8e7;
  background: rgba(2, 8, 15, 0.44);
  font-size: 11px;
  font-weight: 900;
}

.tab-button.active .tab-icon {
  border-color: rgba(56, 213, 230, 0.34);
  color: #021018;
  background: linear-gradient(135deg, var(--cyan), var(--teal));
}

.refresh-button {
  min-width: 128px;
  min-height: 36px;
  box-shadow: 0 12px 22px rgba(31, 191, 165, 0.12);
}

.identity-badge {
  min-height: 34px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metrics {
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
}

.metric-card,
.table-panel,
.detail-panel,
.chart-card {
  border-color: rgba(141, 165, 186, 0.14);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(17, 31, 49, 0.82), rgba(8, 17, 29, 0.76)),
    rgba(7, 15, 25, 0.74);
  box-shadow: var(--soft-glow);
}

.metric-card {
  min-height: 82px;
  padding: 14px;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.metric-card:hover,
.chart-card:hover,
.table-panel:hover,
.detail-panel:hover {
  border-color: rgba(56, 213, 230, 0.22);
}

.metric-card strong {
  margin-top: 13px;
  font-size: 21px;
}

.metric-card span,
.filters span,
.admin-form span,
.detail-item span,
.review-form label span,
.reviewed-check span,
.admin-mini-filters span,
.onboarding-field span,
.onboarding-setup span {
  letter-spacing: 0.07em;
}

.journal-layout {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
  gap: 14px;
  margin-top: 14px;
}

.admin-layout {
  grid-template-columns: minmax(0, 1fr) minmax(380px, 470px);
  gap: 14px;
}

.panel-header,
.detail-header {
  padding: 14px 16px;
  background: rgba(4, 11, 20, 0.34);
}

h2 {
  font-size: 16px;
}

#statusText,
#detailStatus,
#analyticsStatusText,
#adminStatusText,
#apiKeyStatusText,
#accountStatusText,
#userTradesStatusText,
#userSummaryStatusText,
.section-heading p {
  color: var(--muted);
  font-size: 12px;
}

.filters,
.admin-form {
  gap: 10px;
  padding: 12px 16px;
  background: rgba(4, 11, 20, 0.26);
}

.filters,
.analytics-filters {
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
}

.filters .search-field {
  min-width: min(220px, 100%);
}

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

textarea {
  min-height: 74px;
}

.table-wrap {
  scrollbar-color: rgba(56, 213, 230, 0.32) rgba(3, 9, 17, 0.7);
}

table {
  min-width: 1060px;
}

th,
td {
  padding: 9px 12px;
  border-bottom-color: rgba(40, 64, 88, 0.56);
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(6, 14, 24, 0.96);
  backdrop-filter: blur(12px);
}

td {
  font-size: 12px;
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.012);
}

tbody tr:hover,
tbody tr:focus {
  background: rgba(56, 213, 230, 0.065);
}

.review-badge,
.meta-chip {
  border-radius: 7px;
  letter-spacing: 0.03em;
}

.empty-state,
.detail-empty,
.evidence-empty {
  position: relative;
  margin: 16px;
  padding: 34px 18px;
  border-color: rgba(141, 165, 186, 0.22);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(56, 213, 230, 0.04), transparent 46%),
    rgba(4, 11, 20, 0.34);
  color: #9cadbf;
}

.empty-state::before,
.detail-empty::before,
.evidence-empty::before {
  content: "";
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  border: 1px solid rgba(56, 213, 230, 0.2);
  border-radius: 9px;
  background:
    linear-gradient(135deg, rgba(56, 213, 230, 0.13), transparent),
    rgba(7, 17, 31, 0.72);
}

.detail-panel,
.admin-detail-panel {
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow: auto;
}

.admin-detail-panel .detail-header {
  padding: 13px 15px;
}

.admin-detail-panel .detail-header h2 {
  font-size: 15px;
  line-height: 1.2;
}

#selectedUserStatus {
  max-width: 38rem;
  line-height: 1.4;
}

#adminDetailEmpty {
  display: flex;
  min-height: 172px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 14px;
  padding: 24px 18px;
  line-height: 1.5;
}

#adminDetailEmpty[hidden],
.detail-content[hidden],
.generated-key-box[hidden],
.selected-user-meta[hidden] {
  display: none !important;
}

#adminDetailEmpty::before {
  width: 42px;
  height: 42px;
  margin-bottom: 13px;
  border-radius: 13px;
  background:
    linear-gradient(180deg, rgba(56, 213, 230, 0.12), rgba(31, 191, 165, 0.04)),
    rgba(4, 11, 20, 0.72);
  box-shadow:
    inset 0 0 0 1px rgba(56, 213, 230, 0.2),
    0 12px 28px rgba(0, 0, 0, 0.2);
}

#adminDetailEmpty::after {
  content: "CRM client profile";
  display: inline-flex;
  margin-top: 12px;
  padding: 5px 9px;
  border: 1px solid rgba(56, 213, 230, 0.18);
  border-radius: 7px;
  color: #bceff6;
  background: rgba(56, 213, 230, 0.06);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-content {
  padding: 14px;
}

.detail-section,
.detail-item,
.raw-payload,
.generated-key-box,
.onboarding-field,
.onboarding-setup,
.compact-wrap,
.admin-trade-detail {
  border-radius: 9px;
  border-color: rgba(141, 165, 186, 0.14);
  background: rgba(5, 13, 23, 0.5);
}

.chart-grid {
  gap: 12px;
}

.chart-card {
  padding: 14px;
}

.chart-box.large {
  height: 300px;
}

.chart-box {
  height: 260px;
  max-height: 300px;
}

.chart-box.compact {
  height: 240px;
}

.analytics-panel {
  gap: 14px;
}

.admin-summary-grid {
  gap: 8px;
}

.user-overview-section {
  border-color: rgba(56, 213, 230, 0.2);
  background:
    linear-gradient(135deg, rgba(56, 213, 230, 0.075), transparent 42%),
    rgba(5, 13, 23, 0.58);
}

.overview-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.overview-chip {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid rgba(141, 165, 186, 0.18);
  border-radius: 7px;
  color: #c9d8e6;
  background: rgba(5, 14, 25, 0.62);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.overview-chip.success {
  border-color: rgba(55, 214, 122, 0.34);
  color: var(--green);
  background: rgba(55, 214, 122, 0.08);
}

.overview-chip.warning {
  border-color: rgba(232, 197, 108, 0.34);
  color: var(--gold);
  background: rgba(232, 197, 108, 0.08);
}

.overview-chip.info {
  border-color: rgba(56, 213, 230, 0.34);
  color: #bdf8ff;
  background: rgba(56, 213, 230, 0.08);
}

.user-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.overview-item {
  min-height: 64px;
  padding: 10px;
  border: 1px solid rgba(141, 165, 186, 0.14);
  border-radius: 9px;
  background: rgba(4, 11, 20, 0.42);
}

.overview-item span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.overview-item strong {
  display: block;
  margin-top: 9px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
}

.overview-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.overview-actions .secondary-button {
  padding-inline: 8px;
}

.selected-user-meta {
  gap: 6px;
  margin-top: 9px;
}

.selected-user-meta .meta-chip {
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 11px;
}

.onboarding-section {
  background:
    linear-gradient(135deg, rgba(56, 213, 230, 0.07), transparent 44%),
    rgba(5, 13, 23, 0.56);
}

.product-footer {
  padding: 16px 4px 2px;
  color: rgba(141, 165, 186, 0.62);
  font-size: 11px;
  text-align: right;
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .sidebar {
    padding: 12px;
  }

  .brand-block {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .brand-block .eyebrow,
  .brand-block strong,
  .sidebar-footer span {
    display: none;
  }

  .tabs {
    justify-items: stretch;
  }

  .tab-button {
    justify-content: center;
    padding: 0;
  }

  .tab-button > span:not(.tab-icon) {
    display: none;
  }

  .sidebar-footer {
    justify-content: center;
  }

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

  .journal-layout,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel,
  .admin-detail-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
    width: min(100% - 18px, 1560px);
    padding-top: 9px;
  }

  .sidebar {
    position: sticky;
    top: 8px;
    z-index: 10;
    min-height: auto;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto;
    align-items: center;
    padding: 10px;
  }

  .brand-block {
    grid-template-columns: 36px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 10px;
  }

  .tabs {
    display: flex;
    min-width: 0;
    overflow-x: auto;
  }

  .tab-button {
    min-width: 40px;
    flex: 0 0 auto;
  }

  .sidebar-footer {
    display: none;
  }

  .hero {
    align-items: stretch;
    flex-direction: column;
    min-height: auto;
    padding: 14px;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .topbar {
    padding: 10px;
  }

  .api-key-switcher {
    grid-template-columns: 1fr;
  }

  .api-key-switcher button,
  .identity-badge,
  .refresh-button {
    width: 100%;
  }

  .metrics,
  .filters,
  .admin-form,
  .admin-summary-grid,
  .analytics-filters,
  .onboarding-grid,
  .onboarding-generate-form,
  .onboarding-steps,
  .settings-grid,
  .admin-trade-detail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .chart-box,
  .chart-box.large,
  .chart-box.compact {
    height: 240px;
    max-height: 260px;
  }
}

@media (max-width: 560px) {
  .hero-actions,
  .onboarding-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .metrics,
  .filters,
  .admin-form,
  .admin-summary-grid,
  .analytics-filters,
  .onboarding-grid,
  .onboarding-generate-form,
  .onboarding-steps,
  .settings-grid,
  .admin-trade-detail,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 74px;
  }

  .metric-card strong {
    font-size: 20px;
  }

  .user-overview-grid,
  .overview-actions {
    grid-template-columns: 1fr;
  }
}
