@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 400; font-display: swap; src: url(fonts/atkinson-hyperlegible-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 700; font-display: swap; src: url(fonts/atkinson-hyperlegible-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 400; font-display: swap; src: url(fonts/atkinson-hyperlegible-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 700; font-display: swap; src: url(fonts/atkinson-hyperlegible-latin-ext-700-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'OpenDyslexic'; font-weight: 400; font-display: swap; src: url(fonts/opendyslexic-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'OpenDyslexic'; font-weight: 700; font-display: swap; src: url(fonts/opendyslexic-latin-700-normal.woff2) format('woff2'); }

:root {
    --bg: #f9f7f4; --fg: #333; --grey: #ede8e2; --line: #d8d2c9; --nav-bg: #f1ede7;
    --accent: #00695c; --accent-soft: #cfe8e3; --radius: 10px; --gap: 16px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color-scheme: light;
}
[data-theme="dark"] { --bg: #1e1e22; --fg: #e6e6e6; --grey: #333338; --line: #4a4a50; --nav-bg: #26262b; --accent: #4db6ac; --accent-soft: #24433f; color-scheme: dark; }
[data-font="atkinson"] { --font: 'Atkinson Hyperlegible', system-ui, sans-serif; }
[data-font="dyslexic"] { --font: 'OpenDyslexic', 'Comic Sans MS', sans-serif; }
[data-nav="line"] { --nav-bg: var(--bg); }
[data-nav="line"] .nav { border-left: 2px solid var(--line); }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); font-size: 16px; line-height: 1.45; background: var(--bg); color: var(--fg); -webkit-tap-highlight-color: transparent; }
h1 { font-size: 22px; font-weight: 700; margin: 0 0 var(--gap); color: var(--accent); }
h2 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 8px; opacity: .8; }
p { margin: 0 0 12px; }
.muted { opacity: .7; font-size: 14px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 1fr auto; height: 100dvh; }
main { overflow-y: auto; padding: calc(16px + env(safe-area-inset-top)) 16px 24px calc(16px + env(safe-area-inset-left)); }
section { max-width: 520px; margin: 0 auto; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: calc(8px + env(safe-area-inset-top)) calc(4px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) 4px; background: var(--nav-bg); overflow-y: auto; justify-content: center; }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 64px; min-height: 52px; padding: 6px 2px; background: none; border: 0; border-radius: var(--radius); color: var(--fg); font: inherit; font-size: 12px; cursor: pointer; }
.nav-item svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

button, input, textarea, select { font: inherit; color: var(--fg); }
.btn { min-height: 44px; padding: 8px 18px; background: var(--grey); border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; }
.btn:hover { border-color: var(--line); }
.btn.primary { background: var(--accent); color: var(--bg); font-weight: 700; }
.btn.danger { background: none; border-color: var(--line); }
.btn:disabled { opacity: .35; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.center { justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.block { margin-bottom: 24px; }
input[type="text"], input[type="number"], input[type="date"], textarea { width: 100%; min-height: 44px; padding: 8px 12px; background: var(--grey); border: 1px solid transparent; border-radius: var(--radius); }
textarea { min-height: 120px; resize: vertical; }
label { display: block; font-weight: 700; margin-bottom: 4px; }

.tog { min-width: 44px; min-height: 44px; padding: 6px 12px; background: none; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.tog[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.tog:disabled { opacity: .35; }
.tog-col { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; flex: 1; }
.tog-col .tog { width: 100%; }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: 13px; opacity: .7; }
.cal-cell { position: relative; min-height: 52px; padding: 0; background: var(--grey); border: 2px solid transparent; border-radius: var(--radius); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.cal-cell:disabled { opacity: .3; cursor: default; }
.cal-cell .d { position: absolute; top: 2px; left: 5px; font-size: 12px; opacity: .7; }
.cal-cell .v { font-weight: 700; font-size: 15px; }
.cal-cell .e { position: absolute; bottom: 2px; right: 3px; min-width: 16px; height: 16px; line-height: 14px; font-size: 11px; text-align: center; border: 1px solid var(--accent); border-radius: 8px; color: var(--accent); }
.cal-cell.sel { border-color: var(--accent); }
.cal-cell.today .d { color: var(--accent); font-weight: 700; opacity: 1; text-decoration: underline; }
.day-box { margin-top: 16px; padding: 12px 14px; background: var(--grey); border-radius: var(--radius); word-break: break-word; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: center; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 12px; text-transform: uppercase; opacity: .75; }
tr.today td { background: var(--accent-soft); font-weight: 700; }
tr.sum td { font-weight: 700; }
tr.sum.first td { border-top: 2px solid var(--line); }

canvas { width: 100%; height: 260px; display: block; background: var(--grey); border-radius: var(--radius); touch-action: pan-y; }
.chart-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; }
.chart-label { text-align: center; font-size: 14px; }

dialog { width: min(92vw, 340px); padding: 20px; border: 0; border-radius: var(--radius); background: var(--bg); color: var(--fg); box-shadow: 0 8px 28px rgba(0,0,0,.3); text-align: center; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog .row { margin-top: 16px; }
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 10px 18px; background: var(--fg); color: var(--bg); border-radius: var(--radius); z-index: 50; }
#importFile { display: none; }
@media (prefers-reduced-motion: no-preference) { .btn, .tog, .nav-item { transition: background .15s, border-color .15s; } }
