:root {
  --mauve: #845460; --mauve-2: #B07580; --mauve-3: #DE9AB0; --mauve-tint: #F1E6EA;
  --blush: #EAD3CB; --peach: #F2B6A0; --coral: #F28C6E;
  --warn-bg: #FBE3DA; --warn-fg: #7A3420;
  --grey: #BDC7C9; --teal-2: #8ABAC4; --teal: #5AA5B3;
  --ok-bg: #DCEBEE; --ok-fg: #2B4F60;
  --deep: #2B4F60; --deep-2: #3F7B93; --sky: #5AA9CC;
  --ink: #2B4F60; --muted: #5C6F78; --line: #E4EBEC;
  --bg: #F8F2EF; --card: #FFFFFF;
  --accent: var(--mauve); --accent-2: var(--mauve-2); --accent-3: var(--mauve-3); --head: var(--blush); --head-ink: #5E3A43;
  --r: 18px;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--ink); font-size: 14px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
.house-theme { --accent: var(--deep); --accent-2: var(--deep-2); --accent-3: var(--sky); --head: var(--grey); --head-ink: var(--deep); --bg: #EEF2F3; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1 { font-size: 19px; font-weight: 800; margin: 0; }
h2 { font-size: 15px; font-weight: 700; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.big { font-size: 25px; font-weight: 800; letter-spacing: -0.3px; }
.mid { font-size: 20px; font-weight: 800; }
.b { font-weight: 700; }
.row { display: flex; align-items: center; gap: 8px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hidden { display: none !important; }

/* Shell */
.shell { display: flex; min-height: 100vh; background: var(--bg); }
.side { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 0 16px 110px; display: flex; flex-direction: column; gap: 12px; max-width: 1100px; width: 100%; margin: 0 auto; }

/* Header with scalloped edge */
.hdr { position: relative; background: var(--head); padding: calc(env(safe-area-inset-top) + 14px) 18px 8px; margin-bottom: 22px; display: flex; justify-content: space-between; align-items: flex-end; }
.hdr::after { content: ''; position: absolute; left: 0; right: 0; bottom: -12px; height: 24px;
  background: radial-gradient(circle at 12px 0, var(--head) 12px, transparent 12.5px) 0 0 / 24px 24px repeat-x; }
.brand { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 15px; color: var(--accent); }
.hdr .title { font-size: 19px; font-weight: 800; color: var(--ink); }
.hdr .sub { font-size: 12px; color: var(--head-ink); }
.hdr .mascot { width: 88px; height: auto; margin-bottom: -20px; position: relative; z-index: 1; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: #FFFFFF; border-radius: 14px; }
.seg a { text-align: center; text-decoration: none; height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 10px; font-weight: 600; color: var(--muted); }
.seg a.on { background: var(--accent); color: #FFFFFF; }

/* Cards */
.card { background: var(--card); border-radius: var(--r); padding: 14px 16px; }
.hero { background: var(--accent); color: #FFFFFF; border-radius: 22px; padding: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero .muted, .hero .sub { color: rgba(255,255,255,0.86); }
.warn { background: var(--warn-bg); color: var(--warn-fg); }
.okbox { background: var(--ok-bg); color: var(--ok-fg); }
.deep { background: var(--deep); color: #FFFFFF; }
.tile { background: var(--card); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.tile svg { width: 24px; height: 24px; stroke: var(--deep-2); }
.list > * + * { border-top: 1px solid var(--line); }
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; min-height: 44px; text-decoration: none; color: inherit; }
.item .l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.item .l > div { min-width: 0; }
.item .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 5px; flex: none; background: var(--grey); }
.dot.ok { background: var(--teal); } .dot.warn { background: var(--coral); } .dot.soon { background: var(--peach); }
.pill { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.enter { background: var(--mauve-tint); color: var(--mauve); }
.pill.grey { background: #EEF1F2; color: var(--muted); }
.bar { height: 8px; background: #E4EBEC; border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 4px; background: var(--teal); }
.stackbar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; gap: 2px; background: #EEF1F2; }
.stackbar > div { height: 100%; }
.legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; font-size: 11px; }
.legend b { display: block; font-size: 14px; }
.sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }

/* Forms */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input, select, textarea { height: 44px; border: 1.5px solid var(--grey); border-radius: 12px; padding: 0 12px; background: #FFFFFF; font-size: 16px; color: var(--ink); width: 100%; min-width: 0; }
textarea { height: 72px; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-3); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.btn { height: 44px; border-radius: 12px; border: 1.5px solid var(--accent); background: transparent; color: var(--accent); font-weight: 700; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; cursor: pointer; }
.btn.pri { background: var(--accent); color: #FFFFFF; }
.btn.danger { border-color: #B4452A; color: #B4452A; }
.btn.sm { height: 34px; font-size: 12px; padding: 0 12px; border-radius: 999px; }
.btn.full { width: 100%; }
.iconbtn { width: 44px; height: 44px; border-radius: 22px; border: 0; background: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); text-decoration: none; cursor: pointer; flex: none; }
.subrow { display: grid; gap: 8px; align-items: end; padding: 10px 0; border-top: 1px solid var(--line); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.monthnav { display: flex; align-items: center; gap: 6px; background: #FFFFFF; border-radius: 999px; padding: 4px; }
.monthnav span { min-width: 92px; text-align: center; font-weight: 700; }
.monthnav button { width: 36px; height: 36px; border-radius: 18px; border: 0; background: var(--bg); cursor: pointer; }
.empty { text-align: center; padding: 18px 10px; color: var(--muted); }
.empty img { width: 90px; display: block; margin: 0 auto 6px; }
.err { color: #B4452A; font-size: 12px; }

/* Bottom nav (phone) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--deep); padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; z-index: 20; }
.tabbar a, .tabbar button { color: var(--grey); text-decoration: none; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 44px; justify-content: center; background: none; border: 0; cursor: pointer; }
.tabbar .on { color: #FFFFFF; font-weight: 700; }
.tabbar .plus { justify-self: center; width: 52px; height: 52px; border-radius: 26px; background: var(--coral); color: #2B1A14; margin-top: -26px; }
.tabbar svg, .side svg { width: 22px; height: 22px; }

/* Sheet / modal */
.scrim { position: fixed; inset: 0; background: rgba(20, 30, 36, 0.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); display: flex; flex-direction: column; gap: 10px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 86px); background: var(--deep); color: #FFFFFF; padding: 10px 16px; border-radius: 999px; z-index: 50; font-weight: 600; }

/* Login */
.login { max-width: 420px; margin: 0 auto; padding: 40px 20px; display: flex; flex-direction: column; gap: 14px; }
.login img.m { width: 160px; align-self: center; }

/* Desktop */
@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; gap: 2px; width: 232px; flex: none; background: var(--deep); color: #FFFFFF; padding: 24px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .side .brand { color: #FFFFFF; font-size: 18px; padding: 0 10px 18px; }
  .side .grp { font-size: 11px; font-weight: 700; color: var(--grey); padding: 14px 10px 4px; letter-spacing: 0.5px; }
  .side a { color: #D6E3E6; text-decoration: none; padding: 9px 10px; border-radius: 10px; display: flex; gap: 10px; align-items: center; }
  .side a.on { background: var(--accent); color: #FFFFFF; font-weight: 600; }
  .side a:hover { background: rgba(255,255,255,0.08); }
  .tabbar { display: none; }
  .hdr { margin: 20px 28px 20px; border-radius: 24px; padding: 18px 26px 0; overflow: hidden; min-height: 116px; align-items: center; }
  .hdr > .stack { padding-bottom: 18px; }
  .hdr::after { display: none; }
  .hdr .brand { display: none; }
  .hdr .title { font-size: 25px; }
  .hdr .mascot { width: 128px; margin-bottom: -6px; align-self: flex-end; }
  .hdr-wrap .seg { display: none; }
  .content { padding: 0 28px 40px; }
  .dgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .tiles4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
  .sheet { border-radius: 22px; margin-bottom: 10vh; }
  .scrim { align-items: center; }
}
