/* ==========================================================================
   Ledger & Yield — design tokens
   A financial instrument rendered as an engraved certificate: deep bond-
   paper green, brass ink, monospace figures for anything that is money.
   ========================================================================== */

:root {
  /* Color */
  --ink:          #0B2418;   /* deepest background */
  --ink-2:        #10301F;   /* panel background */
  --ink-3:        #16402A;   /* raised / hover surface */
  --paper:        #F4EFDD;   /* parchment surface (light accents only) */
  --brass:        #C6A15B;   /* primary accent */
  --brass-bright: #E7C583;   /* hover / emphasis */
  --brass-dim:    rgba(198, 161, 91, 0.28);
  --text-hi:      #F1ECDA;   /* headings, high emphasis */
  --text:         #D8D2BE;   /* body text on dark */
  --text-dim:     #9CA895;   /* captions, hints */
  --gain:         #6FAE7E;   /* positive / interest */
  --gain-dim:     rgba(111, 174, 126, 0.22);
  --rust:         #C06B4E;   /* warnings, disclaimers accent */
  --line:         rgba(198, 161, 91, 0.22);

  /* Type */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;

  /* Layout */
  --radius: 3px;
  --shadow-panel: 0 24px 60px -30px rgba(0, 0, 0, 0.65);
  --content-width: 1180px;
}

@media (prefers-reduced-motion: no-preference) {
  :root { --transition: 180ms ease; }
}
@media (prefers-reduced-motion: reduce) {
  :root { --transition: 0ms; }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 3px;
}

.page {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 28px 80px;
}

/* ==========================================================================
   Header / nav
   ========================================================================== */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 30px 0 24px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
}

.wordmark-mark {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--brass);
}

.wordmark-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--text-hi);
}

.site-nav {
  display: flex;
  gap: 28px;
}

.site-nav a {
  text-decoration: none;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.site-nav a:hover { color: var(--text-hi); }

.site-nav a.is-active {
  color: var(--brass-bright);
  border-bottom-color: var(--brass-bright);
}

/* ==========================================================================
   Hero / certificate frame — the signature element
   ========================================================================== */

.certificate-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--brass-dim);
  border-radius: var(--radius);
  background: radial-gradient(circle at 50% -10%, var(--ink-3) 0%, var(--ink-2) 55%, var(--ink) 100%);
}

.guilloche-bg {
  position: absolute;
  inset: 0;
  color: var(--brass);
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72'%3E%3Cg fill='none' stroke='%23C6A15B' stroke-width='0.6'%3E%3Ccircle cx='36' cy='36' r='30'/%3E%3Ccircle cx='36' cy='36' r='22'/%3E%3Ccircle cx='0' cy='0' r='30'/%3E%3Ccircle cx='72' cy='0' r='30'/%3E%3Ccircle cx='0' cy='72' r='30'/%3E%3Ccircle cx='72' cy='72' r='30'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 60px;
  height: 60px;
  color: var(--brass);
  opacity: 0.6;
}
.corner-tl { top: 14px; left: 14px; }
.corner-tr { top: 14px; right: 14px; transform: scaleX(-1); }
.corner-bl { bottom: 14px; left: 14px; transform: scaleY(-1); }
.corner-br { bottom: 14px; right: 14px; transform: scale(-1, -1); }

.hero { margin-top: 32px; padding: 76px 48px; text-align: center; }
.hero-compact { padding: 56px 48px; }

.hero-inner { position: relative; z-index: 1; max-width: 640px; margin: 0 auto; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 18px;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.08;
  color: var(--text-hi);
  margin: 0 0 20px;
}

.hero-sub {
  font-size: 16px;
  color: var(--text);
  margin: 0;
}

/* ==========================================================================
   Layout grid
   ========================================================================== */

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 24px;
  margin-top: 24px;
  align-items: start;
}

.layout-single { grid-template-columns: 1fr; }

.panel {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-panel);
}

.panel-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--text-hi);
  margin: 0 0 26px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

/* ==========================================================================
   Form
   ========================================================================== */

.field { margin-bottom: 22px; }

.field label {
  display: block;
  font-size: 13px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.field-hint {
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 8px 0 0;
}

.input-currency {
  display: flex;
  align-items: center;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
  transition: border-color var(--transition);
}

.input-currency:focus-within { border-color: var(--brass); }

.input-currency span {
  font-family: var(--font-mono);
  color: var(--brass);
  padding-right: 6px;
}

.input-currency input,
select {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-hi);
  font-family: var(--font-mono);
  font-size: 16px;
  padding: 13px 0;
}

.input-currency input:focus, select:focus { outline: none; }

select {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23C6A15B' stroke-width='1.4' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.slider-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.slider-label-row label { margin-bottom: 0; }

.slider-label-row output {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--brass-bright);
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brass);
  border: 2px solid var(--ink-2);
  box-shadow: 0 0 0 1px var(--brass);
  cursor: pointer;
  margin-top: -6.5px;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brass);
  border: 2px solid var(--ink-2);
  box-shadow: 0 0 0 1px var(--brass);
  cursor: pointer;
}

.advanced-toggle {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-bottom: 24px;
}

.advanced-toggle summary {
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.advanced-toggle summary:hover { color: var(--brass-bright); }

.advanced-toggle[open] summary { color: var(--brass); margin-bottom: 18px; }

.btn-brass {
  width: 100%;
  border: 1px solid var(--brass);
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: filter var(--transition), transform var(--transition);
}

.btn-brass:hover { filter: brightness(1.08); }
.btn-brass:active { transform: translateY(1px); }

.btn-outline {
  border: 1px solid var(--brass);
  background: transparent;
  color: var(--brass-bright);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: var(--radius);
  padding: 13px 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  display: inline-block;
}

.btn-outline:hover { background: var(--brass); color: var(--ink); }

/* ==========================================================================
   Results
   ========================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
}

.stat-block {
  background: var(--ink-2);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-primary { background: var(--ink-3); }

.stat-label {
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.stat-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(18px, 2vw, 24px);
  color: var(--text-hi);
}

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

.chart-row {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 28px;
  margin-bottom: 36px;
  align-items: center;
}

.chart-wrap { min-height: 260px; }

.donut-wrap { text-align: center; }

.donut-legend {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  text-align: left;
  font-size: 13px;
}

.donut-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--text);
}

.donut-legend strong {
  margin-left: auto;
  font-family: var(--font-mono);
  color: var(--text-hi);
}

.swatch {
  width: 10px; height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.swatch-contrib { background: var(--brass); }
.swatch-interest { background: var(--gain); }

.ledger-heading {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  color: var(--text-hi);
  margin: 0 0 16px;
}

.table-scroll { overflow-x: auto; margin-bottom: 8px; }

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.ledger-table th {
  text-align: right;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
}

.ledger-table th:first-child, .ledger-table td:first-child { text-align: left; }

.ledger-table td {
  text-align: right;
  font-family: var(--font-mono);
  padding: 10px 12px;
  color: var(--text);
  border-bottom: 1px solid rgba(198, 161, 91, 0.1);
}

.ledger-table tbody tr:nth-child(even) { background: rgba(198, 161, 91, 0.035); }
.ledger-table tbody tr:hover { background: var(--gain-dim); }

.history-table td:first-child { font-family: var(--font-body); color: var(--text-hi); }

/* ==========================================================================
   Content panel (About + FAQ)
   ========================================================================== */

.content-panel { margin-top: 24px; }
.content-panel p { margin: 0 0 16px; color: var(--text); }
.content-panel p:last-of-type { margin-bottom: 0; }
.content-panel a { color: var(--brass-bright); text-decoration: underline; text-underline-offset: 2px; }

.faq-list { display: flex; flex-direction: column; gap: 10px; }

.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  background: var(--ink);
}

.faq-item summary {
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text-hi);
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before {
  content: '+';
  color: var(--brass);
  display: inline-block;
  width: 16px;
  font-family: var(--font-mono);
}
.faq-item[open] summary::before { content: '–'; }

.faq-item p {
  margin: 12px 0 2px 16px;
  font-size: 14px;
  color: var(--text);
}

/* ==========================================================================
   Save panel
   ========================================================================== */

.save-panel {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.save-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.save-row input {
  flex: 1;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-hi);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 13px 14px;
}

.save-panel textarea {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 12px 14px;
  resize: vertical;
}

.save-status {
  font-size: 13px;
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--gain);
}
.save-status.is-error { color: var(--rust); }

/* ==========================================================================
   History page extras
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
}
.empty-state a { margin-top: 16px; }

.row-delete {
  background: transparent;
  border: 1px solid transparent;
  color: var(--rust);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: border-color var(--transition), background var(--transition);
}
.row-delete:hover { border-color: var(--rust); background: rgba(192, 107, 78, 0.12); }

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-dim);
}

.site-footer p { margin: 0 0 10px; }
.site-footer code {
  font-family: var(--font-mono);
  background: var(--ink-2);
  padding: 1px 6px;
  border-radius: 2px;
}
.disclaimer { color: var(--text-dim); font-style: italic; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-row { grid-template-columns: 1fr; }
  .hero { padding: 56px 28px; }
}

@media (max-width: 560px) {
  .page { padding: 0 16px 60px; }
  .site-header { flex-direction: column; align-items: flex-start; gap: 14px; }
  .stat-grid { grid-template-columns: 1fr; }
  .save-row { flex-direction: column; }
  .panel { padding: 22px; }
  .corner { width: 36px; height: 36px; }
}
