/* PrintLedger — one stylesheet, mobile first. No external fonts or frameworks. */

:root {
  --bg: #f4f3ef;
  --card: #ffffff;
  --ink: #1b2422;
  --muted: #5b6662;
  --line: #e2e0d8;
  --line-strong: #cfccc2;
  --brand: #0f766e;
  --brand-dark: #0b5c55;
  --brand-soft: #e3f3f0;
  --brand-ink: #ffffff;
  --in: #11803d;
  --ok-soft: #e7f5ec;
  --warn: #8a4b04;
  --warn-soft: #fff4dd;
  --warn-line: #f0c46b;
  --err: #b42318;
  --err-soft: #fdeceb;
  --focus: #2563eb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(18, 28, 25, .06), 0 3px 10px rgba(18, 28, 25, .06);
  --tap: 48px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}
body.has-tabbar { padding-bottom: calc(76px + var(--safe-bottom)); }
img { max-width: 100%; }
a { color: var(--brand-dark); text-underline-offset: 2px; }
a:hover { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
small, .small { font-size: .875rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.right { text-align: right; }
.in { color: var(--in); }
.h1 { font-size: 1.45rem; font-weight: 700; }
.h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: .5rem; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .5rem 1rem; z-index: 50; }
.skip:focus { left: .5rem; top: .5rem; }

/* ---------- top bar & tab bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner { display: flex; align-items: center; gap: .6rem; min-height: 56px; padding: .35rem 1rem; max-width: 1100px; margin: 0 auto; }
.topbar a { color: inherit; text-decoration: none; }
.back, .brand {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto;
  background: rgba(255, 255, 255, .14); font-size: 1.35rem; font-weight: 700;
}
.brand { background: transparent; }
.brand img { border-radius: 9px; }
.titles { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.biz { font-size: .78rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-title { font-size: 1.08rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topnav { display: none; gap: .25rem; }
.topnav a { padding: .55rem .9rem; border-radius: 10px; font-weight: 600; }
.topnav a.active, .topnav a:hover { background: rgba(255, 255, 255, .18); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 10px rgba(18, 28, 25, .06);
}
.tabbar.tabs-5 { grid-template-columns: repeat(5, 1fr); }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 62px; color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 600;
}
.tabbar .tab-icon { font-size: 1.35rem; line-height: 1; }
.tabbar a.active { color: var(--brand-dark); }
.tabbar a.active .tab-icon { transform: translateY(-1px); }

/* ---------- layout ---------- */
.container { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 1.5rem; }
.page-head { display: flex; align-items: center; gap: .6rem; margin: .25rem 0 .75rem; }
.page-icon { font-size: 1.8rem; line-height: 1; }
.section-title { font-size: .95rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 1.4rem 0 .6rem; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem; margin-bottom: 1rem; border: 1px solid rgba(0, 0, 0, .02);
}
.card-title { font-size: 1.08rem; font-weight: 700; margin-bottom: .6rem; }
.card-link { margin-top: .75rem; font-weight: 600; }
.card-link a { text-decoration: none; }
.stack > * + * { margin-top: .9rem; }
.button-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.button-stack { display: grid; gap: .6rem; }
.inline-form { display: inline; margin: 0; }
.intro { color: var(--muted); margin-bottom: 1rem; }
.meta { color: var(--muted); font-size: .9rem; margin: -.25rem 0 1rem; }
.totals { color: var(--muted); font-size: .95rem; margin: .25rem 0 .75rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: .6rem 1.1rem; border-radius: 12px;
  border: 1px solid transparent; font: inherit; font-weight: 650; line-height: 1.2;
  text-decoration: none; cursor: pointer; text-align: center;
  background: #fff; color: var(--ink); -webkit-tap-highlight-color: transparent;
  transition: background-color .12s, border-color .12s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-dark); color: var(--brand-ink); }
.btn-secondary { background: var(--brand-soft); color: var(--brand-dark); border-color: #bfe3dc; }
.btn-secondary:hover { background: #d3ece7; color: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--brand-dark); border-color: var(--line-strong); }
.btn-ghost:hover { background: #f1f0eb; }
.btn-danger { background: var(--err); color: #fff; }
.btn-warn { background: #f59e0b; color: #1f1300; }
.btn-warn:hover { background: #e48d00; }
.btn-lg { min-height: 56px; font-size: 1.1rem; }
.btn-block { width: 100%; }
.btn-small { min-height: 38px; padding: .35rem .75rem; font-size: .9rem; border-radius: 10px; }
.small-link { display: inline-block; margin-top: .5rem; font-size: .92rem; font-weight: 600; }

/* ---------- flash & boxes ---------- */
.flash { border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; font-weight: 600; }
.flash-ok { background: var(--ok-soft); color: #0d5c2d; border: 1px solid #bfe3cb; }
.flash-error { background: var(--err-soft); color: var(--err); border: 1px solid #f5c2bd; }
.flash-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.flash-undo { display: flex; align-items: center; justify-content: space-between; gap: .75rem; background: #233; color: #fff; }
.flash-undo .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .5); }
.notice-box { background: #eef4ff; border: 1px solid #c9d8f5; border-radius: 12px; padding: .9rem 1rem; margin: 0 0 1rem; }
.notice-actions { display: grid; gap: .5rem; margin-top: .75rem; }
.error-summary { background: var(--err-soft); border: 1px solid #f5c2bd; border-radius: 12px; padding: .85rem 1rem; margin-bottom: 1rem; color: var(--err); }
.error-summary ul { margin: .35rem 0 0; padding-left: 1.2rem; }
.error-summary a { color: var(--err); font-weight: 600; }
.es-title { font-weight: 700; margin: 0; }
.warn-box { background: var(--warn-soft); border: 2px solid var(--warn-line); border-radius: 14px; padding: 1rem; margin: 1rem 0; color: #4a2c00; }
.warn-box ul { margin: .4rem 0 .9rem; padding-left: 1.2rem; }
.warn-box li + li { margin-top: .4rem; }
.warn-box a { color: #6b3a00; font-weight: 700; }
.warn-title { font-weight: 800; margin: 0; }
.warn-actions { display: grid; gap: .5rem; }
.warn-text { color: var(--warn); font-weight: 600; margin-top: .35rem; }
.ok-text { color: var(--in); font-weight: 600; }
.info-box { background: var(--brand-soft); border-radius: 12px; padding: .5rem .9rem; margin-top: 1rem; }

/* ---------- home ---------- */
.pending { border-left: 5px solid #f59e0b; }
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li + li { border-top: 1px solid var(--line); }
.link-list a {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  min-height: 52px; padding: .55rem .1rem; text-decoration: none; color: var(--ink); font-weight: 600;
}
.chev { color: var(--muted); font-size: 1.4rem; line-height: 1; }
.check-list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.check-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .5rem 0; border-top: 1px solid var(--line); }
.check-list li:first-child { border-top: 0; }
.check-mark { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; flex: 0 0 auto; }
.check-list li.done .check-mark { background: var(--in); border-color: var(--in); }
.check-list li.done span:last-child { color: var(--muted); text-decoration: line-through; }
.check-list li > span:not(.check-mark) { flex: 1 1 0; min-width: 0; }
.check-list a { font-weight: 600; flex: 1 1 12rem; }

.tile-section { margin-bottom: .5rem; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.tile {
  display: flex; flex-direction: column; justify-content: center; gap: .35rem;
  min-height: 92px; padding: .85rem .9rem; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); border: 1px solid rgba(0, 0, 0, .03);
  color: var(--ink); text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.tile:hover { border-color: #bfe3dc; color: var(--ink); }
.tile:active { transform: scale(.985); }
.tile-icon { font-size: 1.75rem; line-height: 1; }
.tile-label { font-weight: 700; font-size: 1rem; line-height: 1.2; }

.status-grid { display: grid; gap: 0; margin-top: 1.25rem; }
.stat-list { list-style: none; padding: 0; margin: 0; }
.stat-list li { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.stat-list li .inline-form { margin-top: .3rem; }
.stat-list li:first-child { border-top: 0; }
.stat-name { font-weight: 650; }
.stat-val { text-align: left; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-bottom: .35rem; }
.summary-grid .card { padding: .8rem .7rem; }
.stat { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .65rem; }
.stat-label { color: var(--muted); font-size: .9rem; font-weight: 600; }
.stat-big { font-size: clamp(1.05rem, 4.6vw, 1.45rem); font-weight: 800; white-space: nowrap; }
.big-number { font-size: 1.6rem; font-weight: 800; margin: 0; }
.big-number small { font-size: .95rem; color: var(--muted); font-weight: 600; }
.stock-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.yield { border-top: 1px solid var(--line); margin-top: .75rem; padding-top: .6rem; }
.yield-title { font-weight: 700; margin: 0 0 .2rem; }

/* key / value */
.kv { margin: 0; }
.kv > div { display: grid; grid-template-columns: minmax(40%, 1fr) minmax(0, max-content); gap: .75rem; align-items: baseline; padding: .45rem 0; border-top: 1px solid var(--line); }
.kv > div:first-child { border-top: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 650; text-align: right; overflow-wrap: break-word; }

/* entries */
.entry-list { display: grid; }
.entry-row {
  display: grid; grid-template-columns: 2.2rem minmax(0, 1fr) auto; align-items: center; gap: .65rem;
  min-height: 60px; padding: .6rem .15rem; border-top: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
}
.entry-list .entry-row:first-child { border-top: 0; }
.entry-row:hover { background: #faf9f6; color: var(--ink); }
.entry-icon { font-size: 1.45rem; text-align: center; }
.entry-main { display: flex; flex-direction: column; min-width: 0; }
.entry-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-sum { color: var(--muted); font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .2rem; }
.entry-side { display: flex; flex-direction: column; align-items: flex-end; gap: .1rem; }
.amt { font-weight: 750; white-space: nowrap; }
.amt-in { color: var(--in); }
.amt-billed { color: var(--muted); font-weight: 600; font-size: .9rem; }
.entry-by { font-size: .78rem; color: var(--muted); }
.tag { display: inline-block; font-size: .76rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; background: #eceae3; color: #4b5451; }
.tag-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.day { margin-bottom: 1rem; }
.day-head { font-size: .95rem; font-weight: 700; color: var(--muted); margin: .9rem 0 .3rem; }
.history .entry-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0 .75rem; }
.empty { text-align: center; padding: 1.5rem 1rem; }
.filters { display: grid; gap: .6rem; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.filter-row .filter:first-child { grid-column: 1 / -1; }
.filter { display: flex; flex-direction: column; gap: .25rem; }

/* lists (admin) */
.item-list { list-style: none; margin: 0; padding: 0; }
.item-list > li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.item-list > li:first-child { border-top: 0; }
.item-list > li.inactive { opacity: .7; }
.item-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 14rem; }
.item-name { font-weight: 700; }
.item-sub { color: var(--muted); font-size: .9rem; }
.item-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.user-edit { width: 100%; }
.user-edit summary { cursor: pointer; list-style: none; display: flex; flex-direction: column; }
.user-edit summary::-webkit-details-marker { display: none; }
.user-edit[open] summary { margin-bottom: .75rem; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: .35rem 0; border-top: 1px solid var(--line); }
.plain-list li:first-child { border-top: 0; }
.checks { list-style: none; padding: 0; margin: 0 0 .75rem; }
.checks li { padding: .4rem 0; }
.checks li.bad { color: var(--err); font-weight: 650; }
.table { width: 100%; border-collapse: collapse; margin: .5rem 0; }
.table th, .table td { text-align: left; padding: .5rem .35rem; border-top: 1px solid var(--line); }
.table th { color: var(--muted); font-size: .85rem; border-top: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table tr.total td { font-weight: 800; border-top: 2px solid var(--line-strong); }
.tips { margin: 0; padding-left: 1.1rem; }
.tips li + li { margin-top: .55rem; }
.help-list { margin: 0; }
.help-list > div { padding: .55rem 0; border-top: 1px solid var(--line); }
.help-list > div:first-child { border-top: 0; }
.help-list dt { font-weight: 700; }
.help-list dd { margin: .15rem 0 0; color: var(--muted); }

/* ---------- forms ---------- */
.entry-form { display: block; }
.field { margin-bottom: 1.15rem; }
.label-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .5rem; margin-bottom: .4rem; }
.label { font-weight: 700; font-size: 1rem; }
.label.small { font-size: .85rem; color: var(--muted); }
.opt { color: var(--muted); font-size: .88rem; font-weight: 500; }
.field.req .opt { display: none; }
.opt-inline { color: var(--muted); font-weight: 500; font-size: .88rem; }
.input {
  display: block; width: 100%; min-height: var(--tap);
  padding: .65rem .8rem; font: inherit; font-size: 1.05rem; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line-strong); border-radius: 12px;
  -webkit-appearance: none; appearance: none;
}
select.input {
  padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, #6b7672 50%), linear-gradient(135deg, #6b7672 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { border-color: var(--brand); outline: 3px solid rgba(15, 118, 110, .2); outline-offset: 0; }
.has-error .input { border-color: var(--err); }
.input-date { max-width: 16rem; }
.input-wrap { display: flex; align-items: stretch; position: relative; }
.input-wrap .input { flex: 1 1 auto; min-width: 0; }
.prefix, .suffix {
  display: inline-flex; align-items: center; padding: 0 .75rem; color: var(--muted); font-weight: 700;
  background: #f1f0eb; border: 1.5px solid var(--line-strong);
}
.prefix { border-right: 0; border-radius: 12px 0 0 12px; font-size: 1.1rem; }
.suffix { border-left: 0; border-radius: 0 12px 12px 0; font-size: .92rem; white-space: nowrap; }
.input-wrap.has-prefix .input { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-wrap .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-wrap .suffix[hidden] + * , .input-wrap .input:has(+ .suffix[hidden]) { border-radius: 12px; }
.input-wrap.has-prefix .input:has(+ .suffix[hidden]) { border-radius: 0 12px 12px 0; }
.input-wrap.has-action .input { padding-right: 5rem; border-radius: 12px; }
.input-wrap.has-action .btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.help { color: var(--muted); font-size: .9rem; margin: .35rem 0 0; }
.echo { color: var(--brand-dark); font-weight: 700; font-size: .95rem; margin: .3rem 0 0; min-height: 0; }
.echo:empty, .live-hint:empty, .field-error:empty, .fill-chips:empty { display: none; }
.live-hint { background: var(--brand-soft); color: #134e48; border-radius: 10px; padding: .45rem .7rem; margin: .45rem 0 0; font-size: .93rem; font-weight: 600; }
.field-error { color: var(--err); font-weight: 650; font-size: .93rem; margin: .35rem 0 0; }
.fill-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .45rem; }
.fill-chip { border: 1.5px dashed var(--brand); background: #fff; color: var(--brand-dark); border-radius: 999px; min-height: 40px; padding: .35rem .9rem; font: inherit; font-weight: 650; font-size: .92rem; cursor: pointer; }
.quick { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .5rem; }
.fixed-value { display: inline-block; font-weight: 700; background: #f1f0eb; border-radius: 10px; padding: .55rem .85rem; margin: 0; }
.empty-ref { margin: 0; color: var(--muted); }
.sticky-tag { border: 0; background: #fff1c7; color: #6b4b00; border-radius: 999px; font: inherit; font-size: .78rem; font-weight: 700; padding: .2rem .6rem; cursor: pointer; }
.check { display: flex; align-items: center; gap: .6rem; min-height: 44px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }

/* chips (radio buttons that look like big buttons) */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { position: relative; display: inline-flex; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip > span, button.chip {
  display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-height: var(--tap); padding: .5rem .95rem; border-radius: 12px;
  border: 1.5px solid var(--line-strong); background: #fff; color: var(--ink);
  font: inherit; font-weight: 650; font-size: 1rem; line-height: 1.2; text-align: left;
}
.chip > span small { font-weight: 500; font-size: .78rem; color: var(--muted); }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 3px rgba(15, 118, 110, .35); }
.chip input:checked + span small { color: rgba(255, 255, 255, .85); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.chip input:disabled + span { opacity: .5; }
button.chip { cursor: pointer; color: var(--brand-dark); }
button.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); }
.month-other { margin-top: .5rem; max-width: 18rem; }
.has-error .chip > span { border-color: #f0a39b; }
.preset-cat { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.preset-name { font-weight: 700; background: var(--brand-soft); color: var(--brand-dark); border-radius: 10px; padding: .5rem .85rem; }
.change-cat summary, .more-cats summary { cursor: pointer; color: var(--brand-dark); font-weight: 650; padding: .35rem 0; }
.change-cat[open] { flex-basis: 100%; }
.more-cats { margin-top: .5rem; }
.more-cats[open] .chips { margin-top: .4rem; }

/* toggle */
.toggle { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; min-height: 44px; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-ui { width: 52px; height: 30px; border-radius: 999px; background: #cfccc2; position: relative; transition: background .15s; flex: 0 0 auto; }
.toggle-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.toggle input:checked + .toggle-ui { background: var(--brand); }
.toggle input:checked + .toggle-ui::after { transform: translateX(22px); }
.toggle input:focus-visible + .toggle-ui { outline: 3px solid var(--focus); outline-offset: 2px; }
.toggle-text { font-weight: 600; }

details.more { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: .2rem 1rem; margin: .5rem 0 1rem; background: rgba(255, 255, 255, .55); }
details.more > summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; font-weight: 700; color: var(--brand-dark); }
details.more[open] > summary { margin-bottom: .6rem; }
.more-body { padding-bottom: .4rem; }
.form-actions { display: grid; gap: .6rem; margin-top: 1.25rem; }
.saving-msg { color: var(--warn); font-weight: 650; text-align: center; }
.draft-banner { background: #eef4ff; border: 1px solid #c9d8f5; border-radius: 12px; padding: .75rem 1rem; margin-bottom: 1rem; }
.draft-banner .button-row { margin: .5rem 0 0; }
.danger-zone { margin-top: 1.5rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.danger-zone summary { cursor: pointer; color: var(--err); font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.danger-zone p { color: var(--muted); }

.count-row { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .85rem 1rem; margin-bottom: .75rem; }
.count-row .help { margin: .1rem 0 .5rem; }
.count-row.has-error .input { border-color: var(--err); }

/* saved */
.saved-card { text-align: left; }
.saved-tick { width: 64px; height: 64px; border-radius: 50%; background: var(--in); color: #fff; font-size: 2.2rem; font-weight: 800; display: flex; align-items: center; justify-content: center; margin: .25rem auto .5rem; }
.saved-head { display: flex; align-items: center; gap: .75rem; margin: 1rem 0 .5rem; }
.saved-title { font-weight: 800; font-size: 1.1rem; margin: 0; }
.message-card { text-align: center; padding: 2rem 1.25rem; }
.message-icon { font-size: 2.6rem; margin-bottom: .5rem; }
.recent summary { cursor: pointer; color: var(--brand-dark); font-weight: 650; margin-top: .5rem; }

/* login / setup */
body.bare { background: linear-gradient(180deg, #0f766e 0, #0f766e 210px, var(--bg) 210px); }
.auth-wrap { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 3rem 0 2rem; }
.auth-card { width: 100%; max-width: 440px; padding: 1.5rem 1.25rem; }
.auth-logo { display: block; margin: 0 auto .75rem; border-radius: 16px; }
.auth-card .h1 { text-align: center; margin-bottom: .35rem; }
.auth-card > .muted { text-align: center; }
.error-card { margin-top: 2rem; }

/* ---------- wider screens ---------- */
@media (min-width: 560px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-row { grid-template-columns: 2fr 2fr 1.5fr; }
  .filter-row .filter:first-child { grid-column: auto; }
  .button-stack { grid-template-columns: 1fr 1fr; }
  .form-actions { grid-template-columns: 2fr 1fr; align-items: start; }
  .form-actions .warn-box, .form-actions .saving-msg { grid-column: 1 / -1; }
}
@media (min-width: 900px) {
  body.has-tabbar { padding-bottom: 0; }
  .tabbar { display: none; }
  .topnav { display: flex; }
  .container { padding-top: 1.5rem; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
  .status-grid .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (min-width: 1024px) {
  .container { max-width: 900px; }
  .history .entry-row { grid-template-columns: 2.2rem minmax(0, 1fr) 11rem; }
  .history .entry-main { flex-direction: row; align-items: baseline; gap: 1rem; }
  .history .entry-title { flex: 0 0 13rem; }
  .history .entry-sum { flex: 1 1 auto; }
  .history .entry-side { flex-direction: row; align-items: baseline; justify-content: flex-end; gap: .75rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- reports & charts ---------- */
:root {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-neg: #e34948;
  --chart-grid: #ebe9e3; --chart-axis: #c3c2b7; --chart-muted: #6f6c66; --chart-deemph: #c9c7bf;
  --good-ink: #006300; --bad-ink: #b42318;
}
#went, #plan, #data, .rgrid > [id] { scroll-margin-top: 70px; }
.rgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.rgrid > * { min-width: 0; }

/* period: one segmented control + a sentence that opens the other settings */
.period-form { margin-bottom: .2rem; }
.seg-control { border: 0; margin: 0 0 .45rem; padding: 0; display: flex; align-items: center; gap: .6rem; }
.seg-control legend { float: left; font-weight: 700; font-size: .92rem; color: var(--muted); margin-right: .6rem; padding: 0; line-height: 40px; }
.seg { display: inline-flex; background: #fff; border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 2px; gap: 2px; }
.seg-item { position: relative; display: inline-flex; }
.seg-item input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-item span { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 38px; padding: 0 .7rem; border-radius: 9px; font-weight: 700; font-size: .95rem; color: var(--ink); }
.seg-item input:checked + span { background: var(--brand); color: #fff; }
.seg-item input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.period-line { color: var(--muted); font-size: .92rem; margin: 0 0 .9rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; }
.period-line strong { color: var(--ink); }
.period-more > summary { cursor: pointer; color: var(--brand-dark); font-weight: 700; list-style: none; display: inline-flex; align-items: center; min-height: 32px; }
.period-more > summary::-webkit-details-marker { display: none; }
.period-more > summary::after { content: "▾"; margin-left: .25rem; }
.period-more[open] { flex-basis: 100%; }
.period-more-body { display: grid; gap: .75rem; background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: .8rem 1rem; margin-top: .4rem; color: var(--ink); }
.period-more-body .input { min-height: 42px; padding-top: .45rem; padding-bottom: .45rem; font-size: .98rem; max-width: 20rem; }
.basis { border: 0; margin: 0; padding: 0; }
.basis .check { min-height: 38px; }
.check.is-disabled { color: var(--muted); }

/* hero */
.hero { padding: 1.1rem 1rem; }
.hero-label { color: var(--muted); font-weight: 700; margin: 0; }
.hero-value { font-size: clamp(2.5rem, 11vw, 3.3rem); font-weight: 800; line-height: 1.05; margin: .15rem 0 .4rem; letter-spacing: -.02em; overflow-wrap: anywhere; }
.hero-value.neg { color: var(--bad-ink); }
.hero-sub { color: var(--muted); margin: 0 0 .25rem; }
.hero-delta { font-weight: 700; margin: .45rem 0 0; }
.hero-note { margin: .5rem 0 0; font-size: .9rem; color: var(--muted); }
.hero-warn { margin: .5rem 0 0; font-size: .92rem; font-weight: 650; color: var(--warn); }
.reconcile { margin-top: .75rem; border-top: 1px solid var(--line); padding-top: .4rem; }
.reconcile summary { cursor: pointer; color: var(--brand-dark); font-weight: 650; font-size: .92rem; min-height: 36px; display: flex; align-items: center; }
.reconcile td:first-child { color: var(--muted); }
.delta { display: inline-block; font-weight: 700; font-size: .85rem; }
.delta-good { color: var(--good-ink); }
.delta-bad { color: var(--bad-ink); }
.delta-flat { color: var(--muted); }

/* what to do now */
.insight-list { list-style: none; margin: 0; padding: 0; }
.insight { display: flex; gap: .65rem; align-items: flex-start; padding: .6rem 0; border-top: 1px solid var(--line); }
.insight:first-child { border-top: 0; }
.lvl-icon { flex: 0 0 auto; width: 20px; height: 20px; margin-top: .15rem; }
.insight-body { min-width: 0; flex: 1 1 auto; }
.insight-body p { margin: 0 0 .35rem; }
.insight-body .btn { margin-top: .1rem; }
.insight-tag { font-weight: 800; }
.see-all { margin-top: .5rem; }
@media (max-width: 1023px) {
  .insight-list.collapsed .extra { display: none; }
}
@media (min-width: 1024px) {
  .see-all { display: none; } /* every item is shown beside the hero on a PC */
}

/* tiles */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; margin-bottom: 1rem; }
.kpi { margin: 0; padding: .75rem .8rem; display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.kpi-label { color: var(--muted); font-size: .85rem; font-weight: 700; }
.kpi-value { font-size: 1.3rem; font-weight: 800; white-space: nowrap; }
.kpi-sub { color: var(--muted); font-size: .78rem; line-height: 1.3; }
.kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: .4rem; min-height: 22px; margin-top: auto; }
.kpi-foot .delta { font-size: .78rem; line-height: 1.25; white-space: normal; }
.kpi-caption { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; margin: -.1rem 0 0; }
.spark { width: 72px; height: 20px; flex: 0 0 auto; margin-left: auto; }
.jump { font-size: .95rem; color: var(--muted); margin: -.25rem 0 1rem; }
.jump a { font-weight: 700; text-decoration: none; padding: .35rem .15rem; display: inline-block; }

/* charts */
.chart { margin: 0 0 1rem; }
.chart figcaption { margin-bottom: .35rem; }
.chart-note { color: var(--muted); font-size: .88rem; margin: -.35rem 0 .4rem; }
.chart > .chart-note { margin: .5rem 0 0; }
.chart-plot { position: relative; width: 100%; min-height: 40px; touch-action: pan-y; }
.chart-plot svg { display: block; max-width: 100%; overflow: visible; }
.chart-plot svg:focus { outline: none; }
.chart-plot svg:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .85rem; color: var(--ink); margin: 0 0 .35rem; }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.legend-key { display: inline-block; flex: 0 0 auto; }
.legend-key.key-box { width: 12px; height: 12px; border-radius: 3px; }
.legend-key.key-line { width: 16px; height: 3px; border-radius: 2px; }
.chart-tip { position: absolute; top: 0; z-index: 5; pointer-events: none; background: #fff; border: 1px solid rgba(11, 11, 11, .12); border-radius: 10px; box-shadow: 0 4px 16px rgba(18, 28, 25, .12); padding: .45rem .6rem; font-size: .85rem; min-width: 140px; }
.tip-title { font-weight: 700; color: var(--muted); font-size: .8rem; margin-bottom: .15rem; }
.tip-row { display: flex; align-items: center; gap: .45rem; white-space: nowrap; }
.tip-key { width: 12px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.tip-name { color: var(--muted); }
.barlist { display: grid; gap: .6rem; }
.bar-row { display: grid; gap: .25rem; border-radius: 8px; }
.bar-head { display: flex; justify-content: space-between; gap: .75rem; font-size: .92rem; }
.bar-name { font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.bar-val { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-row.is-muted .bar-name, .bar-row.is-muted .bar-val { color: var(--muted); font-weight: 600; }
.bar-track { height: 14px; }
.bar-fill { height: 14px; border-radius: 0 4px 4px 0; min-width: 2px; }
.chart-table { margin-top: .5rem; }
.chart-table summary { cursor: pointer; color: var(--brand-dark); font-weight: 650; font-size: .9rem; padding: .25rem 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table td.num, .table th.num { font-variant-numeric: tabular-nums; }
.waste-sum { margin-top: .6rem; border-top: 1px solid var(--line); padding-top: .5rem; }
.status { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; font-weight: 700; color: var(--ink); vertical-align: middle; margin-left: .35rem; }
.status .lvl-icon { margin: 0; width: 16px; height: 16px; }

/* plan ahead */
.plan-money .big-number { margin: .1rem 0 .2rem; }
.big-number.stale { color: var(--muted); }
.plan-lines { margin-top: .75rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.plan-lines p { margin: 0 0 .45rem; }
.plan-list { list-style: none; margin: 0; padding: 0; }
.plan-row { padding: .65rem 0; border-top: 1px solid var(--line); }
.plan-row:first-child { border-top: 0; }
.plan-head { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.plan-head .lvl-icon { margin: 0; }
.plan-detail { margin: .2rem 0 .35rem; }
.calc-grid { display: grid; gap: 1rem; }
.stepper { display: flex; align-items: stretch; gap: .4rem; max-width: 18rem; }
.stepper .btn { min-width: 48px; font-size: 1.3rem; padding: 0; }
.stepper .input { text-align: center; font-size: 1.2rem; font-weight: 700; }
.calc-h { font-size: .9rem; font-weight: 700; color: var(--muted); margin: 0 0 .3rem; text-transform: uppercase; letter-spacing: .03em; }
.calc-list { margin: 0 0 .9rem; padding-left: 1.1rem; }
.calc-list li + li { margin-top: .3rem; }
.calc-money { font-weight: 700; }
.fc-note { margin: .6rem 0 0; font-size: .88rem; color: var(--muted); }
.conf { font-weight: 700; color: var(--ink); }

/* how much data */
.steps { list-style: none; margin: 0 0 .9rem; padding: 0; display: grid; gap: .45rem; }
.steps li { display: flex; gap: .55rem; align-items: flex-start; }
.step-mark { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 800; color: #fff; margin-top: .1rem; }
.steps li.done .step-mark { background: var(--in); border-color: var(--in); }
.ready-list { list-style: none; margin: .5rem 0 0; padding: 0; }
.ready-list li { display: flex; gap: .6rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.ready-list li:first-child { border-top: 0; }
.ready-mark { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; background: #eceae3; }
.ready-ok .ready-mark { background: var(--ok-soft); color: var(--in); }
.ready-partial .ready-mark { background: var(--warn-soft); color: var(--warn); }
.ready-missing .ready-mark { background: var(--err-soft); color: var(--err); }
.ready-more summary { cursor: pointer; color: var(--brand-dark); font-weight: 650; margin-top: .6rem; }
.getting-started { border-left: 5px solid var(--brand); }
.money-card .big-number { margin: .1rem 0 .3rem; }
.money-card .button-row { margin-bottom: 0; }
.big-number.neg { color: var(--bad-ink); }
.money-card { border-left: 5px solid var(--brand); }

@media (min-width: 560px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .calc-grid { grid-template-columns: minmax(0, 18rem) minmax(0, 1fr); align-items: start; }
}
@media (min-width: 1024px) {
  body.page-wide .container { max-width: 1200px; }
  .rgrid { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0 1rem; grid-auto-flow: row dense; align-items: start; }
  .rgrid > * { grid-column: 1 / -1; }
  .rgrid > .span-4 { grid-column: span 4; }
  .rgrid > .span-5 { grid-column: span 5; }
  .rgrid > .span-6 { grid-column: span 6; }
  .rgrid > .span-7 { grid-column: span 7; }
  .rgrid > .span-12 { grid-column: 1 / -1; }
  .rgrid > .plan-money { order: 10; }
  .rgrid > .forecast { order: 9; }
}
.stat-big.neg { color: var(--bad-ink); }
.reconcile-card summary { cursor: pointer; color: var(--brand-dark); font-weight: 700; min-height: 40px; display: flex; align-items: center; }
.reconcile-card td:first-child { color: var(--muted); }
.explain { border-left: 5px solid #f59e0b; }
@media (min-width: 1024px) {
  body.page-wide .topbar-inner { max-width: 1200px; }
}

/* ---------- computer layout (the same pages, using a big screen) ---------- */
.add-menu { position: relative; margin-left: .4rem; }
.add-menu > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; min-height: 40px;
  padding: .45rem .95rem; border-radius: 10px; font-weight: 800; background: #fff; color: var(--brand-dark);
}
.add-menu > summary::-webkit-details-marker { display: none; }
.add-menu > summary:hover, .add-menu[open] > summary { background: var(--brand-soft); }
.add-menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: min(760px, 92vw);
  background: #fff; color: var(--ink); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(18, 28, 25, .2);
  padding: .9rem 1rem; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .25rem 1rem;
}
.add-menu-h { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .2rem .5rem .3rem; }
.topnav .add-menu-panel a { display: flex; gap: .5rem; align-items: center; padding: .4rem .5rem; border-radius: 8px; color: var(--ink); font-weight: 600; font-size: .95rem; }
.topnav .add-menu-panel a:hover, .topnav .add-menu-panel a:focus-visible { background: var(--brand-soft); color: var(--brand-dark); }
.topnav-logout { margin: 0 0 0 .4rem; }
.topnav-logout button {
  min-height: 40px; padding: .45rem .8rem; border-radius: 10px; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .45);
}
.topnav-logout button:hover { background: rgba(255, 255, 255, .15); }
@media (min-width: 1024px) {
  .topbar-inner { max-width: 1200px; }
  body.page-wide .container { max-width: 1200px; }
  body.page-narrow .container { max-width: 820px; }
  body.pg-add .entry-form, body.pg-edit .entry-form { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.4rem 1.6rem 1.6rem; }
  .home-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0 1.25rem; align-items: start; }
  .home-grid > * { grid-column: 1 / -1; min-width: 0; }
  .home-grid > .hg-half { grid-column: span 6; }
  .home-grid .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .home-grid .status-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home-grid .status-grid .card:last-child:nth-child(odd) { grid-column: auto; }
  .stock-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; align-items: start; }
  .more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; align-items: start; }
}
