:root {
  --bg: #080c13;
  --sidebar: #080d12;
  --panel: #10151d;
  --panel-2: #151c27;
  --panel-hover: #141c28;
  --line: #27303d;
  --line-soft: #202834;
  --text: #e5e9f0;
  --muted: #8a97aa;
  --blue: #4f88ff;
  --green: #32c77f;
  --red: #f05263;
  --amber: #f5b942;
  --radius: 14px;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 28px 16px 20px;
  overflow: auto;
  background: var(--sidebar);
  border-right: 1px solid #111923;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
}

.brand-mark {
  display: inline-grid;
  min-width: 27px;
  color: var(--blue);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.06em;
}

.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 13px; letter-spacing: -.01em; text-transform: uppercase; }
.brand-copy small { color: var(--muted); font-size: 9px; }

.sidebar nav {
  display: grid;
  gap: 6px;
  margin-top: 48px;
}

.nav-link {
  min-height: 40px;
  padding: 11px 16px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  transition: background .16s ease, color .16s ease;
}

.nav-link:hover { color: var(--text); background: #111923; }
.nav-link.active { color: var(--text); background: #1b2b49; }

.sidebar-footer {
  display: grid;
  gap: 14px;
  margin-top: auto;
  padding: 18px 12px 0;
  border-top: 1px solid var(--line-soft);
}

.user-summary { display: flex; align-items: center; gap: 10px; }
.user-summary > span:last-child { display: grid; gap: 2px; min-width: 0; }
.user-summary strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; }
.user-summary small { color: var(--muted); font-size: 10px; }

.user-avatar {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid #2d3c52;
  border-radius: 50%;
  background: #152238;
  color: #9dbbff;
  font-size: 11px;
  font-weight: 800;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}
.link-button:hover { color: var(--text); }

.main-content {
  min-width: 0;
  padding: 32px clamp(24px, 2.3vw, 40px) 56px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.page-header h1 {
  margin: 5px 0 7px;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.05;
  letter-spacing: -.035em;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--blue);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.muted { margin: 0; color: var(--muted); }

.button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.button:hover { border-color: #415069; background: #1a2330; }
.button:active { transform: translateY(1px); }
.button.primary { border-color: var(--blue); background: var(--blue); color: #07101f; }
.button.primary:hover { background: #6698ff; }
.button.ghost { background: transparent; }
.button:disabled { opacity: .45; cursor: not-allowed; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 24px;
}

.filter-heading {
  display: grid;
  flex: 1 0 100%;
  gap: 3px;
  margin-bottom: 2px;
}
.filter-heading strong { font-size: 12px; }
.filter-heading span { color: var(--muted); font-size: 10px; }

.filters label,
.stack-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.filters input,
.filters select,
.stack-form input,
textarea {
  height: 36px;
  min-width: 124px;
  padding: 0 11px;
  outline: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
}

.filters input:focus,
.filters select:focus,
.stack-form input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 136, 255, .12);
}

.filter-actions { display: flex; gap: 8px; }

.currency-section { margin: 28px 0 48px; }
.currency-section + .currency-section { padding-top: 40px; border-top: 1px solid var(--line-soft); }

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.section-title > div { display: grid; gap: 4px; }
.section-title h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }

.currency-pill,
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 750;
}
.currency-pill { padding: 5px 9px; background: #14213a; color: #8fb0fa; }
.badge { padding: 5px 8px; }
.badge.long,
.badge.entry { background: rgba(50, 199, 127, .12); color: var(--green); }
.badge.short,
.badge.exit { background: rgba(164, 128, 255, .14); color: #b599ff; }
.badge.neutral { background: #202b3e; color: #aab7ca; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 15px;
}
.metric-grid.compact { margin-bottom: 24px; }

.metric-card {
  display: grid;
  min-width: 0;
  min-height: 108px;
  align-content: start;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.metric-card span { margin-bottom: 10px; color: var(--muted); font-size: 10px; font-weight: 650; text-transform: uppercase; }
.metric-card strong { overflow: hidden; font-size: clamp(18px, 1.55vw, 24px); letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
.metric-card small { margin-top: 5px; color: var(--muted); font-size: 10px; }

.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }

.panel {
  margin-bottom: 16px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.panel-heading > div { display: grid; gap: 4px; }
.panel-heading h2,
.panel-heading h3,
.panel h2 { margin: 0; font-size: 14px; }
.panel-heading span { color: var(--muted); font-size: 10px; }

.dashboard-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 16px;
  margin-top: 20px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.chart-panel { min-height: 320px; }
.chart-panel canvas { width: 100% !important; max-height: 250px; }
.chart-panel-equity canvas,
.chart-panel-daily canvas { height: 244px !important; }

.table-panel { padding: 0; overflow: hidden; }
.dashboard-trades { margin-top: 2px; }
.table-heading { margin: 0; padding: 18px 19px 14px; }
.table-wrap { overflow: auto; }

table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  text-align: left;
}
th {
  background: #0f151e;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: var(--panel-hover); }
tbody tr:last-child td { border-bottom: 0; }

.status-dot { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; }
.status-dot.win { background: var(--green); }
.status-dot.loss { background: var(--red); }

.row-link,
.back-link { color: #82aaff; font-weight: 650; }
.row-link:hover,
.back-link:hover { color: #a7c0ff; }
.empty-cell { padding: 44px; color: var(--muted); text-align: center; }

.trade-title { display: flex; align-items: center; gap: 12px; }
.detail-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 16px; }
.timeline { display: grid; }
.timeline-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.timeline-row:last-child { border: 0; }
.timeline-row div:nth-child(2) { display: grid; gap: 4px; }
.timeline-row div:nth-child(2) span { color: var(--muted); font-size: 12px; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; }
.timeline-dot.entry { background: var(--green); }
.timeline-dot.exit { background: var(--red); }
.timeline-value { font-variant-numeric: tabular-nums; }

.form-panel form { display: grid; gap: 12px; }
.form-panel textarea { height: auto; padding: 12px; resize: vertical; }
.screenshot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.screenshot-grid img { width: 100%; height: 170px; border: 1px solid var(--line); border-radius: 11px; object-fit: cover; }
.inline-form { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.upload-panel { padding: 34px; }
.upload-form { display: grid; justify-items: center; gap: 12px; padding: 38px; border: 1px dashed #354560; border-radius: 14px; text-align: center; }
.upload-icon { display: grid; width: 56px; height: 56px; place-items: center; border-radius: 15px; background: #192944; color: #8ab4ff; font-weight: 850; }
.field-error,
.error-list { color: #ff8ba0; }
.confirm-bar { display: flex; align-items: center; justify-content: space-between; padding: 18px; border: 1px solid #2d4467; border-radius: 14px; background: #101a29; }

.messages { display: grid; gap: 8px; margin-bottom: 18px; }
.message { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #152136; }
.message.success { border-color: rgba(50, 199, 127, .4); }
.message.error { border-color: rgba(240, 82, 99, .5); }
.message.warning { border-color: rgba(245, 185, 66, .5); }

.empty-state { padding: 80px 20px; border: 1px dashed var(--line); border-radius: var(--radius); background: rgba(16, 21, 29, .55); text-align: center; }
.empty-state h2 { margin-top: 0; }
.empty-state .button { margin-top: 20px; }

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0, #15223a 0, var(--bg) 45%);
}
.login-card {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(16, 21, 29, .97);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .42);
}
.login-brand { margin-bottom: 34px; padding: 0; }
.login-card h1 { margin: 10px 0; font-size: 32px; letter-spacing: -.04em; }
.stack-form { display: grid; gap: 12px; margin-top: 26px; }
.stack-form input { width: 100%; min-width: 0; }
.stack-form .button { margin-top: 10px; }
.errorlist { color: var(--red); font-size: 12px; }
.back-link { display: block; margin-bottom: 16px; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-chart-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 12px; overflow-x: auto; }
  .sidebar { scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar nav { display: flex; margin: 0; }
  .nav-link { min-height: 36px; padding: 9px 12px; white-space: nowrap; }
  .sidebar-footer { display: none; }
  .brand { padding: 0 6px; }
  .brand-copy { display: none; }
  .main-content { padding: 24px 14px 40px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-heading,
  .filter-actions { grid-column: 1 / -1; }
  .filters input,
  .filters select { width: 100%; min-width: 0; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
  .section-title { align-items: flex-start; flex-direction: column; }
  .inline-form,
  .confirm-bar { align-items: stretch; flex-direction: column; }
}

@media (max-width: 480px) {
  .metric-grid,
  .filters { grid-template-columns: 1fr; }
  .filter-heading,
  .filter-actions { grid-column: auto; }
  .filter-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .metric-card strong { font-size: 22px; }
}
