:root {
  --bg: #dfe5ea;
  --bg-deep: #cfd7df;
  --ink: #12151a;
  --muted: #5a6570;
  --line: rgba(18, 21, 26, 0.12);
  --panel: #f7f9fb;
  --panel-2: #ffffff;
  --accent: #0a6b52;
  --accent-ink: #ffffff;
  --warn: #9a3412;
  --flash-up: rgba(10, 107, 82, 0.18);
  --flash-down: rgba(154, 52, 18, 0.16);
  --shadow: 0 18px 50px rgba(18, 21, 26, 0.08);
  --radius: 18px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(10, 107, 82, 0.10), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(18, 21, 26, 0.08), transparent 50%),
    linear-gradient(165deg, var(--bg), var(--bg-deep));
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2.5rem;
  animation: rise 0.55s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.brand { display: flex; align-items: center; gap: 0.85rem; }
.brand-mark {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.85rem;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 0.95rem;
}
.brand-text { display: flex; flex-direction: column; gap: 0.1rem; }
.brand-text strong { font-size: 1.05rem; letter-spacing: -0.02em; }
.brand-text span { color: var(--muted); font-size: 0.82rem; }

.session { display: flex; align-items: center; gap: 1rem; }
.session-meta { text-align: right; }
.eyebrow {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
}
.session-meta strong { font-size: 0.95rem; }

.live-pill {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 600;
  width: 9.75rem;
  min-width: 9.75rem;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
}
.live-pill span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-pill i {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #9aa3ad;
  flex: 0 0 auto;
}
.live-pill[data-state="live"] i {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(10, 107, 82, 0.5);
  animation: pulse 1.6s ease infinite;
}
.live-pill[data-state="stale"] i { background: var(--warn); }
.live-pill[data-state="down"] i { background: #b91c1c; }

.market-pill {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.85rem;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  width: 10.75rem;
  min-width: 10.75rem;
  min-height: 2.65rem;
  box-sizing: border-box;
}
.market-pill strong {
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.market-pill span {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.market-pill[data-state="open"] {
  border-color: rgba(10, 107, 82, 0.45);
  background: rgba(10, 107, 82, 0.10);
}
.market-pill[data-state="open"] strong { color: var(--accent); }
.market-pill[data-state="closed"] {
  border-color: rgba(154, 52, 18, 0.35);
  background: rgba(154, 52, 18, 0.08);
}
.market-pill[data-state="closed"] strong { color: var(--warn); }

@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(10, 107, 82, 0); }
  100% { box-shadow: 0 0 0 0 rgba(10, 107, 82, 0); }
}

.balances {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.bal {
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  backdrop-filter: blur(8px);
}
.bal strong {
  display: block;
  margin-top: 0.35rem;
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  min-height: 1.55em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bal.clock strong {
  font-family: var(--mono);
  font-size: 1.1rem;
  min-width: 4.5rem;
}

.board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.board.board-single {
  grid-template-columns: 1fr;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  justify-items: stretch;
}

.px-card {
  appearance: none;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem 1.1rem;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.px-card:hover { transform: translateY(-2px); }
.px-card.is-selected {
  border-color: rgba(10, 107, 82, 0.55);
  box-shadow: 0 0 0 3px rgba(10, 107, 82, 0.12), var(--shadow);
}
.px-head { display: flex; flex-direction: column; gap: 0.2rem; margin-bottom: 1.1rem; }
.px-pair { font-weight: 700; font-size: 1rem; letter-spacing: -0.02em; }
.px-hint { color: var(--muted); font-size: 0.82rem; }
.px-rate {
  font-size: clamp(2rem, 5vw, 2.85rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.15;
  min-height: 1.25em;
  min-width: 8.5rem;
  transition: background-color 0.35s ease, color 0.2s ease;
  border-radius: 0.4rem;
  padding: 0.15rem 0.2rem;
  display: inline-block;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.px-rate.flash-up { background: var(--flash-up); }
.px-rate.flash-down { background: var(--flash-down); color: var(--warn); }
.px-foot {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  min-height: 1.2em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.px-card.is-selected .px-foot { color: var(--accent); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.ticket {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  padding: 1.35rem 1.4rem 1.45rem;
  box-shadow: var(--shadow);
}
.ticket-head h1 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}
.ticket-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.ticket-form {
  margin-top: 1.2rem;
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 0.9fr auto;
  gap: 0.85rem;
  align-items: end;
}
.ticket-form.ticket-form-single {
  grid-template-columns: 1.4fr 1fr auto;
}

.receive-box {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border-radius: calc(var(--radius) + 2px);
  border: 1px solid rgba(10, 107, 82, 0.28);
  background: rgba(10, 107, 82, 0.07);
}
.receive-box .eyebrow {
  margin-bottom: 0.25rem;
}
.receive-box strong {
  display: block;
  font-size: clamp(1.15rem, 2.5vw, 1.55rem);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  min-height: 1.55em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.receive-arrow {
  font-size: 1.4rem;
  color: var(--accent);
  font-weight: 700;
}

.ticket-lead { margin-bottom: 1rem; }
.board { margin-top: 0.15rem; }

.btn-exec:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field > span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}
.field select,
.field input {
  width: 100%;
  height: 3rem;
  border-radius: 0.85rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 0.9rem;
  font: 500 1rem var(--font);
}
.field select:focus,
.field input:focus {
  outline: none;
  border-color: rgba(10, 107, 82, 0.55);
  box-shadow: 0 0 0 3px rgba(10, 107, 82, 0.12);
}
.field.readonly > div {
  height: 3rem;
  min-width: 8.5rem;
  display: flex;
  align-items: center;
  padding: 0 0.9rem;
  border-radius: 0.85rem;
  background: rgba(18, 21, 26, 0.04);
  border: 1px dashed var(--line);
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}

.btn-exec {
  height: 3rem;
  min-width: 8.5rem;
  border: 0;
  border-radius: 0.85rem;
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 0.95rem var(--font);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}
.btn-exec:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-exec:active { transform: none; }
.btn-ghost {
  height: 2.2rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.65);
  color: var(--ink);
  font: 600 0.78rem var(--font);
  padding: 0 0.85rem;
  cursor: pointer;
}
.btn-ghost:hover { background: #fff; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.gate-card {
  width: min(420px, 100%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.45rem 1.5rem;
  animation: rise 0.45s ease both;
}
.gate-brand { margin-bottom: 1.2rem; }
.gate-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.gate-form .btn-exec { width: 100%; }

.ticket-note {
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}
.ticket-note.is-error { color: var(--warn); }

.foot {
  margin-top: 1.25rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 860px) {
  .balances,
  .board { grid-template-columns: 1fr; }
  .ticket-form { grid-template-columns: 1fr 1fr; }
  .btn-exec { grid-column: 1 / -1; width: 100%; }
  .session { flex-direction: column; align-items: flex-end; gap: 0.5rem; }
}

@media (max-width: 560px) {
  .top { flex-direction: column; align-items: flex-start; }
  .session { width: 100%; flex-direction: row; justify-content: space-between; align-items: center; }
  .session-meta { text-align: left; }
  .ticket-form { grid-template-columns: 1fr; }
  .foot { flex-direction: column; }
}
