:root {
  --bg: #071718;
  --panel: #0b2022;
  --panel2: #0e282a;
  --line: #1d383b;
  --line2: #25484b;
  --text: #d7eeee;
  --muted: #86a2a5;
  --faint: #57777a;
  --cyan: #35d7cc;
  --cyan2: #1aa59d;
  --red: #ff5b68;
  --green: #16c99a;
  --yellow: #d3a61f;
  --shadow: rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
}
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button {
  border: 1px solid var(--line2);
  background: #10292b;
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
}
button:hover { border-color: var(--cyan2); }
button.active, button[type="submit"] {
  background: #0f3b3b;
  border-color: var(--cyan);
  color: #dffffc;
}
button.ghost { background: transparent; }
button.danger { border-color: #7f2e39; color: #ff9aa3; background: #2a1116; }
.hidden { display: none !important; }

.login-shell {
  height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 0%, #123437 0%, #071718 55%);
}
.login-panel {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line2);
  background: #0b2022;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 30px 80px var(--shadow);
}
.brand-line { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.brand-mark, .logo span {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: #112f32;
  color: var(--cyan);
  font-weight: 800;
}
.login-panel h1 { margin: 0; font-size: 24px; }
.login-panel p { margin: 4px 0 0; color: var(--muted); }
label { display: grid; gap: 6px; color: var(--muted); margin: 13px 0; }
input, select, textarea {
  border: 1px solid var(--line2);
  background: #07191b;
  border-radius: 6px;
  outline: none;
}
input, select { height: 36px; padding: 0 10px; }
textarea {
  width: 100%;
  min-height: 420px;
  padding: 12px;
  line-height: 1.45;
  font-family: "SFMono-Regular", Consolas, monospace;
  resize: vertical;
}
.error-text { min-height: 18px; color: var(--red); }
.helper-text { margin: -4px 0 10px; min-height: 16px; color: var(--muted); line-height: 1.3; }
.inline-check { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); }
.inline-check input { width: auto; height: auto; }

.app { display: flex; height: 100vh; }
.side {
  width: 48px;
  border-right: 1px solid var(--line);
  background: #081718;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
}
.logo { margin-bottom: 8px; }
.nav {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
}
.nav.active { color: var(--cyan); background: #102d2f; }
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 72px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(280px, 1fr) repeat(4, minmax(90px, 1fr)) 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: #081b1d;
}
.symbol-select { display: flex; align-items: center; gap: 10px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.symbol-select input {
  width: 120px;
  border: 0;
  background: transparent;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.symbol-select input:focus {
  outline: none;
}
.market-detail {
  height: 180px;
  border-top: 1px solid var(--line);
  overflow: auto;
  padding: 8px 10px;
}
.market-detail .mono {
  font-family: "SFMono-Regular", Consolas, monospace;
}
.market-detail table {
  margin: 0;
  width: 100%;
  border-collapse: collapse;
}
.market-detail thead th {
  position: sticky;
  top: 0;
  background: #0b2022;
}
#networkBadge {
  background: #0e4745;
  color: var(--cyan);
  border-radius: 5px;
  padding: 5px 7px;
  font-weight: 700;
}
.stat span { display: block; color: var(--muted); margin-bottom: 3px; }
.stat strong { font-size: 14px; }
.status-strip { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line2);
  background: #102729;
  color: var(--muted);
  border-radius: 5px;
  padding: 4px 7px;
}
.chip.ok { color: var(--cyan); border-color: #1b6b66; }
.chip.bad { color: var(--red); border-color: #76323b; }

.panel-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 330px 300px;
  border-bottom: 1px solid var(--line);
}
.chart-panel { position: relative; min-width: 0; background: #081b1d; }
.toolbar {
  height: 46px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}
.timeframes { display: flex; gap: 4px; }
.timeframes button, .tool {
  border: 0;
  background: transparent;
  color: var(--muted);
}
.timeframes button.active { color: var(--cyan); border: 1px solid var(--line2); background: #102729; }
.chart-title {
  position: absolute;
  top: 58px;
  left: 18px;
  z-index: 2;
  color: var(--muted);
}
#chart { height: calc(100% - 266px); min-height: 260px; }
.chart-tabs {
  height: 40px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
}
.chart-tabs button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  height: 100%;
}
.chart-tabs button.active { color: var(--text); border-bottom: 1px solid var(--cyan); }

.book-panel {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: #081b1d;
  overflow: hidden;
}
.trade-panel {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: #09191b;
  padding: 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.trade-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.trade-row.three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.trade-pill {
  min-height: 42px;
  width: 100%;
  font-weight: 700;
  text-align: center;
  background: #17292d;
}
.input-pill {
  padding: 0;
  border: 1px solid var(--line2);
  border-radius: 6px;
}
.trade-tabs,
.side-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}
.trade-tabs button,
.side-switch button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  min-height: 40px;
  font-weight: 700;
}
.trade-tabs button.active {
  color: var(--text);
  border-bottom: 1px solid var(--cyan);
}
.side-switch {
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.side-switch button.active {
  background: var(--cyan);
  color: #062022;
}
.trade-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  color: var(--muted);
}
.trade-meta strong {
  color: var(--text);
  text-align: right;
}
.trade-panel label {
  margin: 0;
}
.trade-panel input,
.trade-panel select {
  width: 100%;
  height: 42px;
}
.trade-panel input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0;
  accent-color: var(--cyan);
}
.trade-panel .inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
}
.trade-panel select {
  padding: 0 10px;
  border: 1px solid var(--line2);
  background: #07191b;
  border-radius: 6px;
}
.size-slider {
  display: grid;
  grid-template-columns: 1fr 62px;
  gap: 10px;
  align-items: center;
}
.size-slider input {
  height: auto;
  padding: 0;
  accent-color: var(--cyan);
}
.size-slider output {
  border: 1px solid var(--line2);
  border-radius: 6px;
  height: 36px;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.live-check {
  color: #ffd2d6;
}
.submit-trade {
  min-height: 46px;
  background: var(--cyan);
  border-color: var(--cyan);
  color: #062022;
  font-weight: 800;
}
.trade-estimates {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: grid;
  gap: 8px;
}
.trade-estimates div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.trade-estimates span {
  color: var(--muted);
}
.trade-result {
  min-height: 72px;
  max-height: 220px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #07191b;
  color: #b8d5d7;
  white-space: pre-wrap;
}
.tabs, .bottom-tabs {
  height: 46px;
  display: flex;
  border-bottom: 1px solid var(--line);
}
.tabs button, .bottom-tabs button {
  flex: 1;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}
.tabs button.active, .bottom-tabs button.active {
  color: var(--text);
  border-bottom: 1px solid var(--cyan);
}
.ladder, .trades {
  height: calc(100% - 46px);
  overflow: auto;
  padding: 8px 0;
}
.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  position: relative;
  padding: 4px 12px;
  min-height: 24px;
}
.row3.header { color: var(--muted); }
.row3 span { position: relative; z-index: 1; text-align: right; }
.row3 span:first-child { text-align: left; }
.ask { color: var(--red); }
.bid, .buy { color: var(--green); }
.bar {
  position: absolute;
  top: 1px;
  bottom: 1px;
  right: 0;
  opacity: .28;
}
.bar.ask { background: var(--red); }
.bar.bid { background: var(--green); }
.spread {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #112528;
  font-weight: 700;
}

.bottom-panel {
  height: 280px;
  background: var(--panel);
  display: grid;
  grid-template-rows: 46px 1fr;
  position: relative;
}
.bottom-actions {
  position: absolute;
  right: 12px;
  top: 7px;
  display: flex;
  gap: 8px;
}
.table-view { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 600; background: #0b2022; position: sticky; top: 0; }
td.mono { font-family: "SFMono-Regular", Consolas, monospace; color: #b8d5d7; }
.mini-actions { display: flex; gap: 6px; }
.mini-actions button { padding: 4px 7px; }
.toggle-on { color: var(--green); }
.toggle-off { color: var(--red); }
.pos { color: var(--green); }
.neg { color: var(--red); }

.mini-head {
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text);
}
.mini-stats b {
  color: var(--cyan);
}

.webhook-config {
  padding: 12px;
  display: grid;
  gap: 12px;
}
.webhook-row {
  display: grid;
  gap: 6px;
}
.webhook-row input,
.webhook-row textarea {
  width: 100%;
  background: #07191b;
}
.webhook-row textarea {
  min-height: 90px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .58);
  display: grid;
  place-items: center;
  z-index: 20;
}
.modal-box {
  width: min(880px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--line2);
  border-radius: 8px;
  background: #0b2022;
  box-shadow: 0 30px 80px var(--shadow);
  padding: 18px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.icon-btn { width: 30px; height: 30px; padding: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

@media (max-width: 1100px) {
  body { overflow: auto; }
  .app { min-height: 100vh; height: auto; }
  .topbar { grid-template-columns: 1fr 1fr; height: auto; padding: 10px; }
  .panel-grid { grid-template-columns: 1fr; }
  .book-panel { height: 360px; border-left: 0; border-top: 1px solid var(--line); }
  .trade-panel { min-height: 620px; border-left: 0; border-top: 1px solid var(--line); }
  .bottom-panel { height: 420px; }
}
