/* ==========================================================================
   MOTHER — design tokens
   Background: near-black navy (mysterious, low eye-strain)
   Accent:     Kaspersky-style bright turquoise
   Positive:   neon green   Negative: neon rose
   Display face: Space Grotesk (technical/scientific — fits the DNA/atom motif)
   Body face:    Inter
   Data face:    JetBrains Mono (all prices, %, quantities)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=Roboto+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg-void:      #070a12;
  --bg-base:      #0a0e1a;
  --bg-panel:     #10152470;
  --bg-panel-solid:#111729;
  --bg-card:      #141b30;
  --bg-card-hover:#182140;
  --bg-input:     #0d1220;
  --border:       #232c47;
  --border-soft:  #1a2138;

  --text-primary:   #e8ecf7;
  --text-secondary: #8b93b0;
  --text-muted:     #5b6382;

  --accent:            #3d9e90;
  --accent-dim:        #34877b;
  --accent-glow:       rgba(61, 158, 144, 0.28);
  --accent-soft-bg:rgba(61, 158, 144, 0.07);

  --positive:          #4fae82;
  --positive-glow:     rgba(79, 174, 130, 0.35);
  --negative:      #cf6679;
  --negative-glow: rgba(207, 102, 121, 0.30);
  --warning:       #ffb020;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(0,230,184,0.06), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(0,180,255,0.04), transparent 55%);
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- layout */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--bg-panel-solid);
  border-right: 1px solid var(--border-soft);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 26px 10px;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #0077ff);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; color: #04140f; font-size: 15px;
  box-shadow: 0 0 18px var(--accent-glow);
}
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: 0.02em; }
.brand-name span { color: var(--accent); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px; font-weight: 500;
  border-left: 2px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-soft-bg);
  color: var(--accent);
  border-left: 2px solid var(--accent);
}
.nav-icon { width: 16px; text-align: center; font-size: 14px; opacity: 0.9; }

.sidebar-foot { border-top: 1px solid var(--border-soft); padding-top: 14px; margin-top: 10px; }
.logout-link { font-size: 21px; color: #ffffff; }
.logout-link:hover { color: var(--negative); }

.main { flex: 1; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 30px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(10,14,26,0.7);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 19px; }
.topbar-meta { display: flex; align-items: center; gap: 18px; font-size: 12.5px; color: var(--text-secondary); }
.dry-run-pill {
  background: rgba(255,176,32,0.12); color: var(--warning);
  border: 1px solid rgba(255,176,32,0.3);
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.live-pill {
  background: rgba(207,102,121,0.12); color: var(--negative);
  border: 1px solid rgba(207,102,121,0.35);
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
}

.content { padding: 26px 30px 60px 30px; max-width: 1400px; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; margin-bottom: 10px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.stat-label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.stat-value { font-family: var(--font-mono); font-size: 22px; font-weight: 600; }
.stat-value.positive { color: var(--positive); }
.stat-value.negative { color: var(--negative); }
.stat-sub { font-size: 11.5px; color: var(--text-secondary); margin-top: 4px; }

.section { margin-bottom: 30px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { font-size: 16px; }
.section-head .muted-link { font-size: 12.5px; color: var(--accent); }

/* ---------------------------------------------------------------- tables */

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border-soft);
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-card-hover); }
.data-table .num { font-family: var(--font-mono); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius-lg); background: var(--bg-card); }
.table-wrap table.data-table { background: transparent; }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.badge-enabled { background: rgba(44,255,158,0.1); color: var(--positive); border: 1px solid rgba(44,255,158,0.28); }
.badge-disabled { background: rgba(139,147,176,0.1); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-inposition { background: rgba(0,230,184,0.1); color: var(--accent); border: 1px solid rgba(0,230,184,0.3); }
.badge-idle { background: rgba(139,147,176,0.08); color: var(--text-muted); border: 1px solid var(--border); }
.badge-buy { background: rgba(44,255,158,0.12); color: var(--positive); }
.badge-sell { background: rgba(207,102,121,0.12); color: var(--negative); }

.pnl-pos { color: var(--positive); }
.pnl-neg { color: var(--negative); }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-primary); cursor: pointer; transition: all 0.15s;
}
.btn:hover { background: var(--bg-card-hover); border-color: var(--accent-dim); }
.btn-primary {
  background: var(--accent); color: #04140f; border-color: var(--accent);
  box-shadow: 0 0 0 rgba(0,230,184,0);
}
.btn-primary:hover { box-shadow: 0 0 24px var(--accent-glow); background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: transparent; border-color: rgba(207,102,121,0.4); color: var(--negative); }
.btn-danger:hover { background: rgba(207,102,121,0.1); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- forms */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.field .hint { font-size: 11px; color: var(--text-muted); }
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  background: var(--bg-input); border: 1px solid var(--border); color: var(--text-primary);
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; font-family: var(--font-mono);
  width: 100%;
}
input:not([type="checkbox"]):focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft-bg); outline: none;
}
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.toggle-row label { font-size: 13.5px; color: var(--text-primary); font-weight: 500; font-family: var(--font-body); }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 999px; transition: 0.2s;
}
.switch-track:before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: var(--text-secondary); border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .switch-track { background: var(--accent-dim); }
.switch input:checked + .switch-track:before { transform: translateX(18px); background: #04140f; }

fieldset.panel { border: 1px solid var(--border-soft); border-radius: var(--radius-md); padding: 16px; margin-bottom: 18px; background: var(--bg-panel); }
fieldset.panel legend { font-family: var(--font-display); font-size: 13px; color: var(--accent); padding: 0 8px; font-weight: 600; }
.sub-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.sub-row { display: grid; grid-template-columns: 40px 1fr 1fr; gap: 8px; align-items: center; }
.sub-row .lvl { font-family: var(--font-mono); color: var(--text-muted); font-size: 12px; }

.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- active trade bars */

.trade-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s;
}
.trade-bar.positive { border-color: rgba(44,255,158,0.35); box-shadow: inset 3px 0 0 var(--positive), 0 0 22px -6px var(--positive-glow); }
.trade-bar.negative { border-color: rgba(207,102,121,0.35); box-shadow: inset 3px 0 0 var(--negative), 0 0 22px -6px var(--negative-glow); }
.trade-bar-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.trade-bar-name { font-family: var(--font-display); font-weight: 600; font-size: 14.5px; }
.trade-bar-pair { color: var(--text-muted); font-size: 12px; margin-left: 8px; font-family: var(--font-mono); }
.trade-bar-pnl { font-family: var(--font-mono); font-size: 19px; font-weight: 700; text-align: right; }
.trade-bar-pnl-pct { font-size: 12px; font-weight: 600; }
.trade-bar-track { height: 8px; background: var(--bg-input); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.trade-bar-fill { height: 100%; border-radius: 999px; transition: width 0.6s ease; }
.trade-bar-fill.positive { background: linear-gradient(90deg, var(--accent), var(--positive)); box-shadow: 0 0 12px var(--positive-glow); }
.trade-bar-fill.negative { background: linear-gradient(90deg, #e28ba0, var(--negative)); box-shadow: 0 0 12px var(--negative-glow); }
.trade-bar-meta { display: flex; gap: 22px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; }
.trade-bar-meta .mono { color: var(--text-primary); }
.trade-bar-meta .k { color: var(--text-muted); margin-right: 4px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; font-size: 15px; }

/* ---------------------------------------------------------------- info list (bot detail) */

.info-list { width: 100%; border-collapse: collapse; }
.info-list td { padding: 10px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.info-list td:first-child { color: var(--text-secondary); width: 46%; }
.info-list td:last-child { font-family: var(--font-mono); text-align: right; }

.event-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.event-row .t { color: var(--text-muted); font-family: var(--font-mono); font-size: 11.5px; }
.event-row:last-child { border-bottom: none; }

.signal-item { border: 1px solid var(--border-soft); border-radius: var(--radius-sm); margin-bottom: 8px; overflow: hidden; }
.signal-head { padding: 11px 14px; font-size: 12.5px; color: var(--accent); cursor: pointer; display: flex; justify-content: space-between; background: var(--bg-panel); }
.signal-body { display: none; padding: 12px 14px; background: var(--bg-input); }
.signal-body.open { display: block; }
.signal-body pre { margin: 0; font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); white-space: pre-wrap; word-break: break-all; }
.copy-btn { font-size: 10.5px; color: var(--text-muted); }
.copy-btn:hover { color: var(--accent); }

/* ---------------------------------------------------------------- misc */

.tag-row { display: flex; gap: 8px; margin-bottom: 18px; }
.filter-pill {
  padding: 6px 14px; border-radius: 999px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); color: var(--text-secondary);
}
.filter-pill.active { background: var(--accent-soft-bg); color: var(--accent); border-color: var(--accent-dim); }

.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.status-dot.on { background: var(--positive); box-shadow: 0 0 8px var(--positive-glow); }
.status-dot.off { background: var(--text-muted); }

canvas#pnlChart, canvas.chart-canvas { width: 100%; max-height: 260px; }

.breadcrumb { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
.breadcrumb a:hover { color: var(--accent); }

/* ---------------------------------------------------------------- segmented toggle */

.seg-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg-toggle input { display: none; }
.seg-toggle label {
  flex: 1; text-align: center; padding: 10px 14px; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); cursor: pointer; background: var(--bg-input); transition: all 0.15s;
  font-family: var(--font-body);
}
.seg-toggle input:checked + label { background: var(--accent-soft-bg); color: var(--accent); }
.seg-toggle label:not(:last-of-type) { border-right: 1px solid var(--border); }

.form-actions { display: flex; gap: 12px; margin-top: 10px; position: sticky; bottom: 0; background: var(--bg-base); padding: 16px 0; border-top: 1px solid var(--border-soft); }
.save-banner { background: rgba(44,255,158,0.1); border: 1px solid rgba(44,255,158,0.3); color: var(--positive); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 18px; }
.collapsible-panel { display: none; }
.collapsible-panel.open { display: block; }



/* Trade refresh icon buttons */
.refresh-btn { display:inline-block; margin-left:8px; cursor:pointer; color: var(--text-muted); font-size: 21px; line-height: 1; transition: transform 0.4s ease, color 0.2s ease; user-select:none; vertical-align: middle; }
.refresh-btn:hover { color: var(--accent); }
.refresh-btn.spinning { animation: spin-refresh 0.6s linear; }
@keyframes spin-refresh { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }


/* Topbar date/time */
.topbar-date { font-size: 19px; color: #ffffff; font-weight: 500; margin-right: 28px; font-variant-numeric: tabular-nums; }
.topbar-time { font-size: 22px; color: #ffffff; font-family: var(--font-mono); font-weight: 600; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }


/* Trailing take-profit active - frame only, fill bar keeps its own positive/negative color */
.trade-bar.trailing { border-color: rgba(77,159,224,0.45); box-shadow: inset 3px 0 0 #4d9fe0, 0 0 22px -6px rgba(77,159,224,0.30); }
.trailing-info .k, .trailing-info .mono { color: #d9b54c !important; }
