:root {
  --ink: #080a0c;
  --panel: rgba(16, 19, 22, .92);
  --panel-2: #11161a;
  --line: #2b3338;
  --line-hot: #52636b;
  --text: #f5f2e8;
  --muted: #7e8b90;
  --amber: #f6c453;
  --amber-dim: #5a481f;
  --green: #6df5a9;
  --green-dim: #153d2b;
  --red: #ff667c;
  --red-dim: #421b24;
  --blue: #72b7ff;
  --shadow: 0 22px 70px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--ink); }
body { min-height: 100vh; margin: 0; color: var(--text); background: radial-gradient(circle at 12% -10%, #1b2427 0, transparent 34%), radial-gradient(circle at 92% 4%, #2b2413 0, transparent 25%), var(--ink); font-family: Galmuri11, ui-monospace, SFMono-Regular, Menlo, monospace; }
button, a { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.grid-sky { position: fixed; z-index: -2; inset: 0; opacity: .18; background-image: linear-gradient(rgba(164, 188, 195, .13) 1px, transparent 1px), linear-gradient(90deg, rgba(164, 188, 195, .13) 1px, transparent 1px); background-size: 48px 48px; mask-image: linear-gradient(to bottom, #000, transparent 72%); }
.scanline { position: fixed; z-index: 20; inset: 0; pointer-events: none; opacity: .07; background: repeating-linear-gradient(to bottom, transparent 0, transparent 3px, #fff 4px); }

.desk-header { position: sticky; z-index: 10; top: 0; display: flex; min-height: 78px; align-items: center; justify-content: space-between; gap: 24px; padding: 0 max(24px, calc((100vw - 1440px) / 2)); border-bottom: 1px solid rgba(100, 116, 123, .35); background: rgba(8, 10, 12, .88); backdrop-filter: blur(20px); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; width: 38px; height: 38px; color: var(--ink); background: var(--amber); box-shadow: 5px 5px 0 #000; place-items: center; }
.brand b, .brand small { display: block; }
.brand b { font-size: 13px; letter-spacing: .08em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 8px; letter-spacing: .15em; }
.header-status { display: flex; align-items: center; gap: 9px; }
.view-badge, .mode-badge, .worker-badge, .floor-link { min-height: 31px; padding: 8px 10px; border: 1px solid var(--line); color: var(--muted); background: #0d1012; font-size: 9px; letter-spacing: .08em; text-decoration: none; }
.view-badge { color: var(--blue); border-color: #29445d; background: #0d1922; }
.mode-badge { color: var(--amber); border-color: var(--amber-dim); }
body[data-mode="live"] .mode-badge { color: #fff; border-color: var(--red); background: var(--red-dim); animation: live-border 1.8s ease-in-out infinite; }
body[data-mode="testnet"] .mode-badge { color: var(--blue); border-color: #315f86; background: #0b1b29; }
.worker-badge { display: flex; align-items: center; gap: 7px; }
.worker-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.worker-badge.running { color: var(--green); border-color: #28543c; }
.worker-badge.running i { background: var(--green); box-shadow: 0 0 14px var(--green); animation: pulse 1.4s infinite; }
.floor-link:hover { color: var(--text); border-color: var(--line-hot); }

.desk-shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 58px 0 40px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(430px, .65fr); gap: 30px; align-items: end; }
.hero-copy { padding: 20px 0 8px; }
.kicker { margin: 0 0 13px; color: var(--amber); font-size: 9px; font-weight: 800; letter-spacing: .19em; }
.hero-copy h1 { max-width: 860px; margin: 0; font-size: clamp(34px, 5vw, 68px); line-height: 1.07; letter-spacing: -.055em; }
.hero-copy h1 em { color: var(--amber); font-style: normal; }
.hero-copy > p:last-child { max-width: 730px; margin: 24px 0 0; color: #a0a9ad; font-size: 12px; line-height: 1.9; }
.panel { position: relative; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.engine-card { padding: 22px; border-top: 3px solid var(--amber); }
.panel-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 8px; letter-spacing: .15em; }
.panel-label time, .panel-label b { color: #a8b0b3; font-weight: 500; letter-spacing: 0; }
.engine-title { display: flex; align-items: center; gap: 15px; padding: 23px 0; }
.engine-pulse { flex: 0 0 auto; width: 17px; height: 17px; border: 3px solid var(--amber); transform: rotate(45deg); }
.engine-pulse.running { border-color: var(--green); background: var(--green); box-shadow: 0 0 22px rgba(109, 245, 169, .6); }
.engine-title strong, .engine-title small { display: block; }
.engine-title strong { font-size: 17px; }
.engine-title small { margin-top: 6px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.contract-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; border: 1px solid var(--line); background: #0b0e10; }
.contract-grid div { min-width: 0; padding: 12px 10px; border-right: 1px solid var(--line); }
.contract-grid div:last-child { border-right: 0; }
.contract-grid dt { color: var(--muted); font-size: 8px; }
.contract-grid dd { overflow: hidden; margin: 6px 0 0; font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }

.scan-status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.scan-status-grid article { min-width: 0; padding: 11px; border: 1px solid var(--line); background: #0b0e10; }
.scan-status-grid span, .scan-status-grid strong, .scan-status-grid small { display: block; }
.scan-status-grid span { color: var(--muted); font-size: 7px; letter-spacing: .06em; }
.scan-status-grid strong { margin-top: 6px; color: #aeb7ba; font-size: 10px; }
.scan-status-grid strong.active { color: var(--green); }
.scan-status-grid strong.managed { color: var(--blue); }
.scan-status-grid small { margin-top: 5px; overflow: hidden; color: #69757a; font-size: 7px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }

.profile-choice-row { display: grid; grid-template-columns: auto repeat(2, minmax(0, 1fr)); gap: 8px; align-items: stretch; margin-top: 8px; }
.profile-choice-row > span { display: grid; padding: 0 8px; color: var(--muted); font-size: 7px; place-items: center start; }
.profile-choice-row button { display: grid; gap: 4px; min-width: 0; padding: 9px 10px; color: #9ba5a8; border: 1px solid var(--line); background: #0b0e10; text-align: left; }
.profile-choice-row button b, .profile-choice-row button small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-choice-row button b { font-size: 9px; }
.profile-choice-row button small { color: #657176; font-size: 7px; }
.profile-choice-row button.selected { color: var(--ink); border-color: var(--amber); background: var(--amber); }
.profile-choice-row button.selected small { color: #55430c; }
.profile-choice-row button:disabled { cursor: not-allowed; opacity: .55; }

.engine-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.engine-controls button { min-height: 38px; padding: 9px 8px; color: var(--text); border: 1px solid var(--line-hot); background: #151a1d; font-size: 8px; font-weight: 800; }
.engine-controls button:hover:not(:disabled) { color: var(--amber); border-color: var(--amber); }
.engine-controls .start-control { color: var(--ink); border-color: var(--amber); background: var(--amber); }
.engine-controls .stop-control { color: #ffd9df; border-color: #71313e; background: var(--red-dim); }
.engine-controls button:disabled { opacity: .32; cursor: not-allowed; }
.engine-controls > span { grid-column: 1 / -1; min-height: 30px; padding: 7px 9px; color: var(--muted); border-left: 2px solid var(--line-hot); background: #0b0e10; font-size: 8px; line-height: 1.55; }
.engine-controls > span.success { color: var(--green); border-left-color: var(--green); }
.engine-controls > span.error { color: var(--red); border-left-color: var(--red); }

.performance-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 26px; border: 1px solid var(--line); background: rgba(9, 12, 14, .92); box-shadow: var(--shadow); }
.performance-strip article { min-width: 0; padding: 17px 15px; border-right: 1px solid var(--line); }
.performance-strip article:last-child { border-right: 0; }
.performance-strip span, .performance-strip small { display: block; overflow: hidden; color: var(--muted); font-size: 8px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.performance-strip strong { display: block; overflow: hidden; margin: 9px 0 5px; font-size: clamp(13px, 1.8vw, 20px); text-overflow: ellipsis; white-space: nowrap; }
.performance-strip .return-cell { background: #18150e; }
.performance-strip .return-cell strong { color: var(--amber); }
.performance-strip strong.positive { color: var(--green); }
.performance-strip strong.negative { color: var(--red); }

.error-banner { margin: 22px 0 -7px; padding: 12px 15px; color: #ffd9df; border: 1px solid #6a2e39; background: rgba(71, 21, 31, .72); font-size: 10px; line-height: 1.6; }
.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 42px; border: 1px solid var(--line); background: rgba(9, 12, 14, .92); box-shadow: var(--shadow); }
.metric-cell { min-width: 0; padding: 23px 24px; border-right: 1px solid var(--line); }
.metric-cell:last-child { border-right: 0; }
.metric-cell span, .metric-cell small { display: block; color: var(--muted); font-size: 9px; }
.metric-cell strong { display: inline-block; overflow: hidden; max-width: 100%; margin: 10px 0 6px; font-size: clamp(21px, 3vw, 32px); line-height: 1; text-overflow: ellipsis; vertical-align: bottom; }
.metric-cell .positive { color: var(--green); }
.metric-cell .negative { color: var(--red); }

.section-block { margin-top: 54px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 17px; }
.section-heading h2, .lower-grid h2 { margin: 0; font-size: 21px; letter-spacing: -.035em; }
.refresh-cluster { display: flex; align-items: center; gap: 13px; color: var(--muted); font-size: 9px; }
.refresh-cluster button { padding: 9px 12px; color: var(--text); border: 1px solid var(--line-hot); background: #151a1d; }
.refresh-cluster button:hover { color: var(--amber); border-color: var(--amber); }
.refresh-cluster button:disabled { opacity: .45; cursor: wait; }
.symbol-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.symbol-card { overflow: hidden; min-height: 430px; }
.symbol-card.long { border-top: 3px solid var(--green); }
.symbol-card.short { border-top: 3px solid var(--red); }
.symbol-card.flat { border-top: 3px solid #576369; }
.symbol-top { display: flex; align-items: start; justify-content: space-between; gap: 18px; padding: 21px 22px 17px; border-bottom: 1px solid var(--line); }
.symbol-title { display: flex; align-items: center; gap: 13px; }
.coin-mark { display: grid; width: 42px; height: 42px; color: var(--amber); border: 1px solid var(--amber-dim); background: #19160d; font-size: 11px; place-items: center; }
.symbol-title h3, .symbol-title small { display: block; margin: 0; }
.symbol-title h3 { font-size: 19px; }
.symbol-title small { margin-top: 5px; color: var(--muted); font-size: 8px; }
.symbol-price { text-align: right; }
.symbol-price strong, .symbol-price small { display: block; }
.symbol-price strong { font-size: clamp(20px, 3vw, 29px); }
.symbol-price small { margin-top: 5px; color: var(--muted); font-size: 8px; }
.decision-state { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; padding: 17px 22px; border-bottom: 1px solid var(--line); background: #0b0f11; }
.decision-state span { color: var(--muted); font-size: 8px; }
.decision-state strong { grid-row: 1 / 3; grid-column: 2; align-self: center; max-width: 220px; color: var(--amber); font-size: 12px; text-align: right; }
.decision-state small { overflow: hidden; color: #9aa5a9; font-size: 9px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.execution-track { padding: 19px 22px 17px; }
.track-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 8px; }
.track-line { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); height: 20px; margin: 14px 0 7px; }
.track-line::before { position: absolute; top: 7px; right: 7%; left: 7%; height: 2px; content: ''; background: #313a3f; }
.track-line::after { position: absolute; top: 7px; left: 7%; width: 0; height: 2px; content: ''; background: var(--amber); transition: width .5s ease; }
.track-line.done-1::after { width: 17%; }
.track-line.done-2::after { width: 34%; }
.track-line.done-3::after { width: 51%; }
.track-line.done-4::after { width: 68%; }
.track-line.done-5::after { width: 85%; background: var(--green); }
.track-line.done-6::after { width: 86%; background: var(--green); }
.track-line i { position: relative; z-index: 1; width: 16px; height: 16px; margin: 0 auto; border: 3px solid #313a3f; border-radius: 50%; background: var(--panel-2); }
.track-line.done-1 i:nth-child(-n+1), .track-line.done-2 i:nth-child(-n+2), .track-line.done-3 i:nth-child(-n+3), .track-line.done-4 i:nth-child(-n+4) { border-color: var(--amber); background: var(--amber); }
.track-line.done-5 i:nth-child(-n+5), .track-line.done-6 i:nth-child(-n+6) { border-color: var(--green); background: var(--green); }
.track-names { display: grid; grid-template-columns: repeat(6, 1fr); color: #657176; font-size: 7px; text-align: center; }
.position-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 22px 18px; border: 1px solid var(--line); background: #0a0d0f; }
.position-grid div { min-width: 0; padding: 11px; border-right: 1px solid var(--line); }
.position-grid div:last-child { border-right: 0; }
.position-grid dt { color: var(--muted); font-size: 7px; }
.position-grid dd { overflow: hidden; margin: 6px 0 0; font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.position-grid dd.long { color: var(--green); }
.position-grid dd.short { color: var(--red); }
.protection-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 22px 20px; }
.order-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.order-pill { padding: 6px 8px; color: var(--muted); border: 1px solid var(--line); background: #0b0e10; font-size: 7px; }
.order-pill.protected { color: var(--green); border-color: #24563a; background: #0c1d14; }
.plan-link { color: var(--muted); font-size: 8px; white-space: nowrap; }
.symbol-skeleton { min-height: 430px; overflow: hidden; background: linear-gradient(110deg, #111519 8%, #1b2226 18%, #111519 33%); background-size: 200% 100%; animation: shimmer 1.5s linear infinite; }

.lower-grid { display: grid; grid-template-columns: minmax(350px, .72fr) minmax(0, 1.28fr); gap: 16px; margin-top: 54px; }
.readiness-panel, .timeline-panel { min-height: 430px; padding: 22px; }
.lower-grid h2 { margin-top: 15px; }
.readiness-list { display: grid; gap: 8px; margin-top: 22px; }
.check-row { display: flex; align-items: center; gap: 13px; padding: 12px; border: 1px solid var(--line); background: #0b0e10; }
.check-row > i { display: grid; flex: 0 0 auto; width: 25px; height: 25px; color: var(--muted); border: 1px solid var(--line); font-size: 10px; font-style: normal; place-items: center; }
.check-row b, .check-row small { display: block; }
.check-row b { font-size: 9px; }
.check-row small { margin-top: 4px; color: var(--muted); font-size: 8px; }
.check-row.pass { border-color: #244d36; }
.check-row.pass > i { color: var(--green); border-color: #2e714c; background: var(--green-dim); }
.check-row.fail { border-color: #61303a; }
.check-row.fail > i { color: var(--red); border-color: #833b49; background: var(--red-dim); }
.check-row.locked { border-color: var(--amber-dim); }
.check-row.locked > i { color: var(--amber); border-color: var(--amber-dim); background: #251f0f; }
.safety-note { margin: 15px 0 0; padding: 12px; color: #aaa28d; border-left: 3px solid var(--amber); background: #18150e; font-size: 8px; line-height: 1.7; }
.safety-note b { color: var(--amber); }
.timeline { max-height: 350px; margin-top: 20px; padding-right: 5px; overflow-y: auto; scrollbar-color: #3d484d transparent; scrollbar-width: thin; }
.timeline-empty { display: grid; min-height: 250px; color: var(--muted); text-align: center; place-content: center; }
.timeline-empty span { color: var(--amber); font-size: 26px; }
.timeline-empty p { margin: 13px 0 7px; color: #bdc4c6; font-size: 10px; }
.timeline-empty small { font-size: 8px; }
.timeline-item { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 12px; padding: 0 0 18px; }
.timeline-item > i { width: 9px; height: 9px; margin-top: 3px; border: 2px solid var(--amber); border-radius: 50%; background: var(--panel); }
.timeline-item:not(:last-child) > i::after { display: block; width: 1px; height: 50px; margin: 8px 0 0 2px; content: ''; background: var(--line); }
.timeline-item strong, .timeline-item small { display: block; }
.timeline-item strong { font-size: 9px; }
.timeline-item small { margin-top: 5px; color: var(--muted); font-size: 8px; line-height: 1.5; }
.timeline-item time { color: #667277; font-size: 7px; }
.timeline-item.success > i { border-color: var(--green); background: var(--green); }
.timeline-item.danger > i { border-color: var(--red); background: var(--red); }
.desk-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 42px; padding-top: 18px; color: #566066; border-top: 1px solid var(--line); font-size: 7px; letter-spacing: .12em; }

.session-gate { position: fixed; z-index: 30; inset: 0; display: grid; padding: 24px; background: rgba(5, 6, 7, .9); backdrop-filter: blur(14px); place-items: center; }
.session-card { width: min(440px, 100%); padding: 36px; border: 1px solid var(--line-hot); background: #101417; box-shadow: 12px 12px 0 #000; text-align: center; }
.session-icon { display: block; color: var(--amber); font-size: 34px; }
.session-card .kicker { margin-top: 20px; }
.session-card h2 { margin: 0; font-size: 23px; }
.session-card p:not(.kicker) { margin: 16px 0 24px; color: var(--muted); font-size: 10px; line-height: 1.7; }
.session-card a { display: inline-block; padding: 12px 16px; color: var(--ink); background: var(--amber); font-size: 10px; font-weight: 800; text-decoration: none; }

.control-modal { position: fixed; z-index: 40; inset: 0; display: grid; padding: 24px; background: rgba(5, 6, 7, .88); backdrop-filter: blur(14px); place-items: center; }
.control-modal-card { position: relative; width: min(520px, 100%); padding: 30px; border: 1px solid var(--amber); border-top-width: 3px; background: #101417; box-shadow: 14px 14px 0 #000; }
.control-modal-card h2 { margin: 0; font-size: 22px; }
.control-modal-card > p:not(.kicker) { margin: 14px 0 20px; color: #a0a9ad; font-size: 10px; line-height: 1.7; }
.control-modal-card label { display: block; color: var(--muted); font-size: 9px; line-height: 1.7; }
.control-modal-card label b { display: block; margin: 8px 0; padding: 10px; color: var(--amber); border: 1px solid var(--amber-dim); background: #18150e; font-size: 11px; }
.control-modal-card input { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--text); border: 1px solid var(--line-hot); outline: 0; background: #090c0e; font: inherit; }
.control-modal-card input:focus { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(246, 196, 83, .13); }
.control-modal-card > small { display: block; margin-top: 15px; color: var(--red); font-size: 8px; line-height: 1.6; }
.control-modal-close { position: absolute; top: 13px; right: 13px; width: 31px; height: 31px; color: var(--muted); border: 1px solid var(--line); background: #0b0e10; }
.control-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 17px; }
.control-modal-actions button { min-height: 40px; padding: 10px 14px; color: var(--text); border: 1px solid var(--line-hot); background: #151a1d; font-size: 9px; }
.control-modal-actions .confirm { color: var(--ink); border-color: var(--amber); background: var(--amber); font-weight: 800; }
.control-modal-actions button:disabled { opacity: .32; cursor: not-allowed; }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes live-border { 50% { box-shadow: 0 0 20px rgba(255, 102, 124, .28); } }
@keyframes shimmer { to { background-position-x: -200%; } }

@media (max-width: 1040px) {
  .hero-grid { grid-template-columns: 1fr; }
  .engine-card { max-width: none; }
  .lower-grid { grid-template-columns: 1fr; }
  .performance-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .performance-strip article:nth-child(3) { border-right: 0; }
  .performance-strip article:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .desk-header { position: relative; align-items: flex-start; flex-direction: column; padding: 18px 20px; }
  .header-status { width: 100%; flex-wrap: wrap; }
  .view-badge { display: none; }
  .desk-shell { width: min(100% - 28px, 1440px); padding-top: 32px; }
  .hero-copy h1 { font-size: 35px; }
  .hero-copy h1 br { display: none; }
  .contract-grid { grid-template-columns: repeat(2, 1fr); }
  .contract-grid div:nth-child(2) { border-right: 0; }
  .contract-grid div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric-cell:nth-child(2) { border-right: 0; }
  .metric-cell:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .symbol-grid { grid-template-columns: 1fr; }
  .performance-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .performance-strip article:nth-child(3) { border-right: 1px solid var(--line); }
  .performance-strip article:nth-child(2n) { border-right: 0; }
  .performance-strip article:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
  .engine-controls { grid-template-columns: 1fr; }
  .engine-controls > span { grid-column: 1; }
  .scan-status-grid { grid-template-columns: 1fr; }
  .profile-choice-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-choice-row > span { grid-column: 1 / -1; padding: 3px 0; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .position-grid { grid-template-columns: repeat(2, 1fr); }
  .position-grid div:nth-child(2) { border-right: 0; }
  .position-grid div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .desk-footer { flex-direction: column; }
}

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