*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f14;
  --card: #141720;
  --border: #252836;
  --text: #c9cdd8;
  --muted: #5a6070;
  --green: #26a69a;
  --red: #ef5350;
  --yellow: #ffd740;
  --blue: #4fc3f7;
  --orange: #ff9800;
}

html {
  background: var(--bg);
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Menlo', 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Top Nav */
#topnav {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
  height: 36px;
}
.nav-brand {
  font-size: 13px;
  font-weight: bold;
  color: var(--text);
  margin-right: 20px;
  letter-spacing: 0.03em;
}
.nav-brand-v {
  color: var(--blue);
}
.nav-link {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--blue); border-bottom-color: var(--blue); }

/* Stats Bar */
#stats-bar {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
#stats-subbar {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.stat {
  flex: 1;
  background: var(--card);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat.stat-primary {
  justify-content: center;
  min-height: 78px;
}
.stat.stat-mini {
  padding: 8px 14px;
  min-height: 54px;
}
.stat .label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat .val { font-size: 14px; font-weight: bold; }
.stat .subval { font-size: 13px; font-weight: bold; color: var(--muted); }

/* Cards */
.card {
  margin: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-width: 0;
  overflow: hidden;
}
.card-title {
  padding: 8px 12px;
  font-weight: bold;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.card-title-split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.card-title .hint { color: var(--muted); font-weight: normal; font-size: 10px; margin-left: 6px; }

/* Tables */
.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}
thead th {
  padding: 6px 8px;
  text-align: left;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid #1a1d27;
  transition: background 0.1s;
}
tbody tr:hover { background: #1c1f2c; }
tbody tr:last-child { border-bottom: none; }
td {
  padding: 5px 8px;
  white-space: nowrap;
  vertical-align: middle;
}
td.sym { font-weight: bold; color: #fff; }
td.muted, .muted { color: var(--muted); }
td.small, .small { font-size: 10px; }

/* Colors */
.green { color: var(--green); }
.red { color: var(--red); }
.yellow { color: var(--yellow); }
.blue { color: var(--blue); }

/* Badges */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 0.03em;
}
.badge-green { background: rgba(38,166,154,0.2); color: var(--green); border: 1px solid rgba(38,166,154,0.4); }
.badge-red   { background: rgba(239,83,80,0.2);  color: var(--red);   border: 1px solid rgba(239,83,80,0.4); }
.badge-yellow { background: rgba(255,215,64,0.2); color: var(--yellow); border: 1px solid rgba(255,215,64,0.4); }

/* Percent cell (colored background on loss) */
.pct-cell { font-weight: bold; text-align: right; border-radius: 3px; padding: 2px 6px; }

/* Buttons */
button { cursor: pointer; border: none; border-radius: 3px; font-size: 11px; font-family: inherit; }
.btn-red    { background: rgba(239,83,80,0.2);   color: var(--red);    border: 1px solid rgba(239,83,80,0.5);   padding: 3px 8px; }
.btn-orange { background: rgba(255,152,0,0.2);   color: var(--orange); border: 1px solid rgba(255,152,0,0.5);   padding: 3px 8px; }
.btn-green  { background: rgba(38,166,154,0.2);  color: var(--green);  border: 1px solid rgba(38,166,154,0.5);  padding: 3px 8px; }
.btn-red:hover    { background: rgba(239,83,80,0.35); }
.btn-orange:hover { background: rgba(255,152,0,0.35); }
.btn-green:hover  { background: rgba(38,166,154,0.35); }

/* Closed grid (2 sütun) */
#closed-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

#summary-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0;
}

.pnl-bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-height: 180px;
  padding: 16px;
}

.pnl-bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pnl-bar-value {
  font-size: 10px;
  color: var(--muted);
}

.pnl-bar-track {
  position: relative;
  width: 100%;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pnl-bar-axis {
  position: absolute;
  inset: 50% 0 auto;
  height: 1px;
  background: var(--border);
}

.pnl-bar {
  position: absolute;
  width: 28px;
  border-radius: 4px 4px 0 0;
  transition: height 0.15s ease;
}

.pnl-bar.negative {
  border-radius: 0 0 4px 4px;
}

.pnl-bar-label {
  font-size: 10px;
  color: var(--muted);
}

.warnings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  min-height: 180px;
}

.warning-item {
  border: 1px solid rgba(255, 215, 64, 0.22);
  background: rgba(255, 215, 64, 0.08);
  border-radius: 4px;
  padding: 8px 10px;
}

.warning-item .title {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--yellow);
  margin-bottom: 4px;
}

.warning-item .body {
  font-size: 11px;
  color: var(--text);
}

.warning-item .time {
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
}

/* Grafik Overlay */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
}
#overlay.open { display: block; }

/* Grafik Paneli */
#chart-panel {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 65vh;
  background: var(--card);
  border-top: 2px solid var(--border);
  z-index: 101;
  flex-direction: column;
}
#chart-panel.open { display: flex; }

#chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#chart-title { font-size: 15px; font-weight: bold; color: #fff; margin-right: 12px; }
#chart-price { font-size: 13px; color: var(--yellow); }
#chart-overlay-info { margin-top: 4px; max-width: 78vw; line-height: 1.35; }
#chart-close-btn { background: rgba(239,83,80,0.15); color: var(--red); border: 1px solid rgba(239,83,80,0.4); padding: 4px 12px; font-size: 12px; }
#chart-close-btn:hover { background: rgba(239,83,80,0.3); }

#chart-container { flex: 7; min-height: 0; }
#wt-container { flex: 3; min-height: 0; border-top: 1px solid var(--border); }

@media (max-width: 1100px) {
  #summary-grid,
  #closed-grid {
    grid-template-columns: 1fr;
  }

  #stats-bar {
    flex-wrap: wrap;
  }

  #stats-subbar {
    flex-wrap: wrap;
  }

  .stat {
    min-width: 33.33%;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 11px;
  }

  #topnav {
    overflow-x: auto;
    white-space: nowrap;
    padding: 0 8px;
  }

  .nav-brand {
    margin-right: 10px;
  }

  #stats-bar,
  #stats-subbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
  }

  .stat {
    min-width: 0;
    padding: 8px 10px;
  }

  .stat.stat-primary {
    min-height: 64px;
  }

  .stat .val {
    font-size: 13px;
  }

  .card {
    margin: 6px;
  }

  .card-title {
    padding: 8px 10px;
  }

  .card-title-split {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-title-actions {
    width: 100%;
  }

  .card-title-actions button {
    flex: 1 1 0;
  }

  thead th,
  td {
    padding-left: 6px;
    padding-right: 6px;
  }

  #chart-panel {
    height: 78vh;
  }

  #chart-header {
    align-items: flex-start;
    gap: 8px;
    flex-direction: column;
  }

  #chart-overlay-info {
    max-width: none;
  }

  #chart-close-btn {
    align-self: flex-end;
  }
}
