:root {
  --ink: #1d2433; --muted: #5f6878; --line: #e7e2d9; --bg: #faf7f2; --card: #ffffff; --soft: #f3efe8;
  --brand: #23395d; --brand-soft: #e9eef6; --accent: #c2603e; --accent-soft: #fbece5;
  --ok: #2f7d4f; --ok-soft: #e6f3ea; --warn: #9a6400; --warn-soft: #fdf3e1; --bad: #b42318; --bad-soft: #fdeceb;
  --s0: #d9d4cb; --s1: #b9c6dc; --s2: #7f97bd; --s3: #3f5f92; --s4: #2f7d4f;
  --r: 14px; --shadow: 0 1px 2px rgba(29,36,51,.05), 0 4px 14px rgba(29,36,51,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
button { font: inherit; color: inherit; }
#bar { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent); z-index: 50; transition: width .3s, opacity .3s; opacity: 0; }
#bar.on { width: 70%; opacity: 1; transition: width 8s cubic-bezier(.1,.7,.2,1); }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px 20px;
  padding-top: max(10px, env(safe-area-inset-top)); background: rgba(250,247,242,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--brand); }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.beta { font-style: normal; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 99px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a, .bottom a { text-decoration: none; color: var(--muted); font-weight: 600; }
.tabs a { padding: 7px 14px; border-radius: 99px; }
.tabs a.on { background: var(--brand); color: #fff; }
.who { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.bottom { display: none; }

main { max-width: 1080px; margin: 0 auto; padding: 22px 20px 40px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 22px; }
.muted { color: var(--muted); } .small { font-size: 13px; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card h2 .n { color: var(--muted); font-weight: 500; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow);
  text-decoration: none; color: inherit; display: block; }
.stat b { display: block; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--brand); }
.stat span { color: var(--muted); font-size: 13px; }
.stat.alert b { color: var(--accent); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; }
.list li:first-child { border-top: 0; padding-top: 2px; }
.list .grow { flex: 1; min-width: 0; }
.list .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .d { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.brand { background: var(--brand-soft); color: var(--brand); }
.more { background: none; border: 0; color: var(--brand); font-weight: 600; padding: 8px 0 0; cursor: pointer; }
.empty { color: var(--muted); padding: 6px 0; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Dashboard */
.dhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.month { display: flex; align-items: center; gap: 6px; }
.month button, .btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 12px; cursor: pointer; font-weight: 600; }
.month strong { min-width: 130px; text-align: center; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.ccard { cursor: pointer; transition: border-color .15s, transform .15s; }
.ccard:hover { border-color: var(--s2); }
.ccard .top2 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ccard .name { font-weight: 700; font-size: 16px; }
.ccard .count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; white-space: nowrap; }
.ccard .count b { color: var(--ink); font-size: 18px; }
.bar2 { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--soft); margin: 12px 0 10px; gap: 2px; }
.bar2 span { display: block; height: 100%; }
.nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: 12px; color: var(--muted); }
.nums b { display: block; font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.flags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.skel { background: linear-gradient(90deg, var(--soft), #fbf9f5, var(--soft)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }
.stagehead { display: flex; align-items: center; gap: 8px; margin: 18px 0 6px; font-weight: 700; }
.stagehead i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.back { background: none; border: 0; color: var(--brand); font-weight: 600; cursor: pointer; padding: 0; margin-bottom: 12px; }

/* Sign-in */
.signin { max-width: 380px; margin: 8vh auto 0; }
.signin h1 { margin-bottom: 6px; }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input { width: 100%; padding: 12px 13px; border: 1px solid #d6d0c5; border-radius: 10px; font: inherit; background: #fff; color: var(--ink); font-size: 16px; }
input:focus { outline: 2px solid #9db4d8; border-color: var(--brand); }
.signin .btn { width: 100%; margin-top: 18px; padding: 12px; }
.err { color: var(--bad); margin-top: 12px; }
.note { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; font-size: 14px; }

@media (max-width: 720px) {
  .top { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .tabs { display: none; }
  .brand { flex: 1; }
  main { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; }
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .bottom { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .bottom a { flex: 1; text-align: center; padding: 6px 0; font-size: 12px; border-radius: 10px; }
  .bottom a svg { display: block; margin: 0 auto 2px; width: 22px; height: 22px; }
  .bottom a.on { color: var(--brand); background: var(--brand-soft); }
  .month strong { min-width: 110px; }
}

/* v0.2.0: link pills keep their size; long titles wrap to two lines */
.list li > .pill, .list li > a.pill { flex: none; text-decoration: none; }
.list .t { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.list li { flex-wrap: wrap; }
.list li > .grow { flex-basis: 60%; }

/* v0.3.0: to-do buttons and the add form */
.acts { display: inline-flex; gap: 6px; flex: none; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.quiet { background: transparent; color: var(--muted); }
.btn:disabled { opacity: .5; }
.tform { margin-bottom: 16px; max-width: 560px; }
.tform .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
select, textarea { font: inherit; font-size: 16px; width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card, #fff); color: inherit; }
.tform .btn.primary { margin-top: 14px; }
.month { flex-wrap: wrap; }

/* v0.4.0: More page tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; }
.tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 16px; color: var(--brand); margin-bottom: 4px; }
.tile span { color: var(--muted); font-size: 13px; }
.tile:hover { border-color: var(--brand); }
.tabs { flex-wrap: wrap; }
a.btn { text-decoration: none; color: inherit; display: inline-block; }

/* v0.5.0: review / submit forms inside a list row */
.dform { flex-basis: 100%; background: var(--soft); border-radius: 12px; padding: 4px 12px 12px; margin-top: 4px; }
.dform label { margin-top: 10px; }
.dform .acts { margin-top: 10px; flex-wrap: wrap; }
