* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.market-spread-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-color, #d7dde5);
  border-left: 0.4rem solid #64748b;
  border-radius: 0.75rem;
  background: var(--surface-color, #fff);
}

.market-spread-card > div:first-child,
.market-spread-values {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.market-spread-values {
  flex-wrap: wrap;
}

.market-spread-values small {
  display: block;
  color: #64748b;
}

.spread-heading {
  font-weight: 700;
}

.spread-positive { border-left-color: #dc2626; }
.spread-positive [data-field="label"],
.spread-positive [data-field="spread"] { color: #dc2626; }
.spread-negative { border-left-color: #16a34a; }
.spread-negative [data-field="label"],
.spread-negative [data-field="spread"] { color: #15803d; }
.spread-flat { border-left-color: #2563eb; }
.spread-waiting { border-left-color: #64748b; }

@media (max-width: 720px) {
  .market-spread-card > div:first-child,
  .market-spread-values {
    align-items: flex-start;
    flex-direction: column;
  }
}

:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --surface-subtle: #f8fafc;
  --text: #111827;
  --text-muted: #526070;
  --text-soft: #718096;
  --primary: #0f3d5e;
  --primary-strong: #092f49;
  --primary-soft: #e6f0f7;
  --accent: #12805c;
  --accent-soft: #dcfce7;
  --warning: #b7791f;
  --warning-soft: #fff7d6;
  --danger: #b42318;
  --danger-soft: #fff1f2;
  --border: #d9e2ec;
  --border-strong: #c4d0dd;
  --ring: #2f80ed;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 6%);
  --shadow-md: 0 12px 28px rgb(15 23 42 / 9%);
  --radius: 8px;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef4f9 0, var(--bg) 260px),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, calc(100vw - 32px));
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.auth-panel h1,
.topbar h1 {
  margin: 0;
  color: var(--text);
  font-size: 24px;
  letter-spacing: 0;
  line-height: 1.2;
}

.auth-panel form,
.query-form {
  display: grid;
  gap: 14px;
}

.auth-panel form {
  margin-top: 22px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.field-help {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

select {
  width: 100%;
  min-height: 42px;
  padding: 9px 36px 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input::placeholder {
  color: #94a3b8;
}

input:focus,
select:focus,
button:focus-visible,
.button-link:focus-visible,
summary:focus-visible,
.company-tags a:focus-visible {
  outline: 3px solid rgb(47 128 237 / 24%);
  outline-offset: 2px;
  border-color: var(--ring);
}

button {
  min-height: 42px;
  padding: 9px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

button:hover {
  background: var(--primary-strong);
  box-shadow: 0 7px 18px rgb(15 61 94 / 18%);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  background: #334155;
}

button.danger {
  background: var(--danger);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.button-link:hover {
  background: var(--primary-strong);
  box-shadow: 0 7px 18px rgb(15 61 94 / 18%);
  transform: translateY(-1px);
}

.button-link.active {
  background: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgb(255 255 255 / 92%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 12px rgb(15 23 42 / 5%);
  backdrop-filter: blur(14px);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-toggle {
  display: none;
}

.top-actions form {
  margin: 0;
}

.message {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-weight: 700;
}

.message.error {
  background: var(--danger-soft);
  border: 1px solid #fecdd3;
  color: var(--danger);
}

.message.info {
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  color: var(--primary);
}

.layout {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 56px;
}

.query-form {
  grid-template-columns: minmax(220px, 420px) auto;
  align-items: end;
  margin-bottom: 18px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.signal-query-form {
  grid-template-columns: minmax(140px, 1fr) repeat(2, minmax(150px, 1fr)) minmax(130px, 160px) auto;
}

.sort-details {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-subtle);
}

.sort-details summary {
  cursor: pointer;
  font-weight: 700;
}

.sort-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.sort-pair {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(70px, 90px);
  gap: 8px;
}

.table-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.section-title {
  margin: 18px 0 12px;
  color: var(--text);
  font-size: 20px;
  letter-spacing: 0;
}

.admin-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.admin-panel .section-title {
  margin-top: 0;
}

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

.inline-field {
  min-width: 180px;
}

.status-text {
  margin: 0;
  color: var(--text-muted);
  font-weight: 700;
}

.progress-panel {
  display: grid;
  gap: 16px;
}

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

.status-grid div {
  min-width: 0;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.status-grid dt {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.status-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.monitor-layout {
  display: grid;
  gap: 16px;
}

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

.monitor-warning {
  margin: 0;
  padding: 12px 14px;
  color: var(--danger-text, #991b1b);
  background: var(--danger-bg, #fee2e2);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  font-weight: 700;
}

.monitor-filters {
  grid-template-columns: repeat(2, minmax(180px, 320px));
}

.monitor-events {
  min-height: 280px;
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log-output {
  min-height: 320px;
  max-height: 560px;
  margin: 0;
  overflow: auto;
  padding: 14px;
  border: 1px solid #1f2933;
  border-radius: var(--radius);
  background: #111827;
  color: #e5e7eb;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  scrollbar-color: #94a3b8 #e2e8f0;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #eef4f8;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover td,
tbody tr:hover th[scope="row"] {
  background: #f8fbfd;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td:first-child,
td a,
th[scope="row"] a {
  font-weight: 800;
}

td a,
th[scope="row"] a {
  color: var(--primary);
  text-underline-offset: 3px;
}

tr.price-alert td,
tr.price-alert th[scope="row"] {
  background: #fff7d6;
}

tr.price-alert td:nth-child(3),
tr.price-alert td:nth-child(6) {
  color: #8a5600;
  font-weight: 800;
}

.subscribed-stock-table tr.below-lower-band td,
.subscribed-stock-table tr.below-lower-band th[scope="row"] {
  background: #fde8e8;
}

.subscribed-stock-table tr.below-lower-band th[scope="row"] {
  box-shadow: inset 4px 0 0 #c62828;
}

.subscribed-stock-table tr.near-lower-band td,
.subscribed-stock-table tr.near-lower-band th[scope="row"] {
  background: #fff7d6;
}

.subscribed-stock-table tr.near-lower-band th[scope="row"] {
  box-shadow: inset 4px 0 0 #b26a00;
}

.stock-code-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stock-code-link {
  display: inline-flex;
  min-width: 0;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  padding: 5px 4px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--primary);
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
}

.stock-code-link:hover,
.stock-code-link:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.stock-code-link.below-lower-band {
  border-color: #c62828;
  background: #dc2626;
  color: #ffffff;
}

.stock-code-link.near-lower-band {
  border-color: #d9a400;
  background: #facc15;
  color: #4a3500;
}

.subscribed-stock-table tr[id] {
  scroll-margin-top: 16px;
}

.subscribed-stock-table tr:target {
  outline: 3px solid var(--ring);
  outline-offset: -3px;
}

.subscribed-stock-table tr.below-lower-band td[data-stock-field="latest-price"],
.subscribed-stock-table tr.near-lower-band td[data-stock-field="latest-price"] {
  font-weight: 800;
}

.subscribed-stock-wrap {
  border-color: #d9e3ec;
}

.subscribed-stock-table {
  min-width: 1450px;
}

.subscribed-stock-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  letter-spacing: 0.01em;
}

.subscribed-stock-table tbody tr:nth-child(even):not(.price-alert):not(.below-lower-band):not(.near-lower-band) td,
.subscribed-stock-table tbody tr:nth-child(even):not(.price-alert):not(.below-lower-band):not(.near-lower-band) th[scope="row"] {
  background: #fbfdff;
}

.subscribed-stock-table tbody td:nth-child(n + 3):nth-child(-n + 6) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.profile-cell {
  min-width: 150px;
  max-width: 190px;
  white-space: normal;
}

.poc-trend-cell {
  min-width: 210px;
  white-space: normal;
}

.poc-trend-content {
  display: grid;
  gap: 3px;
  font-size: 12px;
  line-height: 1.4;
}

.poc-trend-alignment {
  width: fit-content;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--text);
}

.poc-trend-alignment.poc-trend-sync-up {
  background: #fde8e8;
  color: #b42318;
  font-weight: 800;
}

.poc-trend-alignment.poc-trend-single-up {
  padding-right: 0;
  padding-left: 0;
  background: transparent;
}

.poc-trend-line,
.poc-trend-history {
  display: block;
  font-variant-numeric: tabular-nums;
}

.poc-trend-history {
  color: var(--text-muted);
}

.profile-link {
  display: block;
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
}

.profile-link:hover .profile-shape {
  color: var(--primary);
}

.profile-content {
  display: grid;
  gap: 2px;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

.profile-shape {
  width: fit-content;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eaf2f8;
  color: var(--text);
  font-size: 13px;
}

.profile-line {
  display: block;
  font-variant-numeric: tabular-nums;
}

.profile-lvn,
.profile-updated {
  color: var(--text-muted);
}

.profile-partial {
  color: #8a5600;
  font-weight: 800;
}

.profile-waiting {
  color: var(--text-muted);
  font-weight: 700;
}

.profile-method-note {
  margin: -4px 0 14px;
  color: var(--text-muted);
}

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

.profile-detail-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.profile-detail-card h3,
.profile-detail-card h4 {
  margin: 0 0 10px;
}

.profile-detail-card h4 {
  margin-top: 18px;
  font-size: 14px;
}

.profile-position {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}

.profile-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--border);
}

.profile-metrics div {
  min-width: 0;
  padding: 8px;
  background: var(--surface-subtle);
}

.profile-metrics dt {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.profile-metrics dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 800;
}

.profile-lvn-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 12px;
}

.horizontal-profile {
  max-height: 360px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid #1f2933;
  border-radius: var(--radius);
  background: #111827;
  color: #e5e7eb;
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

.market-overview td:first-child small {
  display: block;
  color: var(--muted);
  font-weight: 600;
}

.market-overview tr.price-alert td:nth-child(8) {
  color: #8a5600;
  font-weight: 800;
}

td form {
  margin: 0;
}

.chip-signal-list {
  display: grid;
  gap: 6px;
}

.chip-signal-item {
  display: grid;
  gap: 4px;
  padding: 6px 0;
  border-bottom: 1px solid #edf2f7;
  font-size: 13px;
}

.chip-signal-item:last-child {
  border-bottom: 0;
}

.signal-badge {
  display: inline-flex;
  justify-content: center;
  min-width: 34px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
}

.signal-b {
  background: var(--danger-soft);
  color: var(--danger);
}

.signal-s {
  background: var(--accent-soft);
  color: #166534;
}

.signal-n {
  background: var(--warning-soft);
  color: #8a5600;
}

.pagination {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.chain-role-list {
  display: grid;
  gap: 16px;
}

.chain-role-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.chain-role-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #edf2f7;
}

.chain-role-header h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.chain-role-header p {
  margin: 0;
  color: var(--text-muted);
  font-weight: 700;
}

.chain-code {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

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

.chain-columns h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.industry-select-form {
  margin-top: 14px;
}

.stage-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.stage-overview h3,
.edge-list h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.chain-node {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #e4ebf2;
  border-radius: var(--radius);
  background: var(--surface-subtle);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.chain-node + .chain-node {
  margin-top: 10px;
}

.chain-node:hover {
  border-color: #bfd0de;
  box-shadow: 0 8px 18px rgb(15 23 42 / 7%);
  transform: translateY(-1px);
}

.chain-node-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
}

.chain-node p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.subchain-list {
  display: grid;
  gap: 8px;
}

.subchain-block {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.subchain-block summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.subchain-block .company-tags {
  margin-top: 8px;
}

.edge-list {
  margin-top: 18px;
}

.edge-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(220px, 2fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e4ebf2;
  border-radius: var(--radius);
  background: var(--surface-subtle);
  font-weight: 700;
}

.edge-row + .edge-row {
  margin-top: 8px;
}

.relation-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.relation-value_flow {
  background: #dbeafe;
  color: #1d4ed8;
}

.relation-support_input {
  background: #fef3c7;
  color: #92400e;
}

.company-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.company-tags span,
.company-tags a {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.company-tags a:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.empty-note {
  margin: 0;
  color: var(--text-muted);
  font-weight: 700;
}

.subscription-counter {
  position: fixed;
  left: 16px;
  bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 94%);
  color: var(--text);
  font-weight: 700;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}

@media (max-width: 720px) {
  body {
    font-size: 14px;
  }

  .topbar,
  .query-form,
  .signal-query-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 14px 16px;
  }

  .topbar h1 {
    min-width: 0;
    font-size: 20px;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 44px;
    padding: 9px 14px;
    white-space: nowrap;
    touch-action: manipulation;
  }

  .top-actions {
    display: none;
    grid-column: 1 / -1;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .topbar.menu-open .top-actions {
    display: flex;
    animation: menu-reveal 200ms ease-out;
  }

  .top-actions .button-link,
  .top-actions button {
    min-height: 44px;
  }

  @keyframes menu-reveal {
    from {
      opacity: 0;
      transform: translateY(-6px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .button-link,
  button {
    width: 100%;
  }

  .layout {
    width: min(100% - 24px, 1180px);
    margin-top: 16px;
  }

  .query-form {
    padding: 14px;
  }

  .sort-grid,
  .sort-pair {
    grid-template-columns: 1fr;
  }

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

  th,
  td {
    padding: 10px;
  }

  .admin-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .control-actions {
    justify-content: stretch;
  }

  .control-actions button {
    flex: 1 1 120px;
  }

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

  .monitor-filters {
    grid-template-columns: 1fr;
  }

  .chain-role-header,
  .chain-node-title {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .subscribed-stock-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .subscribed-stock-table {
    min-width: 0;
  }

  .subscribed-stock-table tbody {
    display: grid;
    gap: 12px;
    padding: 10px;
  }

  .subscribed-stock-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .subscribed-stock-table tbody th,
  .subscribed-stock-table tbody td {
    display: grid;
    grid-template-columns: minmax(88px, 0.8fr) minmax(0, 1fr);
    gap: 8px;
    align-content: start;
    border-bottom: 1px solid #edf2f7;
    white-space: normal;
  }

  .subscribed-stock-table tbody th[scope="row"],
  .subscribed-stock-table tbody td:nth-child(2) {
    background: #f4f8fb;
  }

  .subscribed-stock-table tbody td:nth-child(n + 3):nth-child(-n + 6) {
    text-align: left;
  }

  .subscribed-stock-table tbody th::before,
  .subscribed-stock-table tbody td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
  }

  .subscribed-stock-table .profile-cell {
    grid-column: 1 / -1;
    grid-template-columns: minmax(88px, 0.8fr) minmax(0, 1fr);
    width: 100%;
    max-width: none;
  }

  .subscribed-stock-table .poc-trend-cell {
    grid-column: 1 / -1;
    width: 100%;
  }

  .subscribed-stock-table .profile-cell::before {
    content: attr(data-profile-label);
  }

  .profile-detail-grid {
    grid-template-columns: 1fr;
  }

  .stage-overview,
  .edge-row {
    grid-template-columns: 1fr;
  }

  .chain-role-card {
    padding: 14px;
  }

  .chain-code {
    white-space: normal;
  }

  .view-tabs {
    flex-direction: column;
  }

  .subscription-counter {
    position: static;
    margin-top: 14px;
    width: 100%;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .topbar.menu-open .top-actions {
    animation: none;
  }
}
/* Account management */
.user-form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; align-items: end; }
.user-form-grid label, .reset-password-form { display: grid; gap: .4rem; }
.user-actions { display: grid; gap: .6rem; min-width: 15rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; }
.status-badge { display: inline-block; padding: .25rem .6rem; border-radius: 999px; font-weight: 700; }
.status-badge.active { background: #dcfce7; color: #166534; }
.status-badge.inactive { background: #fee2e2; color: #991b1b; }
@media (max-width: 720px) { .user-form-grid { grid-template-columns: 1fr; } .user-actions { min-width: 0; } }

/* Intraday trade calculator */
.trade-calculator-layout { max-width: 1440px; }
.trade-disclaimer { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 14px 18px; border: 1px solid #f0c36a; border-left: 5px solid #b7791f; border-radius: 8px; background: #fff9e8; color: #5c4300; }
.trade-disclaimer span { color: #6b5a2c; }
.trade-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(170px, .45fr) auto; gap: 14px; align-items: end; margin: 24px 0; }
.trade-toolbar label { display: grid; gap: 6px; font-weight: 700; }
.trade-update-status { display: grid; gap: 4px; min-width: 170px; text-align: right; }
.trade-update-status small { color: #64748b; }
.trade-ranking-panel,.trade-detail,.manual-override-panel { margin-top: 24px; padding: 20px; border: 1px solid #d9e1ea; border-radius: 10px; background: #fff; box-shadow: 0 8px 24px rgba(15,23,42,.05); }
.trade-ranking-wrap { max-height: 62vh; overflow: auto; }
.trade-ranking-table { min-width: 1120px; }
.trade-ranking-table thead { position: sticky; top: 0; z-index: 2; background: #edf3f8; }
.trade-ranking-row { cursor: pointer; }
.trade-ranking-row:hover,.trade-ranking-row:focus,.trade-ranking-row.is-selected { background: #eef7ff; outline: none; }
.trade-ranking-row th small,.trade-ranking-row td small { display: block; margin-top: 3px; color: #64748b; font-weight: 400; }
.trade-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 9px; border: 1px solid currentColor; border-radius: 999px; font-weight: 800; white-space: nowrap; }
.confidence-a { color: #067647; background: #ecfdf3; }
.confidence-b { color: #175cd3; background: #eff8ff; }
.confidence-c { color: #93370d; background: #fff6ed; }
.confidence-rejected { color: #b42318; background: #fef3f2; }
.trade-mobile-summary { display: none; }
.trade-detail-heading,.manual-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.trade-detail-heading > div { display: flex; align-items: center; gap: 12px; font-size: 1.1rem; }
.trade-level-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin: 18px 0; }
.trade-level-grid article { display: grid; gap: 5px; padding: 16px; border: 1px solid #dbe4ee; border-radius: 8px; background: #f8fafc; }
.trade-level-grid article > span,.trade-level-grid small { color: #64748b; }
.trade-level-grid strong { font-size: 1.25rem; }
.trade-order-book { margin: 18px 0; padding: 16px; border: 1px solid #dbe4ee; border-radius: 8px; background: #f8fafc; }
.trade-order-book-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.trade-order-book-heading h3 { margin: 0; }
.trade-order-book-heading small { color: #64748b; }
.trade-order-book-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; margin-top: 12px; }
.trade-order-book-side { padding: 12px; border: 1px solid #dbe4ee; border-radius: 7px; background: #fff; }
.trade-order-book-side.ask > strong { color: #b42318; }
.trade-order-book-side.bid > strong { color: #067647; }
.trade-order-book-level { display: grid; grid-template-columns: 44px minmax(70px,1fr) minmax(64px,auto) minmax(100px,auto); gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid #edf1f5; }
.trade-order-book-level:last-child { border-bottom: 0; }
.trade-order-book-level small { color: #175cd3; font-weight: 700; text-align: right; }
.trade-order-book-empty { margin: 10px 0 0; color: #64748b; }
.trade-detail-columns { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.trade-detail-columns article { padding: 16px; border: 1px solid #dbe4ee; border-radius: 8px; }
.trade-detail-columns h3 { margin-top: 0; }
.trade-detail-columns dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; }
.trade-detail-columns dt { color: #64748b; }
.trade-detail-columns dd { margin: 0; font-weight: 700; }
.manual-override-panel { border-style: dashed; border-color: #7c3aed; }
.manual-heading p { margin: 0; color: #64748b; }
.manual-override-grid { display: grid; grid-template-columns: repeat(4,minmax(140px,1fr)); gap: 12px; align-items: end; }
.manual-override-grid label { display: grid; gap: 6px; font-weight: 700; }
.form-error { padding: 10px 12px; border-left: 4px solid #b42318; background: #fef3f2; color: #912018; }

@media (max-width: 760px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .trade-calculator-layout { width: 100%; padding-left: 12px; padding-right: 12px; }
  .trade-disclaimer,.trade-detail-heading,.manual-heading { align-items: flex-start; flex-direction: column; }
  .trade-toolbar { grid-template-columns: 1fr; }
  .trade-update-status { min-width: 0; text-align: left; }
  .trade-ranking-panel,.trade-detail,.manual-override-panel { padding: 14px; }
  .trade-ranking-wrap { max-height: none; overflow: visible; }
  .trade-ranking-table { display: block; min-width: 0; width: 100%; }
  .trade-ranking-table thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); }
  .trade-ranking-table tbody,.trade-ranking-table tr { display: block; width: 100%; }
  .trade-ranking-table tr { margin-bottom: 10px; border: 1px solid #d9e1ea; border-left: 5px solid #2f6f9f; border-radius: 8px; background: #fff; }
  .trade-ranking-table th,.trade-ranking-table td { display: none; }
  .trade-ranking-table .trade-mobile-summary { display: grid; gap: 4px; width: 100%; padding: 14px; border: 0; }
  .trade-ranking-table .trade-mobile-summary span,.trade-ranking-table .trade-mobile-summary small { display: block; }
  .trade-level-grid,.trade-detail-columns,.manual-override-grid { grid-template-columns: 1fr; }
  .trade-order-book-heading { align-items: flex-start; flex-direction: column; }
  .trade-order-book-grid { grid-template-columns: 1fr; }
  .trade-order-book-level { grid-template-columns: 40px minmax(64px,1fr) auto; }
  .trade-order-book-level small { grid-column: 1 / -1; text-align: left; }
}
