:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #f8f9f6;
  --surface-3: #eef1eb;
  --ink: #202721;
  --ink-2: #59635c;
  --muted: #8b948c;
  --line: #e5e9e2;
  --green: #29483a;
  --green-2: #365b48;
  --green-soft: #edf3ed;
  --amber: #d7a14b;
  --amber-soft: #fbf2e3;
  --red: #b94e47;
  --red-soft: #faefed;
  --shadow-sm: 0 5px 18px rgba(29, 43, 32, .045);
  --shadow-lg: 0 24px 75px rgba(19, 30, 22, .20);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; min-height: 100svh; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid rgba(67, 112, 82, .26); outline-offset: 3px; }
[hidden] { display: none !important; }
button:disabled { opacity: .45; cursor: not-allowed !important; }
svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.app-shell { width: min(100% - 72px, 1160px); min-height: 100vh; min-height: 100svh; margin: 0 auto; display: flex; flex-direction: column; }
.topbar { position: relative; min-height: 92px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 22px; border-bottom: 1px solid rgba(34, 49, 38, .075); }
.brand { display: inline-flex; align-items: center; gap: 11px; width: fit-content; color: inherit; text-decoration: none; }
.brand-mark { width: 43px; height: 43px; display: grid; place-items: center; color: #f8f8f3; background: var(--green); border-radius: 15px; box-shadow: 0 6px 14px rgba(41, 72, 58, .16); }
.brand-mark svg { width: 27px; height: 27px; }
.brand-copy { display: flex; flex-direction: column; gap: 3px; }
.brand-copy strong { font-size: 17px; font-weight: 800; letter-spacing: -.65px; }
.brand-copy small { color: #98a098; font-size: 8px; font-weight: 800; letter-spacing: 1.15px; }
.main-nav { display: flex; align-items: center; padding: 5px; gap: 3px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.72); box-shadow: 0 2px 7px rgba(28, 42, 32, .018); }
.nav-item { min-height: 41px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 11px; color: #7d877e; background: transparent; cursor: pointer; font-size: 11px; font-weight: 700; transition: color .18s ease, background .18s ease; }
.nav-item svg { width: 16px; height: 16px; }
.nav-item.active { color: var(--green); background: var(--green-soft); }
.nav-item:hover:not(.active) { color: var(--ink); background: #f4f6f1; }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }
.round-action { width: 43px; height: 43px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; color: var(--green); background: rgba(255,255,255,.78); cursor: pointer; transition: transform .16s ease, background .16s ease, border-color .16s ease; }
.round-action:hover { transform: translateY(-1px); border-color: #cfd9cf; background: #fff; }
.round-action svg { width: 20px; height: 20px; }
.profile-trigger { min-height: 43px; display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 5px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink-2); background: rgba(255,255,255,.78); cursor: pointer; font-size: 11px; font-weight: 700; }
.profile-trigger:hover { background: #fff; }
.avatar { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 11px; color: var(--green); background: var(--green-soft); }
.avatar svg { width: 17px; height: 17px; }
.avatar.has-initial { font-size: 12px; font-weight: 800; }
.profile-trigger-label { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-trigger .chevron { width: 13px; height: 13px; color: #9aa39b; }
.main-content { flex: 1; display: flex; flex-direction: column; }
.page { flex: 1; min-height: 0; animation: page-in .28s ease both; }
.page.active { display: flex; flex-direction: column; }
#page-home { min-height: calc(100svh - 93px); }
.home-content { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 35px 0 22px; text-align: center; }
.home-intro { margin: 0 0 26px; }
.eyebrow { display: inline-block; color: #9aa39a; font-size: 9px; line-height: 1.45; font-weight: 800; letter-spacing: 1.55px; }
.home-intro h1, .subpage-heading h1 { margin: 11px 0 9px; font-size: clamp(36px, 4.8vw, 54px); line-height: 1.04; letter-spacing: -2.6px; font-weight: 800; }
.home-intro h1 span { color: var(--green-2); }
.home-intro p, .subpage-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.capture-area { display: flex; flex-direction: column; align-items: center; }
.active-quantity { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 19px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; color: #838d84; background: rgba(255,255,255,.78); font-size: 10px; }
.active-quantity strong { color: var(--green); font-size: 11px; font-weight: 800; }
.quantity-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(215,161,75,.13); }
.capture-button { position: relative; isolation: isolate; width: clamp(208px, 26vw, 250px); aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 20px; border: 0; border-radius: 50%; color: #fff; background: radial-gradient(circle at 34% 23%, #416a55 0%, #2f5241 46%, #213c30 100%); box-shadow: 0 23px 43px rgba(34, 64, 49, .22), inset 0 1px 1px rgba(255,255,255,.2), inset 0 -5px 12px rgba(9,25,17,.18); cursor: pointer; transition: transform .17s cubic-bezier(.2,.8,.2,1), box-shadow .17s ease; }
.capture-button::before { content: ""; position: absolute; z-index: -1; inset: 9px; border: 1px solid rgba(255,255,255,.17); border-radius: 50%; }
.capture-button::after { content: ""; position: absolute; z-index: -2; inset: -14px; border: 1px solid rgba(44,79,63,.08); border-radius: 50%; }
.capture-button:hover { transform: translateY(-3px); box-shadow: 0 28px 48px rgba(34,64,49,.25), inset 0 1px 1px rgba(255,255,255,.2), inset 0 -5px 12px rgba(9,25,17,.18); }
.capture-button:active, .capture-button.pressed { transform: scale(.955); box-shadow: 0 10px 24px rgba(34,64,49,.2), inset 0 2px 7px rgba(9,25,17,.18); }
.capture-button.recorded { animation: capture-pulse .48s ease; }
.capture-icon { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 5px; color: #fff; }
.capture-icon svg { width: 100%; height: 100%; }
.capture-label { font-size: 12px; font-weight: 850; letter-spacing: 2.1px; }
.capture-amount { color: rgba(255,255,255,.68); font-size: 10px; font-weight: 600; letter-spacing: .3px; }
.capture-hint { display: flex; align-items: center; gap: 7px; margin: 23px 0 0; color: #8d968e; font-size: 10px; }
.hint-check { width: 15px; height: 15px; display: inline-grid; place-items: center; color: var(--green-2); background: #e6eee6; border-radius: 50%; font-size: 9px; font-weight: 800; }
.home-stats { width: min(100%, 455px); min-height: 94px; margin: 0 auto 22px; display: grid; grid-template-columns: 1fr 1px 1fr; align-items: center; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.72); box-shadow: var(--shadow-sm); }
.home-stat { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 13px 10px; }
.stat-label { color: #9aa39a; font-size: 8px; font-weight: 800; letter-spacing: 1.6px; }
.home-stat strong { margin-top: 1px; font-size: 27px; line-height: 1.2; font-weight: 850; letter-spacing: -1px; }
.stat-unit { color: #9aa39a; font-size: 10px; }
.stat-divider { height: 41px; background: var(--line); }

.subpage-heading { padding: 45px 0 26px; }
.subpage-heading h1 { margin: 9px 0 8px; font-size: 43px; letter-spacing: -2px; }
.subpage-heading p { font-size: 12px; }
.history-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.search-field { min-height: 43px; flex: 1; display: flex; align-items: center; gap: 9px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.8); }
.search-field svg { width: 17px; height: 17px; flex: 0 0 auto; color: #9aa39a; }
.search-field input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 11px; }
.search-field input::placeholder { color: #a2aaa2; }
.date-filter { min-height: 43px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.8); }
.date-filter span { color: #9aa39a; font-size: 10px; font-weight: 700; }
.date-filter input { width: 125px; border: 0; outline: 0; color: var(--ink-2); background: transparent; font-size: 10px; }
.small-quiet-button { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 9px; border: 0; border-radius: 9px; color: #758076; background: transparent; cursor: pointer; font-size: 10px; font-weight: 700; white-space: nowrap; }
.small-quiet-button:hover { color: var(--green); background: var(--green-soft); }
.small-quiet-button svg { width: 14px; height: 14px; }
.list-toolbar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border: 1px solid var(--line); border-radius: 15px 15px 0 0; background: rgba(255,255,255,.78); }
.list-toolbar > div { display: flex; align-items: baseline; gap: 10px; }
.list-toolbar strong { font-size: 13px; font-weight: 800; }
.list-toolbar span { color: var(--muted); font-size: 10px; }
.entry-list { margin-bottom: 35px; overflow: hidden; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 15px 15px; background: rgba(255,255,255,.76); }
.entry-day { padding: 12px 18px 7px; color: #929c93; background: rgba(247,248,245,.88); font-size: 8px; font-weight: 850; letter-spacing: 1.35px; text-transform: uppercase; }
.entry-row { min-height: 70px; display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 12px; padding: 10px 15px 10px 18px; border-top: 1px solid #eff1ed; }
.entry-meta { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.entry-meta strong { overflow: hidden; color: var(--ink); font-size: 11px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.entry-meta span { color: #929b93; font-size: 9px; }
.entry-amount { min-width: 76px; color: var(--green); text-align: right; font-size: 13px; font-weight: 850; }
.entry-actions { display: flex; gap: 4px; }
.entry-action { width: 33px; height: 33px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 10px; color: #8c968d; background: transparent; cursor: pointer; transition: background .14s ease, color .14s ease; }
.entry-action:hover { color: var(--green); background: var(--green-soft); }
.entry-action.delete:hover { color: var(--red); background: var(--red-soft); }
.entry-action svg { width: 15px; height: 15px; }
.entry-subnote { display: block; max-width: 420px; overflow: hidden; color: #9ca49c; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; text-align: center; }
.empty-icon { width: 43px; height: 43px; display: grid; place-items: center; margin-bottom: 12px; border-radius: 14px; color: var(--green); background: var(--green-soft); }
.empty-icon svg { width: 21px; height: 21px; }
.empty-state strong { margin-bottom: 5px; font-size: 13px; font-weight: 800; }
.empty-state p { max-width: 270px; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

.period-tabs { width: fit-content; display: flex; align-items: center; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.76); }
.period-tab { min-height: 34px; padding: 0 13px; border: 0; border-radius: 9px; color: #839087; background: transparent; cursor: pointer; font-size: 10px; font-weight: 750; white-space: nowrap; }
.period-tab.active { color: var(--green); background: var(--green-soft); }
.period-tab:hover:not(.active) { background: #f2f5f0; }
.overview-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; margin: 16px 0; }
.overview-card { min-height: 132px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 17px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.8); box-shadow: var(--shadow-sm); }
.overview-card-primary { color: #fff; border-color: transparent; background: var(--green); }
.overview-label { margin-bottom: 11px; color: #9aa39b; font-size: 8px; font-weight: 850; letter-spacing: 1.15px; }
.overview-card-primary .overview-label { color: rgba(255,255,255,.58); }
.overview-card > strong { font-size: clamp(23px, 2.7vw, 30px); font-weight: 850; line-height: 1; letter-spacing: -1.2px; }
.overview-card > strong small { font-size: 13px; letter-spacing: 0; }
.overview-card > span:last-child { margin-top: 7px; color: #9aa39a; font-size: 9px; }
.overview-card-primary > span:last-child { color: rgba(255,255,255,.63); }
.chart-card { padding: 21px 22px 16px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.8); box-shadow: var(--shadow-sm); }
.chart-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chart-heading h2 { margin: 5px 0 0; font-size: 18px; font-weight: 850; letter-spacing: -.55px; }
.chart-unit { color: #9aa39a; font-size: 9px; }
.bar-chart { min-height: 190px; display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); align-items: end; gap: 12px; padding: 22px 3px 0; }
.bar-column { min-width: 0; height: 160px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; }
.bar-track { width: min(100%, 35px); height: 126px; display: flex; align-items: flex-end; overflow: hidden; border-radius: 7px; background: #eff2ed; }
.bar-fill { width: 100%; min-height: 2px; border-radius: 7px; background: linear-gradient(180deg, #dfb46d, #c28c3d); transition: height .35s ease; }
.bar-value { min-height: 12px; color: #758177; font-size: 9px; font-weight: 750; }
.bar-day { color: #9ba49b; font-size: 8px; font-weight: 700; }
.stats-bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 36px; }
.detail-card { min-height: 95px; display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.8); }
.detail-card strong { color: var(--green); font-size: 18px; font-weight: 850; }
.detail-card > span:last-child { color: #9aa39a; font-size: 9px; }

.ranking-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.period-tabs.compact .period-tab { padding: 0 12px; }
.metric-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.75); }
.metric-switch button { min-height: 29px; padding: 0 12px; border: 0; border-radius: 8px; color: #89938a; background: transparent; cursor: pointer; font-size: 9px; font-weight: 800; }
.metric-switch button.active { color: var(--green); background: var(--green-soft); }
.ranking-summary { min-height: 89px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 13px; align-content: center; margin-bottom: 13px; padding: 17px 19px; border: 1px solid #dfe8df; border-radius: 17px; background: linear-gradient(110deg, #eff5ee, #f8faf6); }
.ranking-summary .eyebrow { grid-column: 1; grid-row: 1; align-self: end; margin-bottom: 4px; }
.ranking-summary strong { grid-column: 1; grid-row: 2; color: var(--green); font-size: 26px; line-height: 1; font-weight: 850; }
.ranking-summary > span:last-child { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: #78847a; font-size: 10px; line-height: 1.45; }
.ranking-list { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.82); }
.ranking-row { min-height: 69px; display: grid; grid-template-columns: 28px 36px minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 10px 16px; border-bottom: 1px solid #eff1ed; }
.ranking-row:last-child { border-bottom: 0; }
.ranking-row.me { background: #f5f8f3; }
.rank-number { color: #89938a; text-align: center; font-size: 13px; font-weight: 850; }
.rank-number.first { color: #c28b36; }
.rank-avatar { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 12px; color: var(--green); background: var(--green-soft); font-size: 12px; font-weight: 850; }
.rank-person { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.rank-person strong { overflow: hidden; font-size: 11px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.rank-person span { color: #9aa39a; font-size: 9px; }
.rank-value { color: var(--green); text-align: right; font-size: 13px; font-weight: 850; white-space: nowrap; }
.rank-value small { display: block; margin-top: 2px; color: #9aa39a; font-size: 8px; font-weight: 600; }
.ranking-empty { min-height: 175px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.ranking-empty strong { margin: 5px 0; font-size: 13px; font-weight: 850; }
.ranking-empty p { max-width: 290px; margin: 0; color: #929d93; font-size: 10px; line-height: 1.55; }
.ranking-empty button { margin-top: 14px; }
.ranking-footnote { margin: 12px 0 35px; color: #9ca49c; font-size: 9px; line-height: 1.5; }

.toast { position: fixed; z-index: 90; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); max-width: calc(100vw - 28px); display: flex; align-items: center; gap: 10px; padding: 12px 16px; border: 1px solid rgba(255,255,255,.13); border-radius: 13px; color: #fff; background: rgba(31,44,37,.96); box-shadow: 0 12px 34px rgba(0,0,0,.16); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s ease, transform .2s ease; font-size: 11px; font-weight: 700; white-space: nowrap; }
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%,0); }
.toast button { padding: 3px 0 3px 10px; border: 0; border-left: 1px solid rgba(255,255,255,.22); color: #f1c980; background: transparent; cursor: pointer; font-size: 10px; font-weight: 850; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(23,32,26,.36); backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px); animation: fade-in .16s ease both; }
.modal-card { width: min(100%, 445px); max-height: min(92svh, 850px); overflow-y: auto; padding: 25px; border: 1px solid rgba(255,255,255,.84); border-radius: 25px; background: #fbfcf9; box-shadow: var(--shadow-lg); animation: modal-in .22s cubic-bezier(.2,.8,.2,1) both; overscroll-behavior: contain; }
.modal-grabber { display: none; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.modal-heading h2 { margin: 6px 0 0; font-size: 22px; line-height: 1.2; font-weight: 850; letter-spacing: -.85px; }
.icon-button { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border: 0; border-radius: 11px; color: #849087; background: #eff2ed; cursor: pointer; }
.icon-button:hover { color: var(--ink); background: #e7ece5; }
.icon-button svg { width: 16px; height: 16px; }
.modal-description { margin: 9px 0 18px; color: #89948b; font-size: 11px; line-height: 1.5; }
.preset-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.preset-button { min-height: 64px; display: flex; align-items: baseline; justify-content: center; gap: 4px; border: 1px solid #e5e9e2; border-radius: 13px; color: #5e695f; background: #fff; cursor: pointer; transition: border-color .15s ease, background .15s ease, color .15s ease, transform .15s ease; }
.preset-button:hover { border-color: #ccd9ce; transform: translateY(-1px); }
.preset-button strong { font-size: 16px; font-weight: 850; letter-spacing: -.35px; }
.preset-button span { color: #a1aaa1; font-size: 9px; }
.preset-button.selected { border-color: #6b8a71; color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px rgba(40,75,56,.04); }
.preset-button.selected span { color: #718c75; }
.custom-quantity { margin-top: 18px; }
.custom-quantity label, .field > span { display: block; margin-bottom: 7px; color: #505b52; font-size: 10px; font-weight: 800; }
.input-wrap { height: 47px; display: flex; align-items: center; border: 1px solid #e2e8df; border-radius: 12px; background: #fff; transition: border-color .15s ease, box-shadow .15s ease; }
.input-wrap:focus-within { border-color: #95b09a; box-shadow: 0 0 0 3px rgba(86,122,95,.09); }
.input-wrap input { width: 100%; min-width: 0; height: 100%; padding: 0 13px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; font-weight: 700; }
.input-wrap input::placeholder { color: #adb6ad; font-weight: 500; }
.input-wrap input::-webkit-outer-spin-button, .input-wrap input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
.input-wrap input[type=number] { -moz-appearance: textfield; }
.input-wrap > span { padding: 0 14px; color: #98a298; font-size: 10px; font-weight: 800; }
.input-help { min-height: 13px; margin: 6px 0 0; color: #9aa49a; font-size: 9px; }
.input-help.error { color: var(--red); }
.modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 17px; padding-top: 16px; border-top: 1px solid #ecefe9; }
.text-button { min-height: 42px; padding: 0 10px; border: 0; color: #818d82; background: transparent; cursor: pointer; font-size: 10px; font-weight: 800; }
.text-button:hover { color: var(--ink); }
.primary-button { min-height: 43px; min-width: 120px; padding: 0 17px; border: 0; border-radius: 12px; color: #fff; background: var(--green); box-shadow: 0 5px 12px rgba(40,70,58,.13); cursor: pointer; font-size: 10px; font-weight: 850; transition: transform .15s ease, background .15s ease; }
.primary-button:hover { background: #355d49; transform: translateY(-1px); }
.full-button { width: 100%; margin-top: 4px; }
.edit-card { width: min(100%, 470px); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { min-width: 0; display: flex; flex-direction: column; }
.field.full { grid-column: 1 / -1; }
.form-control { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid #e2e8df; border-radius: 11px; outline: 0; color: var(--ink); background: #fff; font-size: 11px; }
.form-control:focus { border-color: #95b09a; box-shadow: 0 0 0 3px rgba(86,122,95,.09); }
.form-control::placeholder { color: #a9b2a9; }

.profile-card { width: min(100%, 460px); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 16px 0; border: 1px solid var(--line); border-radius: 12px; background: #f3f5f1; }
.auth-tabs button { min-height: 36px; border: 0; border-radius: 9px; color: #89948b; background: transparent; cursor: pointer; font-size: 10px; font-weight: 800; }
.auth-tabs button.active { color: var(--green); background: #fff; box-shadow: 0 2px 7px rgba(25,40,29,.06); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form .field { gap: 0; }
.auth-message, .inline-message { min-height: 13px; margin: 0; color: var(--red); font-size: 9px; line-height: 1.4; }
.privacy-note { margin: 15px 0 0; color: #98a198; font-size: 9px; line-height: 1.55; }
.account-identity { display: flex; align-items: center; gap: 12px; margin: 15px 0 18px; }
.large-avatar { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; color: var(--green); background: var(--green-soft); font-size: 17px; font-weight: 850; }
.account-identity > div { display: flex; flex-direction: column; gap: 4px; }
.account-identity strong { font-size: 13px; font-weight: 850; }
.account-identity span:not(.large-avatar) { color: #98a199; font-size: 10px; }
.inline-form { display: flex; align-items: center; gap: 7px; }
.inline-form .form-control { flex: 1; min-width: 0; }
.icon-save { width: 43px; height: 43px; display: grid; place-items: center; border: 0; border-radius: 11px; color: var(--green); background: var(--green-soft); cursor: pointer; }
.icon-save svg { width: 18px; height: 18px; }
.friend-code-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 15px 0; padding: 14px 15px; border: 1px dashed #cdd9ce; border-radius: 14px; background: #f5f8f3; }
.friend-code-box > div { display: flex; flex-direction: column; gap: 4px; }
.friend-code-box strong { color: var(--green); font-size: 20px; font-weight: 900; letter-spacing: 2px; }
.friend-code-box small { color: #94a095; font-size: 9px; }
.add-friend { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.add-friend .inline-form .primary-button { min-width: 105px; }
.inline-message { padding-top: 5px; color: #819181; }
.section-label { display: flex; justify-content: space-between; margin: 13px 0 7px; color: #9aa49a; font-size: 8px; font-weight: 850; letter-spacing: 1.3px; }
.section-label span { color: var(--green); letter-spacing: 0; }
.friend-row { min-height: 49px; display: grid; grid-template-columns: 31px 1fr auto; align-items: center; gap: 9px; border-bottom: 1px solid #eff1ed; }
.friend-row:last-child { border-bottom: 0; }
.friend-avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; color: var(--green); background: var(--green-soft); font-size: 10px; font-weight: 850; }
.friend-name { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.friend-name strong { overflow: hidden; font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.friend-name span { color: #9da69d; font-size: 8px; }
.friend-actions { display: flex; align-items: center; gap: 5px; }
.friend-action { min-height: 29px; padding: 0 9px; border: 0; border-radius: 8px; color: var(--green); background: var(--green-soft); cursor: pointer; font-size: 8px; font-weight: 800; }
.friend-action.muted { color: #8b958c; background: #f2f4f0; }
.friend-action.danger { color: var(--red); background: var(--red-soft); }
.friend-empty { padding: 10px 0; color: #9ba49b; font-size: 9px; }
.logout-button { width: 100%; min-height: 41px; margin-top: 16px; border: 1px solid #f0d9d6; border-radius: 11px; color: var(--red); background: #fff8f7; cursor: pointer; font-size: 10px; font-weight: 850; }
.logout-button:hover { background: var(--red-soft); }
.danger-button { min-height: 42px; min-width: 105px; padding: 0 18px; border: 0; border-radius: 11px; color: #fff; background: var(--red); cursor: pointer; font-size: 10px; font-weight: 850; }
.confirm-card { width: min(100%, 390px); }

.mobile-nav { display: none; }
@keyframes page-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes capture-pulse { 0% { box-shadow: 0 23px 43px rgba(34,64,49,.22), 0 0 0 0 rgba(68,112,81,.20); } 70% { box-shadow: 0 23px 43px rgba(34,64,49,.22), 0 0 0 16px rgba(68,112,81,0); } 100% { box-shadow: 0 23px 43px rgba(34,64,49,.22), 0 0 0 0 rgba(68,112,81,0); } }

@media (max-width: 900px) {
  .app-shell { width: min(100% - 44px, 760px); }
  .topbar { grid-template-columns: 1fr auto; min-height: 82px; }
  .main-nav { grid-column: 1 / -1; grid-row: 2; justify-self: center; margin-top: -7px; margin-bottom: 11px; }
  .topbar { padding: 12px 0 2px; }
  .top-actions { grid-column: 2; grid-row: 1; }
  #page-home { min-height: calc(100svh - 145px); }
  .overview-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 640px) {
  body { background: #f7f8f5; }
  .app-shell { width: 100%; min-height: 100svh; padding: 0 19px calc(80px + env(safe-area-inset-bottom)); }
  .topbar { min-height: 69px; grid-template-columns: 1fr auto; gap: 12px; padding: 10px 0; border-bottom-color: rgba(34,49,38,.07); }
  .brand { gap: 8px; }
  .brand-mark { width: 37px; height: 37px; border-radius: 13px; }
  .brand-mark svg { width: 24px; height: 24px; }
  .brand-copy strong { font-size: 15px; }
  .brand-copy small { font-size: 7px; letter-spacing: .9px; }
  .main-nav { display: none; }
  .top-actions { gap: 7px; }
  .round-action { width: 39px; height: 39px; border-radius: 13px; }
  .profile-trigger { min-height: 39px; padding: 3px 8px 3px 4px; gap: 5px; border-radius: 13px; }
  .avatar { width: 29px; height: 29px; border-radius: 10px; }
  .profile-trigger-label { max-width: 70px; font-size: 9px; }
  .profile-trigger .chevron { width: 11px; }
  #page-home { min-height: calc(100svh - 158px); }
  .home-content { padding: 25px 0 18px; }
  .home-intro { margin-bottom: 25px; }
  .eyebrow { font-size: 8px; letter-spacing: 1.35px; }
  .home-intro h1 { margin: 9px 0 8px; font-size: clamp(35px, 10vw, 46px); letter-spacing: -2px; }
  .home-intro p { font-size: 11px; }
  .active-quantity { margin-bottom: 17px; font-size: 9px; }
  .capture-button { width: min(63vw, 232px); }
  .capture-icon { width: 54px; height: 54px; }
  .capture-label { font-size: 11px; letter-spacing: 1.75px; }
  .capture-hint { margin-top: 22px; font-size: 9px; }
  .home-stats { min-height: 83px; margin-bottom: 8px; border-radius: 17px; }
  .home-stat strong { font-size: 25px; }
  .stat-label { font-size: 8px; }
  .stat-unit { font-size: 9px; }
  .mobile-nav { position: fixed; z-index: 40; right: 0; bottom: 0; left: 0; min-height: calc(64px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4,1fr); align-items: start; padding: 8px 8px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(36,52,40,.08); background: rgba(250,251,248,.94); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
  .mobile-nav button { min-width: 0; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 12px; color: #9aa39a; background: transparent; cursor: pointer; }
  .mobile-nav button.active { color: var(--green); }
  .mobile-nav button svg { width: 19px; height: 19px; }
  .mobile-nav button span { font-size: 8px; font-weight: 800; }
  .subpage-heading { padding: 27px 0 19px; }
  .subpage-heading h1 { margin: 8px 0 7px; font-size: 37px; letter-spacing: -1.7px; }
  .subpage-heading p { max-width: 340px; font-size: 10px; line-height: 1.5; }
  .history-tools { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
  .search-field { grid-column: 1 / -1; min-height: 40px; }
  .date-filter { min-height: 40px; }
  .date-filter input { width: 116px; }
  .small-quiet-button { min-height: 32px; font-size: 9px; }
  .list-toolbar { min-height: 52px; padding: 10px 12px; }
  .list-toolbar > div { gap: 7px; }
  .list-toolbar strong { font-size: 11px; }
  .list-toolbar span { font-size: 9px; }
  .list-toolbar .small-quiet-button { padding: 0 6px; }
  .entry-row { grid-template-columns: minmax(0,1fr) auto auto; gap: 6px; padding: 9px 8px 9px 12px; }
  .entry-amount { min-width: 62px; font-size: 11px; }
  .entry-actions { gap: 1px; }
  .entry-action { width: 30px; height: 31px; }
  .overview-grid { gap: 8px; margin: 12px 0; }
  .overview-card { min-height: 107px; padding: 13px; border-radius: 14px; }
  .overview-label { margin-bottom: 9px; font-size: 7px; letter-spacing: .85px; }
  .overview-card > strong { font-size: 25px; }
  .overview-card > span:last-child { margin-top: 5px; font-size: 8px; }
  .period-tabs { max-width: 100%; gap: 2px; }
  .period-tab { min-height: 31px; padding: 0 9px; font-size: 9px; }
  .chart-card { padding: 16px 14px 12px; border-radius: 15px; }
  .chart-heading h2 { font-size: 15px; }
  .bar-chart { gap: 7px; min-height: 165px; padding-top: 17px; }
  .bar-column { height: 140px; }
  .bar-track { height: 108px; width: min(100%,29px); }
  .bar-day, .bar-value { font-size: 7px; }
  .stats-bottom-grid { gap: 8px; margin: 10px 0 22px; }
  .detail-card { min-height: 84px; padding: 12px; border-radius: 13px; }
  .detail-card .eyebrow { font-size: 7px; }
  .detail-card strong { font-size: 15px; }
  .detail-card > span:last-child { font-size: 8px; }
  .ranking-controls { align-items: flex-start; flex-direction: column; gap: 8px; }
  .ranking-controls .period-tabs { width: 100%; justify-content: space-between; }
  .ranking-summary { min-height: 80px; padding: 13px 15px; }
  .ranking-row { grid-template-columns: 22px 32px minmax(0,1fr) auto; gap: 7px; padding: 9px 10px; }
  .rank-avatar { width: 31px; height: 31px; border-radius: 10px; }
  .rank-value { font-size: 11px; }
  .ranking-footnote { margin-bottom: 18px; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-card { width: 100%; max-height: min(91svh, 820px); padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; border-bottom: 0; animation: sheet-in .22s cubic-bezier(.2,.8,.2,1) both; }
  .modal-grabber { display: block; width: 38px; height: 4px; margin: -10px auto 17px; border-radius: 99px; background: #dce2da; }
  .modal-heading h2 { font-size: 21px; }
  .preset-grid { gap: 7px; }
  .preset-button { min-height: 59px; border-radius: 12px; }
  .form-grid { gap: 10px; }
  .profile-card { max-height: min(94svh, 900px); }
  .confirm-card { width: 100%; }
  .toast { bottom: calc(75px + env(safe-area-inset-bottom)); }
}
@media (max-width: 370px) {
  .app-shell { padding-right: 14px; padding-left: 14px; }
  .profile-trigger-label { max-width: 54px; }
  .brand-copy small { display: none; }
  .period-tab { padding: 0 7px; }
  .overview-card { padding: 10px; }
  .overview-card > strong { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@keyframes sheet-in { from { opacity: .65; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
.account-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 12px 0 14px; }
.account-tools button { min-height: 35px; padding: 0 9px; border: 1px solid var(--line); border-radius: 10px; color: var(--green); background: #fff; cursor: pointer; font-size: 8px; font-weight: 800; }
.account-tools button:hover { border-color: #cbd8cc; background: var(--green-soft); }
