:root {
  --bg: #f3f4f6; --card: #fff; --fg: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #1f2937; --danger: #dc2626; --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b0f17; --card: #161b26; --fg: #f3f4f6; --muted: #9ca3af; --line: #2a3140; --accent: #e5e7eb; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: #1f2937; color: #fff;
}
.topbar .brand { font-weight: 700; text-decoration: none; }
.topbar nav { display: flex; gap: 14px; align-items: center; }
.topbar nav a, .topbar .link { color: #d1d5db; text-decoration: none; font-size: 14px; }
.link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
main { max-width: 560px; margin: 0 auto; padding: 12px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgb(0 0 0 / .06); }
.msg { background: #dcfce7; color: #14532d; padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.error { color: var(--danger); font-size: 14px; margin: 4px 0 8px; }
.error ul { margin: 0; padding: 0; list-style: none; }
.muted { color: var(--muted); }
.center { text-align: center; }

input, button, .button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=date] {
  width: 100%; min-height: 48px; padding: 10px 12px; font-size: 16px; /* 16px prevents iOS zoom */
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.primary, .button {
  display: block; width: 100%; min-height: 50px; border: 0; border-radius: 12px; text-align: center;
  background: var(--accent); color: var(--card); font-weight: 600; font-size: 17px; cursor: pointer;
  text-decoration: none; line-height: 50px; padding: 0;
}
.button { background: transparent; color: var(--fg); border: 1px solid var(--line); margin-top: 14px; font-size: 15px; }

.amount-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.amount-row .currency { font-size: 32px; font-weight: 600; color: var(--muted); }
.amount-row input { font-size: 32px; font-weight: 700; min-height: 60px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 10px 14px; border-radius: 999px; font-size: 15px; font-weight: 500;
  border: 2px solid var(--c); color: var(--fg); background: transparent; transition: .1s;
}
.chip input:checked + span { background: var(--c); color: var(--t); box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--c); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }

.row { display: grid; grid-template-columns: 11rem 1fr; gap: 8px; margin-bottom: 12px; }
@media (max-width: 360px) { .row { grid-template-columns: 1fr; } }

.week-nav { display: flex; align-items: center; justify-content: space-between; text-align: center; }
.week-nav h2 { margin: 0; font-size: 18px; }
.week-nav .range { font-size: 14px; }
.week-nav a, .week-nav span { width: 44px; height: 44px; display: grid; place-items: center; font-size: 28px; text-decoration: none; }
.total { font-size: 34px; font-weight: 700; text-align: center; margin: 6px 0 12px; }
.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin-bottom: 10px; }
.breakdown, .list { list-style: none; margin: 0; padding: 0; }
.breakdown li { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.breakdown .muted { margin-left: auto; font-size: 14px; }
.breakdown b { min-width: 6rem; text-align: right; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }

.day { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 4px; }
.day:first-child { margin-top: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.tag { padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.list .note { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.list b { white-space: nowrap; }
.del { background: none; border: 0; color: var(--muted); font-size: 22px; width: 36px; height: 36px; cursor: pointer; }
.list form { margin: 0; }

.login { display: grid; gap: 10px; margin-top: 10vh; }
.login h2 { margin: 0 0 4px; }
