/* Stash: warm paper, quiet structure, local fonts only. */
:root {
  color-scheme: light;
  --paper: #F5F3EE; --surface: #FFFEFA; --ink: #242820;
  --muted: #62675B; --border: #DEDCD3; --gold: #A87723;
  --gold-light: #F0DFB5; --silver: #777F87;
  --success: #28604A; --danger: #9B3832;
  --radius: 20px; --shadow: 0 4px 20px rgb(36 40 32 / 3%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--paper);
  font-synthesis: none; line-height: 1.55;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
img, svg { max-width: 100%; vertical-align: middle; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-underline-offset: .2em; overflow-wrap: anywhere; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
.hero :focus-visible { outline-color: var(--gold-light); }
[hidden] { display: none !important; }
h1, h2, h3, p, dl { margin: 0; }
h1, h2, h3 { letter-spacing: -.035em; line-height: 1.18; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 4vw, 2.75rem); font-weight: 650; }
h2 { font-size: clamp(1.3rem, 2.4vw, 1.65rem); font-weight: 650; }
h3 { font-size: 1.125rem; font-weight: 650; }
p + p { margin-top: .8rem; }
small, .small { font-size: .85rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.muted, dt, .field small { color: var(--muted); }
.positive { color: var(--success); }
.negative { color: var(--danger); }
.overline { font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.value, .amount, dd, td { font-variant-numeric: tabular-nums; }
.value, .amount { letter-spacing: -.035em; font-weight: 650; }
.skip-link { position: fixed; top: .75rem; left: .75rem; z-index: 10; padding: .75rem 1rem; background: var(--surface); transform: translateY(-200%); border: 1px solid var(--ink); border-radius: 12px; }
.skip-link:focus { transform: none; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner, .page, .site-footer { width: min(100% - 2rem, 1180px); margin-inline: auto; }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem 2rem; padding-block: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; min-height: 44px; text-decoration: none; font-size: 2rem; line-height: 1; letter-spacing: -.075em; font-weight: 750; }
.brand-mark { width: 42px; height: 42px; color: var(--gold); }
.header-note { color: var(--muted); font-size: .85rem; }
.main-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.main-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: .55rem .8rem; border-radius: 12px; font-size: .9rem; text-decoration: none; font-weight: 600; }
.main-nav a:hover, .main-nav a[aria-current="page"] { background: var(--paper); }
.main-nav a[aria-current="page"] { box-shadow: inset 0 -2px var(--gold); }
.main-nav form { margin: 0; }
.page { flex: 1; padding-block: clamp(1.5rem, 4vw, 3rem); min-width: 0; }
.page > * + * { margin-top: 1.5rem; }
.site-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1.5rem; padding-block: 1rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .8rem; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; }
.section-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; }
.section-heading p { margin-top: .5rem; }
.card, .metal-card, .position-card, .auth-card { padding: clamp(1.1rem, 2.5vw, 1.75rem); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > * + *, .position-card > * + *, .auth-card > * + * { margin-top: 1.25rem; }
.grid, .stats, .form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.grid > *, .stats > *, .form-grid > *, .section-heading > *, .actions > *, .header-inner > *, .auth-layout > * { min-width: 0; }
.card, .hero, .position-card, .metal-card, .auth-card, .field { min-width: 0; overflow-wrap: anywhere; }
.hero { position: relative; padding: clamp(1.5rem, 3.5vw, 2.5rem); border-radius: 24px; background: var(--ink); color: var(--surface); border: 1px solid var(--ink); border-top: 3px solid var(--gold); }
.hero > * + * { margin-top: 1rem; }
.hero .value { display: block; font-size: clamp(2.25rem, 5vw, 3.5rem); line-height: 1.12; }
.hero .muted, .hero dt { color: #D1D2C8; }
.hero .positive { color: #A9D8BF; }
.hero .negative { color: #FFC1B9; }
.hero .stats { border-top: 1px solid #505447; padding-top: 1.4rem; margin-top: 1.75rem; gap: 1.25rem; }
dt { font-size: .85rem; }
dd { margin: .3rem 0 0; font-size: 1.2rem; font-weight: 600; }
.metal-card { border-top: 3px solid var(--gold); }
.metal-card.silver { border-top-color: var(--silver); }
.metal-card .value { font-size: clamp(1.3rem, 3vw, 1.9rem); margin-block: .65rem .35rem; }
.metal-card small { display: block; margin-top: .4rem; color: var(--muted); }
.badge { display: inline-block; padding: .25rem .65rem; border-radius: 999px; background: var(--gold-light); color: #65450F; font-size: .75rem; font-weight: 650; vertical-align: middle; }
.badge.secondary { background: #ECEDE8; color: var(--muted); }
.badge.positive { background: #E2EFE7; color: var(--success); }
.badge.negative { background: #F7E7E3; color: var(--danger); }
.field { display: flex; flex-direction: column; gap: .45rem; }
label, legend { font-weight: 600; font-size: .9rem; }
input:not([type="hidden"]), select, textarea { width: 100%; max-width: 100%; min-width: 0; min-height: 46px; border: 1px solid #A6AA9D; border-radius: 12px; padding: .65rem .85rem; background: var(--surface); color: var(--ink); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"], input[type="radio"] { width: 1.35rem; min-height: 1.35rem; accent-color: var(--ink); }
label:has(input[type="checkbox"]), label:has(input[type="radio"]) { display: flex; align-items: center; gap: .7rem; min-height: 44px; }
textarea { min-height: 110px; resize: vertical; }
fieldset { min-width: 0; border: 1px solid var(--border); border-radius: 16px; padding: 1rem; }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-size: .85rem; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; max-width: 100%; padding: .7rem 1.1rem; border: 1px solid var(--ink); border-radius: 12px; background: var(--ink); color: var(--surface); text-align: center; text-decoration: none; font-size: .9rem; font-weight: 600; line-height: 1.4; cursor: pointer; white-space: normal; overflow-wrap: anywhere; }
button:hover, .button:hover { background: #3B4134; border-color: #3B4134; }
button.secondary, .button.secondary { background: var(--surface); border-color: var(--border); color: var(--ink); }
button.secondary:hover, .button.secondary:hover { background: #ECEAE2; border-color: #A6AA9D; }
button.danger, .button.danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
button.danger:hover, .button.danger:hover { background: #7D2925; }
.card.danger { border-color: #D7A49D; }
button:disabled, input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.actions form { margin: 0; }
.empty-state { padding: clamp(2rem, 5vw, 4rem) 1.25rem; text-align: center; border: 1px dashed #B4B5A8; border-radius: var(--radius); }
.empty-state p { max-width: 48ch; margin: .8rem auto 1.3rem; color: var(--muted); }
.auth-layout { display: grid; gap: 2rem; align-items: center; max-width: 1040px; margin-inline: auto; padding-block: 1rem; }
.auth-intro h1 { max-width: 13ch; font-size: clamp(2.5rem, 5vw, 3.5rem); }
.auth-intro p { max-width: 42ch; margin-top: 1.25rem; color: var(--muted); }
.auth-art { display: block; width: min(100%, 260px); margin-top: 2rem; }
.auth-card form > * + * { margin-top: 1rem; }
.auth-card .button, .auth-card button[type="submit"] { width: 100%; }
.flash-list { display: grid; gap: .65rem; }
.flash { padding: .9rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--gold); border-radius: 12px; overflow-wrap: anywhere; }
.flash-success { border-left-color: var(--success); }
.flash-error, .flash-danger { border-left-color: var(--danger); color: var(--danger); }
.flash-warning { background: #FBF2DF; color: #65450F; }
details { min-width: 0; }
summary { min-height: 44px; padding-block: .65rem; font-weight: 600; cursor: pointer; }
details[open] > summary { margin-bottom: 1rem; }
.table-wrap { width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-inline: contain; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: .9rem; }
th, td { padding: .9rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.ledger-table th, .ledger-table td { white-space: nowrap; overflow-wrap: normal; }
th { background: var(--paper); color: var(--muted); font-size: .8rem; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
caption { text-align: left; padding: 1rem; font-weight: 600; }
@media (min-width: 360px) { .grid.metals { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 640px) {
  .header-inner, .page, .site-footer { width: min(100% - 3rem, 1180px); }
  .grid, .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field.full, .form-grid > .actions { grid-column: 1 / -1; }
}
@media (min-width: 900px) { .auth-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 5rem; padding-block: 3rem; } }
@media (max-width: 639px) {
  .main-nav { flex-basis: 100%; gap: .2rem; }
  .main-nav a { padding-inline: .6rem; }
  .main-nav button { padding-inline: .75rem; }
  .header-note { max-width: 16ch; text-align: right; }
  .section-heading > .actions { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
