:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #d9dce1;
  --text: #16191d;
  --muted: #616a75;
  --accent: #1c5d8c;
  --accent-soft: #e6eef5;
  --good: #1f7a4d;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --danger: #a32626;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 5rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

header.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .85rem 1rem;
  background: var(--accent);
  color: #fff;
}
header.bar a { color: #fff; text-decoration: none; }
header.bar .title { font-weight: 600; font-size: 1.05rem; }
header.bar nav { display: flex; gap: 1rem; font-size: .9rem; }

main { max-width: 720px; margin: 0 auto; padding: 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.card h2 { margin: 0 0 .75rem; font-size: 1rem; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }

.total { font-size: 2.4rem; font-weight: 700; line-height: 1.1; }
.total-sub { color: var(--muted); font-size: .9rem; margin-top: .25rem; }

.month-nav { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.month-nav select { flex: 1; }
.month-nav a {
  display: flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; font-size: 1.2rem;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem 0; vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr + tr td { border-top: 1px solid var(--border); }

.list-row {
  display: flex; justify-content: space-between; gap: .75rem;
  padding: .75rem 0; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.list-row .meta { color: var(--muted); font-size: .85rem; }
.list-row .amt { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--accent-soft); color: var(--accent); }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
input[type=text], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: .6rem .65rem; font-size: 16px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
textarea { min-height: 4rem; resize: vertical; }
.field { margin-bottom: .85rem; }
.row2 { display: flex; gap: .75rem; }
.row2 > * { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 46px; padding: 0 1.1rem;
  border: 1px solid var(--accent); border-radius: 8px;
  background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.secondary { background: var(--surface); color: var(--accent); }
.btn.danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn.wide { width: 100%; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }

.items { margin-top: .5rem; }
.item {
  display: grid;
  grid-template-columns: 28px 1fr 88px;
  gap: .5rem .6rem;
  align-items: start;
  padding: .7rem 0;
  border-top: 1px solid var(--border);
}
.item .check { padding-top: .55rem; }
.item input[type=checkbox] { width: 22px; height: 22px; }
.item .cat { grid-column: 2 / 4; }
.item .cat[hidden] { display: none; }
.item.suggested { background: var(--warn-soft); }
.item .drop { grid-column: 1 / 4; text-align: right; }
.item .drop button {
  background: none; border: 0; color: var(--danger);
  font: inherit; font-size: .85rem; cursor: pointer; padding: .25rem;
}

.note { color: var(--muted); font-size: .85rem; }
.flash {
  padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem;
  background: var(--warn-soft); color: var(--warn); border: 1px solid #eccf9d;
}
.flash.error { background: #fbeaea; color: var(--danger); border-color: #e8b9b9; }

.thumb { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); display: block; }

.savebar {
  position: sticky; bottom: 0; margin: 0 -1rem -1rem; padding: .75rem 1rem;
  background: var(--surface); border-top: 1px solid var(--border);
}

.bar-track { height: 6px; background: var(--accent-soft); border-radius: 3px; margin-top: .3rem; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a; --surface: #1d2126; --border: #333940;
    --text: #e8eaed; --muted: #9aa3ad; --accent: #6aa9d8; --accent-soft: #26333d;
    --good: #58c08a; --warn: #e0ac5b; --warn-soft: #33291a; --danger: #e08282;
  }
  header.bar { background: #1d2126; border-bottom: 1px solid var(--border); }
  input, select, textarea { background: #14171a !important; color: var(--text) !important; }
  .btn { color: #14171a; }
  .btn.secondary, .btn.danger { background: var(--surface); }
  .flash { border-color: #4a3c22; }
  .flash.error { background: #33201f; border-color: #573030; }
}

.tally {
  margin-top: .9rem;
  padding: .7rem .8rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: .9rem;
}
.tally.over {
  background: #fbeaea;
  color: var(--danger);
  border: 1px solid #e8b9b9;
}
@media (prefers-color-scheme: dark) {
  .tally.over { background: #33201f; border-color: #573030; }
}

.linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* Sign-in: a large, unmistakable target, and monospace so look-alike
   characters stay distinguishable while typing. */
.password-input {
  font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
  font-size: 1.35rem !important;
  letter-spacing: .06em;
  padding: .9rem .75rem !important;
  min-height: 56px;
  text-align: center;
}
.show-pw {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 0 0 1rem;
  font-size: 1rem;
  color: var(--text);
  cursor: pointer;
}
.show-pw input[type=checkbox] {
  width: 24px;
  height: 24px;
}
