:root {
    --paper: #f6f3ee;
    --ink: #1d1a16;
    --muted: #6b645b;
    --line: #e4ddd3;
    --card: #fffdf9;
    --accent: #2f4a3d;
    --accent-soft: #e7efe9;
    --warn: #7a3e1d;
    --warn-soft: #f6ebe3;
    --ok: #24543a;
    --ok-soft: #e5f2ea;
    --danger: #7a1f1f;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    font-size: 17px;
    line-height: 1.45;
}

a { color: var(--accent); }
a:hover { color: #1c2e26; }

.wrap {
    width: min(1080px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.25rem 0 3rem;
}
.wrap-dashboard {
    width: min(1180px, calc(100% - 2rem));
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
}

.brand {
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

.brand strong { font-weight: 650; }

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.85rem;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    font-size: 0.82rem;
    justify-content: flex-end;
}

.nav a { text-decoration: none; color: var(--muted); }
.nav a[aria-current="page"], .nav a:hover { color: var(--ink); }

h1, h2, h3 {
    font-weight: 650;
    letter-spacing: -0.01em;
    margin: 0 0 0.6rem;
}

h1 { font-size: 1.7rem; }
h2 { font-size: 1.15rem; margin-top: 1.5rem; }
p { margin: 0 0 0.85rem; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1rem 1.1rem;
    margin: 0 0 1rem;
}

.grid {
    display: grid;
    gap: 1rem;
}
@media (min-width: 780px) {
    .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
    .grid.cols-2 { grid-template-columns: 1fr 1fr; }
    .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
}

.stat {
    font-family: "Avenir Next", "Segoe UI", sans-serif;
}
.stat .label {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.stat .value {
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
}

.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    font-size: 0.92rem;
}
th, td {
    text-align: left;
    padding: 0.45rem 0.4rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 650; border-bottom: 0; }
.delta-up { color: var(--ok); }
.delta-down { color: var(--danger); }

label { display: block; margin: 0.7rem 0 0.25rem; font-family: "Avenir Next", "Segoe UI", sans-serif; font-size: 0.9rem; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    max-width: 28rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid #cfc6ba;
    border-radius: 7px;
    background: #fff;
    font: inherit;
}
textarea { min-height: 5rem; }
table input[type="number"], table input[type="text"], table input[type="date"] { max-width: 9rem; }
.meta-table input { max-width: 8rem; }
.narrow { max-width: 8rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.btn, button {
    appearance: none;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #f8f6f1;
    border-radius: 7px;
    padding: 0.45rem 0.8rem;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
}
.btn.secondary, button.secondary {
    background: transparent;
    color: var(--accent);
}
.btn.quiet, button.quiet {
    background: transparent;
    border-color: var(--line);
    color: var(--muted);
}
button.linkish {
    background: none;
    border: 0;
    color: var(--accent);
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.flash {
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
}
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: #f8e8e8; color: var(--danger); }

.banner {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}
.banner.warn { background: var(--warn-soft); color: var(--warn); }

.auth-card {
    max-width: 26rem;
    margin: 12vh auto;
}

.period {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: end;
    margin-bottom: 1rem;
}
.period label { margin-top: 0; }
.period select, .period input { max-width: 10rem; }

.suggestions li { margin-bottom: 0.45rem; }

.inline-forms { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.inline-forms input { max-width: 12rem; }

.note { font-size: 0.88rem; color: var(--muted); }

footer.site {
    margin-top: 2rem;
    color: var(--muted);
    font-size: 0.82rem;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.dash-head { margin-bottom: 1rem; }
.eyebrow {
    margin: 0 0 0.2rem;
    color: var(--muted);
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.lede { color: var(--muted); max-width: 40rem; }
.dash-cta { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0 0 1.25rem; }
.country-panel h2 { margin-top: 0; }
.held-callout { margin-top: 0.4rem; }
.section-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr));
    gap: 0.75rem;
    margin: 1.25rem 0;
}
.section-card {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin: 0;
}
.section-card:hover { border-color: var(--accent); }
.section-card span { color: var(--muted); font-size: 0.88rem; }
.section-card-edit { border-color: var(--accent); background: var(--accent-soft); }

.chart-card h2 { margin-top: 0; }
.chart-frame {
    position: relative;
    height: 16rem;
}
.chart-frame-wide { height: 18rem; }
.chart-fallback {
    margin: 0.7rem 0 0;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    font-size: 0.82rem;
    color: var(--muted);
}

.row-held td { background: #eef0f5; }
.row-cash td { background: #f3f7f3; }
.row-isa td { background: #eef4fb; }

.colour-table input[type="color"] {
    width: 3rem;
    height: 2rem;
    padding: 0;
    border: 1px solid #cfc6ba;
    background: #fff;
    cursor: pointer;
}

.sheet-jump {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.85rem;
    margin: 0 0 1rem;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    font-size: 0.86rem;
}
table.sheet th, table.sheet td { padding: 0.28rem 0.35rem; vertical-align: middle; }
table.sheet input[type="text"] {
    width: 100%;
    max-width: none;
    text-align: right;
    font-variant-numeric: tabular-nums;
    padding: 0.35rem 0.45rem;
}
.sheet-name { margin: 0; font-weight: 550; }
.save-bar {
    position: sticky;
    bottom: 0;
    background: var(--paper);
    padding: 0.75rem 0 0.4rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--line);
}

@media (max-width: 779px) {
    .site-header { flex-direction: column; align-items: flex-start; }
    .nav { justify-content: flex-start; }
    .chart-frame, .chart-frame-wide { height: 14rem; }
}
