:root{
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.10);
  --shadow-soft: 0 8px 24px rgba(2, 6, 23, 0.06);
  --primary: #2563eb;
  --primary-600: #1d4ed8;

  --good: #22c55e;
  --good-soft: rgba(34,197,94,0.14);

  --bad: #ef4444;
  --bad-soft: rgba(239,68,68,0.12);

  --blue: #3b82f6;
  --blue-soft: rgba(59,130,246,0.18);

  --warn: #f59e0b;
  --warn-soft: rgba(245,158,11,0.18);

  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% 0%, #e9efff 0%, rgba(233,239,255,0) 60%),
    radial-gradient(900px 500px at 80% 20%, #eefbf5 0%, rgba(238,251,245,0) 60%),
    var(--bg);
}

.app-shell{ min-height: 100%; display: flex; flex-direction: column; }

/* ===== Topbar ===== */
.topbar{
  height: 68px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(245,247,251,0.65);
  backdrop-filter: blur(10px);
}

.page-title{
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title h1{
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.4px;
}

.back-link{
  width: 36px; height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.7);
  display: grid;
  place-items: center;
  text-decoration: none;
  color: var(--text);
}

.back-link:hover{ background: rgba(255,255,255,0.95); box-shadow: var(--shadow-soft); }

.chev{ font-size: 18px; line-height: 1; margin-top: -1px; }

.topbar-actions{ display: flex; align-items: center; gap: 14px; }

.status-pill{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.18);
  box-shadow: 0 6px 18px rgba(2,6,23,0.05);
}

.status-dot{
  width: 10px; height: 10px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34,197,94,0.18);
}

.status-text{
  font-size: 13px;
  color: #0f766e;
  font-weight: 600;
}

.settings-link{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.65);
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}

.settings-link:hover{ background: rgba(255,255,255,0.9); box-shadow: 0 8px 22px rgba(2,6,23,0.06); }

.settings-icon{
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(2,6,23,0.04);
}

.icon-btn{
  width: 40px; height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.65);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-btn:hover{ background: rgba(255,255,255,0.9); box-shadow: 0 8px 22px rgba(2,6,23,0.06); }

/* ===== Main ===== */
.main{
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.muted{ color: var(--muted); }
.sep{ margin: 0 10px; color: rgba(15,23,42,0.22); }

/* ===== Filters Row ===== */
.filters-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0 16px;
}

.filters{ display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.select{
  min-width: 150px;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.75);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 18px rgba(2,6,23,0.04);
}

.select-label{
  display: none; /* keep structure but hide label for this design */
}

.select-value{
  font-size: 13px;
  font-weight: 600;
  color: rgba(15,23,42,0.70);
}

.select-caret{
  margin-left: auto;
  color: rgba(15,23,42,0.45);
}

.live-meta{
  display: flex;
  align-items: center;
  gap: 14px;
}

.live-pill{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(34,197,94,0.20);
  background: rgba(34,197,94,0.08);
}

.live-dot{
  width: 10px; height: 10px;
  border-radius: 999px;
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(34,197,94,0.18);
}

.live-text{ font-weight: 700; color: #0f766e; }
.updated-text{ font-size: 13px; color: rgba(15,23,42,0.55); }

/* ===== Panels ===== */
.panel{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.panel-header{
  padding: 16px 18px;
  border-bottom: 1px solid rgba(15,23,42,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title{
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.2px;
}

.panel-tools{ display: inline-flex; align-items: center; gap: 8px; }

.tool-btn{
  width: 38px; height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.75);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.tool-btn:hover{ background: rgba(255,255,255,0.95); }

/* ===== Table ===== */
.table-wrap{ overflow: auto; }

.plans-table{
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}

.plans-table th, .plans-table td{
  padding: 12px 14px;
  border-bottom: 1px solid rgba(15,23,42,0.06);
  white-space: nowrap;
  font-size: 13px;
}

.plans-table th{
  font-size: 12px;
  color: rgba(15,23,42,0.55);
  font-weight: 700;
  text-transform: none;
}

.plans-table tbody tr:hover{
  background: rgba(37,99,235,0.04);
}

.num{ text-align: right; }

.symbol{
  font-weight: 800;
  letter-spacing: 0.2px;
}

.sym-badge{
  display: inline-flex;
  width: 22px; height: 22px;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  margin-right: 8px;
  border: 1px solid rgba(15,23,42,0.08);
}

.sym-btc{ background: rgba(245,158,11,0.18); color: #b45309; }
.sym-eth{ background: rgba(59,130,246,0.18); color: #1d4ed8; }
.sym-bnb{ background: rgba(234,179,8,0.16); color: #a16207; }
.sym-sol{ background: rgba(34,197,94,0.14); color: #047857; }

/* Direction pills */
.dir{
  font-weight: 800;
}
.dir-long{ color: #16a34a; }
.dir-short{ color: #ef4444; }
.dir-test{ color: rgba(15,23,42,0.55); }

/* Progress bars */
.bar{
  width: 120px;
  height: 10px;
  border-radius: 999px;
  background: rgba(15,23,42,0.08);
  overflow: hidden;
  border: 1px solid rgba(15,23,42,0.06);
}

.bar.small{ width: 100px; }
.bar-fill{
  height: 100%;
  display: block;
  border-radius: 999px;
}

.bar-green{ background: rgba(34,197,94,0.90); }
.bar-blue{ background: rgba(59,130,246,0.88); }

/* PnL */
.pnl{ font-weight: 900; }
.pnl-pos{ color: #16a34a; }
.pnl-neg{ color: #ef4444; }

.distance{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.distance-val{
  font-weight: 800;
  color: rgba(15,23,42,0.72);
}

.dot-warn{
  width: 8px; height: 8px;
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239,68,68,0.14);
}

/* Status chips */
.chip{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 10px;
  font-weight: 900;
  font-size: 12px;
  border: 1px solid rgba(15,23,42,0.08);
}

.chip-active{
  background: rgba(34,197,94,0.14);
  color: #15803d;
}
.chip-partial{
  background: rgba(59,130,246,0.14);
  color: #1d4ed8;
}
.chip-tp{
  background: rgba(16,185,129,0.12);
  color: #0f766e;
}
.chip-stop{
  background: rgba(239,68,68,0.12);
  color: #b91c1c;
}

.go{
  text-align: right;
  font-size: 18px;
  color: rgba(15,23,42,0.35);
}

/* ===== Risk Allocation grid ===== */
.risk-grid{
  margin-top: 18px;
  display: grid;
  gap: 18px;
  grid-template-columns: 360px 1fr;
}

.risk-metrics{
  padding: 14px 18px 18px;
}

.risk-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(15,23,42,0.08);
}
.risk-row:last-child{ border-bottom: 0; }

.panel-header-split{
  align-items: flex-start;
}
.risk-header-line{
  font-size: 13px;
  color: rgba(15,23,42,0.62);
}
.risk-header-line strong{ color: rgba(15,23,42,0.90); }

/* Toggle */
.toggle{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}
.toggle input{ display:none; }
.toggle-ui{
  width: 54px;
  height: 30px;
  border-radius: 999px;
  background: rgba(15,23,42,0.14);
  position: relative;
  border: 1px solid rgba(15,23,42,0.10);
}
.toggle-ui::after{
  content:"";
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 10px 18px rgba(2,6,23,0.10);
  transition: transform 180ms ease, background 180ms ease;
}
.toggle input:checked + .toggle-ui{
  background: rgba(37,99,235,0.95);
  border-color: rgba(37,99,235,0.22);
}
.toggle input:checked + .toggle-ui::after{
  transform: translateX(24px);
}

/* Risk track */
.risk-track{ padding: 14px 18px 18px; }
.track{
  position: relative;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(15,23,42,0.08);
  background: rgba(15,23,42,0.06);
  display: grid;
  grid-template-columns: 1.2fr .9fr .7fr 1.2fr;
}

.seg{ height: 100%; }
.seg-safe{ background: rgba(34,197,94,0.22); }
.seg-warn{ background: rgba(245,158,11,0.22); }
.seg-danger{ background: rgba(239,68,68,0.20); }

.marker{
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid white;
  box-shadow: 0 10px 18px rgba(2,6,23,0.12);
}
.marker-a{ left: 42.5%; background: #2563eb; }
.marker-b{ left: 62%; background: #f59e0b; }

.balance-row{
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-switch{
  width: 34px; height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(15,23,42,0.08);
  position: relative;
}
.mini-pill{
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 999px;
  background: #fff;
  top: 1px; left: 1px;
  box-shadow: 0 8px 16px rgba(2,6,23,0.10);
}

/* Footer */
.footer{ padding: 20px 0 0; }
.footer-inner{
  display: flex;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
.footer-inner .dot{ opacity: .7; }

/* Responsive */
@media (max-width: 1100px){
  .risk-grid{ grid-template-columns: 1fr; }
}

@media (max-width: 620px){
  .topbar{
    padding: 12px 14px;
    height: auto;
    gap: 12px;
    flex-wrap: wrap;
  }
  .filters-row{
    flex-direction: column;
    align-items: flex-start;
  }
}
