:root {
  --bg: #0d0f1a; --surface: #141726; --surface2: #1c2036;
  --border: #2a2f4a; --yellow: #f9d923; --blue: #4fc3f7;
  --red: #ff5370; --green: #69ff47; --purple: #c792ea;
  --text: #e8eaf6; --muted: #8892b0;
}
body.day {
  --bg: #f4f6fb; --surface: #ffffff; --surface2: #edf0f8;
  --border: #cdd2e8; --yellow: #b07800; --blue: #0078b0;
  --red: #cc0033; --green: #1a8800; --purple: #6030a8;
  --text: #1e2340; --muted: #6070a0;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; min-height: 100vh; transition: background 0.2s, color 0.2s; }
body::before {
  content: ''; position: fixed; inset: 0;
  background-image: linear-gradient(rgba(79,195,247,0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(79,195,247,0.03) 1px, transparent 1px);
  background-size: 32px 32px; pointer-events: none; z-index: 0;
}
body.day::before {
  background-image: linear-gradient(rgba(30,35,64,0.04) 1px, transparent 1px), linear-gradient(90deg, rgba(30,35,64,0.04) 1px, transparent 1px);
}
.theme-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 14px;
  font-family: 'DM Sans', sans-serif; transition: all 0.15s; margin-left: 8px;
}
.theme-btn:hover { border-color: var(--yellow); color: var(--yellow); }
.header {
  position: relative; z-index: 1; padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.pokeball-icon { width: 44px; height: 44px; flex-shrink: 0; }
.header-text h1 { font-family: 'Press Start 2P', monospace; font-size: 12px; color: var(--yellow); line-height: 1.6; }
.header-text p { font-size: 12px; color: var(--muted); margin-top: 4px; }
.header-actions { margin-left: auto; display: flex; gap: 0; flex-wrap: wrap; align-items: center; }
.date-nav {
  display: flex; align-items: center; gap: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.date-nav-arrow {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 0 13px; font-size: 16px; height: 100%; transition: all 0.15s;
  display: flex; align-items: center;
}
.date-nav-arrow:hover:not(:disabled) { color: var(--yellow); background: rgba(255,215,0,0.08); }
.date-nav-arrow:disabled { opacity: 0.2; cursor: default; }
.date-nav-center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px 16px; min-width: 220px; border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  gap: 3px;
}
.date-nav-label {
  font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--fg); letter-spacing: 0.5px;
}
.date-nav-meta {
  display: flex; gap: 10px; align-items: center;
}
.date-nav-chip {
  font-size: 10px; color: var(--muted); font-weight: 500;
}
.date-nav-chip.pos { color: var(--green); }
.date-nav-chip.neg { color: var(--red); }
.date-nav-divider {
  width: 1px; background: var(--border); align-self: stretch;
}
.date-nav-action {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 0 12px; font-size: 12px; font-family: 'DM Sans', sans-serif;
  font-weight: 600; height: 100%; transition: all 0.15s;
  display: flex; align-items: center; white-space: nowrap;
  border-left: 1px solid var(--border);
}
.date-nav-action:first-of-type { border-left: none; }
.date-nav-action:hover { color: var(--yellow); background: rgba(255,215,0,0.08); }
.date-nav-action-primary { color: var(--yellow); }
.date-nav-action-primary:hover { background: rgba(255,215,0,0.12); }
.btn { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 12px; font-family: 'DM Sans', sans-serif; transition: all 0.15s; }
.btn-primary { }
.btn-primary:hover { border-color: var(--yellow); color: var(--yellow); }
.btn-secondary { }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }
.main { position: relative; z-index: 1; padding: 24px 32px; display: grid; gap: 20px; }
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; position: relative; overflow: hidden; transition: border-color 0.2s, transform 0.15s;
}
.kpi-card:hover { border-color: var(--blue); transform: translateY(-2px); }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.kpi-card:nth-child(1)::before { background: var(--yellow); }
.kpi-card:nth-child(2)::before { background: var(--green); }
.kpi-card:nth-child(3)::before { background: var(--blue); }
.kpi-card:nth-child(4)::before { background: var(--purple); }
.kpi-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.kpi-value { font-family: 'Press Start 2P', monospace; font-size: 14px; color: var(--text); margin-bottom: 6px; line-height: 1.4; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.badge-green { background: rgba(105,255,71,0.15); color: var(--green); }
.badge-red { background: rgba(255,83,112,0.15); color: var(--red); }
.charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.card-title { font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--yellow); letter-spacing: 1px; }
.chart-wrap { position: relative; height: 240px; width: 100%; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 9px 11px; font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.8px; border-bottom: 1px solid var(--border);
  font-weight: 500; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid rgba(42,47,74,0.5); transition: background 0.1s; }
tbody tr:hover { background: rgba(79,195,247,0.04); }
tbody td { padding: 10px 11px; color: var(--text); white-space: nowrap; }
.name-cell { font-weight: 500; }
.profit-pos { color: var(--green); font-weight: 600; }
.profit-neg { color: var(--red); font-weight: 600; }
.roi-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.roi-bar-bg { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.roi-bar-fill { height: 100%; border-radius: 3px; }
.roi-label { font-size: 11px; font-weight: 600; min-width: 46px; }
.sold-tag { display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 4px; background: rgba(105,255,71,0.1); color: var(--green); border: 1px solid rgba(105,255,71,0.25); }
.holding-tag { display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 4px; background: rgba(79,195,247,0.1); color: var(--blue); border: 1px solid rgba(79,195,247,0.25); }
.reset-link { font-size: 11px; color: var(--muted); cursor: pointer; text-decoration: underline; }
.reset-link:hover { color: var(--red); }
.export-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); cursor: pointer; font-size: 11px; font-family: 'DM Sans', sans-serif;
  font-weight: 600; padding: 4px 10px; transition: all 0.15s;
}
.export-btn:hover { border-color: var(--blue); color: var(--blue); }
.pd-link {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; color: var(--muted); text-decoration: none;
  background: var(--surface2); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 4px; transition: all 0.15s; white-space: nowrap;
}
.pd-link:hover { color: var(--yellow); border-color: var(--yellow); }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px; width: 100%; max-width: 540px; max-height: 88vh; overflow-y: auto;
  transform: translateY(16px); transition: transform 0.2s;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-title { font-family: 'Press Start 2P', monospace; font-size: 10px; color: var(--yellow); margin-bottom: 22px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 500; }
input[type=text], input[type=number], input[type=date] {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: 7px; font-family: 'DM Sans', sans-serif; font-size: 14px;
  outline: none; transition: border-color 0.15s; width: 100%;
}
input:focus { border-color: var(--blue); }
input::placeholder { color: var(--muted); }
.price-table { width: 100%; border-collapse: collapse; }
.price-table th { font-size: 10px; color: var(--muted); padding: 6px 8px; text-align: left; text-transform: uppercase; letter-spacing: 0.8px; border-bottom: 1px solid var(--border); }
.price-table td { padding: 7px 8px; border-bottom: 1px solid rgba(42,47,74,0.4); vertical-align: middle; }
.price-table td:first-child { font-size: 13px; font-weight: 500; color: var(--text); }
.prev-price { font-size: 11px; color: var(--muted); display: block; margin-top: 2px; }
.hint { font-size: 12px; color: var(--muted); margin: 10px 0 14px; line-height: 1.5; }

/* ── TABLET (≤ 900px) ── */
@media (max-width: 900px) {
  .main { padding: 16px; }
  .header { padding: 16px; }
  .tab-nav { padding: 0 16px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .verkoop-grid { grid-template-columns: 1fr; }
  .card-header { flex-wrap: wrap; gap: 10px; }
}

/* ── MOBIEL (≤ 600px) ── */
@media (max-width: 600px) {
  /* Header */
  .header { padding: 12px; gap: 8px; }
  .header-text h1 { font-size: 10px; }
  .header-actions { width: 100%; margin-left: 0; justify-content: space-between; flex-wrap: nowrap; }
  .logout-btn { padding: 6px 10px; font-size: 11px; margin-left: 6px; }
  .theme-btn { padding: 6px 10px; font-size: 12px; }

  /* Date nav */
  .date-nav { flex: 1; min-width: 0; }
  .date-nav-center { min-width: 0; flex: 1; padding: 6px 8px; }
  .date-nav-label { font-size: 9px; }
  .date-nav-meta { gap: 4px; }
  .date-nav-action { padding: 0 8px; font-size: 11px; }

  /* Tab nav: horizontaal scrollbaar, geen scrollbar zichtbaar */
  .tab-nav { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex-wrap: nowrap; }
  .tab-nav::-webkit-scrollbar { display: none; }
  .tab-nav-btn { padding: 12px 14px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }

  /* KPI cards */
  .kpi-row { gap: 10px; }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 11px; }

  /* Charts */
  .chart-wrap { height: 190px; }

  /* Overzicht summary */
  .summary-row { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* Modal: bottom sheet */
  .modal-overlay { align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 88vh; padding: 20px 16px; transform: translateY(32px); }
  .modal-overlay.open .modal { transform: translateY(0); }

  /* Login */
  .login-card { padding: 28px 20px; margin: 0 12px; max-width: 100%; }

  /* Tabel: kleinere padding op mobiel */
  thead th { padding: 8px 8px; font-size: 9px; }
  tbody td { padding: 9px 8px; font-size: 12px; }
  .overview-table thead th { padding: 8px 8px; font-size: 9px; }
  .overview-table tbody td { padding: 9px 8px; font-size: 12px; }
}

/* ── TAB NAV ── */
.tab-nav {
  position: relative; z-index: 1;
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  padding: 0 32px;
}
.tab-nav-btn {
  background: none; border: none; color: var(--muted);
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 600;
  padding: 14px 20px; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all 0.15s;
}
.tab-nav-btn:hover { color: var(--text); }
.tab-nav-btn.active { color: var(--yellow); border-bottom-color: var(--yellow); }

/* ── DROPDOWN ── */
.select-wrap { position: relative; display: inline-block; }
.select-wrap select {
  appearance: none; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 8px 32px 8px 12px; border-radius: 7px;
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500;
  cursor: pointer; outline: none; transition: border-color 0.15s;
}
.select-wrap select:focus { border-color: var(--blue); }
.select-wrap::after {
  content: '▾'; position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 12px;
}

/* ── OVERZICHT PAGE ── */
.overview-controls {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px;
}
.overview-controls label { font-size: 12px; color: var(--muted); font-weight: 500; }
.arrow-sep { color: var(--muted); font-size: 18px; }

.overview-table-wrap { overflow-x: auto; }
.overview-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.overview-table thead th {
  text-align: left; padding: 9px 12px; font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.8px; border-bottom: 1px solid var(--border);
  font-weight: 500; white-space: nowrap; cursor: pointer; user-select: none;
}
.overview-table thead th:hover { color: var(--text); }
.overview-table thead th.sort-asc::after { content: ' ▲'; font-size: 9px; }
.overview-table thead th.sort-desc::after { content: ' ▼'; font-size: 9px; }
.overview-table tbody tr { border-bottom: 1px solid rgba(42,47,74,0.5); transition: background 0.1s; }
.overview-table tbody tr:hover { background: rgba(79,195,247,0.04); }
.overview-table tbody td { padding: 10px 12px; color: var(--text); white-space: nowrap; }

.delta-pos { color: var(--green); font-weight: 600; }
.delta-neg { color: var(--red); font-weight: 600; }
.delta-zero { color: var(--muted); }

.spark { display: inline-flex; gap: 2px; align-items: flex-end; height: 24px; vertical-align: middle; margin-left: 6px; }
.spark-bar { width: 5px; border-radius: 2px 2px 0 0; min-height: 2px; }

.summary-row {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 20px;
}

/* ── VERKOPEN TAB ── */
.verkoop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.verkoop-stat { text-align: center; padding: 16px; }
.verkoop-stat-val { font-family: 'Press Start 2P', monospace; font-size: 13px; margin-bottom: 6px; }
.verkoop-stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.tag-win { background: rgba(105,255,71,0.12); color: var(--green); border: 1px solid rgba(105,255,71,0.3); padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.tag-loss { background: rgba(255,83,112,0.12); color: var(--red); border: 1px solid rgba(255,83,112,0.3); padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.del-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 4px; transition: all 0.15s; }
.del-btn:hover { color: var(--red); background: rgba(255,83,112,0.1); }

/* ── Login screen ────────────────────────────────────────────────── */
#loginScreen {
  position: fixed; inset: 0; background: var(--bg); z-index: 10000;
  display: flex; align-items: center; justify-content: center;
}
#loginScreen::before {
  content: ''; position: fixed; inset: 0;
  background-image: linear-gradient(rgba(79,195,247,0.03) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(79,195,247,0.03) 1px, transparent 1px);
  background-size: 32px 32px; pointer-events: none;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 380px;
  position: relative; z-index: 1;
  box-shadow: 0 0 40px rgba(79,195,247,0.08);
}
.login-logo {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  margin-bottom: 32px;
}
.login-logo svg { width: 48px; height: 48px; }
.login-logo h1 {
  font-family: 'Press Start 2P', monospace; font-size: 10px;
  color: var(--yellow); text-align: center; line-height: 1.8;
}
.login-field { margin-bottom: 16px; }
.login-field label {
  display: block; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.login-field input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 11px 14px; color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 14px; outline: none;
  transition: border-color 0.15s;
}
.login-field input:focus { border-color: var(--blue); }
.login-btn {
  width: 100%; padding: 12px; margin-top: 8px; background: var(--yellow);
  color: #000; border: none; border-radius: 8px; cursor: pointer;
  font-family: 'Press Start 2P', monospace; font-size: 9px; letter-spacing: 0.5px;
  transition: background 0.15s;
}
.login-btn:hover { background: #ffe66d; }
.login-btn:disabled { opacity: 0.5; cursor: default; }
.login-error {
  color: var(--red); font-size: 12px; text-align: center;
  margin-top: 12px; min-height: 18px;
}
.logout-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 12px;
  font-family: 'DM Sans', sans-serif; transition: all 0.15s; margin-left: 12px;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); }
.del-etb-btn {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 14px; padding: 2px 6px; border-radius: 4px; transition: all 0.15s;
  opacity: 0.4;
}
.del-etb-btn:hover { opacity: 1; color: var(--red); background: rgba(255,83,112,0.1); }
