:root {
  --bg: #f3f4f7;
  --panel: #ffffffd9;
  --line: #d9dbe2;
  --text: #111214;
  --muted: #6b6d76;
  --up: #0b7a43;
  --down: #c62828;
  --amber: #9a6700;
  --shadow: 0 12px 30px rgba(17, 18, 20, 0.06);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: linear-gradient(180deg, #f7f7f9, #eef0f4);
  color: var(--text);
  font:
    14px/1.38 "SF Pro Text",
    "SF Pro Display",
    "Helvetica Neue",
    Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button {
  font: inherit;
}
.app {
  max-width: 1220px;
  margin: 0 auto;
  padding: 18px 18px calc(108px + env(safe-area-inset-bottom, 0px));
}
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(
      circle at top,
      rgba(255, 255, 255, 0.82),
      rgba(243, 244, 247, 0.96)
    ),
    rgba(243, 244, 247, 0.92);
  backdrop-filter: blur(18px) saturate(1.08);
}
.lock-card {
  width: min(440px, 100%);
  padding: 24px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 30px 70px rgba(17, 18, 20, 0.12);
  display: grid;
  gap: 12px;
}
.lock-card h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 560;
  letter-spacing: -0.05em;
}
.top,
.card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: saturate(1.15) blur(18px);
}
.top {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(calc(100vw - 24px), 1220px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 10px;
  margin: 0;
  flex-wrap: nowrap;
  z-index: 12;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  min-width: 0;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  justify-content: space-around;
}

.tab {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 16px;
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.tab.active {
  background: #111214;
  color: #fff;
}
.view {
  display: none;
}
.view.active {
  display: block;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 10px;
}
.hero {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 0;
  padding: 12px;
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.92),
      rgba(244, 246, 251, 0.86)
    ),
    var(--panel);
}
.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
}
.mini-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 0;
}
.mini-cards-overview {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.mini {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(248, 249, 252, 0.92);
  border: 1px solid #e7e9ef;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}
.mini span {
  display: inline;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini strong {
  font-size: 20px;
  font-weight: 540;
  letter-spacing: -0.05em;
  white-space: nowrap;
  flex: 0 0 auto;
}
.mini #liveState {
  font-size: 14px;
  font-weight: 520;
  letter-spacing: -0.02em;
}
.cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.card,
.panel {
  padding: 16px;
}
.card span,
.panel h2 {
  display: block;
  margin: 0 0 6px;
}
.card span {
  color: var(--muted);
  font-size: 12px;
}
.card strong {
  font-size: 22px;
  font-weight: 540;
  letter-spacing: -0.05em;
  white-space: nowrap;
  flex: 0 0 auto;
}
.card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
}
.card span {
  display: inline;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grid.two {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 12px;
}
.panel h2 {
  font-size: 17px;
  font-weight: 560;
  letter-spacing: -0.03em;
  color: var(--text);
}
.head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: auto;
}
.formula-rich {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.formula-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid #dfe3eb;
  border-radius: 999px;
  background: rgba(248, 249, 252, 0.94);
  color: var(--text);
  font-size: 12px;
  line-height: 1.2;
}
.formula-chip button {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}
.formula-chip .down {
  color: var(--down);
}
.formula-chip .up {
  color: var(--up);
}
.help-sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
}
.help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 18, 20, 0.22);
  backdrop-filter: blur(8px);
}
.help-card {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100vw - 32px));
  max-height: min(82vh, 900px);
  overflow: auto;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 26px 70px rgba(17, 18, 20, 0.16);
}
.help-body {
  display: grid;
  gap: 12px;
}
.help-grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.help-section {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(248, 249, 252, 0.88);
  border: 1px solid #e4e7ee;
}
.help-section h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
  text-transform: uppercase;
}
.help-section p {
  margin: 0;
  font-size: 14px;
  line-height: 1.42;
}
.help-section strong {
  font-weight: 620;
}
.help-section code {
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(17, 18, 20, 0.06);
  font:
    12px/1.3 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
}
.help-section ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}
.help-section li {
  font-size: 14px;
  line-height: 1.42;
}
.help-metrics {
  margin-top: 2px;
}
.help-metrics dt,
.help-metrics dd {
  font-size: 13px;
}
.help-metrics dd {
  font-weight: 600;
}
.head-row .controls {
  align-items: center;
}
.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  font-size: 12px;
  font-weight: 520;
  letter-spacing: -0.01em;
}
.toggle-inline input {
  width: 16px;
  height: 16px;
  accent-color: #111214;
}
.wallet-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}
.wallet-filter .toggle-inline {
  cursor: pointer;
}
.wallet-filter input {
  cursor: pointer;
}
.trade-table-wrap {
  width: 100%;
  overflow-x: auto;
}
.trade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.trade-table th,
.trade-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
.trade-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.trade-table td:last-child {
  white-space: normal;
}
.wallet-matrix-section {
  margin-top: 18px;
}
.wallet-matrix-head {
  margin: 6px 2px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.master-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
}
.master-toggle .hint {
  min-width: 84px;
}
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f5f6f9;
}
.seg {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
}
.seg.active {
  background: #111214;
  color: #fff;
}
.section {
  min-height: 320px;
}
dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 12px;
}
dt {
  color: var(--muted);
  font-size: 13px;
}
dd {
  margin: 0;
  font-weight: 540;
  text-align: right;
  letter-spacing: -0.02em;
}
.list {
  display: grid;
  gap: 12px;
}
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.item {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.runtime-admin {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}
.field,
.field-inline {
  display: grid;
  gap: 6px;
}
.field span,
.field-inline span {
  color: var(--muted);
  font-size: 12px;
}
.field input,
.field-inline input {
  width: 100%;
}
input[type="number"],
input[type="password"] {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
}
.runtime-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.runtime-controls .head-row {
  grid-column: 1 / -1;
  margin-top: 4px;
}
.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}
.pattern-card,
.execution-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  display: grid;
  gap: 12px;
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}
.pattern-card.card-paused,
.execution-card.card-paused {
  opacity: 0.52;
  background: rgba(255, 255, 255, 0.48);
}
.pattern-card.card-active,
.execution-card.card-active {
  opacity: 1;
}
.pattern-card.card-legacy,
.execution-card.card-legacy,
.pattern-card.card-system,
.execution-card.card-system {
  opacity: 0.78;
}
.execution-card.has-open.has-open-up {
  background:
    linear-gradient(
      180deg,
      rgba(231, 247, 237, 0.92),
      rgba(244, 250, 246, 0.88)
    ),
    rgba(255, 255, 255, 0.78);
  border-color: rgba(11, 122, 67, 0.28);
  box-shadow:
    inset 0 0 0 1px rgba(11, 122, 67, 0.1),
    0 12px 30px rgba(17, 18, 20, 0.06);
}
.execution-card.has-open.has-open-down {
  background:
    linear-gradient(
      180deg,
      rgba(252, 234, 234, 0.92),
      rgba(250, 243, 243, 0.88)
    ),
    rgba(255, 255, 255, 0.78);
  border-color: rgba(198, 40, 40, 0.28);
  box-shadow:
    inset 0 0 0 1px rgba(198, 40, 40, 0.1),
    0 12px 30px rgba(17, 18, 20, 0.06);
}
.clickable {
  cursor: pointer;
}
.pattern-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.pattern-top strong {
  font-size: 16px;
  font-weight: 560;
  letter-spacing: -0.03em;
}
.pattern-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.mini-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
}
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch-ui {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #d3d7df;
  border: 1px solid #c8ccd6;
  transition: background 120ms ease;
  position: relative;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(17, 18, 20, 0.16);
  transition: transform 120ms ease;
}
.switch input:checked + .switch-ui {
  background: #111214;
  border-color: #111214;
}
.switch input:checked + .switch-ui::after {
  transform: translateX(16px);
}
.switch-hint {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.audit-list {
  display: grid;
  gap: 10px;
}
.audit-row {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
}
.audit-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f7f8fb;
  font-size: 12px;
  color: var(--muted);
}
.pill.up {
  color: var(--up);
}
.pill.down {
  color: var(--down);
}
.pill.status-active {
  color: var(--up);
  border-color: rgba(11, 122, 67, 0.18);
  background: rgba(11, 122, 67, 0.06);
}
.pill.status-inactive,
.pill.status-paused {
  color: var(--amber);
  border-color: rgba(154, 103, 0, 0.18);
  background: rgba(154, 103, 0, 0.06);
}
.pill.status-legacy {
  color: #3856a8;
  border-color: rgba(56, 86, 168, 0.18);
  background: rgba(56, 86, 168, 0.06);
}
.pill.status-system {
  color: var(--muted);
}
.pattern-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.pattern-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}
.pattern-stats strong {
  font-size: 18px;
  font-weight: 540;
  letter-spacing: -0.04em;
}
.bars {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.bar {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
}
.track {
  height: 8px;
  border-radius: 999px;
  background: #eceef3;
  overflow: hidden;
}
.fill {
  height: 100%;
  border-radius: 999px;
  background: #b6bcc9;
}
.fill.up {
  background: #1d9257;
}
.fill.down {
  background: #d14848;
}
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 18, 20, 0.28);
}
.detail-sheet {
  position: fixed;
  right: 18px;
  top: 18px;
  bottom: 18px;
  width: min(980px, calc(100vw - 36px));
  padding: 18px;
  overflow: auto;
  background: #f5f6fa;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 30px 70px rgba(17, 18, 20, 0.2);
  transform: translateX(104%);
  transition: transform 180ms ease;
  z-index: 20;
}
.detail-sheet.open {
  transform: translateX(0);
}
body.sheet-open {
  overflow: hidden;
}
body.locked {
  overflow: hidden;
}
@media (max-width: 900px) {
  .hero-grid,
  .grid.two,
  .pattern-grid,
  .runtime-controls,
  .cards,
  .pattern-stats {
    grid-template-columns: 1fr;
  }
  .mini-cards,
  .mini-cards-overview,
  .overview-strip {
    grid-template-columns: 1fr;
  }
}
.pattern-card {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(248, 249, 252, 0.9);
}
.execution-card {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(248, 249, 252, 0.9);
}
.clickable {
  cursor: pointer;
}
.clickable:hover {
  border-color: #c4c9d4;
  box-shadow: 0 8px 20px rgba(17, 18, 20, 0.05);
}
.item:first-child {
  border-top: 0;
  padding-top: 0;
}
.item h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 560;
  letter-spacing: -0.03em;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.pattern-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.pattern-top strong {
  font-size: 18px;
  font-weight: 560;
  letter-spacing: -0.04em;
}
.pattern-sub {
  color: var(--muted);
  font-size: 12px;
}
.pattern-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.pattern-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.pattern-stats strong {
  font-size: 16px;
  font-weight: 540;
  letter-spacing: -0.04em;
}
.pattern-stats.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.pattern-stats.compact > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.pattern-stats.compact span {
  display: inline;
  margin: 0;
  white-space: nowrap;
}
.pattern-stats.compact strong {
  white-space: nowrap;
  flex: 0 0 auto;
}
.execution-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.pill {
  padding: 5px 9px;
  border-radius: 999px;
  background: #f2f3f7;
  border: 1px solid #e6e8ee;
}
.bars {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.bar {
  display: grid;
  grid-template-columns: 110px 1fr 48px;
  gap: 10px;
  align-items: center;
}
.bar span {
  color: var(--muted);
  font-size: 12px;
}
.track {
  height: 8px;
  border-radius: 999px;
  background: #eef0f4;
  overflow: hidden;
}
.fill {
  height: 100%;
  border-radius: 999px;
  background: #cfd5df;
}
.fill.up {
  background: linear-gradient(90deg, #30a46c, #66d19e);
}
.fill.down {
  background: linear-gradient(90deg, #e26666, #ff9a9a);
}
.fill.flat {
  background: linear-gradient(90deg, #c5cad4, #d7dbe2);
}
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 18, 20, 0.18);
  backdrop-filter: blur(6px);
}
.detail-sheet {
  position: fixed;
  right: 18px;
  top: 18px;
  bottom: 18px;
  width: min(560px, calc(100vw - 36px));
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 30px 60px rgba(17, 18, 20, 0.12);
  backdrop-filter: saturate(1.15) blur(18px);
  overflow: auto;
  transform: translateX(108%);
  transition: transform 180ms ease;
  z-index: 20;
}
.detail-sheet.open {
  transform: translateX(0);
}
.up {
  color: var(--up);
}
.down {
  color: var(--down);
}
.amber {
  color: var(--amber);
}

/* Execution view: prioritize deck on iPad landscape */
.view.active[data-view="execution"] {
  display: grid;
  grid-template-rows: auto auto;
  gap: 12px;
  align-content: start;
}
.execution-deck-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}
.execution-deck-section .controls * {
  pointer-events: auto;
}
.execution-bottom {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 10px;
}
.execution-bottom .section {
  min-height: 0;
}
.execution-tape-section {
  display: none;
}
#executionDeck {
  min-height: 0;
  max-height: calc(100vh - 355px);
  overflow: auto;
  padding-right: 4px;
}
#executionDeck .pattern-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.execution-card {
  padding: 10px 11px;
  border-radius: 16px;
  gap: 8px;
}
.execution-card.execution-card-v54 {
  padding: 0;
  gap: 0;
  background: #fff;
  border: 1px solid #d9cfbf;
  box-shadow: none;
}
.execution-card.execution-card-v54.has-open.has-open-up,
.execution-card.execution-card-v54.has-open.has-open-down {
  background: #fff;
  border-color: #d9cfbf;
  box-shadow: none;
}
.execution-card.execution-card-v54.card-paused {
  background: #fff;
}
.execution-v54-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #d9cfbf;
}
.execution-v54-title strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.execution-v54-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.execution-open-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid #cbbda8;
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  margin-right: 6px;
}
.execution-open-pnl {
  font-size: 15px;
  font-weight: 700;
}
.execution-v54-row,
.execution-v54-horizon {
  display: grid;
  align-items: center;
}
.execution-v54-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.execution-v54-row + .execution-v54-row {
  border-top: 1px solid #d9cfbf;
}
.execution-v54-cell {
  min-width: 0;
  padding: 9px 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
}
.execution-v54-cell + .execution-v54-cell {
  border-left: 1px solid #d9cfbf;
}
.execution-v54-key {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.execution-v54-val {
  font-size: 13px;
  font-weight: 700;
}
.execution-v54-horizons {
  margin-top: 8px;
  border-top: 1px solid #d9cfbf;
}
.execution-v54-horizon {
  grid-template-columns: 44px repeat(4, minmax(0, 1fr));
}
.execution-v54-horizon + .execution-v54-horizon {
  border-top: 1px solid #d9cfbf;
}
.execution-v54-target {
  display: grid;
  grid-template-columns: 58px repeat(3, minmax(0, 1fr));
  align-items: center;
  margin-top: 8px;
  border-top: 1px solid #d9cfbf;
}
.execution-v54-tag {
  padding: 9px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.execution-v54-hint,
.execution-v54-meta {
  margin: 8px 14px 0;
}
.execution-card .pattern-top {
  gap: 8px;
  margin-bottom: 0;
}
.execution-card .pattern-top strong {
  font-size: 14px;
  line-height: 1.08;
  letter-spacing: -0.03em;
}
.execution-card .pattern-sub {
  font-size: 11px;
  margin-top: 2px;
}
.execution-card .meta {
  gap: 4px;
  font-size: 11px;
}
.execution-card .pill {
  padding: 4px 7px;
  font-size: 11px;
}
.execution-card .top-actions {
  gap: 6px;
}
.execution-card .pattern-stats {
  gap: 8px;
  margin-top: 0;
}
.execution-card .pattern-stats.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.execution-card .pattern-stats strong {
  font-size: 14px;
}
@media (max-width: 640px) {
  #executionDeck .pattern-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .execution-card.execution-card-v54 {
    border-radius: 14px;
  }
  .execution-v54-top {
    padding: 9px 10px;
    gap: 8px;
  }
  .execution-v54-title strong {
    font-size: 13px;
  }
  .execution-v54-right {
    gap: 6px;
  }
  .execution-open-count {
    width: 18px;
    height: 18px;
    font-size: 11px;
    margin-right: 2px;
  }
  .execution-open-pnl {
    font-size: 12px;
  }
  .execution-v54-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .execution-v54-horizons {
    margin-top: 0;
  }
  .execution-v54-horizon {
    grid-template-columns: 34px repeat(4, minmax(0, 1fr));
  }
  .execution-v54-target {
    margin-top: 0;
    grid-template-columns: 42px repeat(3, minmax(0, 1fr));
  }
  .execution-v54-tag {
    padding: 7px 6px;
    font-size: 10px;
    letter-spacing: 0.05em;
  }
  .execution-v54-cell {
    padding: 6px 7px;
    gap: 4px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
  }
  .execution-v54-cell + .execution-v54-cell {
    border-left: 1px solid #d9cfbf;
    border-top: 0;
  }
  .execution-v54-key {
    font-size: 9px;
    letter-spacing: 0.03em;
  }
  .execution-v54-val {
    font-size: 11px;
    line-height: 1.05;
  }
}
.execution-bottom .panel {
  padding: 12px;
}
.execution-bottom .panel h2 {
  margin-bottom: 8px;
  font-size: 15px;
}
.execution-bottom dl {
  gap: 6px 10px;
}
.execution-bottom dt,
.execution-bottom dd {
  font-size: 11px;
  line-height: 1.2;
}
.execution-bottom .bars {
  gap: 6px;
  margin-top: 8px;
}
.execution-bottom .bar {
  grid-template-columns: 52px 1fr 34px;
  gap: 6px;
  font-size: 11px;
}
.execution-bottom .bar span:last-child {
  font-weight: 600;
}
.pattern-detail-screen {
  display: grid;
  gap: 12px;
}
.detail-nav-row {
  margin-bottom: 0;
}
.detail-title-wrap {
  flex: 1 1 auto;
  min-width: 0;
}
.detail-title-wrap h2 {
  margin: 0 0 2px;
}
.detail-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.compact-panel {
  min-height: 0;
}
.trade-list {
  display: grid;
  gap: 8px;
}
.pattern-version-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.pattern-version-row {
  border: 1px solid #e6e8ee;
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(248, 249, 252, 0.9);
  display: grid;
  gap: 6px;
}
.trade-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.9fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #e6e8ee;
  border-radius: 14px;
  background: rgba(248, 249, 252, 0.9);
}
.trade-row.clickable {
  cursor: pointer;
}
.trade-row.clickable:hover {
  background: rgba(243, 245, 250, 0.98);
}
.trade-main {
  min-width: 0;
}
.trade-symbol {
  font-weight: 560;
  letter-spacing: -0.02em;
}
.trade-meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trade-side {
  display: grid;
  gap: 2px;
  justify-items: end;
}
.trade-price {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.trade-pnl {
  font-weight: 560;
  white-space: nowrap;
}
.event-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 540;
  letter-spacing: -0.01em;
}
.event-up {
  color: var(--up);
  border-color: rgba(11, 122, 67, 0.18);
  background: rgba(11, 122, 67, 0.08);
}
.event-down {
  color: var(--down);
  border-color: rgba(198, 40, 40, 0.18);
  background: rgba(198, 40, 40, 0.08);
}
.event-warn {
  color: var(--amber);
  border-color: rgba(154, 103, 0, 0.18);
  background: rgba(154, 103, 0, 0.08);
}
.event-live {
  color: #0a5bd8;
  border-color: rgba(10, 91, 216, 0.18);
  background: rgba(10, 91, 216, 0.08);
}
.event-flat {
  color: var(--muted);
  border-color: rgba(107, 109, 118, 0.16);
  background: rgba(107, 109, 118, 0.08);
}
@media (max-width: 900px) {
  .hero-grid,
  .cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .pattern-grid {
    grid-template-columns: 1fr;
  }
  .execution-grid {
    grid-template-columns: 1fr;
  }
  .hero-grid {
    grid-template-columns: 1fr;
  }
  .grid.two {
    grid-template-columns: 1fr;
  }
  .view[data-view="execution"] .execution-bottom {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .execution-tape-section {
    display: block;
  }
  .head-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .trade-row {
    grid-template-columns: 1fr;
    justify-items: start;
  }
  .trade-side {
    justify-items: start;
  }
  .top {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }
  .top-sync {
    order: 3;
  }
  .detail-sheet {
    inset: auto 12px 12px 12px;
    width: auto;
  }
}
@media (max-width: 680px) {
  .app {
    padding: 12px;
  }
  .top {
    align-items: flex-start;
    gap: 12px;
  }
  .cards {
    grid-template-columns: 1fr 1fr;
  }
  .mini-cards {
    grid-template-columns: 1fr;
  }
  .pattern-stats {
    grid-template-columns: 1fr 1fr;
  }
  #executionDeck {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
  #executionDeck .pattern-grid {
    grid-template-columns: 1fr;
  }
  .card strong {
    font-size: 24px;
  }
  .hero h2 {
    font-size: 40px;
  }
}

/* iPad/tablet: larger readable UI while keeping dense, stable layout */
@media (min-width: 768px) and (max-width: 1366px) {
  body {
    font-size: 16px;
    line-height: 1.46;
  }
  .app {
    max-width: none;
    padding: 18px 18px calc(112px + env(safe-area-inset-bottom, 0px));
  }
  .top {
    width: calc(100vw - 24px);
    padding: 10px 12px;
  }
  .tab {
    width: 58px;
    height: 58px;
    border-radius: 18px;
  }
  .overview-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
  .exchange-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .overview-chip {
    min-height: 58px;
    padding: 10px 12px;
  }
  .overview-chip span {
    font-size: 13px;
  }
  .overview-chip strong {
    font-size: 22px;
  }
  .exchange-kpi-head strong {
    font-size: 18px;
  }
  .cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid.two {
    grid-template-columns: 1.1fr 0.9fr;
    gap: 14px;
  }
  .pattern-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
  #executionDeck .pattern-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pattern-card,
  .execution-card {
    padding: 16px;
    gap: 12px;
  }
  .pattern-top strong {
    font-size: 20px;
  }
  .pattern-sub,
  .meta,
  .pill,
  .hint,
  .mini-btn {
    font-size: 14px;
  }
  .pill {
    padding: 7px 11px;
  }
  .pattern-stats strong {
    font-size: 20px;
  }
  .daily-matrix {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
  .day-card {
    min-width: 0;
    padding: 14px;
  }
  .day-head strong {
    font-size: 15px;
  }
  .equity-value {
    font-size: 16px;
  }
}
.open-count {
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  margin-left: 2px;
}

.ticker-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(138, 148, 168, 0.55);
  text-underline-offset: 2px;
}
.ticker-link:hover {
  text-decoration-color: currentColor;
}

.overview-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-flow: row;
  gap: 8px;
}
.overview-chip {
  min-width: 0;
  padding: 8px 10px;
  min-height: 46px;
  border-radius: 14px;
  background: rgba(248, 249, 252, 0.92);
  border: 1px solid #e7e9ef;
  box-shadow: none;
}
.overview-chip span {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.overview-chip strong {
  font-size: 18px;
  letter-spacing: -0.04em;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
}
.exchange-kpi-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.exchange-kpi-card {
  min-width: 0;
  border: 1px solid #e3e7ef;
  border-radius: 14px;
  background: rgba(248, 249, 252, 0.96);
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}
.exchange-kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.exchange-kpi-head strong {
  font-size: 16px;
  letter-spacing: -0.03em;
}
.exchange-kpi-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@media (max-width: 1280px) {
  .overview-strip {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
@media (max-width: 900px) {
  .overview-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .exchange-kpi-grid {
    grid-template-columns: 1fr;
  }
}

.daily-matrix {
  display: grid;
  grid-template-columns: repeat(7, minmax(140px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.day-card {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(248, 249, 252, 0.92);
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.day-card.up {
  background: rgba(11, 122, 67, 0.08);
  border-color: rgba(11, 122, 67, 0.18);
}
.day-card.down {
  background: rgba(198, 40, 40, 0.08);
  border-color: rgba(198, 40, 40, 0.18);
}
.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}
.day-head strong {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.day-stats {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}
.day-equity {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 8px;
}
.equity-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.equity-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.day-delta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
}
.day-delta.up {
  background: rgba(11, 122, 67, 0.1);
  color: var(--up);
}
.day-delta.down {
  background: rgba(198, 40, 40, 0.1);
  color: var(--down);
}
.day-delta .delta-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
}
.day-delta .delta-value {
  font-weight: 600;
}
.day-drawdown {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  background: rgba(198, 40, 40, 0.08);
  color: var(--down);
}
.day-drawdown .dd-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
}
.day-drawdown .dd-value {
  font-weight: 600;
}
.day-drawdowns {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}
.dd-item {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  background: rgba(198, 40, 40, 0.08);
  color: var(--down);
}
.dd-item .dd-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
}
.dd-item .dd-value {
  font-weight: 600;
}
.day-min-equity {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  font-size: 12px;
}
.day-min-equity .min-eq-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.day-min-equity .min-eq-value {
  font-weight: 600;
  color: var(--text);
}
.day-lines {
  display: grid;
  gap: 3px;
}
.day-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.day-line span {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.day-line strong {
  font-size: 10px;
  font-weight: 520;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
.day-line .metric-neutral {
  color: var(--text) !important;
}
.day-line .metric-split {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  color: var(--text) !important;
}
.day-line .metric-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.day-line .metric-value.up {
  color: var(--up);
  flex: 0 0 auto;
}
.day-line .metric-value.down {
  color: var(--down);
  flex: 0 0 auto;
}
@media (max-width: 1280px) {
  .daily-matrix {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (max-width: 1024px) {
  .daily-matrix {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.analytics-head {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}
.analytics-head h2 {
  margin: 0;
  white-space: nowrap;
  flex: 0 0 auto;
}
.analytics-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
}
.analytics-summary .pill {
  flex: 0 0 auto;
}
.analytics-summary .pill.equity {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
  font-weight: 600;
}
.summary-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
@media (max-width: 600px) {
  .summary-row {
    gap: 6px;
  }
  .summary-row .pill {
    font-size: 11px;
    padding: 4px 8px;
  }
}

.mini-pill {
  padding: 3px 7px;
  border-radius: 999px;
  background: #f2f3f7;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}

.tab svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.live-open-pnl {
  font-size: 13px;
  font-weight: 560;
  letter-spacing: -0.03em;
  white-space: nowrap;
  flex: 0 0 auto;
}

.execution-deck-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 10px 0;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.health-full {
  grid-column: 1 / -1;
}
@media (max-width: 1024px) {
  .health-grid {
    grid-template-columns: 1fr;
  }
  .health-full {
    grid-column: auto;
  }
}
