/* ================================================================
   Crypto Trading Assistant — GUI stil faylı (Modul M)
   Tünd, sıx, terminal estetikası. Rəng = MƏLUMAT, bəzək deyil:
     yaşıl = READY / qazanc, sarı = WAIT, qırmızı = NO_TRADE / zərər.
   Kənar font və CDN yoxdur — yalnız sistem şriftləri.
   ================================================================ */

:root {
  /* Fon qatları */
  --bg:        #07090c;
  --bg-soft:   #0b0e13;
  --panel:     #0f1319;
  --panel-2:   #141923;
  --panel-3:   #1a2029;

  /* Xətlər */
  --line:      #1c222c;
  --line-2:    #2a323f;

  /* Mətn */
  --txt:       #d8dee8;
  --txt-2:     #8b96a6;
  --txt-3:     #5b6472;

  /* Vahid aksent (yalnız interaktivlik üçün) */
  --accent:    #4d8dfa;
  --accent-dim: rgba(77, 141, 250, 0.16);

  /* Semantik rənglər (yalnız məna daşıyanda) */
  --green:     #2fbe77;
  --green-dim: rgba(47, 190, 119, 0.15);
  --amber:     #e0a53a;
  --amber-dim: rgba(224, 165, 58, 0.15);
  --red:       #e5544b;
  --red-dim:   rgba(229, 84, 75, 0.15);

  --radius:    8px;
  --radius-sm: 5px;

  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  --topbar-h: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
}

body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  padding-bottom: 24px;
  min-height: 100vh;
}

h1, h2, h3, h4, p, ul, ol { margin: 0; }
ul { list-style: none; padding: 0; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* `hidden` atributu HƏMİŞƏ qalib gəlməlidir: aşağıdakı .drawer / .chart-empty
   kimi qaydalar display təyin etdiyi üçün brauzerin öz [hidden] qaydasını əzir. */
[hidden] { display: none !important; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 0 0 var(--radius) 0;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* Fokus — hər yerdə görünən */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Rəng köməkçiləri */
.c-green { color: var(--green); }
.c-red   { color: var(--red); }
.c-amber { color: var(--amber); }
.c-muted { color: var(--txt-2); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.flat { color: var(--txt-2); }
.ta-r { text-align: right; }

/* Dəyişiklik parıltısı — canlı yeniləmədə göz itirməsin */
@keyframes flashNeutral { from { background-color: rgba(120, 140, 170, 0.28); } to { background-color: transparent; } }
@keyframes flashUp      { from { background-color: rgba(47, 190, 119, 0.30); }  to { background-color: transparent; } }
@keyframes flashDown    { from { background-color: rgba(229, 84, 75, 0.30); }   to { background-color: transparent; } }
.flash      { animation: flashNeutral 0.85s ease-out; }
.flash-up   { animation: flashUp 0.85s ease-out; }
.flash-down { animation: flashDown 0.85s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .flash, .flash-up, .flash-down { animation: none; }
  * { transition: none !important; }
}

/* ================================ TOPBAR ================================ */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 14px;
  background: rgba(9, 12, 16, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark {
  width: 10px; height: 10px; border-radius: 2px; flex: none;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(77, 141, 250, 0.7);
}
.brand-name {
  font-size: 12px; font-weight: 650; letter-spacing: 0.09em;
  color: var(--txt); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.mode-badge {
  flex: none;
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  padding: 3px 8px; border-radius: 3px;
  border: 1px solid var(--line-2); color: var(--txt-2); background: var(--panel-2);
}
.mode-badge[data-mode="PAPER"] { color: var(--accent); border-color: rgba(77,141,250,.45); background: var(--accent-dim); }
.mode-badge[data-mode="LIVE"]  { color: #fff; border-color: var(--red); background: var(--red); animation: livePulse 1.8s ease-in-out infinite; }
@keyframes livePulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,84,75,.6);} 50% { box-shadow: 0 0 0 6px rgba(229,84,75,0);} }
.mode-badge-lg { font-size: 12px; padding: 4px 12px; }

/* Kitab nişanı: bu serverin xidmət etdiyi variant (A1..C3) */
.book-badge {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  padding: 3px 8px; border-radius: 3px;
  border: 1px solid var(--line-2); background: var(--panel-2);
  cursor: help;
}
.book-badge .book-id { font-weight: 700; color: var(--txt); }
.book-badge .book-label { color: var(--txt-2); }
@media (max-width: 720px) { .book-badge .book-label { display: none; } }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.conn {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--txt-2);
  padding: 3px 8px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--panel);
}
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--txt-3); flex: none; }
.conn[data-state="live"]        .conn-dot { background: var(--green); box-shadow: 0 0 7px var(--green); }
.conn[data-state="connecting"]  .conn-dot { background: var(--amber); animation: blink 1s steps(2, start) infinite; }
.conn[data-state="offline"]     .conn-dot { background: var(--red); }
.conn[data-state="live"]        .conn-text { color: var(--green); }
.conn[data-state="connecting"]  .conn-text { color: var(--amber); }
.conn[data-state="offline"]     .conn-text { color: var(--red); }
@keyframes blink { to { opacity: 0.25; } }
.conn-age { font-family: var(--mono); color: var(--txt-3); min-width: 30px; text-align: right; }
.conn.is-late .conn-age { color: var(--amber); }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn {
  background: transparent; border: 0; cursor: pointer;
  padding: 4px 10px; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  color: var(--txt-2); transition: background .12s, color .12s;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--line-2); }
.seg-btn:hover { background: var(--panel-2); color: var(--txt); }
.seg-btn.is-on { background: var(--accent-dim); color: var(--accent); }

.icon-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--txt-2);
  width: 30px; height: 30px; border-radius: var(--radius-sm); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; transition: background .12s, color .12s, border-color .12s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--txt); border-color: var(--line-2); }
.icon-btn-sm { width: 24px; height: 24px; font-size: 12px; }
.icon-btn[data-busy="1"] { opacity: .5; pointer-events: none; }

/* ================================ LAYOUT ================================ */
.layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
  max-width: 1900px;
  margin: 0 auto;
  align-items: start;
}

/* İki müstəqil sütun: sol (watchlist+trade) sağ sütunun hündürlüyünə bağlı
   deyil — əks halda watchlist-in altında böyük boşluq qalırdı. */
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel-overview { grid-column: span 12; }
.col-main       { grid-column: span 7; }
.col-side       { grid-column: span 5; }
.panel-stats    { grid-column: span 12; }

@media (max-width: 1240px) {
  .col-main, .col-side { grid-column: span 12; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  min-height: 38px;
}
.panel-title {
  font-size: 11px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase;
  color: var(--txt-2);
}
.panel-sub { font-size: 11px; color: var(--txt-3); }
.panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.panel-body { padding: 12px; }
.panel-body-flush { padding: 0; }

.sub-title {
  font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase;
  color: var(--txt-3); margin: 16px 0 7px;
}
.sub-title-sm { margin-top: 10px; }
.panel-body > .sub-title:first-child { margin-top: 0; }

.hint { font-size: 11px; color: var(--txt-3); margin-top: 8px; }
.empty { font-size: 12px; color: var(--txt-3); padding: 14px 12px; text-align: center; }

/* ================================ FORM ================================ */
.input {
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  color: var(--txt);
  width: 100%;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  transition: border-color .12s, background .12s;
}
.input:hover { border-color: #38404f; }
.input:focus { border-color: var(--accent); background: #0d1219; outline: none; box-shadow: 0 0 0 2px var(--accent-dim); }
.input-sm { width: 150px; padding: 4px 8px; }
input[type="search"] { -webkit-appearance: none; appearance: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--txt);
  padding: 7px 14px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: var(--panel-3); border-color: #38404f; }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn-sm { padding: 5px 11px; font-size: 11px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #5f9bff; border-color: #5f9bff; }
.btn-ghost { background: transparent; }
.btn-danger-ghost { background: transparent; border-color: rgba(229,84,75,.45); color: var(--red); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--red-dim); }
.btn[data-busy="1"] { pointer-events: none; opacity: .7; }
.btn[data-busy="1"]::before {
  content: ""; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 12px; color: var(--txt-2); }
.check input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; flex: none; }
.check:hover { color: var(--txt); }
.check-sm { font-size: 11px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--txt-3); }
.field-btn { justify-content: flex-end; }

.row-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-inline .input { flex: 1 1 160px; }
.row-inline-tight { margin-bottom: 10px; }

/* ================================ TILES ================================ */
.tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.tile {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.tile-label { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--txt-3); }
.tile-value { font-size: 15px; font-weight: 600; color: var(--txt); overflow: hidden; text-overflow: ellipsis; }
.tile-hero .tile-value { font-size: 19px; font-family: var(--mono); }
.tile-delta { font-size: 12px; font-family: var(--mono); }
.tile-row-stats .tile-value { font-size: 17px; font-family: var(--mono); }

.reason-line {
  margin-top: 10px; font-size: 12px; color: var(--txt-2);
  border-left: 2px solid var(--line-2); padding-left: 9px;
}

.health-strip, .risk-strip, .stat-mini {
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line);
  font-size: 11px;
}
.risk-strip, .stat-mini { margin-top: 14px; }
.health-item { display: inline-flex; align-items: baseline; gap: 6px; }
.health-item b { font-weight: 500; color: var(--txt-3); text-transform: uppercase; letter-spacing: .05em; font-size: 10px; }
.health-item i { font-style: normal; color: var(--txt); }
.health-errors { margin-top: 8px; font-size: 11px; color: var(--red); word-break: break-word; }

/* ================================ TABLES ================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th {
  position: sticky; top: 0; z-index: 2;
  background: var(--panel-2);
  font-size: 10px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--txt-3); text-align: left;
  padding: 7px 10px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.tbl td { padding: 7px 10px; border-bottom: 1px solid rgba(28,34,44,.7); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl-watchlist thead th[data-sort] { cursor: pointer; user-select: none; }
.tbl-watchlist thead th[data-sort]:hover { color: var(--txt); background: var(--panel-3); }
.sort-ind { display: inline-block; width: 9px; margin-left: 4px; color: var(--accent); font-style: normal; }
.tbl-watchlist thead th[aria-sort="ascending"]  .sort-ind::after { content: "▲"; font-size: 8px; }
.tbl-watchlist thead th[aria-sort="descending"] .sort-ind::after { content: "▼"; font-size: 8px; }

.tbl-watchlist tbody tr { cursor: pointer; transition: background .1s; }
.tbl-watchlist tbody tr:hover { background: var(--panel-2); }
.tbl-watchlist tbody tr.is-selected { background: var(--accent-dim); box-shadow: inset 2px 0 0 var(--accent); }
.tbl-watchlist tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.wl-sym { font-weight: 600; font-family: var(--mono); }
.wl-sym small { color: var(--txt-3); font-weight: 400; }

.tbl-tf td, .tbl-break td { color: var(--txt-2); }
.tbl-tf .tf-name { font-family: var(--mono); color: var(--txt); font-weight: 600; }
.tf-table-wrap { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); }

.panel-watchlist .table-wrap { max-height: 460px; overflow-y: auto; }

/* Status pill */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  font-family: var(--mono);
  border: 1px solid var(--line-2); color: var(--txt-2); background: var(--panel-2);
}
.pill-muted { color: var(--txt-3); }
.pill[data-status="READY"]    { color: var(--green); border-color: rgba(47,190,119,.45); background: var(--green-dim); }
.pill[data-status="WAIT"]     { color: var(--amber); border-color: rgba(224,165,58,.45); background: var(--amber-dim); }
.pill[data-status="NO_TRADE"] { color: var(--red);   border-color: rgba(229,84,75,.4);   background: var(--red-dim); }
.pill-stale { color: var(--amber); border-color: rgba(224,165,58,.5); background: var(--amber-dim); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--panel-2);
  font-size: 11px; color: var(--txt-2);
}
.chip b { font-weight: 500; color: var(--txt-3); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.chip i { font-style: normal; color: var(--txt); }
.chip[data-side="LONG"]  { color: var(--green); border-color: rgba(47,190,119,.35); }
.chip[data-side="SHORT"] { color: var(--red);   border-color: rgba(229,84,75,.35); }

/* ================================ DETAIL ================================ */
.detail-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.detail-symbol { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.d-sym { font-size: 17px; font-weight: 700; font-family: var(--mono); letter-spacing: .02em; }
.d-price { font-size: 15px; color: var(--txt-2); }
.detail-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Qiymət nərdivanı */
.ladder { margin-top: 14px; }
.ladder-track {
  position: relative; height: 26px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.lad-zone { position: absolute; top: 0; bottom: 0; }
.lad-risk   { background: linear-gradient(90deg, rgba(229,84,75,.22), rgba(229,84,75,.07)); }
.lad-reward { background: linear-gradient(90deg, rgba(47,190,119,.07), rgba(47,190,119,.22)); }
.lad-tick { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; }
.lad-tick.t-sl  { background: var(--red); }
.lad-tick.t-e1  { background: var(--accent); }
.lad-tick.t-e2  { background: rgba(77,141,250,.55); }
.lad-tick.t-tp1 { background: rgba(47,190,119,.65); }
.lad-tick.t-tp2 { background: var(--green); }
.lad-price {
  position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px;
  background: #fff; box-shadow: 0 0 8px rgba(255,255,255,.55);
  transition: left .35s ease;
}
.lad-price-label {
  position: absolute; top: -1px; left: 50%; transform: translateX(-50%);
  font-size: 10px; background: #fff; color: #07090c; padding: 0 4px;
  border-radius: 2px; white-space: nowrap; font-weight: 700;
}
.ladder-ends { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: 10px; }
.lad-mid { color: var(--txt-3); letter-spacing: .05em; text-transform: uppercase; }

.levels {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; margin-top: 12px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden;
}
.lvl { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 9px; background: var(--panel); }
.lvl-k { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--txt-3); }
.lvl-v { font-size: 12px; color: var(--txt); }
.lvl-risk .lvl-v { color: var(--red); }
.lvl-rew .lvl-v  { color: var(--green); }
.dot { width: 7px; height: 2px; border-radius: 1px; display: inline-block; flex: none; }
.d-sl { background: var(--red); } .d-e1 { background: var(--accent); }
.d-e2 { background: rgba(77,141,250,.55); } .d-avg { background: #fff; }
.d-tp1 { background: rgba(47,190,119,.65); } .d-tp2 { background: var(--green); }

.mini-row { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; font-size: 11px; }
.mini { display: inline-flex; gap: 6px; align-items: baseline; min-width: 0; }
.mini b { font-weight: 500; color: var(--txt-3); text-transform: uppercase; letter-spacing: .05em; font-size: 10px; }
.mini i { font-style: normal; color: var(--txt-2); }

.score-head { display: flex; align-items: baseline; gap: 8px; }
.score-total { font-size: 20px; font-weight: 700; font-family: var(--mono); }
.score-req { font-size: 11px; color: var(--txt-3); }

.score-list { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.score-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  padding: 6px 9px; background: var(--panel-2); border: 1px solid var(--line);
  border-left-width: 2px; border-radius: var(--radius-sm);
}
.score-item.is-pos { border-left-color: var(--green); }
.score-item.is-neg { border-left-color: var(--red); }
.score-item.is-zero { border-left-color: var(--line-2); }
.score-name { font-size: 12px; color: var(--txt); }
.score-pts { font-family: var(--mono); font-size: 12px; font-weight: 700; white-space: nowrap; }
.score-detail { grid-column: 1 / -1; font-size: 11px; color: var(--txt-3); }

.tf-list { display: flex; flex-direction: column; gap: 4px; }
.tf-row { display: flex; gap: 9px; align-items: baseline; }
.tf-k {
  flex: none; width: 34px; font-family: var(--mono); font-size: 10px; font-weight: 700;
  color: var(--txt-3); letter-spacing: .06em;
}
.tf-v { font-size: 12px; color: var(--txt-2); }

.blocker-list { display: flex; flex-direction: column; gap: 4px; }
.blocker-list li {
  font-size: 12px; color: var(--txt-2);
  padding: 5px 9px; background: var(--amber-dim);
  border-left: 2px solid var(--amber); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.expl { font-size: 12.5px; color: var(--txt); line-height: 1.6; }
.bullets { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.bullets li { font-size: 12px; color: var(--txt-2); padding-left: 14px; position: relative; }
.bullets li::before { content: "▸"; position: absolute; left: 0; color: var(--accent); }

/* ================================ TRADE ================================ */
.trade-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; align-items: end;
}
.calc-row, .flow-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px; margin-top: 12px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden;
}
.calc { display: flex; flex-direction: column; gap: 2px; padding: 7px 10px; background: var(--panel-2); min-width: 0; }
.calc-k { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--txt-3); }
.calc-v { font-size: 13px; color: var(--txt); overflow: hidden; text-overflow: ellipsis; }

.exec-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.btn-exec { min-width: 150px; padding: 9px 18px; font-size: 13px; letter-spacing: .04em; }
.btn-exec:not(:disabled) { background: var(--green); border-color: var(--green); color: #04150c; }
.btn-exec:not(:disabled):hover { background: #3ad285; border-color: #3ad285; }
.exec-hint { font-size: 11px; color: var(--txt-3); flex: 1 1 200px; }

.ctrl-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.trade-side-LONG  { color: var(--green); }
.trade-side-SHORT { color: var(--red); }
.state-cell { font-family: var(--mono); font-size: 11px; color: var(--txt-2); }

/* ================================ ORDER FLOW ================================ */
.imb-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--txt-3); }
.imb-val { font-size: 14px; font-weight: 700; color: var(--txt); }
.imb-bar {
  display: flex; align-items: stretch; height: 22px; margin-top: 5px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; position: relative;
}
.imb-half { flex: 1 1 50%; display: flex; min-width: 0; }
.imb-left { justify-content: flex-end; }
.imb-right { justify-content: flex-start; }
.imb-fill { width: 0%; transition: width .3s ease; }
.imb-fill-neg { background: linear-gradient(90deg, rgba(229,84,75,.25), var(--red)); }
.imb-fill-pos { background: linear-gradient(90deg, var(--green), rgba(47,190,119,.25)); }
.imb-axis { width: 1px; background: var(--line-2); flex: none; }

/* ================================ STATS ================================ */
.banner {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--txt-2);
  margin-bottom: 12px;
}
.banner-warn { border-color: rgba(224,165,58,.5); background: var(--amber-dim); color: #f0c876; }
.banner-warn::before { content: "!"; font-weight: 800; color: var(--amber); flex: none; }
.banner-ok { border-color: rgba(47,190,119,.45); background: var(--green-dim); color: #7fdcac; }
.banner-ok::before { content: "✓"; font-weight: 800; color: var(--green); flex: none; }

.chart-box { position: relative; height: 190px; margin-top: 4px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.chart-box canvas { display: block; width: 100%; height: 100%; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--txt-3); }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }

/* ================================ DRAWER (Settings) ================================ */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 90; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 100;
  width: min(460px, 100vw);
  background: var(--panel); border-left: 1px solid var(--line-2);
  display: flex; flex-direction: column;
  box-shadow: -18px 0 44px rgba(0,0,0,.55);
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--line); flex: none;
  background: var(--panel-2);
}
.drawer-body { padding: 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; }
.set-block { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.set-block:last-child { border-bottom: 0; margin-bottom: 0; }
.set-block > .sub-title:first-child { margin-top: 0; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 10px; }
.toggle-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }

.live-box {
  display: flex; flex-direction: column; gap: 4px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--panel-2); margin-bottom: 9px;
}
.live-box[data-state="blocked"] { border-color: rgba(229,84,75,.45); background: var(--red-dim); }
.live-box[data-state="allowed"] { border-color: rgba(47,190,119,.45); background: var(--green-dim); }
.live-flag { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .06em; }
.live-box[data-state="blocked"] .live-flag { color: var(--red); }
.live-box[data-state="allowed"] .live-flag { color: var(--green); }
.live-reason { font-size: 11.5px; color: var(--txt-2); word-break: break-word; }

.coin-groups { display: flex; flex-direction: column; gap: 10px; }
.coin-group { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.coin-group-head {
  padding: 5px 9px; background: var(--panel-2); font-size: 10px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--txt-3);
  display: flex; justify-content: space-between; gap: 8px;
}
.coin-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 2px 8px; padding: 8px 9px; }
.coin-list .check { font-family: var(--mono); font-size: 11px; }
.coin-list .check.is-active span { color: var(--txt); }
.coin-list .check .tag-dyn { color: var(--accent); font-size: 9px; letter-spacing: .05em; }

.reject-list { display: flex; flex-direction: column; gap: 3px; }
.reject-list li { font-size: 11px; color: var(--txt-3); font-family: var(--mono); }
.reject-list li b { color: var(--txt-2); font-weight: 600; }

.tg-box { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.tg-detail { font-size: 11.5px; color: var(--txt-2); }

.kv-list { display: flex; flex-direction: column; gap: 3px; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--txt-3); }
.kv span:last-child { color: var(--txt); font-family: var(--mono); }

/* ================================ TOASTS ================================ */
.toasts {
  position: fixed; right: 12px; bottom: 12px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  width: min(360px, calc(100vw - 24px));
}
.toast {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 11px; border-radius: var(--radius-sm);
  background: var(--panel-3); border: 1px solid var(--line-2);
  box-shadow: 0 10px 26px rgba(0,0,0,.5);
  font-size: 12px; color: var(--txt);
  animation: toastIn .18s ease-out;
}
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.is-out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-info    { border-left: 3px solid var(--accent); }
.toast-msg { flex: 1 1 auto; word-break: break-word; }
.toast-close {
  flex: none; background: transparent; border: 0; color: var(--txt-3);
  cursor: pointer; font-size: 13px; line-height: 1; padding: 0 2px;
}
.toast-close:hover { color: var(--txt); }

/* ================================ MOBİL ================================ */
@media (max-width: 720px) {
  body { font-size: 13px; }
  .layout { padding: 8px; gap: 8px; }
  .col { gap: 8px; }
  .panel-body { padding: 10px; }
  .brand-name { display: none; }
  .conn-text { display: none; }
  .topbar { padding: 0 10px; gap: 8px; }
  .chart-box { height: 160px; }
  .panel-watchlist .table-wrap { max-height: none; overflow-y: visible; }
  .input-sm { width: 100%; }
  .panel-tools { width: 100%; }
  .panel-head { flex-wrap: wrap; }

  /* Watchlist -> kart görünüşü */
  .tbl-watchlist { display: block; }
  .tbl-watchlist thead { display: none; }
  .tbl-watchlist tbody { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
  .tbl-watchlist tbody tr {
    display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--panel-2); padding: 8px 10px;
  }
  .tbl-watchlist tbody tr.is-selected { box-shadow: inset 0 0 0 1px var(--accent); }
  .tbl-watchlist td { border: 0; padding: 1px 0; white-space: nowrap; display: flex; align-items: baseline; gap: 6px; }
  .tbl-watchlist td::before {
    content: attr(data-label); font-size: 9px; letter-spacing: .06em;
    text-transform: uppercase; color: var(--txt-3); flex: none;
  }
  .tbl-watchlist td[data-col="symbol"] { grid-column: 1; grid-row: 1; font-size: 14px; }
  .tbl-watchlist td[data-col="symbol"]::before { content: none; }
  .tbl-watchlist td[data-col="status"] { grid-column: 2; grid-row: 1; justify-content: flex-end; }
  .tbl-watchlist td[data-col="status"]::before { content: none; }
  .tbl-watchlist td[data-col="score"]  { grid-column: 1; grid-row: 2; }
  .tbl-watchlist td[data-col="conf"]   { grid-column: 2; grid-row: 2; justify-content: flex-end; }
  .tbl-watchlist td[data-col="trend"]  { grid-column: 1; grid-row: 3; }
  .tbl-watchlist td[data-col="chg"]    { grid-column: 2; grid-row: 3; justify-content: flex-end; }
  .tbl-watchlist td[data-col="vol"]    { grid-column: 1; grid-row: 4; }
  .tbl-watchlist td[data-col="class"]  { grid-column: 2; grid-row: 4; justify-content: flex-end; }

  .drawer { width: 100vw; }
  .toasts { left: 8px; right: 8px; width: auto; }
}

@media (max-width: 400px) {
  .tile-row { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); }
  .btn-exec { width: 100%; }
}
