/* ============== API4ATKA — Pro Trading Dark ============== */
/* fonts loaded via <link> in index.html <head> */

:root {
  /* accent — switchable via tweaks (--accent) */
  --accent: #3B82F6;
  --accent-2: #2563EB;
  --accent-soft: rgba(59,130,246,0.12);
  --accent-ring: rgba(59,130,246,0.35);

  --emerald: #14B8A6;
  --emerald-2: #26A269;

  --green: #22C55E;
  --green-soft: rgba(34,197,94,0.12);
  --red: #EF4444;
  --red-soft: rgba(239,68,68,0.12);
  --amber: #F59E0B;
  --amber-soft: rgba(245,158,11,0.12);

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 18px;

  --sidebar-w: 240px;
  --header-h: 56px;

  --row-h: 44px; /* density */
}

[data-theme="dark"] {
  --bg-0: #0E1217;
  --bg-1: #11151B;
  --bg-2: #161B23;
  --bg-3: #1C222B;
  --bg-hover: rgba(255,255,255,0.04);
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.12);
  --text: #ECEDEE;
  --text-2: #B4B5B6;
  --text-muted: #7E8081;
  --shadow: 0 12px 32px -8px rgba(0,0,0,0.6);
  --shadow-sm: 0 4px 14px -4px rgba(0,0,0,0.5);
  --scrim: rgba(5,7,10,0.72);
  --skel: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.07) 37%, rgba(255,255,255,0.03) 63%);
}

[data-theme="light"] {
  --bg-0: #F4F6F9;
  --bg-1: #FFFFFF;
  --bg-2: #FFFFFF;
  --bg-3: #F0F2F6;
  --bg-hover: rgba(15,20,30,0.035);
  --border: rgba(15,23,42,0.09);
  --border-strong: rgba(15,23,42,0.16);
  --text: #0C1015;
  --text-2: #475066;
  --text-muted: #8A93A6;
  --shadow: 0 12px 32px -10px rgba(15,23,42,0.18);
  --shadow-sm: 0 4px 14px -6px rgba(15,23,42,0.12);
  --scrim: rgba(20,28,40,0.42);
  --skel: linear-gradient(90deg, rgba(15,23,42,0.04) 25%, rgba(15,23,42,0.08) 37%, rgba(15,23,42,0.04) 63%);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-0);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#root { height: 100vh; overflow: hidden; }

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-feature-settings: "tnum" 1; letter-spacing: -0.01em; }

::selection { background: var(--accent-ring); color: #fff; }

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- primitives ---------- */
.pos { color: var(--green); }
.neg { color: var(--red); }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: background .14s, border-color .14s, transform .06s, box-shadow .14s, color .14s;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px -4px var(--accent-ring); }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: var(--bg-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-3); border-color: var(--border-strong); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn-icon { width: 38px; padding: 0; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

.card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); position: relative;
}
.card-pad { padding: 18px 20px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.pill-soft { background: var(--bg-3); color: var(--text-2); border: 1px solid var(--border); }
.dot { width: 7px; height: 7px; border-radius: 99px; flex: none; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.02em; text-transform: uppercase;
}
.badge-long { background: var(--green-soft); color: var(--green); }
.badge-short { background: var(--red-soft); color: var(--red); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-emerald { background: rgba(20,184,166,0.14); color: var(--emerald); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }

.label-cap { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }

/* segmented control */
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { height: 30px; padding: 0 14px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--text-2); transition: .14s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent); color: #fff; }
.seg.emerald button.on { background: var(--emerald); }

/* tabs (underline) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tabs button { position: relative; padding: 12px 14px; font-size: 14px; font-weight: 600; color: var(--text-muted); transition: color .14s; }
.tabs button:hover { color: var(--text-2); }
.tabs button.on { color: var(--text); }
.tabs button.on::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }

/* table */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  position: sticky; top: 0; z-index: 2; background: var(--bg-1);
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); padding: 0 14px; height: 38px; border-bottom: 1px solid var(--border);
  white-space: nowrap; user-select: none;
}
.tbl thead th.sortable { cursor: pointer; }
.tbl thead th.sortable:hover { color: var(--text-2); }
.tbl thead th.num, .tbl tbody td.num { text-align: right; }
.tbl tbody td { padding: 0 14px; height: var(--row-h); border-bottom: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: var(--bg-hover); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .strong { color: var(--text); font-weight: 600; }

/* skeleton */
.skel { background: var(--skel); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0%{background-position:100% 0} 100%{background-position:-100% 0} }

/* toggle */
.tgl { width: 40px; height: 23px; border-radius: 99px; background: var(--bg-3); border: 1px solid var(--border); position: relative; transition: .16s; flex: none; }
.tgl::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 99px; background: var(--text-2); transition: .16s; }
.tgl.on { background: var(--accent); border-color: var(--accent); }
.tgl.on::after { left: 19px; background: #fff; }

/* input */
.inp {
  height: 38px; width: 100%; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 12px; color: var(--text); font-size: 13.5px; transition: .14s;
}
.inp::placeholder { color: var(--text-muted); }
.inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.inp:hover { border-color: var(--border-strong); }

/* range slider */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 99px; background: var(--bg-3); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 99px; background: var(--accent); cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.4); border: 2px solid var(--bg-1); }

/* modal */
.scrim { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(4px); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 20px; animation: fade .16s ease; overflow-y: auto; }
@keyframes fade { from { opacity: 0 } }
.modal { width: 100%; background: var(--bg-1); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow); animation: pop .18s cubic-bezier(.2,.8,.3,1); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98) } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--bg-1); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* dropdown */
.dd { position: absolute; background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 60; overflow: hidden; animation: ddpop .14s ease; }
@keyframes ddpop { from { opacity: 0; transform: translateY(-6px) } }
.dd-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 13.5px; color: var(--text-2); cursor: pointer; transition: .1s; }
.dd-item:hover { background: var(--bg-hover); color: var(--text); }

/* tooltip-ish micro */
.kpi-spark { width: 100%; height: 34px; display: block; }

.fade-in { animation: fadein .28s ease; }
@keyframes fadein { from { transform: translateY(8px) } to { transform: none } }

.scroll-y { overflow-y: auto; }

/* generic grid utils */
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--text-muted); }
.t2 { color: var(--text-2); }

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

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 48px 20px; color: var(--text-muted); gap: 6px;
}
.empty svg { color: var(--text-muted); opacity: .55; margin-bottom: 6px; }

.divider { height: 1px; background: var(--border); }
