:root {
  --ink: #17242B;
  --ink-soft: #3C4B52;
  --paper: #EEEAE0;
  --paper-raised: #F7F4EC;
  --rule: #C9C0AC;
  --brass: #9C7A3C;
  --brass-deep: #7A5E2C;
  --gain: #3C6E47;
  --loss: #A6402E;
  --muted-line: #A79B7E;
  --font-display: 'Source Serif 4', Georgia, serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, monospace;
  --font-body: 'Inter', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body { margin: 0; }

a { color: var(--brass-deep); }
a:hover { color: var(--brass); }
a:visited { color: var(--brass-deep); }

#app-root {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

.app-header {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 16px;
  background: var(--ink);
  position: sticky;
  top: 0;
  z-index: 110;
}

.hamburger-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--paper);
}

.app-shell {
  display: flex;
  align-items: flex-start;
}

.sidebar {
  width: 0;
  background: var(--paper-raised);
  border-right: 0px solid var(--rule);
  padding: 12px 0;
  overflow: hidden;
  white-space: nowrap;
  flex-shrink: 0;
  transition: width 0.2s ease;
}

html.sidebar-open .sidebar {
  width: 240px;
  border-right-width: 1px;
}

.sidebar-link {
  display: block;
  padding: 12px 24px;
  font-size: 14px;
  color: var(--ink-soft);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: var(--paper);
  color: var(--ink);
}

.sidebar-link.active {
  color: var(--ink);
  font-weight: 600;
  border-left-color: var(--brass);
  background: var(--paper);
}

.app-main {
  flex: 1;
  min-width: 0;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 32px 80px;
}

@media (max-width: 640px) {
  .wrap { padding: 32px 18px 60px; }
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 18px;
  margin-bottom: 6px;
  gap: 16px;
  flex-wrap: wrap;
}

.masthead h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  letter-spacing: -0.01em;
  margin: 0;
}

.period-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.period-arrow {
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1;
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 3px 9px;
}
.period-arrow:hover:not(:disabled) { background: var(--paper-raised); color: var(--ink); }
.period-arrow:disabled { opacity: 0.35; cursor: default; }

.period-select {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-soft);
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 2px;
  max-width: 40vw;
}
.period-select:hover:not(:disabled) { color: var(--ink); }
.period-select:focus { outline: 2px solid var(--brass); outline-offset: 1px; }
.period-select:disabled { cursor: default; }

.subline {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 10px 0 40px;
  line-height: 1.5;
  max-width: 64ch;
}

.hero-equal {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  padding: 30px 0;
  border-bottom: 1px solid var(--rule);
}

@media (max-width: 640px) {
  .hero-equal { grid-template-columns: 1fr; gap: 22px; }
}

.stat-label {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.stat-number {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 38px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.stat-number.gain { color: var(--gain); }
.stat-number.loss { color: var(--loss); }

.stat-delta {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

.stat-subnote {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted-line);
}

.editable-stat {
  cursor: pointer;
  border-radius: 4px;
}

.editable-stat:hover,
.editable-stat:focus {
  outline: none;
  background: var(--paper-soft, rgba(0, 0, 0, 0.04));
}

.editable-stat input {
  font: inherit;
  color: inherit;
  width: 100%;
  border: 1px solid var(--brass-deep, #999);
  border-radius: 4px;
  padding: 0 4px;
  background: var(--paper, #fff);
}

.goal-block {
  padding: 26px 0;
  border-bottom: 1px solid var(--rule);
}

.goal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.goal-head-left { font-size: 14px; color: var(--ink-soft); }
.goal-head-left strong { color: var(--ink); font-weight: 600; }

.goal-track {
  height: 10px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
}

.goal-fill {
  height: 100%;
  background: var(--brass);
  transition: width 0.5s ease;
}

.goal-numbers {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-soft);
}

.notes-callout {
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
}

.notes-callout-label {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.notes-callout-body {
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
}

.notes-callout-body.empty {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 14px;
}

section.block {
  padding: 32px 0;
  border-bottom: 1px solid var(--rule);
}

section.block h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 20px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.section-head h2 { margin: 0 0 20px; }

.section-head-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

dialog.modal {
  width: min(560px, calc(100vw - 48px));
  padding: 28px 30px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  box-shadow: 0 12px 32px rgba(23, 36, 43, 0.25);
}

dialog.modal::backdrop {
  background: rgba(23, 36, 43, 0.45);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.modal-head h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  font-family: var(--font-body);
  font-size: 22px;
  line-height: 1;
  background: none;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
}
.modal-close:hover { color: var(--loss); }

@media (max-width: 640px) {
  dialog.modal { padding: 22px 20px; }
}

.chart-wrap { width: 100%; overflow-x: auto; }
.chart-caption {
  display: flex;
  gap: 18px;
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 10px;
  flex-wrap: wrap;
}
.chart-caption span { display: flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; display: inline-block; }
.swatch.line { width: 14px; height: 2px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th {
  text-align: right;
  font-weight: 500;
  color: var(--ink-soft);
  font-size: 12px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--ink);
  white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }

td {
  text-align: right;
  padding: 10px 8px 10px 0;
  border-bottom: 1px dotted var(--rule);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.month-cell { font-family: var(--font-body); white-space: nowrap; }

td.ytd-current { font-weight: 600; }

td.pos { color: var(--gain); }
td.neg { color: var(--loss); }
td.pct-hit { color: var(--gain); }
td.pct-miss { color: var(--loss); }

.row-actions { white-space: nowrap; }
.row-actions button {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-soft);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-left: 8px;
}
.row-actions button:hover { color: var(--loss); }
.row-actions button.notes-toggle:hover { color: var(--brass-deep); }

tr.row-viewed td { background: var(--paper-raised); }

tr.notes-row td {
  font-family: var(--font-body);
  text-align: left;
  white-space: normal;
  background: var(--paper-raised);
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.5;
  padding: 12px 16px;
}

.empty-note {
  font-size: 14px;
  color: var(--ink-soft);
  font-style: italic;
  padding: 12px 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.form-grid.notes-grid {
  grid-template-columns: 1fr;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

label .hint {
  font-style: italic;
  color: var(--muted-line);
}

input[type="text"], input[type="number"], input[type="month"], textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 9px 10px;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  color: var(--ink);
}

textarea {
  font-family: var(--font-body);
  font-size: 14px;
  min-height: 90px;
  resize: vertical;
  line-height: 1.5;
}

input:focus, textarea:focus { outline: 2px solid var(--brass); outline-offset: 1px; }

.btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  cursor: pointer;
}
.btn:hover { background: var(--brass-deep); }

.btn-ghost {
  background: none;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
}
.btn-ghost:hover { background: var(--paper-raised); color: var(--ink); }

.form-actions { display: flex; gap: 10px; align-items: center; }

.save-note {
  font-size: 12.5px;
  color: var(--gain);
  margin-left: 4px;
}

.footer-note {
  margin-top: 30px;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.edit-banner {
  background: var(--paper-raised);
  border: 1px solid var(--brass);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
