:root {
  color-scheme: light;
  --bg: #f3f6f3;
  --surface: #ffffff;
  --surface-muted: #f7f9f7;
  --ink: #17211d;
  --muted: #66736d;
  --line: #dce3df;
  --line-strong: #c6d0ca;
  --sidebar: #18231f;
  --sidebar-muted: #aebbb5;
  --teal: #0f766e;
  --teal-soft: #e5f4f0;
  --blue: #2563eb;
  --blue-soft: #eaf0ff;
  --green: #16845b;
  --green-soft: #e3f4ec;
  --amber: #b45309;
  --amber-soft: #fff3dc;
  --red: #c43131;
  --red-soft: #fdeaea;
  --shadow: 0 1px 2px rgba(23, 33, 29, 0.05);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}

[hidden] {
  display: none !important;
}

.login-screen {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  padding: 26px 32px;
  background: var(--bg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
}

.login-brand strong,
.login-brand small {
  display: block;
}

.login-brand strong {
  font-size: 16px;
}

.login-brand small {
  margin-top: 2px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
}

.login-form {
  align-self: center;
  justify-self: center;
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  padding: 25px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 38px rgba(23, 33, 29, 0.1);
}

.login-form h1 {
  font-size: 21px;
}

.login-form label,
.account-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.login-form input:not([type="checkbox"]),
.account-form input:not([type="checkbox"]) {
  width: 100%;
  height: 41px;
  padding: 0 11px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.remember-row {
  display: flex !important;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 8px !important;
  min-height: 26px;
  color: var(--ink) !important;
  cursor: pointer;
}

.remember-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.form-error {
  margin: 0;
  padding: 9px 10px;
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid #efb9b9;
  border-radius: 5px;
  font-size: 11px;
}

.transport-notice {
  margin: 0;
  padding: 9px 10px;
  color: #46534d;
  background: var(--surface-muted);
  border-left: 3px solid var(--teal);
  font-size: 11px;
}

.login-screen > footer {
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 14px 18px;
  color: #f7fbf8;
  background: var(--sidebar);
  border-right: 1px solid #26352f;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 0 8px 25px;
}

.brand-mark {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #ffffff;
  background: var(--teal);
  border-radius: 7px;
}

.brand-mark svg {
  width: 19px;
  height: 19px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
  line-height: 1.2;
}

.brand small {
  margin-top: 3px;
  color: #83d7ca;
  font-size: 10px;
  font-weight: 700;
}

.primary-nav {
  display: grid;
  gap: 5px;
}

.nav-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  color: var(--sidebar-muted);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.nav-item:hover {
  color: #ffffff;
  background: #202e29;
}

.nav-item.active {
  color: #ffffff;
  background: #263a33;
  border-color: #335047;
}

.nav-item svg {
  width: 17px;
  height: 17px;
}

.nav-item span:not(.nav-count) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  min-width: 23px;
  padding: 1px 6px;
  color: #cae8df;
  text-align: center;
  background: #32463f;
  border-radius: 999px;
  font-size: 11px;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 13px 9px 0;
  border-top: 1px solid #2c3a35;
}

.sidebar-status strong,
.sidebar-status small {
  display: block;
}

.sidebar-status strong {
  font-size: 12px;
}

.sidebar-status small {
  color: var(--sidebar-muted);
  font-size: 11px;
}

.connection-dot,
.status-dot {
  display: block;
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  background: #9aa6a0;
  border-radius: 50%;
}

.connection-dot.online,
.market-chip.open .status-dot {
  background: #35c78f;
  box-shadow: 0 0 0 3px rgba(53, 199, 143, 0.14);
}

.connection-dot.offline,
.market-chip.error .status-dot {
  background: #f16363;
}

.market-chip.closed .status-dot {
  background: #e5a231;
}

.main-content {
  min-width: 0;
  padding: 0 30px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.section-kicker {
  margin: 0 0 3px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.3;
}

h3 {
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.market-copy {
  display: grid;
  line-height: 1.2;
}

.market-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.account-button {
  display: inline-grid;
  grid-template-columns: 18px minmax(0, auto) 14px;
  align-items: center;
  min-width: 0;
  max-width: 190px;
  height: 38px;
  gap: 7px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  cursor: pointer;
}

.account-button:hover {
  background: var(--surface-muted);
}

.account-button svg {
  width: 16px;
  height: 16px;
}

.account-button span {
  overflow: hidden;
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-chip,
.paper-lock,
.mode-badge,
.table-count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 10px;
  color: #46534d;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

#localClock {
  min-width: 72px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.icon-button {
  display: inline-grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-muted);
  border-color: #9daba4;
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.icon-button.compact {
  flex-basis: 28px;
  width: 28px;
  height: 28px;
  border: 0;
}

.rotating svg {
  animation: rotate 0.8s linear infinite;
}

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

.notice {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 10px 12px;
  border: 1px solid;
  border-radius: 6px;
}

.notice[hidden] {
  display: none;
}

.error-notice {
  color: #8e2424;
  background: var(--red-soft);
  border-color: #efb9b9;
}

.error-notice svg {
  width: 18px;
  height: 18px;
}

.dashboard-panel {
  display: none;
  padding-top: 22px;
}

.dashboard-panel.active {
  display: block;
}

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

.metric-card {
  min-width: 0;
  min-height: 117px;
  padding: 17px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.metric-label svg {
  width: 17px;
  height: 17px;
  color: #82908a;
}

.metric-card > strong {
  display: block;
  overflow: hidden;
  margin-bottom: 2px;
  font-size: 23px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card > small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(290px, 0.7fr);
  gap: 12px;
  margin-top: 12px;
}

.surface {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.portfolio-surface,
.control-surface,
.config-surface {
  padding: 19px;
}

.section-heading,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.chart-range {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 206px;
  margin-top: 14px;
}

#equityChart {
  display: block;
  width: 100%;
  height: 206px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

.chart-empty[hidden] {
  display: none;
}

.chart-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding-top: 8px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.chart-footer span:last-child {
  text-align: right;
}

.mode-badge {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #cbd8ff;
  font-size: 10px;
}

.mode-badge.paper-orders {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #f0cf99;
}

.runtime-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 19px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.runtime-status div {
  min-width: 0;
  padding: 12px 8px;
  border-right: 1px solid var(--line);
}

.runtime-status div:first-child {
  padding-left: 0;
}

.runtime-status div:last-child {
  padding-right: 0;
  border-right: 0;
}

.runtime-status span,
.runtime-status strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runtime-status span {
  color: var(--muted);
  font-size: 10px;
}

.runtime-status strong {
  margin-top: 3px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 40px;
  margin-bottom: 9px;
  padding: 3px;
  background: #edf1ee;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.segmented-control button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.segmented-control button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.65);
}

.segmented-control button.selected {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(23, 33, 29, 0.1);
}

.segmented-control svg,
.primary-button svg,
.secondary-button svg,
.danger-button svg {
  width: 16px;
  height: 16px;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  gap: 8px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.primary-button {
  color: #ffffff;
  background: var(--teal);
  border: 1px solid var(--teal);
}

.primary-button:hover:not(:disabled) {
  background: #0c655f;
}

.secondary-button {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
}

.secondary-button:hover:not(:disabled) {
  background: var(--surface-muted);
}

.danger-button {
  color: #a12626;
  background: #ffffff;
  border: 1px solid #e7a9a9;
}

.danger-button:hover:not(:disabled) {
  background: var(--red-soft);
  border-color: #da8585;
}

.full-width {
  width: 100%;
}

.control-divider {
  height: 1px;
  margin: 18px 0 4px;
  background: var(--line);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: 12px;
  cursor: pointer;
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row strong {
  font-size: 12px;
}

.switch-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.switch {
  position: relative;
  flex: 0 0 42px;
  width: 42px;
  height: 24px;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  background: #b7c1bc;
  border-radius: 999px;
  transition: background 160ms ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  content: "";
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(23, 33, 29, 0.25);
  transition: transform 160ms ease;
}

.switch input:checked + .switch-track {
  background: var(--red);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
}

.table-surface {
  margin-top: 12px;
  overflow: hidden;
}

.table-heading {
  padding: 16px 18px 13px;
}

.table-count {
  min-height: 26px;
  padding: 0 9px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 10px;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  height: 43px;
  padding: 0 18px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  height: 35px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 10px;
  font-weight: 800;
}

td {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.numeric {
  text-align: right;
}

.symbol-cell {
  font-weight: 800;
}

.symbol-cell small {
  margin-left: 6px;
  color: var(--teal);
  font-size: 9px;
  font-weight: 800;
}

.side-label,
.status-label {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 750;
  text-transform: capitalize;
}

.side-label.long,
.status-label.filled,
.status-label.accepted {
  color: var(--green);
  background: var(--green-soft);
}

.side-label.short {
  color: var(--red);
  background: var(--red-soft);
}

.status-label {
  color: var(--blue);
  background: var(--blue-soft);
}

.empty-state {
  height: 88px;
  color: var(--muted);
  text-align: center;
}

.panel-heading {
  align-items: center;
  margin-bottom: 16px;
}

.panel-heading h2 {
  font-size: 21px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-actions select {
  height: 40px;
  min-width: 105px;
  padding: 0 30px 0 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 750;
}

.decision-strip {
  display: grid;
  grid-template-columns: minmax(140px, 0.5fr) minmax(260px, 1.5fr) minmax(160px, 0.6fr);
  min-height: 74px;
  margin-bottom: 12px;
  padding: 13px 18px;
}

.decision-strip > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 0 18px;
  border-right: 1px solid var(--line);
}

.decision-strip > div:first-child {
  padding-left: 0;
}

.decision-strip > div:last-child {
  padding-right: 0;
  border-right: 0;
}

.decision-strip span {
  color: var(--muted);
  font-size: 10px;
}

.decision-strip strong {
  overflow: hidden;
  margin-top: 4px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signal-badge {
  align-self: flex-start;
  padding: 3px 8px;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 4px;
  font-size: 10px !important;
}

.signal-badge.enter-long {
  color: var(--green);
  background: var(--green-soft);
}

.signal-badge.exit-long {
  color: var(--red);
  background: var(--red-soft);
}

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

.chart-surface,
.evidence-surface {
  padding: 17px 18px;
}

.wide-chart {
  grid-column: span 2;
}

.analysis-volume {
  grid-column: span 1;
}

.chart-surface canvas {
  display: block;
  width: 100%;
  height: 178px;
  margin-top: 12px;
}

.wide-chart canvas {
  height: 245px;
}

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  color: var(--muted);
  font-size: 9px;
}

.legend i {
  display: inline-block;
  width: 13px;
  height: 2px;
  margin-left: 5px;
  background: var(--ink);
}

.legend .legend-fast {
  background: var(--teal);
}

.legend .legend-slow {
  background: var(--amber);
}

.chart-value {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.evidence-list {
  display: grid;
  margin-top: 11px;
}

.evidence-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 48px;
  gap: 9px;
  border-top: 1px solid var(--line);
}

.evidence-item svg {
  width: 17px;
  height: 17px;
  color: var(--red);
}

.evidence-item.passed svg {
  color: var(--green);
}

.evidence-item strong,
.evidence-item small {
  display: block;
}

.evidence-item strong {
  font-size: 11px;
}

.evidence-item small {
  color: var(--muted);
  font-size: 9px;
}

.evidence-item > span:last-child {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
}

.account-dialog {
  width: min(470px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 20px 55px rgba(23, 33, 29, 0.24);
}

.account-dialog::backdrop {
  background: rgba(15, 23, 20, 0.58);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 19px 20px 15px;
  border-bottom: 1px solid var(--line);
}

.profile-list {
  display: grid;
  max-height: 190px;
  overflow-y: auto;
}

.profile-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto auto;
  align-items: center;
  min-height: 54px;
  gap: 9px;
  padding: 7px 20px;
  border-bottom: 1px solid var(--line);
}

.profile-item > svg {
  width: 17px;
  height: 17px;
  color: var(--teal);
}

.profile-item strong,
.profile-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-item strong {
  font-size: 11px;
}

.profile-item small {
  color: var(--muted);
  font-size: 9px;
}

.profile-item .icon-button {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
}

.account-form {
  display: grid;
  gap: 11px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.account-form h3 {
  margin-bottom: 0;
}

.logout-button {
  width: calc(100% - 40px);
  margin: 15px 20px 20px;
}

.paper-lock {
  color: var(--teal);
  background: var(--teal-soft);
  border-color: #badfd6;
}

.paper-lock svg {
  width: 14px;
  height: 14px;
}

.activity-surface {
  overflow: hidden;
}

.activity-item {
  display: grid;
  grid-template-columns: 38px minmax(150px, 0.75fr) minmax(0, 2fr) 140px;
  align-items: center;
  min-height: 62px;
  gap: 12px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
}

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

.activity-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 6px;
}

.activity-icon.error {
  color: var(--red);
  background: var(--red-soft);
}

.activity-icon.safety {
  color: var(--amber);
  background: var(--amber-soft);
}

.activity-icon svg {
  width: 15px;
  height: 15px;
}

.activity-type,
.activity-detail,
.activity-time {
  min-width: 0;
}

.activity-type strong,
.activity-type small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-type strong {
  font-size: 12px;
}

.activity-type small,
.activity-time {
  color: var(--muted);
  font-size: 10px;
}

.activity-detail {
  overflow: hidden;
  color: #4f5c56;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-time {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.config-surface {
  display: grid;
  grid-template-columns: minmax(180px, 0.55fr) minmax(0, 2fr);
  gap: 28px;
}

.config-section {
  padding-right: 26px;
  border-right: 1px solid var(--line);
}

.config-section h3 {
  margin-bottom: 12px;
}

.symbol-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.symbol-chip {
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  padding: 0 9px;
  color: #0c655f;
  background: var(--teal-soft);
  border: 1px solid #bee0d8;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
}

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

.config-item {
  min-width: 0;
  min-height: 63px;
  padding: 7px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.config-item:nth-child(3n + 1) {
  padding-left: 0;
}

.config-item:nth-child(3n) {
  padding-right: 0;
}

.config-item span,
.config-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.config-item span {
  color: var(--muted);
  font-size: 10px;
}

.config-item strong {
  margin-top: 5px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.confirm-dialog {
  width: min(430px, calc(100vw - 28px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 20px 55px rgba(23, 33, 29, 0.24);
}

.confirm-dialog::backdrop {
  background: rgba(15, 23, 20, 0.58);
}

.confirm-dialog form {
  padding: 24px;
}

.dialog-icon {
  display: grid;
  width: 38px;
  height: 38px;
  margin-bottom: 14px;
  place-items: center;
  color: var(--red);
  background: var(--red-soft);
  border-radius: 7px;
}

.dialog-icon svg {
  width: 20px;
  height: 20px;
}

.confirm-dialog h2 {
  margin-bottom: 8px;
  font-size: 18px;
}

.confirm-dialog p {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 12px;
}

.confirm-dialog label {
  display: block;
  margin-bottom: 7px;
  font-size: 11px;
}

.confirm-dialog input {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: grid;
  width: min(360px, calc(100vw - 36px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 10px 12px;
  color: #ffffff;
  background: #21302a;
  border: 1px solid #354840;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(23, 33, 29, 0.2);
  animation: toast-in 180ms ease-out;
}

.toast.error {
  background: #912b2b;
  border-color: #b94b4b;
}

.toast svg {
  width: 17px;
  height: 17px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1080px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .control-surface {
    display: grid;
    grid-template-columns: minmax(230px, 0.7fr) minmax(270px, 1fr);
    column-gap: 24px;
  }

  .control-surface > .section-heading,
  .control-surface > .runtime-status {
    grid-column: 1;
  }

  .control-surface > .segmented-control,
  .control-surface > .primary-button,
  .control-surface > .control-divider,
  .control-surface > .switch-row,
  .control-surface > .danger-button {
    grid-column: 2;
  }

  .control-surface > .segmented-control {
    align-self: end;
    grid-row: 1;
    margin: 0;
  }

  .control-surface > .primary-button {
    align-self: start;
    grid-row: 2;
    margin-top: 4px;
  }

  .control-surface > .control-divider {
    display: none;
  }

  .control-surface > .switch-row {
    align-self: end;
    grid-row: 3;
  }

  .control-surface > .danger-button {
    align-self: start;
    grid-row: 4;
  }

  .runtime-status {
    margin-bottom: 0;
  }

  .account-button span,
  .account-button svg:last-child {
    display: none;
  }

  .account-button {
    grid-template-columns: 18px;
    width: 38px;
    padding: 0 9px;
  }

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

  .evidence-surface {
    grid-column: span 2;
  }
}

@media (max-width: 800px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    z-index: 4;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    width: 100%;
    height: auto;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid #2c3a35;
  }

  .brand {
    padding: 0 16px 0 0;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .brand strong {
    font-size: 14px;
  }

  .primary-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    grid-template-columns: 18px minmax(0, 1fr);
    min-height: 38px;
  }

  .nav-count {
    display: none;
  }

  .sidebar-status {
    display: none;
  }

  .main-content {
    padding: 0 18px 36px;
  }

  .topbar {
    min-height: 74px;
  }

  h1 {
    font-size: 21px;
  }

  #localClock {
    display: none;
  }

  .config-surface {
    grid-template-columns: 1fr;
  }

  .config-section {
    padding: 0 0 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .activity-item {
    grid-template-columns: 34px minmax(0, 1fr) 110px;
  }

  .activity-detail {
    display: none;
  }

  .decision-strip {
    grid-template-columns: 0.65fr 1.35fr;
  }

  .decision-strip > div:last-child {
    display: none;
  }

  .decision-strip > div:nth-child(2) {
    border-right: 0;
  }
}

@media (max-width: 600px) {
  .sidebar {
    display: block;
    padding: 11px 12px 8px;
  }

  .brand {
    padding: 0 4px 9px;
  }

  .primary-nav {
    gap: 3px;
  }

  .nav-item {
    display: flex;
    justify-content: center;
    min-width: 0;
    gap: 6px;
    padding: 0 7px;
    font-size: 11px;
  }

  .nav-item svg {
    flex: 0 0 15px;
  }

  .nav-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .main-content {
    padding: 0 12px 30px;
  }

  .topbar {
    min-height: 68px;
    gap: 10px;
  }

  .topbar-actions {
    gap: 7px;
  }

  .market-chip {
    max-width: 123px;
  }

  .account-button {
    display: inline-grid;
    flex: 0 0 38px;
  }

  #marketStatus {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .dashboard-panel {
    padding-top: 14px;
  }

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

  .metric-card {
    min-height: 104px;
    padding: 14px;
  }

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

  .overview-grid,
  .table-surface {
    margin-top: 8px;
  }

  .overview-grid {
    gap: 8px;
  }

  .portfolio-surface,
  .control-surface,
  .config-surface {
    padding: 15px;
  }

  .chart-wrap,
  #equityChart {
    height: 170px;
  }

  .chart-range {
    display: none;
  }

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

  #lastUpdated {
    display: none;
  }

  .control-surface {
    display: block;
  }

  .control-surface > .segmented-control {
    margin-bottom: 9px;
  }

  .control-surface > .control-divider {
    display: block;
  }

  .runtime-status {
    margin: 16px 0;
  }

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

  .config-item,
  .config-item:nth-child(3n + 1),
  .config-item:nth-child(3n) {
    padding: 8px 10px 11px;
  }

  .config-item:nth-child(2n + 1) {
    padding-left: 0;
  }

  .config-item:nth-child(2n) {
    padding-right: 0;
  }

  .activity-item {
    grid-template-columns: 32px minmax(0, 1fr);
    min-height: 58px;
    padding: 8px 12px;
  }

  .activity-time {
    grid-column: 2;
    text-align: left;
  }

  .table-heading {
    padding: 14px;
  }

  th,
  td {
    padding: 0 14px;
  }

  .analysis-heading {
    align-items: flex-start;
  }

  .analysis-heading .panel-actions {
    display: grid;
    grid-template-columns: 1fr 40px;
  }

  .analysis-heading .panel-actions .secondary-button span {
    display: none;
  }

  .analysis-heading .panel-actions .secondary-button {
    width: 40px;
    padding: 0;
  }

  .analysis-heading #exportBars {
    display: none;
  }

  .decision-strip {
    display: block;
    padding: 12px 14px;
  }

  .decision-strip > div {
    padding: 8px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .decision-strip > div:nth-child(2) {
    border-bottom: 0;
  }

  .decision-strip strong {
    white-space: normal;
  }

  .analysis-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .wide-chart,
  .evidence-surface,
  .analysis-volume {
    grid-column: span 1;
  }

  .wide-chart canvas {
    height: 205px;
  }

  .panel-actions .secondary-button {
    padding: 0 10px;
  }

  .login-screen {
    padding: 18px 14px;
  }

  .login-form {
    padding: 20px;
  }
}

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