: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;

  --good: #22c55e;
  --bad: #ef4444;

  --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; }
.muted{ color: var(--muted); }

/* ===== 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: var(--good);
  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(1400px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

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

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

.select{
  min-width: 160px;
  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-value{
  font-size: 13px;
  font-weight: 700;
  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: 800; color: #0f766e; }
.updated-text{ font-size: 13px; color: rgba(15,23,42,0.55); }

/* ===== KPI Grid ===== */
.kpi-grid{
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin: 8px 0 16px;
}

.kpi-card{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 14px 14px 12px;
}

.kpi-label{
  font-size: 12px;
  font-weight: 800;
  color: rgba(15,23,42,0.55);
  letter-spacing: 0.2px;
}
.kpi-value{
  margin-top: 8px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.6px;
}
.kpi-sub{
  margin-top: 6px;
  font-size: 12px;
}

/* ===== Two column layout ===== */
.grid-2{
  display: grid;
  gap: 16px;
  grid-template-columns: 1.2fr 1fr;
}

/* ===== 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: 900;
  font-size: 16px;
  letter-spacing: -0.2px;
}

.panel-meta{
  font-size: 13px;
  color: rgba(15,23,42,0.62);
}
.panel-meta strong{ color: rgba(15,23,42,0.9); }

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

.tool-btn{
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.75);
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
  color: rgba(15,23,42,0.70);
}
.tool-btn:hover{ background: rgba(255,255,255,0.95); }

/* ===== Chart ===== */
.chart-wrap{
  padding: 14px 18px 18px;
}

#equityCanvas{
  width: 100%;
  height: 340px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.08);
  background: linear-gradient(180deg, rgba(37,99,235,0.05), rgba(255,255,255,0));
}

.chart-hint{
  margin-top: 10px;
  font-size: 12px;
}

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

.trades-table{
  width: 100%;
  border-collapse: collapse;
  min-width: 1050px;
}

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

.trades-table th{
  font-size: 12px;
  color: rgba(15,23,42,0.55);
  font-weight: 800;
}

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

.empty{
  text-align: center;
  color: rgba(15,23,42,0.45);
  padding: 18px 14px;
}

/* 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-open{ background: rgba(59,130,246,0.12); color: #1d4ed8; }
.chip-closed{ background: rgba(34,197,94,0.14); color: #15803d; }
.chip-fail{ background: rgba(239,68,68,0.12); color: #b91c1c; }

.pos{ color: #16a34a; font-weight: 900; }
.neg{ color: #ef4444; font-weight: 900; }
.neu{ color: rgba(15,23,42,0.70); font-weight: 900; }

/* 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: 1180px){
  .kpi-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2{ 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;
  }
}