/* Home Essentials — indigo block-print blue, turmeric for "today", chilli for overdue,
   curry-leaf green for done, on cool porcelain. Fraunces for headings and figures. */

@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #F2F4F9;
  --surface: #FFFFFF;
  --surface-2: #EBEEF6;
  --ink: #1B2140;
  --muted: #5D6585;
  --line: #DCE0EC;
  --brand: #3346A8;
  --brand-hover: #2A3A8E;
  --brand-ink: #FFFFFF;
  --brand-soft: #E4E8F8;
  --turmeric: #E8A317;
  --turmeric-soft: #FCF1D9;
  --turmeric-ink: #7A5300;
  --chilli: #C8372D;
  --chilli-soft: #FBE5E2;
  --leaf: #2E7D4F;
  --leaf-soft: #E1F1E7;
  --violet: #7354B8;

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;

  --r-hero: 24px;
  --r-card: 18px;
  --r-item: 14px;
  --r-input: 12px;
  --gutter: 16px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11152A;
    --surface: #1A2040;
    --surface-2: #232A50;
    --ink: #E8EBF7;
    --muted: #9AA2C4;
    --line: #2C3460;
    --brand: #8C9CF0;
    --brand-hover: #A3B0F5;
    --brand-ink: #11152A;
    --brand-soft: #262E5C;
    --turmeric: #F2B53A;
    --turmeric-soft: #3A2F14;
    --turmeric-ink: #F2C566;
    --chilli: #F07A6E;
    --chilli-soft: #3D2023;
    --leaf: #6CC48F;
    --leaf-soft: #1D3A2B;
    --violet: #B39BEB;
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  min-height: 100dvh;
}
a { color: var(--brand); }
h1, h2, h3, p { margin: 0; }
h1 { font: 600 26px/1.15 var(--display); letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 650; line-height: 1.3; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.light { font-weight: 400; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.pre { white-space: pre-wrap; }
.pad { margin: 2px 4px 12px; }
.lead { color: var(--muted); margin: 0 4px 16px; max-width: 60ch; }
.section-title { margin: 28px 4px 12px; font: 600 20px/1.2 var(--display); }
:focus-visible { outline: 3px solid var(--turmeric); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; inset-inline-start: 8px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:not(:focus) { clip-path: inset(50%); width: 1px; height: 1px; padding: 0; overflow: hidden; white-space: nowrap; }

/* ---------------------------------------------------------------- controls */
input, select, button, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; min-width: 0; min-height: 46px;
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: var(--r-input);
  padding: 10px 12px; font-size: 16px; /* 16px stops iPhone zooming on focus */
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px;
}
input[type="date"], input[type="time"], input[type="month"] { min-height: 46px; line-height: 1.2; }
input::-webkit-date-and-time-value { text-align: left; }
textarea { resize: vertical; min-height: 88px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); background: var(--surface); }
input[type="search"] { background: var(--surface); border-color: var(--line); }
::placeholder { color: var(--muted); opacity: .75; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 10px 18px; border-radius: var(--r-input);
  border: 1.5px solid transparent; background: var(--surface); color: var(--ink);
  font-weight: 600; white-space: nowrap; text-decoration: none; cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: background-color .15s, transform .08s;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-ghost { background: transparent; color: var(--chilli); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:active:not(:disabled) { transform: scale(.98); }
.add-btn .plus { font-size: 20px; line-height: 0; margin-top: -2px; }
.icon-btn {
  min-width: 44px; height: 44px; padding: 0 10px; border-radius: var(--r-input);
  border: 1.5px solid var(--line); background: var(--surface); cursor: pointer;
  font-size: 20px; line-height: 1; display: inline-grid; place-content: center; touch-action: manipulation;
}
.link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.error { color: var(--chilli); min-height: 1.2em; font-size: 14.5px; }
.chev { color: var(--muted); font-size: 22px; line-height: 1; }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.tight { gap: 6px; }

/* ---------------------------------------------------------------- shell */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  max-width: 760px; margin: 0 auto;
  padding: calc(12px + var(--safe-t)) var(--gutter) 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
}
.topbar .titles { flex: 1; min-width: 0; }
.topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body[data-route="home"] .topbar { padding-bottom: 0; min-height: var(--safe-t); }
body[data-route="home"] .topbar .titles, body[data-route="home"] #pageSub { display: none; }
main { max-width: 760px; margin: 0 auto; padding: 4px var(--gutter) calc(var(--nav-h) + var(--safe-b) + 32px); outline: none; }
.loading { display: grid; place-content: center; padding: 64px 0; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.offline {
  position: sticky; top: calc(68px + var(--safe-t)); z-index: 19; margin: 0 var(--gutter) 10px;
  background: var(--turmeric-soft); color: var(--turmeric-ink); border-radius: var(--r-input);
  padding: 10px 14px; font-size: 14.5px; font-weight: 600;
}

/* bottom tab bar on phones */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(16px); backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--line);
}
.nav-brand { display: none; }
.nav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; border-radius: 14px; color: var(--muted); text-decoration: none;
  font-size: 12px; font-weight: 600; touch-action: manipulation;
}
.nav-ico { font-size: 21px; line-height: 1.15; filter: grayscale(.6); opacity: .8; }
.nav-btn.active { color: var(--brand); background: var(--brand-soft); }
.nav-btn.active .nav-ico { filter: none; opacity: 1; }

/* tablets and computers: the tab bar becomes a sidebar */
@media (min-width: 900px) {
  :root { --nav-h: 0px; }
  #app { padding-left: 248px; }
  .nav {
    top: 0; right: auto; width: 248px; height: 100dvh;
    display: flex; flex-direction: column; align-items: stretch; gap: 4px;
    padding: 24px 16px; border-top: 0; border-right: 1px solid var(--line); background: var(--surface);
  }
  .nav-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; font: 600 19px/1.2 var(--display); }
  .nav-btn { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 46px; padding: 0 12px; font-size: 15px; }
  .nav-ico { width: 24px; text-align: center; }
  .toast { bottom: 32px; }
}

/* ---------------------------------------------------------------- home */
.hero {
  position: relative; overflow: hidden;
  margin: 8px 0 14px; padding: 18px 20px 20px; border-radius: var(--r-hero);
  background: var(--brand); color: #fff;
}
@media (prefers-color-scheme: dark) { .hero { background: #2A3A8E; } }
.hero::after { /* block-print motif: a row of small turmeric diamonds along the bottom edge */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 8px;
  background: linear-gradient(135deg, transparent 50%, var(--turmeric) 50%) 0 0 / 16px 8px repeat-x,
              linear-gradient(225deg, transparent 50%, var(--turmeric) 50%) 0 0 / 16px 8px repeat-x;
  opacity: .9;
}
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.hero-house { font-weight: 600; opacity: .85; font-size: 15px; }
.hero-avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-content: center;
  background: rgba(255, 255, 255, .16); color: #fff; text-decoration: none; font-weight: 700; font-size: 14.5px;
}
.hero-greet { font: 600 30px/1.1 var(--display); color: #fff; letter-spacing: -.015em; }
.hero-date { opacity: .8; margin: 4px 0 18px; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 10px; border: 0; cursor: pointer;
  background: var(--turmeric); color: #2B1D00; border-radius: 99px; padding: 6px 16px 6px 6px;
  font-weight: 650; font-size: 15px; text-align: left;
}
.hero-badge.calm { background: rgba(255, 255, 255, .16); color: #fff; }
.hero-count {
  min-width: 34px; height: 34px; border-radius: 99px; display: grid; place-content: center; padding: 0 8px;
  background: #fff; color: var(--ink); font: 600 18px/1 var(--display);
}
.hero-badge.calm .hero-count { color: var(--leaf); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  display: flex; flex-direction: column; justify-content: space-between; gap: 4px; min-height: 76px;
  padding: 12px 14px; border-radius: var(--r-item); background: var(--surface); border: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.stat-label { font-size: 13px; color: var(--muted); line-height: 1.25; }
.stat-value { font: 600 21px/1.1 var(--display); font-variant-numeric: tabular-nums lining-nums; overflow-wrap: anywhere; }
.stat-value.neg { color: var(--chilli); }

.alerts { display: flex; flex-direction: column; margin: 0 -6px; }
.alert {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 6px;
  border-radius: 12px; color: inherit; text-decoration: none;
}
.alert + .alert { border-top: 1px solid var(--line); border-radius: 0; }
.alert:hover { background: var(--surface-2); }
.alert .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--brand); }
.alert.warn .dot { background: var(--turmeric); }
.alert.danger .dot { background: var(--chilli); }
.alert-title { display: block; font-weight: 600; line-height: 1.3; }
.alert-sub { display: block; color: var(--muted); font-size: 14px; }
.menu-today { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.menu-today > div { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 12px; background: var(--turmeric-soft); }
.menu-today strong { color: var(--ink); }

.att-row { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.att-row + .att-row { border-top: 1px solid var(--line); }
.att-btns { display: flex; gap: 6px; }
.att-btn {
  width: 42px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 700; color: var(--muted); cursor: pointer; touch-action: manipulation;
}
.s-P { background: var(--leaf) !important; color: #fff !important; border-color: transparent !important; }
.s-A { background: var(--chilli) !important; color: #fff !important; border-color: transparent !important; }
.s-½ { background: var(--turmeric) !important; color: #2B1D00 !important; border-color: transparent !important; }
.s-L { background: var(--brand) !important; color: var(--brand-ink) !important; border-color: transparent !important; }
.s-H { background: var(--violet) !important; color: #fff !important; border-color: transparent !important; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.tile {
  display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-item);
  color: inherit; text-decoration: none; touch-action: manipulation;
}
.tile:hover { border-color: var(--brand); }
.tile:active { transform: scale(.985); }
.tile-ico { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-content: center; font-size: 22px; }
.t-food { background: var(--turmeric-soft); }
.t-money { background: var(--leaf-soft); color: var(--leaf); font-weight: 700; }
.t-home { background: var(--brand-soft); }
.t-care { background: var(--chilli-soft); }
.t-people { background: var(--surface-2); }
.tile-text { display: flex; flex-direction: column; min-width: 0; }
.tile-name { font-weight: 650; line-height: 1.25; }
.tile-desc { font-size: 13px; color: var(--muted); line-height: 1.3; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, 1fr); } }

/* ---------------------------------------------------------------- cards & lists */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 16px; margin-bottom: 14px;
}
.card > h2 { margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.add-form { display: flex; flex-direction: column; gap: 10px; }
.qty { width: 96px; flex: none; }
.list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.list-head { display: flex; justify-content: space-between; align-items: center; }
.group-title { font-size: 14px; font-weight: 650; color: var(--muted); margin: 14px 4px 0; }
.item {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-item);
  border-left-width: 4px; border-left-color: var(--surface);
}
.item.clickable { cursor: pointer; }
.item.clickable:hover { background: color-mix(in srgb, var(--surface) 70%, var(--surface-2)); }
.item .main { flex: 1; min-width: 0; }
.item .title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 600; overflow-wrap: anywhere; line-height: 1.35; }
.item .sub { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; margin-top: 1px; }
.meta { display: flex; flex-wrap: wrap; column-gap: 12px; row-gap: 0; }
.meta > span { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.item.done { opacity: .72; }
.item.done .title { text-decoration: line-through; text-decoration-color: var(--muted); }
.item.overdue { border-left-color: var(--chilli); }
.item.due-soon { border-left-color: var(--turmeric); }
.item.paid { border-left-color: var(--leaf); }
.amount { font: 600 17px/1 var(--display); font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.del {
  width: 40px; height: 40px; flex: none; border: 0; border-radius: 10px; background: none;
  color: var(--muted); font-size: 22px; cursor: pointer;
}
.del:hover { color: var(--chilli); background: var(--chilli-soft); }
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-content: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 15px;
}
.avatar.big { width: 64px; height: 64px; font: 600 24px/1 var(--display); }
.row-ico { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-content: center; background: var(--surface-2); font-size: 18px; }
.check {
  -webkit-appearance: none; appearance: none; flex: none;
  width: 30px; height: 30px; min-height: 0; padding: 0; border-radius: 9px;
  border: 2px solid var(--line); background: var(--surface); cursor: pointer; display: grid; place-content: center;
  touch-action: manipulation;
}
.check:checked { background: var(--leaf); border-color: var(--leaf); }
.check:checked::after { content: "✓"; color: #fff; font-weight: 800; font-size: 17px; line-height: 1; }
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 32px 20px; text-align: center; color: var(--muted);
  border: 1.5px dashed var(--line); border-radius: var(--r-card);
}

.pill { display: inline-block; font-size: 12.5px; font-weight: 650; padding: 2px 9px; border-radius: 99px; white-space: nowrap; line-height: 1.5; }
.pill.paid { background: var(--leaf-soft); color: var(--leaf); }
.pill.overdue { background: var(--chilli-soft); color: var(--chilli); }
.pill.due-soon { background: var(--turmeric-soft); color: var(--turmeric-ink); }
.pill.upcoming { background: var(--surface-2); color: var(--muted); }
.pill.admin { background: var(--brand); color: var(--brand-ink); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(-1 * var(--gutter)); padding: 0 var(--gutter) 4px; scrollbar-width: none; scroll-snap-type: x proximity; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; min-height: 38px; padding: 6px 14px; border-radius: 99px;
  border: 1.5px solid var(--line); background: var(--surface); color: inherit; font-size: 14.5px; font-weight: 550;
  white-space: nowrap; text-decoration: none; cursor: pointer; scroll-snap-align: start; touch-action: manipulation;
}
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip.static { cursor: default; }
.quick-links { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.segmented { display: flex; gap: 2px; padding: 4px; margin-bottom: 14px; background: var(--surface-2); border-radius: 14px; }
.seg {
  flex: 1; min-height: 40px; padding: 6px 4px; border: 0; border-radius: 10px; background: transparent;
  font-size: 14.5px; font-weight: 600; color: var(--muted); cursor: pointer; touch-action: manipulation;
}
.seg.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(27, 33, 64, .12); }
.search { margin-bottom: 12px; }
.month-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.month-nav strong { font: 600 19px/1.2 var(--display); }
.month-nav .btn.small { min-width: 44px; font-size: 20px; }
.warn-card { background: var(--turmeric-soft); border-color: transparent; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ok-card { background: var(--leaf-soft); border-color: transparent; color: var(--leaf); font-weight: 600; }

/* ---------------------------------------------------------------- expenses */
.budget-line { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.budget-line strong { font: 600 24px/1 var(--display); }
.bar { height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.bar-fill { height: 100%; width: 0; border-radius: 99px; background: var(--leaf); transition: width .4s; }
.bar-fill.warn { background: var(--turmeric); }
.bar-fill.over { background: var(--chilli); }
.cats { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 12px; }
.cat-row { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; font-size: 14.5px; }
.mini { grid-column: 1 / -1; height: 6px; border-radius: 99px; overflow: hidden; background: var(--brand-soft); }
.mini > div { height: 100%; background: var(--brand); border-radius: 99px; }

/* ---------------------------------------------------------------- meals */
.day-card { padding: 14px; }
.day-card.today { border: 2px solid var(--turmeric); }
.day-card.past { opacity: .62; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.day-head strong { font: 600 18px/1.2 var(--display); }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slot {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 64px; padding: 8px 10px;
  border: 1.5px dashed var(--line); border-radius: 12px; background: transparent; color: inherit;
  text-align: left; cursor: pointer; touch-action: manipulation;
}
.slot.filled { border-style: solid; border-color: transparent; background: var(--turmeric-soft); }
.slot-name { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.slot-dish { font-size: 14.5px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.slot:not(.filled) .slot-dish { color: var(--muted); font-size: 20px; font-weight: 400; line-height: 1; }
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 48dvh; overflow: auto; margin-bottom: 8px; }
.pick { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.pick input { width: 22px; height: 22px; min-height: 0; margin-top: 1px; flex: none; accent-color: var(--leaf); -webkit-appearance: checkbox; appearance: auto; }

/* ---------------------------------------------------------------- domestic help */
.helper-card { display: flex; flex-direction: column; gap: 12px; margin-bottom: 0; cursor: pointer; }
.helper-card.done { opacity: .6; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-h { text-align: center; font-size: 12.5px; font-weight: 600; color: var(--muted); padding-bottom: 2px; }
.cal-d {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  padding: 0; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: inherit;
  font-variant-numeric: tabular-nums; line-height: 1.1; cursor: pointer; touch-action: manipulation;
}
.cal-d small { font-size: 11px; font-weight: 750; min-height: 12px; }
.cal-d.is-today { border-color: var(--turmeric); border-width: 2.5px; }
.cal-d.future { opacity: .5; }
.cal-d.off { opacity: .2; cursor: default; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.calc { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 15px; }
.calc td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.calc .num { text-align: right; padding-left: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.calc tr.strong td { font-weight: 700; }
.calc tr.total td { border-bottom: 0; padding-top: 12px; font: 600 20px/1.2 var(--display); color: var(--brand); }

/* ---------------------------------------------------------------- scorecards */
.table-wrap { overflow-x: auto; margin: 0 -16px 10px; padding: 0 16px; -webkit-overflow-scrolling: touch; }
.report { border-collapse: separate; border-spacing: 0; font-size: 14px; min-width: 100%; }
.report th, .report td { padding: 8px 10px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.report thead th { font-size: 13px; color: var(--muted); font-weight: 650; }
.report th.left { position: sticky; left: 0; z-index: 1; text-align: left; background: var(--surface); }
.report td small { display: block; font-size: 11.5px; color: var(--muted); }
.report tr.total td, .report tr.total th { border-bottom: 0; font-weight: 700; }
.report .g-A { background: var(--leaf-soft); }
.report .g-D, .report .g-E { background: var(--chilli-soft); }
.report .avg { font-weight: 700; }
.report small.up { color: var(--leaf); }
.report small.down { color: var(--chilli); }
.score-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.score-row { display: grid; grid-template-columns: 1.3fr 76px 76px 1.2fr; gap: 8px; align-items: center; }
.score-row label { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.score-row input { padding: 8px 10px; }
.score-row.head { font-weight: 600; }

/* ---------------------------------------------------------------- places, account */
.freq { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; width: 72px; flex: none; }
.freq strong { font: 600 18px/1 var(--display); }
.freq .mini { width: 100%; }
.profile { display: flex; align-items: center; gap: 16px; }
.profile-name { font: 600 22px/1.2 var(--display); margin-bottom: 2px; }
.profile .pill { margin-top: 6px; }
.steps { margin: 4px 0 8px; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.steps li::marker { color: var(--brand); font-weight: 700; }
.card .btn.block { margin: 4px 0 12px; }

/* ---------------------------------------------------------------- sheets (forms) */
dialog.sheet {
  width: min(580px, 100%); max-width: 100%; max-height: 92dvh; margin: auto;
  padding: 0; border: 0; border-radius: 22px; background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 64px rgba(10, 14, 35, .35); overscroll-behavior: contain;
}
dialog.sheet::backdrop { background: rgba(14, 18, 40, .5); }
dialog.sheet[open] { animation: sheet-in .22s ease-out; }
@keyframes sheet-in { from { transform: translateY(16px); opacity: 0; } }
@media (max-width: 640px) {
  dialog.sheet { margin: auto 0 0; width: 100%; border-radius: 22px 22px 0 0; max-height: calc(100dvh - var(--safe-t) - 24px); }
  dialog.sheet[open] { animation: sheet-up .26s cubic-bezier(.2, .8, .2, 1); }
  @keyframes sheet-up { from { transform: translateY(100%); } }
  dialog.sheet .form::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: -6px auto 2px; }
}
.form { display: flex; flex-direction: column; gap: 12px; padding: 18px 18px calc(16px + var(--safe-b)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h2 { font: 600 21px/1.2 var(--display); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 5px; }
.field.half { grid-column: span 1; }
.field > label { font-size: 14px; font-weight: 600; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-weight: 550; }
.switch input { width: 24px; height: 24px; min-height: 0; flex: none; accent-color: var(--leaf); -webkit-appearance: checkbox; appearance: auto; }
.sheet-actions {
  position: sticky; bottom: calc(-16px - var(--safe-b)); display: flex; align-items: center; gap: 8px;
  margin: 0 -18px calc(-16px - var(--safe-b)); padding: 12px 18px calc(12px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--line);
}
@media (max-width: 380px) { .form-grid { grid-template-columns: 1fr; } .field.half { grid-column: 1 / -1; } }

/* ---------------------------------------------------------------- sign-in screens */
.gate {
  min-height: 100dvh; display: grid; place-items: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--brand) 22%, transparent) 1.2px, transparent 1.6px) 0 0 / 22px 22px,
    var(--bg);
}
.gate-card {
  width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px;
  padding: 28px 22px; border-radius: var(--r-hero); background: var(--surface); border: 1px solid var(--line);
}
.gate-card h1 { font-size: 28px; }
.gate-icon { width: 64px; height: 64px; border-radius: 16px; }
.gate-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.gate-card label.check-line { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; color: var(--ink); }
.check-line input { width: 22px; height: 22px; min-height: 0; accent-color: var(--brand); -webkit-appearance: checkbox; appearance: auto; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 72px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-height: 34px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--brand); font-weight: 650; cursor: pointer;
}

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 18px); z-index: 60;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 550;
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- small phones */
@media (max-width: 420px) {
  :root { --gutter: 14px; }
  .stat-value { font-size: 18px; }
  .slots { grid-template-columns: repeat(2, 1fr); }
  .score-row { grid-template-columns: 1fr 64px 64px; }
  .score-row input[name^="r_"], .score-row.head span:last-child { display: none; }
  .att-btn { width: 38px; }
  .hero-greet { font-size: 27px; }
  .tile { gap: 10px; padding: 10px; min-height: 66px; }
  .tile-ico { width: 38px; height: 38px; font-size: 19px; border-radius: 10px; }
  .tile-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
@media (max-width: 350px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .tiles { grid-template-columns: 1fr; }
  .nav-btn { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.creds { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: var(--r-item); background: var(--surface-2); }
.creds > div { display: flex; flex-direction: column; }
.creds strong { font-size: 18px; letter-spacing: .01em; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }

/* ---------------------------------------------------------------- language picker */
.lang-select { width: auto; min-height: 38px; padding: 6px 30px 6px 10px; font-size: 15px; font-weight: 600; background-color: var(--surface-2); }
.gate-lang { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin: -10px -6px -4px 0; }
.toggle { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-ui { width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; }
.toggle-ui::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.toggle input:checked + .toggle-ui { background: var(--leaf); }
.toggle input:checked + .toggle-ui::after { transform: translateX(20px); }
[dir="rtl"] .toggle input:checked + .toggle-ui::after { transform: translateX(-20px); }
.toggle input:focus-visible + .toggle-ui { outline: 3px solid var(--turmeric); outline-offset: 2px; }

/* Indian scripts need a little more line height and no letter-spacing */
html:not([lang="en"]) h1, html:not([lang="en"]) .hero-greet, html:not([lang="en"]) .section-title { letter-spacing: 0; line-height: 1.3; }
html:not([lang="en"]) body { line-height: 1.6; }
[dir="rtl"] .chips.scroll { direction: rtl; }
[dir="rtl"] .alert .chev, [dir="rtl"] .icon-btn#backBtn { transform: scaleX(-1); }

/* ---------------------------------------------------------------- chat (Home helper) */
.chat-fab {
  position: fixed; z-index: 40; inset-inline-end: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 18px 0 14px;
  border: 0; border-radius: 99px; background: var(--ink); color: var(--bg); cursor: pointer;
  font-weight: 650; font-size: 15px; box-shadow: 0 8px 24px rgba(14, 18, 40, .28); touch-action: manipulation;
}
.chat-fab-ico { font-size: 22px; line-height: 1; }
.chat-fab:active { transform: scale(.97); }
body.chat-open .toast { z-index: 70; }

.chat {
  position: fixed; z-index: 55; inset: 0; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
}
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 12px 10px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.chat-avatar img { display: block; border-radius: 9px; }
.chat-title { font: 600 18px/1.2 var(--display); }
.chat-mode { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.chat-mode.smart { color: var(--leaf); font-weight: 600; }
.chat-head .lang-select { max-width: 120px; }
.chat-icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); font-size: 18px; cursor: pointer; display: grid; place-content: center; touch-action: manipulation;
}
.chat-icon-btn.on { background: var(--chilli); border-color: var(--chilli); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--chilli) 25%, transparent); } }
.chat-log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 10px; padding: 16px 14px;
}
.msg {
  position: relative; max-width: 86%; padding: 10px 14px; border-radius: 18px; font-size: 16px; line-height: 1.55;
  overflow-wrap: anywhere; white-space: normal;
}
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-end-start-radius: 6px; padding-inline-end: 40px; }
.msg.me { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-end-end-radius: 6px; }
.msg-speak {
  position: absolute; inset-inline-end: 4px; bottom: 4px; width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; font-size: 15px; cursor: pointer; opacity: .55;
}
.msg-speak:hover { opacity: 1; background: var(--surface-2); }
.msg.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.msg.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.msg.typing span:nth-child(2) { animation-delay: .2s; }
.msg.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-chip {
  min-height: 40px; padding: 8px 14px; border-radius: 99px; border: 1.5px solid var(--brand);
  background: var(--surface); color: var(--brand); font-size: 14.5px; font-weight: 600; cursor: pointer; text-align: start;
  touch-action: manipulation;
}
.chat-chip:active { background: var(--brand-soft); }
.chat-compose {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--line);
}
.chat-input { flex: 1; min-height: 46px; max-height: 120px; resize: none; border-radius: 23px; padding: 11px 16px; line-height: 1.4; }
.chat-send {
  width: 46px; height: 46px; flex: none; border: 0; border-radius: 50%; background: var(--brand); color: var(--brand-ink);
  font-size: 18px; cursor: pointer; touch-action: manipulation;
}
[dir="rtl"] .chat-send { transform: scaleX(-1); }

@media (min-width: 900px) {
  .chat-fab { bottom: 24px; inset-inline-end: 24px; }
  .chat {
    inset: auto; inset-inline-end: 24px; bottom: 24px; width: 410px; height: min(660px, calc(100dvh - 48px));
    border-radius: 22px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 24px 64px rgba(10, 14, 35, .3);
  }
  .chat-head { padding-top: 12px; }
  .chat-compose { padding-bottom: 12px; }
}
@media (max-width: 380px) { .chat-fab-label { display: none; } .chat-fab { padding: 0 15px; } }
