:root {
  --bg: #f6f5f1; --card: #fff; --text: #1f1f1d; --muted: #6b6a65; --border: #e3e1da;
  --accent: #c2502a; --accent-text: #fff; --danger: #b42d2d; --ok: #3b6d11; --track: #ecebe5;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1c1c1b; --card: #262625; --text: #ecebe6; --muted: #a3a29c; --border: #3a3a38;
          --accent: #e0754f; --accent-text: #1c1c1b; --danger: #f09595; --ok: #97c459; --track: #333331; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
a { color: inherit; }
h1 { font-size: 26px; margin: 8px 0 16px; }
h2 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--border); }
.brand { font-weight: 600; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top nav { display: flex; gap: 16px; font-size: 15px; }
.top nav a { text-decoration: none; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin: 0 0 16px; display: block; text-decoration: none; }
.narrow { max-width: 420px; margin: 10vh auto; }
.empty { text-align: center; }
section { margin-bottom: 8px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 20px 0 10px; }
.section-head a { color: var(--accent); text-decoration: none; font-size: 15px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat strong { font-size: 18px; white-space: nowrap; }
@media (max-width: 380px) { .stat strong { font-size: 15px; } }

.chart { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 16px; align-items: center; margin-top: 12px; }
@media (max-width: 480px) { .chart { grid-template-columns: 1fr; } .donut { max-width: 200px; margin: 0 auto; } }
.donut { width: 100%; display: block; }
.donut-track { stroke: var(--track); }
.donut-label { font-size: 4px; font-weight: 600; fill: var(--text); }
.legend { list-style: none; margin: 0; padding: 0; }
.legend a { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 6px 0; text-decoration: none; font-size: 15px; }
.legend-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-pct { color: var(--muted); font-size: 13px; }
.legend-amount { font-variant-numeric: tabular-nums; text-align: right; min-width: 80px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }

.goals { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.goals .card { margin: 0; }
.goal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--track); color: var(--muted); white-space: nowrap; }
.status-vykdoma .badge { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.status-baigta { opacity: .65; }
.bar { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; margin: 10px 0 6px; }
.bar > div { height: 100%; background: var(--accent); border-radius: 4px; }
.bar.over > div { background: var(--danger); }
.notes { margin: 10px 0 0; font-size: 15px; }

.list { padding: 0 16px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; text-decoration: none; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.clip { font-size: 14px; }
.total { margin: 0 0 4px; }
.filters { display: flex; gap: 8px; margin-bottom: 12px; }
.filters select { flex: 1; min-width: 0; }

.stack { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=file] { padding: 8px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.amount-field { position: relative; display: block; }
.amount input { font-size: 32px; font-weight: 600; padding: 10px 40px 10px 14px; min-height: 64px; }
.amount-field span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 24px; color: var(--muted); }

fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 14px; color: var(--muted); margin-bottom: 8px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { display: block; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips span { display: inline-block; padding: 9px 14px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 15px; cursor: pointer; }
.chips input:checked + span { background: color-mix(in srgb, var(--c) 22%, var(--card)); border-color: var(--c);
  box-shadow: inset 0 0 0 1px var(--c); font-weight: 600; }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

details summary { cursor: pointer; color: var(--accent); font-size: 15px; padding: 4px 0; }
details[open] summary { margin-bottom: 12px; }
details.edit { margin-top: 24px; }

button, .button { font: inherit; font-size: 16px; display: inline-block; text-align: center; text-decoration: none; cursor: pointer;
  padding: 12px 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); min-height: 48px; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; width: 100%; margin-bottom: 16px; }
.sticky { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); }
.danger { background: none; border: 0; color: var(--danger); padding: 12px 0; margin-top: 8px; }

.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.file a { display: block; text-decoration: none; }
.file img, .file-icon { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); display: flex;
  align-items: center; justify-content: center; background: var(--card); font-weight: 600; color: var(--muted); }
.file-name { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; }
.file label { flex-direction: row; align-items: center; gap: 4px; }

.errors { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-radius: 10px; padding: 8px 14px; }
.errors p { margin: 4px 0; }
.toast { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); border-radius: 10px; padding: 8px 14px; margin: 0 0 12px; }

.fab { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 34px; line-height: 58px; text-align: center; text-decoration: none;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.footer-links { text-align: center; margin-top: 32px; font-size: 14px; }
.footer-links a { color: var(--muted); }
