/* Terminal layout. Financial actions and account tables share the same DOM
   at every width; phone navigation changes presentation only. */
.account-icon {
  display: none;
}
.account-button .account-name {
  margin: 0;
  color: var(--text);
}
.terminal-mobile-nav {
  display: none;
}
.terminal-grid {
  grid-template-columns: 184px minmax(0, 1fr) 286px;
  min-height: 520px;
}
.terminal-grid > * {
  min-width: 0;
}
.watchlist {
  padding: 16px 0;
}
.watch-item {
  min-height: 51px;
  padding: 9px 14px;
}
.watch-item.active {
  padding-left: 13px;
}
.watch-foot {
  padding: 16px 14px 0;
}
.chart-tools select {
  min-width: 0;
  max-width: 180px;
}
.chart-tools #indicator {
  flex: 1;
}
.chart-wrap {
  min-height: 300px;
}
.order-panel {
  padding: 18px;
}
.order-panel h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}
#order-symbol {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.order-panel form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.order-kind,
#limit-price-label,
.order-panel .two-col,
.order-panel .order-estimate,
.order-panel .trade-buttons,
.order-panel .form-error {
  grid-column: 1 / -1;
}
.order-panel label {
  min-width: 0;
  font-size: 11px;
}
.order-panel input,
.order-panel select {
  min-height: 44px;
}
.order-estimate {
  gap: 8px;
}
.order-notice {
  font-size: 10px;
}
.book-section {
  min-height: 170px;
}
.book-tabs {
  scrollbar-gutter: stable;
}
.topbar {
  min-height: 64px;
}
.topnav {
  height: 64px;
}
.account-strip {
  min-height: 78px;
  padding-top: 16px;
  padding-bottom: 16px;
}

/* Medium windows keep a useful chart width. The instrument rail moves above it. */
@media (min-width: 701px) and (max-width: 1100px) {
  .terminal-grid {
    grid-template-columns: minmax(0, 1fr) 278px;
  }
  .watchlist {
    grid-column: 1 / -1;
    display: flex;
    overflow-x: auto;
    padding: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .watchlist .section-label,
  .watch-foot {
    display: none;
  }
  .watch-item {
    flex: 0 0 140px;
    min-width: 140px;
    min-height: 60px;
    padding: 10px 12px;
  }
  .watch-item.active {
    border-left: 0;
    border-bottom: 2px solid var(--accent);
    padding-left: 12px;
  }
  .chart-section {
    min-height: 470px;
  }
  .account-strip {
    gap: 22px;
    overflow: visible;
  }
  .metric {
    min-width: 0;
  }
  .metric strong {
    font-size: 17px;
  }
  .metric small {
    font-size: 10px;
    white-space: normal;
  }
  .feed-status {
    display: grid;
  }
}

/* Phones get complete task views instead of three compressed desktop columns. */
@media (max-width: 700px) {
  .topbar {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 0 8px;
    padding: max(8px, env(safe-area-inset-top)) 12px 0;
  }
  .topbar .brand {
    font-size: 14px;
    gap: 6px;
  }
  .topbar .brand img {
    width: 26px;
    height: 26px;
  }
  .topbar .brand-light {
    display: none;
  }
  .demo-label {
    font-size: 8px;
    padding: 5px;
  }
  .top-actions {
    justify-self: end;
    margin: 0;
    gap: 4px;
  }
  .reward-button {
    min-height: 44px;
    padding: 8px 10px;
    font-size: 11px;
    white-space: nowrap;
  }
  .account-button {
    width: 44px;
    height: 44px;
    padding: 11px;
  }
  .account-button .account-name {
    display: none;
  }
  .account-icon {
    display: block;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
  }
  .topnav {
    grid-column: 1 / -1;
    height: 44px;
    margin: 0;
    gap: 24px;
  }
  .topnav a {
    min-height: 44px;
    font-size: 12px;
  }
  #main[data-mobile-view] {
    padding-bottom: 0;
  }
  .account-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 13px 10px;
    padding: 14px 16px;
    overflow: visible;
  }
  .metric {
    min-width: 0;
    gap: 6px;
  }
  .metric:first-child {
    grid-column: 1;
  }
  .metric:nth-child(2) {
    grid-column: 2;
  }
  .metric:nth-child(3) {
    grid-column: 3;
  }
  .metric small {
    white-space: normal;
    font-size: 10px;
    line-height: 1.3;
  }
  .metric strong {
    font-size: 17px;
    overflow-wrap: anywhere;
  }
  .metric:nth-child(n + 4) strong {
    font-size: 14px;
  }
  .feed-status {
    display: grid;
    grid-column: 3;
    margin: 0;
    text-align: left;
    gap: 5px;
    align-self: end;
    font-size: 9px;
  }
  .feed-status strong {
    font-size: 10px;
    line-height: 1.4;
  }
  .terminal-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }
  .watchlist {
    display: flex;
    grid-column: 1;
    padding: 0;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .watchlist .section-label,
  .watch-foot {
    display: none;
  }
  .watch-item {
    flex: 0 0 140px;
    min-width: 140px;
    min-height: 60px;
    padding: 10px 12px;
  }
  .watch-item.active {
    border-left: 0;
    border-bottom: 2px solid var(--accent);
    padding-left: 12px;
  }
  .chart-section {
    min-height: 420px;
  }
  .chart-heading {
    padding: 16px 16px 10px;
  }
  .chart-heading h1 {
    font-size: 20px;
  }
  .chart-last {
    font-size: 23px;
  }
  .chart-tools {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr) 60px 44px;
    gap: 2px;
    padding: 4px 10px 8px;
  }
  .chart-tools select {
    max-width: 100%;
    width: 100%;
    min-height: 44px;
    font-size: 11px;
    padding: 7px 5px;
  }
  .chart-tools button {
    min-height: 44px;
    font-size: 11px;
  }
  #chart-fit {
    grid-column: 4;
    grid-row: 1;
  }
  #chart-undo {
    grid-column: 5;
    grid-row: 1;
  }
  .chart-wrap {
    min-height: max(250px, calc(100svh - 540px));
  }
  .chart-credit {
    font-size: 9px;
    gap: 8px;
  }
  .order-panel {
    border-left: 0;
    border-top: 0;
    padding: 20px 16px;
  }
  .order-panel h2 {
    font-size: 19px;
    margin-bottom: 20px;
  }
  #order-symbol {
    font-size: 13px;
  }
  .order-panel input,
  .order-panel select {
    font-size: 16px;
    min-height: 48px;
  }
  .order-panel label {
    font-size: 12px;
  }
  .order-estimate {
    grid-template-columns: 1fr;
    gap: 11px;
    padding-top: 16px;
  }
  .order-estimate div {
    font-size: 12px;
  }
  .trade-buttons button {
    min-height: 58px;
    font-size: 16px;
  }
  .trade-buttons small {
    font-size: 12px;
  }
  .order-notice {
    font-size: 11px;
  }
  .book-section {
    min-height: 280px;
    padding: 0 16px 20px;
  }
  .book-tabs {
    flex-wrap: wrap;
    gap: 0 20px;
    overflow: visible;
  }
  .book-tabs button {
    font-size: 12px;
    min-height: 48px;
  }
  .book-tabs .export {
    margin-left: 0;
    min-height: 44px;
    font-size: 11px;
  }
  [data-mobile-view="chart"] .order-panel,
  [data-mobile-view="chart"] .book-section,
  [data-mobile-view="trade"] .chart-section,
  [data-mobile-view="trade"] .book-section,
  [data-mobile-view="history"] .terminal-grid {
    display: none;
  }
  .terminal-mobile-nav {
    position: fixed;
    z-index: 15;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 6px 12px max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--panel);
  }
  .terminal-mobile-nav button {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 9px;
    min-height: 48px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
  }
  .terminal-mobile-nav button[aria-pressed="true"] {
    color: var(--accent-ink);
    background: var(--accent);
  }
  .terminal-mobile-nav svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  body:has(.terminal-mobile-nav) > #app .footer {
    padding-bottom: 90px;
  }
}
