/* ---------- theme tokens ---------- */
:root {
  color-scheme: light;
  --page:        #f9f9f7;
  --surface:     #fcfcfb;
  --ink:         #0b0b0b;
  --ink-2:       #52514e;
  --muted:       #898781;
  --grid:        #e1e0d9;
  --border:      rgba(11, 11, 11, 0.10);
  --accent:      #2a78d6;
  --good:        #0ca30c;
  --good-text:   #006300;
  --bad:         #d03b3b;
  --good-wash:   rgba(12, 163, 12, 0.14);
  --bad-wash:    rgba(208, 59, 59, 0.14);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page:      #0d0d0d;
    --surface:   #1a1a19;
    --ink:       #ffffff;
    --ink-2:     #c3c2b7;
    --muted:     #898781;
    --grid:      #2c2c2a;
    --border:    rgba(255, 255, 255, 0.10);
    --accent:    #3987e5;
    --good:      #0ca30c;
    --good-text: #0ca30c;
    --bad:       #e66767;
    --good-wash: rgba(12, 163, 12, 0.18);
    --bad-wash:  rgba(230, 103, 103, 0.18);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { background: var(--page); color: var(--ink); font-weight: 600; }

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* ---------- shared bits ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--ink-2); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { color: var(--ink); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.filter-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.pos { color: var(--good-text); }
.neg { color: var(--bad); }

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button.ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}
button.ghost:hover { color: var(--ink); }
button:disabled { opacity: 0.5; cursor: default; }

input[type="number"], input[type="text"], input[type="date"] {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 15px;
  font-family: inherit;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--grid);
}
td { padding: 7px 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
tfoot td { font-weight: 600; border-top: 1px solid var(--grid); border-bottom: none; }

.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* ---------- today ---------- */
.entry-card { text-align: center; padding: 24px 16px; }
.entry-amount {
  width: 180px;
  font-size: 28px;
  font-weight: 600;
  text-align: center;
  padding: 10px;
}
/* hide number spinners; they're useless at this size */
.entry-amount::-webkit-outer-spin-button, .entry-amount::-webkit-inner-spin-button { -webkit-appearance: none; }
.entry-amount { -moz-appearance: textfield; appearance: textfield; }

.entry-line { display: flex; gap: 8px; justify-content: center; align-items: stretch; }
.currency-toggle { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.currency-toggle button {
  border: none;
  background: var(--page);
  color: var(--muted);
  font-size: 18px;
  width: 44px;
  cursor: pointer;
}
.currency-toggle button.active { background: var(--accent); color: #fff; font-weight: 700; }
.entry-convert { margin-top: 8px; font-size: 13px; color: var(--muted); min-height: 1.2em; font-variant-numeric: tabular-nums; }

.entry-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 14px; }
.btn-win, .btn-loss {
  font-size: 17px;
  font-weight: 700;
  padding: 12px 36px;
  border-radius: 10px;
  border: none;
  color: #fff;
  cursor: pointer;
}
.btn-win { background: var(--good); }
.btn-loss { background: var(--bad); }
.btn-win:active, .btn-loss:active { transform: scale(0.97); }
.entry-hint { margin-top: 10px; font-size: 12px; color: var(--muted); }
kbd {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 11px;
  font-family: inherit;
  background: var(--page);
}

.day-total { display: flex; justify-content: center; gap: 32px; margin: 4px 0 8px; }
.day-total .big { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.day-total .sub { font-size: 13px; color: var(--muted); }

.trade-row { display: flex; align-items: center; gap: 12px; padding: 7px 4px; border-bottom: 1px solid var(--grid); }
.trade-row:last-child { border-bottom: none; }
.trade-time { color: var(--muted); font-size: 13px; width: 48px; }
.trade-amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.trade-acct { color: var(--muted); font-size: 12px; margin-left: auto; }
.trade-del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 6px;
  border-radius: 6px;
}
.trade-del:hover { color: var(--bad); background: var(--bad-wash); }

/* ---------- history calendar ---------- */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-title { font-weight: 600; font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 2px; }
.cal-cell {
  min-height: 62px;
  border: 1px solid var(--grid);
  border-radius: 8px;
  padding: 5px 7px;
  font-size: 12px;
  cursor: default;
}
.cal-cell.has-pnl { cursor: pointer; }
.cal-cell.has-pnl:hover { outline: 2px solid var(--accent); outline-offset: -1px; }
.cal-cell.selected { outline: 2px solid var(--accent); outline-offset: -1px; }
.cal-cell.other { visibility: hidden; }
.cal-cell.win { background: var(--good-wash); }
.cal-cell.loss { background: var(--bad-wash); }
.cal-day { color: var(--muted); }
.cal-cell.today .cal-day { color: var(--accent); font-weight: 700; }
.cal-pnl { font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ---------- analytics ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .label { font-size: 12px; color: var(--muted); }
.tile .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.tile .sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

.chart-box { position: relative; height: 280px; }

/* ---------- settings ---------- */
.form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.form-row label { font-size: 13px; color: var(--ink-2); min-width: 110px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--page);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 20;
}
.toast.show { opacity: 1; }

@media (max-width: 560px) {
  .topbar { flex-direction: column; gap: 8px; align-items: flex-start; }
  .day-total { gap: 20px; }
  .cal-cell { min-height: 52px; font-size: 11px; }
}
