@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:wght@400;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #211812;
  --panel: #2a1f18;
  --line: #4a3a2c;
  --ink: #ecdfc8;
  --ink-dim: #a89478;
  --up: #7fa66b;
  --down: #c26b52;
  --accent: #c98f4e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Source Serif 4', Georgia, serif;
  background: var(--bg);
  color: var(--ink);
  padding: 2.5rem 1.25rem 4rem;
}

main {
  max-width: 760px;
  margin: 0 auto;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
  margin-bottom: 0.25rem;
}

h1 {
  font-size: 1.9rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.3px;
}

.fx-line {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.fx-line span {
  color: var(--accent);
}

.updated-note {
  font-size: 0.75rem;
  color: var(--ink-dim);
  margin: 0.6rem 0 1.75rem;
  font-family: 'IBM Plex Mono', monospace;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
}

thead th {
  text-align: right;
  font-family: 'Source Serif 4', serif;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
  padding: 0 0 0.6rem;
}

thead th:first-child, td.asset { text-align: left; }

tbody td, tfoot td {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

td.asset {
  font-family: 'Source Serif 4', serif;
}

td.asset .symbol {
  font-weight: 600;
  font-size: 1.05rem;
}

td.asset .name {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: var(--ink-dim);
  margin-top: 0.1rem;
}

.inline-select {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
  border-radius: 3px;
  cursor: pointer;
}

.inline-select:focus {
  outline: none;
  border-color: var(--accent);
}

th .period-select {
  margin-left: 0.5rem;
  font-size: 0.7rem;
  padding: 0.15rem 0.35rem;
  text-transform: none;
  font-weight: 400;
}

.change.up { color: var(--up); }
.change.down { color: var(--down); }
.change.flat { color: var(--ink-dim); }

input.qty, input.avgcost {
  width: 5.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
  text-align: right;
  padding: 0.35rem 0.5rem;
  border-radius: 3px;
  -moz-appearance: textfield;
  appearance: textfield;
}

input.qty::-webkit-outer-spin-button,
input.qty::-webkit-inner-spin-button,
input.avgcost::-webkit-outer-spin-button,
input.avgcost::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input.qty:focus, input.avgcost:focus {
  outline: none;
  border-color: var(--accent);
}

tfoot .total-label {
  font-family: 'Source Serif 4', serif;
  font-weight: 600;
  text-align: left;
  color: var(--ink);
}

tfoot td {
  border-bottom: none;
  border-top: 2px solid var(--line);
  font-weight: 600;
  font-size: 1rem;
}

.price-cell.flash-up { color: var(--up); }
.price-cell.flash-down { color: var(--down); }

.err {
  color: var(--down);
  font-size: 0.8rem;
}

.asset-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.asset-text {
  display: flex;
  flex-direction: column;
}

.remove-ticker {
  background: none;
  border: none;
  color: var(--ink-dim);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
  flex-shrink: 0;
}

.remove-ticker:hover { color: var(--down); }

.add-ticker {
  margin-top: 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.add-ticker input.ticker-input {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
  border-radius: 3px;
  width: 9rem;
  text-transform: uppercase;
}

.add-ticker input.ticker-input:focus {
  outline: none;
  border-color: var(--accent);
}

.add-ticker button {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  padding: 0.45rem 0.9rem;
  border-radius: 3px;
  cursor: pointer;
}

.add-ticker button:hover {
  background: var(--accent);
  color: var(--bg);
}

.add-ticker-note {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--ink-dim);
}

footer {
  margin-top: 2rem;
  color: var(--ink-dim);
  font-size: 0.75rem;
  font-family: 'IBM Plex Mono', monospace;
}

@media (max-width: 600px) {
  table, thead, tbody, tfoot, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr {
    border-bottom: 1px solid var(--line);
    padding: 0.75rem 0;
  }
  tbody td, tfoot td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
    padding: 0.25rem 0;
    white-space: normal;
  }
  tbody td::before, tfoot td::before {
    content: attr(data-label);
    color: var(--ink-dim);
    font-size: 0.75rem;
    margin-right: 1rem;
  }
  td.asset::before { content: none; }
  tfoot tr { border-top: 2px solid var(--line); margin-top: 0.5rem; }
}
