:root {
  color-scheme: dark;
  --bg: #05070a;
  --panel: #0b0f15;
  --panel-2: #10151d;
  --panel-3: #151a22;
  --line: #202936;
  --line-strong: #334153;
  --text: #eef4ff;
  --muted: #8e9aaa;
  --soft: #c4ccd8;
  --blue: #2da8ff;
  --blue-2: #105c96;
  --cyan: #16b9aa;
  --red: #ff5d64;
  --green: #24c378;
  --amber: #e7b642;
  --shadow: rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
  scrollbar-color: #263445 #070b11;
  scrollbar-width: thin;
}

[hidden] {
  display: none !important;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: #070b11;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid #070b11;
  border-radius: 999px;
  background: #263445;
}

*::-webkit-scrollbar-thumb:hover {
  background: #36506b;
}

html,
body {
  min-width: 1180px;
  min-height: 760px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.terminal-shell {
  display: grid;
  grid-template-rows: 64px auto minmax(0, 1fr) clamp(220px, 25vh, 320px);
  width: 100vw;
  height: 100vh;
  min-width: 1180px;
  min-height: 760px;
  background:
    radial-gradient(circle at 18% -10%, rgba(45, 168, 255, 0.14), transparent 30%),
    linear-gradient(180deg, #070a0f 0%, #05070a 100%);
}

.topbar {
  grid-row: 1;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 7, 10, 0.94);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-weight: 800;
  letter-spacing: 0;
}

.brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.brand span {
  font-size: 20px;
  white-space: nowrap;
}

.account-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.account-card {
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(21, 26, 34, 0.9), rgba(10, 14, 20, 0.9));
}

.account-card span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
}

.account-card strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  justify-content: flex-end;
  min-width: 0;
}

.top-actions .ghost-button,
.top-actions .primary-button {
  min-width: 64px;
  min-height: 36px;
  padding-inline: 12px;
}

.primary-button,
.ghost-button,
.danger-button,
.success-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 800;
  color: var(--text);
  background: transparent;
}

.primary-button {
  border-color: rgba(45, 168, 255, 0.62);
  background: linear-gradient(180deg, #2da8ff, #147ac2);
  box-shadow: 0 12px 28px rgba(45, 168, 255, 0.2);
}

.ghost-button {
  border-color: var(--line-strong);
  color: var(--soft);
  background: rgba(16, 21, 29, 0.92);
}

.ghost-button:hover {
  border-color: rgba(45, 168, 255, 0.7);
  color: var(--text);
}

.ghost-button.compact {
  min-height: 30px;
  padding: 0 11px;
  font-size: 12px;
}

.danger-button {
  border-color: rgba(255, 93, 100, 0.58);
  background: linear-gradient(180deg, rgba(255, 93, 100, 0.96), rgba(174, 45, 53, 0.96));
}

.success-button {
  border-color: rgba(36, 195, 120, 0.58);
  background: linear-gradient(180deg, rgba(36, 195, 120, 0.96), rgba(21, 126, 80, 0.96));
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-color: var(--line);
  color: var(--muted);
  background: rgba(16, 21, 29, 0.9);
}

.full {
  width: 100%;
}

.status-ribbon {
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  padding: 8px 20px;
  border-bottom: 1px solid rgba(231, 182, 66, 0.28);
  color: #ffe7a3;
  background: rgba(91, 65, 0, 0.32);
}

.status-ribbon strong {
  font-size: 13px;
}

.status-ribbon span {
  color: rgba(255, 231, 163, 0.88);
  font-size: 13px;
}

.workspace {
  grid-row: 3;
  display: grid;
  grid-template-columns: 282px minmax(620px, 1fr) 354px;
  gap: 8px;
  min-height: 0;
  padding: 8px;
}

.panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(11, 15, 21, 0.95);
  box-shadow: 0 20px 60px var(--shadow);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  display: block;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.panel-title h1,
.panel-title h2 {
  margin: 2px 0 0;
  font-size: 16px;
  line-height: 1.2;
}

.market-panel,
.order-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search-box {
  display: block;
  padding: 10px 12px 9px;
  border-bottom: 1px solid var(--line);
}

.search-box span,
.order-form label span,
.modal-form label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
  padding: 8px 10px;
  color: var(--text);
  background: #090d13;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45, 168, 255, 0.13);
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow: hidden;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.category-tabs button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  color: var(--muted);
  background: rgba(16, 21, 29, 0.84);
  white-space: nowrap;
}

.category-tabs button.is-active {
  border-color: rgba(45, 168, 255, 0.7);
  color: var(--text);
  background: rgba(45, 168, 255, 0.16);
}

.market-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.market-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(74px, auto);
  gap: 10px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(32, 41, 54, 0.78);
  padding: 8px 10px;
  color: var(--soft);
  background: transparent;
  text-align: left;
}

.market-row:hover,
.market-row.is-active {
  background: rgba(45, 168, 255, 0.1);
}

.market-row.is-active {
  box-shadow: inset 3px 0 0 var(--blue);
}

.market-name {
  min-width: 0;
}

.market-symbol {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 900;
}

.market-symbol span:last-child,
.market-desc,
.market-price > span,
.market-change {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(255, 93, 100, 0.12);
}

.market-dot.is-open {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(36, 195, 120, 0.12);
}

.market-desc,
.quote-line {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.market-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  max-width: 116px;
  min-width: 0;
  color: var(--text);
  font-weight: 900;
}

.terminal-price {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  max-width: 100%;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}

.terminal-price-lead,
.terminal-price-major {
  min-width: 0;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.terminal-price sup {
  position: relative;
  top: -0.34em;
  margin-left: 1px;
  font-size: 0.72em;
  font-weight: inherit;
  line-height: 1;
}

.market-price > .terminal-price,
.price-tape .terminal-price,
.side-button .terminal-price {
  max-width: 100%;
}

.market-change {
  font-size: 12px;
  color: var(--muted);
}

.market-change.is-up,
.positive {
  color: var(--green);
}

.market-change.is-down,
.negative {
  color: var(--red);
}

.chart-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}

.symbol-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.symbol-heading > div {
  min-width: 0;
}

.symbol-heading .market-dot {
  width: 10px;
  height: 10px;
}

.symbol-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.symbol-line strong {
  font-size: 22px;
  letter-spacing: 0;
}

.symbol-line span {
  overflow: hidden;
  color: var(--soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quote-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeframe-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.timeframe-bar button {
  min-width: 42px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(16, 21, 29, 0.82);
  font-weight: 900;
}

.timeframe-bar button.is-active {
  border-color: rgba(45, 168, 255, 0.75);
  color: var(--blue);
  background: rgba(45, 168, 255, 0.14);
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
}

.price-tape {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.price-tape div {
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid rgba(32, 41, 54, 0.9);
  border-radius: 6px;
  background: rgba(16, 21, 29, 0.62);
}

.price-tape div > span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.price-tape strong {
  display: block;
  font-size: 14px;
  line-height: 1.15;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-tape div:nth-child(5) strong {
  font-size: 12px;
}

.chart-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
}

.chart-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.chart-meta span {
  min-height: 24px;
  border: 1px solid rgba(32, 41, 54, 0.88);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(16, 21, 29, 0.58);
}

.chart-meta .is-stale {
  color: var(--amber);
}

.chart-canvas-wrap {
  position: relative;
  min-height: 0;
  background: #010304;
}

#chartCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-empty {
  position: absolute;
  inset: 50% auto auto 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translate(-50%, -50%);
  color: var(--muted);
}

.chart-empty strong {
  color: var(--soft);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  background: rgba(16, 21, 29, 0.9);
}

.pill.is-open {
  border-color: rgba(36, 195, 120, 0.36);
  color: var(--green);
  background: rgba(36, 195, 120, 0.12);
}

.side-quotes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.side-button {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--text);
  background: rgba(16, 21, 29, 0.88);
  text-align: left;
}

.side-button > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.side-button strong {
  display: block;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.side-button.sell:hover,
.side-button.sell.is-selected {
  border-color: rgba(255, 93, 100, 0.7);
  background: rgba(255, 93, 100, 0.12);
}

.side-button.buy:hover,
.side-button.buy.is-selected {
  border-color: rgba(36, 195, 120, 0.7);
  background: rgba(36, 195, 120, 0.12);
}

.order-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow: auto;
  padding: 9px 12px 12px;
}

.stepper {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  gap: 8px;
  align-items: end;
}

.stepper button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--blue);
  background: rgba(16, 21, 29, 0.9);
  font-size: 22px;
  font-weight: 900;
}

.quick-volumes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.quick-volumes button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--soft);
  background: rgba(16, 21, 29, 0.84);
  font-weight: 800;
}

.quick-volumes button:hover {
  border-color: rgba(45, 168, 255, 0.65);
  color: var(--blue);
}

.pending-fields,
.tp-sl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ticket-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(16, 21, 29, 0.76);
}

.ticket-meta strong {
  color: var(--text);
}

.ticket-note {
  min-height: 16px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.submit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.bottom-dock {
  grid-row: 4;
  display: grid;
  grid-template-rows: 38px 1fr;
  min-height: 0;
  margin: 0 8px 8px;
  overflow: hidden;
}

.dock-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px 0;
  border-bottom: 1px solid var(--line);
}

.dock-tabs button {
  align-self: stretch;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  padding: 0 16px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.dock-tabs button.is-active {
  border-color: var(--line);
  color: var(--text);
  background: rgba(16, 21, 29, 0.92);
}

.dock-content,
.data-panel {
  min-height: 0;
}

.dock-content {
  overflow: hidden;
}

.data-panel {
  display: none;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}

.data-panel.is-active {
  display: block;
}

table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  border-bottom: 1px solid rgba(32, 41, 54, 0.74);
  padding: 7px 9px;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  background: #0b0f15;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  color: var(--soft);
}

td strong {
  color: var(--text);
}

.table-actions {
  display: flex;
  gap: 6px;
}

.mini-button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 9px;
  color: var(--soft);
  background: rgba(16, 21, 29, 0.9);
}

.mini-button:hover {
  border-color: rgba(45, 168, 255, 0.7);
  color: var(--text);
}

.empty-row {
  padding: 24px 10px;
  color: var(--muted);
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(10px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(520px, calc(100vw - 56px));
  max-height: min(820px, calc(100vh - 56px));
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: linear-gradient(180deg, #111720, #090d13);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.62);
}

.auth-modal {
  width: min(760px, calc(100vw - 56px));
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: rgba(16, 21, 29, 0.92);
  font-size: 22px;
  line-height: 1;
}

.modal-head {
  padding: 22px 24px 12px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 4px 0 0;
  font-size: 22px;
}

.switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 16px 24px 0;
}

.switcher button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(16, 21, 29, 0.8);
  font-weight: 900;
}

.switcher button.is-active {
  border-color: rgba(45, 168, 255, 0.7);
  color: var(--blue);
  background: rgba(45, 168, 255, 0.13);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 24px 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.balance-hero {
  padding: 14px;
  border: 1px solid rgba(45, 168, 255, 0.26);
  border-radius: 8px;
  background: rgba(45, 168, 255, 0.1);
}

.balance-hero span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.balance-hero strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 24px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.success-message {
  margin: 0;
  border: 1px solid rgba(36, 195, 120, 0.25);
  border-radius: 6px;
  padding: 10px;
  color: var(--green);
  background: rgba(36, 195, 120, 0.11);
  font-weight: 800;
}

.toast-stack {
  position: fixed;
  top: 76px;
  right: 18px;
  bottom: auto;
  z-index: 120;
  display: grid;
  gap: 10px;
  width: 320px;
  pointer-events: none;
}

.toast {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(14, 19, 27, 0.98);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.toast strong {
  display: block;
  margin-bottom: 4px;
}

.toast span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.toast.is-error {
  border-color: rgba(255, 93, 100, 0.4);
}

.toast.is-success {
  border-color: rgba(36, 195, 120, 0.4);
}

@media (max-width: 1440px) {
  .chart-meta {
    display: none;
  }
}

@media (max-width: 1360px) {
  .topbar {
    grid-template-columns: 204px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .workspace {
    grid-template-columns: 260px minmax(500px, 1fr) 318px;
  }

  .account-strip {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .price-tape {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .brand span {
    font-size: 18px;
  }
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: 248px minmax(520px, 1fr) 300px;
  }

  .panel-title {
    padding-inline: 10px;
  }

  .chart-actions .ghost-button.compact {
    min-width: 34px;
    padding-inline: 9px;
  }

  .chart-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .chart-actions {
    justify-content: flex-end;
  }

  .price-tape {
    flex: 0 0 auto;
  }

  .side-button strong {
    font-size: 18px;
  }

  .quick-volumes {
    gap: 6px;
  }

  .toast-stack {
    width: 300px;
  }
}
