/* GridForge — terminal styles.
 *
 * Палитра подсмотрена у Binance Pro (тёмная тема), типографика — Inter + JetBrains Mono.
 * Никаких градиентов, скруглений максимум 8px, бордеры 1px с приглушённым цветом.
 */

:root {
  --bg:           #0B0E11;
  --card:         #1E2329;
  --card-soft:    #181C22;
  --border:       #2B3139;
  --border-bright:#3D4452;
  --text:         #EAECEF;
  --text-dim:     #848E9C;
  --text-mute:    #5E6673;
  --green:        #02C076;
  --green-soft:   rgba(2, 192, 118, 0.12);
  --green-edge:   rgba(2, 192, 118, 0.35);
  --red:          #F6465D;
  --red-soft:     rgba(246, 70, 93, 0.12);
  --red-edge:     rgba(246, 70, 93, 0.35);
  --yellow:       #F0B90B;
  --yellow-soft:  rgba(240, 185, 11, 0.12);
  --blue:         #1E90FF;
  --shadow:       0 0 0 1px var(--border);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; }

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

/* --- утилиты --- */
.mono { font-family: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, monospace; font-feature-settings: "tnum"; }
.text-dim    { color: var(--text-dim); }
.text-mute   { color: var(--text-mute); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue   { color: var(--blue); }
.fz-12 { font-size: 12px; }
.fz-13 { font-size: 13px; }
.fz-14 { font-size: 14px; }
.fz-16 { font-size: 16px; }
.fz-20 { font-size: 20px; }
.fz-24 { font-size: 24px; }
.fz-32 { font-size: 32px; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* --- скролл --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* --- layout --- */
.app {
  max-width: 800px;
  margin: 0 auto;
  padding-left: max(env(safe-area-inset-left), 16px);
  padding-right: max(env(safe-area-inset-right), 16px);
}

.page-padding {
  padding-top: 16px;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

/* --- topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 600;
  font-size: 18px;
  color: var(--green);
  letter-spacing: -0.02em;
}
.brand .version {
  color: var(--text-mute);
  font-size: 11px;
  font-weight: 400;
  margin-left: 6px;
}
.net-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
}
.net-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-mute); }
.net-pill.testnet .dot { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.net-pill.live    .dot { background: var(--green);  box-shadow: 0 0 8px var(--green); }

/* --- bottom nav --- */
.bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav-inner {
  max-width: 800px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 64px;
}
.bottomnav button {
  background: transparent;
  border: none;
  color: var(--text-mute);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-top: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.bottomnav button:hover { color: var(--text-dim); }
.bottomnav button.active {
  color: var(--green);
  border-top-color: var(--green);
}
.bottomnav button .icon { width: 22px; height: 22px; stroke-width: 1.75; }

/* --- card --- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.card-soft {
  background: var(--card-soft);
}
.card-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 0 0 10px 0;
  font-weight: 500;
}

/* --- button --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border-bright);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  user-select: none;
}
.btn:hover { border-color: var(--text-dim); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-primary { border-color: var(--green); color: var(--green); }
.btn-primary:hover { background: var(--green-soft); border-color: var(--green); }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-ghost { border-color: var(--border); color: var(--text-dim); }
.btn-ghost:hover { border-color: var(--border-bright); color: var(--text); }

/* --- input --- */
.input, select.input {
  width: 100%;
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s;
}
.input:focus, select.input:focus {
  outline: none;
  border-color: var(--text-dim);
}
.input.mono { font-family: 'JetBrains Mono', monospace; }
.input-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  margin-bottom: 6px;
}
.input-row { margin-bottom: 12px; }
.input-hint { font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.input-error { color: var(--red); font-size: 12px; margin-top: 6px; }

/* --- price flash --- */
.flash-up   { animation: flash-up   300ms ease-out; }
.flash-down { animation: flash-down 300ms ease-out; }
@keyframes flash-up {
  0%   { color: var(--green); }
  100% { color: inherit; }
}
@keyframes flash-down {
  0%   { color: var(--red); }
  100% { color: inherit; }
}

/* --- dots --- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; }
.dot-green  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-red    { background: var(--red); }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.dot-dim    { background: var(--text-mute); }
.dot-hollow { background: transparent; border: 1px solid var(--text-mute); box-shadow: none; }

/* --- metric tiles --- */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
@media (max-width: 640px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
.metric {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
}
.metric .label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 8px;
}
.metric .value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.metric.lg .value { font-size: 28px; }

/* --- grid ladder --- */
.ladder {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.ladder-row {
  display: grid;
  grid-template-columns: 20px 1fr 1fr 90px;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.ladder-row:first-child { border-top: none; }
.ladder-row.side-buy  { background: linear-gradient(90deg, var(--green-soft) 0%, transparent 30%); }
.ladder-row.side-sell { background: linear-gradient(90deg, var(--red-soft) 0%, transparent 30%); }
.ladder-row .price   { font-weight: 500; }
.ladder-row .qty     { color: var(--text-dim); }
.ladder-row .status  { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; text-align: right; color: var(--text-mute); }
.ladder-row.active .status { color: var(--green); }
.ladder-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--card);
  border-top: 1px dashed var(--border-bright);
  border-bottom: 1px dashed var(--border-bright);
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  color: var(--yellow);
}

/* --- orders table --- */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 500;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
}
.table tr:last-child td { border-bottom: none; }
.table tr td:first-child { position: relative; }
.table tr.side-buy  td:first-child { box-shadow: inset 2px 0 0 var(--green); }
.table tr.side-sell td:first-child { box-shadow: inset 2px 0 0 var(--red); }
.table .col-side.buy  { color: var(--green); }
.table .col-side.sell { color: var(--red); }

/* --- empty state --- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-dim);
}
.empty .icon { width: 44px; height: 44px; color: var(--text-mute); margin-bottom: 16px; stroke-width: 1.5; }
.empty h2 { font-size: 18px; color: var(--text); margin: 0 0 8px 0; font-weight: 500; }
.empty p { margin: 0 0 20px 0; font-size: 13px; color: var(--text-dim); }

/* --- modal --- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade-in 150ms ease;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scale-in 150ms ease;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 500; }
.modal-head button { background: none; border: none; color: var(--text-mute); cursor: pointer; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* --- toasts --- */
.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--card);
  border: 1px solid var(--border-bright);
  border-left-width: 3px;
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 13px;
  min-width: 220px;
  max-width: 320px;
  animation: toast-in 200ms ease;
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.info    { border-left-color: var(--blue); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* --- skeleton --- */
.skeleton {
  background: linear-gradient(90deg, var(--card) 0%, var(--card-soft) 50%, var(--card) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s linear infinite;
  border-radius: 4px;
  color: transparent !important;
}
@keyframes skeleton-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* --- login screen --- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px 28px;
}
.login-brand {
  font-family: 'JetBrains Mono', monospace;
  font-size: 32px;
  font-weight: 600;
  color: var(--green);
  letter-spacing: -0.03em;
  text-align: center;
}
.login-sub {
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 6px 0 28px 0;
}
.login-status {
  text-align: center;
  margin-top: 18px;
  font-size: 11px;
  color: var(--text-mute);
}

/* --- helper: rows --- */
.row-between {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.kv {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-mute); }
.kv .v { font-family: 'JetBrains Mono', monospace; color: var(--text); }
