/* Investment Tracker – Stylesheet */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f1f3f6;
  --border: #e3e6ec;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --pos: #10b981;
  --neg: #ef4444;
  --warn: #f59e0b;
  --warn-soft: #fef3c7;
  --shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 1px 2px rgba(17, 24, 39, .04);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.brand .logo {
  display: inline-block; width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
  position: relative;
}
.brand .logo::after {
  content: ""; position: absolute; left: 4px; top: 12px; width: 14px; height: 6px;
  border-top: 2px solid var(--pos);
  border-right: 2px solid var(--pos);
  transform: rotate(-32deg) translateY(-2px);
  border-radius: 1px;
}
.brand .domain { color: var(--text-muted); font-weight: 400; font-size: 12px; margin-left: 8px; }
.nav { display: flex; gap: 4px; margin-left: 16px; }
.nav a {
  color: var(--text-muted); text-decoration: none;
  padding: 6px 12px; border-radius: var(--radius-sm); font-weight: 500;
}
.nav a:hover { background: var(--surface-muted); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.header-tools { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.tax-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); cursor: pointer; }

/* ---------- Banner ---------- */
.banner {
  padding: 10px 24px; background: var(--warn-soft); color: #92400e;
  border-bottom: 1px solid #fde68a; font-size: 13px;
}
.banner.hidden { display: none; }

/* ---------- Buttons ---------- */
.btn, .btn-ghost {
  font: inherit; border-radius: var(--radius-sm); padding: 7px 14px;
  cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  color: var(--text);
}
.btn { background: var(--text); color: white; border-color: var(--text); }
.btn:hover { background: #1f2937; }
.btn-ghost:hover { background: var(--surface-muted); }
.btn[disabled], .btn-ghost[disabled] { opacity: .5; cursor: not-allowed; }
label.btn { display: inline-block; }

/* ---------- Main / Views ---------- */
main { flex: 1; padding: 24px; max-width: 1320px; width: 100%; margin: 0 auto; }
.view h1 { font-size: 22px; margin: 0 0 16px; }
.view h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 0 0 12px; font-weight: 600; }
.back { display: inline-block; margin-bottom: 10px; color: var(--text-muted); text-decoration: none; font-size: 13px; }
.back:hover { color: var(--text); }

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid; gap: 12px; margin-bottom: 20px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.kpi-grid-3 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi.accent { background: linear-gradient(135deg, #111827, #1f2937); color: white; border-color: #1f2937; }
.kpi.accent .kpi-label { color: rgba(255,255,255,.7); }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.accent .kpi-sub { color: rgba(255,255,255,.7); }

/* ---------- Card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card.warn { background: var(--warn-soft); border-color: #fde68a; color: #92400e; }
.card canvas { display: block; width: 100% !important; max-height: 300px; }
.chart-box { position: relative; height: 280px; width: 100%; }
.chart-box canvas { position: absolute; inset: 0; max-height: 100% !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.actions { display: flex; gap: 10px; }
.muted { color: var(--text-muted); font-size: 12px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
.data-table th, .data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.data-table th { font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.data-table tr:hover td { background: var(--surface-muted); }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tr.row-link { cursor: pointer; }
.pos { color: var(--pos); font-weight: 500; }
.neg { color: var(--neg); font-weight: 500; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.buy { background: var(--accent-soft); color: var(--accent); }
.badge.sell { background: #fef3c7; color: #92400e; }
.badge.hold { background: var(--surface-muted); color: var(--text-muted); }

/* Kursquellen-Badge (live / manuell / veraltet / n/a) */
.src-badge {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  vertical-align: middle; margin-left: 4px; line-height: 1.4;
}
.src-live    { background: #dcfce7; color: #166534; }
.src-manual  { background: #dbeafe; color: #1e3a8a; }
.src-stale   { background: #fef3c7; color: #92400e; }
.src-missing { background: var(--surface-muted); color: var(--text-muted); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.form-grid label.wide { grid-column: span 4; }
.form-grid input, .form-grid select, .form-grid textarea {
  font: inherit; padding: 7px 9px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: white; color: var(--text);
}
.form-grid input:focus, .form-grid select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.trigger-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.trigger-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.trigger-row input { padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); width: 110px; }

/* ---------- Manual quotes ---------- */
.manual-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.manual-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; margin-bottom: 12px; }
.manual-row { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 10px; row-gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-muted); }
.manual-row.has-manual { background: #ecfdf5; border-color: #a7f3d0; }
.manual-row .name { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.manual-row .name strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.manual-row .name .sub { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.manual-row input { width: 110px; padding: 5px 7px; border: 1px solid var(--border); border-radius: var(--radius-sm); text-align: right; font-variant-numeric: tabular-nums; background: white; justify-self: end; align-self: start; }
.manual-row-actions { grid-column: 2; display: flex; gap: 6px; justify-content: end; }
.manual-row-actions .btn, .manual-row-actions .btn-ghost { padding: 4px 10px; font-size: 12px; }
.manual-row-msg { grid-column: 1 / -1; font-size: 11px; color: var(--text-muted); min-height: 0; }
.manual-row-msg.error { color: var(--neg); font-weight: 500; }
.manual-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Footer ---------- */
.footer {
  padding: 12px 24px; font-size: 12px; color: var(--text-muted);
  border-top: 1px solid var(--border); background: var(--surface);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.footer .sep { opacity: .4; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpi-grid, .kpi-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid label.wide { grid-column: span 2; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .nav { order: 3; margin-left: 0; flex-wrap: wrap; }
  .header-tools { order: 2; margin-left: auto; }
  main { padding: 16px; }
  .kpi-grid, .kpi-grid-3 { grid-template-columns: 1fr 1fr; }
}
