/* Bakery Book */
:root {
  --cream: #FFF8F3; --white: #FFFFFF; --cocoa: #3B211C; --cocoa-2: #5B372F; --ink: #2F1A16; --muted: #6F534B;
  --line: #ECDCD6; --accent: #B03A5A; --accent-d: #8C2C47; --soft: #F6D2DA; --soft-2: #FCEEF0;
  --sales: #B03A5A; --spent: #C08A1E; --profit: #5E8F3E; --good: #1E7B34; --bad: #B00020; --warn: #9A6700;
  --serif: 'Cormorant Garamond', Garamond, Georgia, serif; --sans: 'Jost', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --script: 'Great Vibes', cursive;
  --r: 18px; --shadow: 0 1px 2px rgba(59,33,28,.06), 0 8px 24px rgba(59,33,28,.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: #EFE3DF; }
body { color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45; font-variant-numeric: lining-nums tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3 { margin: 0; font-family: var(--serif); color: var(--cocoa); line-height: 1.1; }
p { margin: 0 0 .6em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; background: var(--cream); position: relative; padding-bottom: calc(84px + env(safe-area-inset-bottom)); box-shadow: 0 0 40px rgba(59,33,28,.08); }

/* Top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 18px 10px; background: var(--cocoa); color: var(--cream); }
.top-logo { width: 42px; height: 42px; border-radius: 50%; background: var(--white); padding: 2px; object-fit: contain; }
.top-text { display: flex; flex-direction: column; line-height: 1.05; }
.top-name { font-family: var(--serif); font-weight: 700; font-size: 1.45rem; }
.top-sub { font-size: .8rem; opacity: .8; }

.view { padding: 16px 16px 24px; outline: none; }
.hello { font-family: var(--script); font-size: 2.1rem; color: var(--accent); line-height: 1; margin: 4px 0 2px; }
.hello-sub { color: var(--muted); font-size: .95rem; margin-bottom: 14px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h2 { font-size: 1.55rem; }
.section-title a, .link { color: var(--accent); font-weight: 600; font-size: .92rem; text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0; cursor: pointer; }

/* Segmented control and chips */
.seg { display: flex; background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: 9px 8px; font-weight: 600; font-size: .9rem; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--cocoa); color: var(--cream); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: 0 -2px 4px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: var(--white); border-radius: 999px; padding: 8px 15px; font-weight: 500; font-size: .92rem; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--cocoa); color: var(--cream); border-color: var(--cocoa); }
.chip .n { display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--soft); color: var(--cocoa); font-size: .78rem; font-weight: 700; text-align: center; }
.chip.on .n { background: var(--accent); color: var(--white); }

/* Stat cards */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 14px 12px; text-align: left; cursor: default; }
button.stat { cursor: pointer; }
.stat .k { display: flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--muted); font-weight: 500; }
.stat .k i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.stat .v { display: block; font-family: var(--serif); font-weight: 700; font-size: 1.75rem; color: var(--cocoa); margin-top: 4px; line-height: 1.05; }
.stat .s { font-size: .8rem; color: var(--muted); }
.stat.profit .v.neg { color: var(--bad); }
.stat.owed { background: var(--soft-2); border-color: #F2D2DA; }
.stat.owed .v { color: var(--accent); }

/* Cards */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card + .card { margin-top: 10px; }
.empty { text-align: center; padding: 28px 18px; color: var(--muted); background: var(--white); border: 1.5px dashed var(--line); border-radius: var(--r); }
.empty b { display: block; font-family: var(--serif); font-size: 1.4rem; color: var(--cocoa); margin-bottom: 6px; }
.empty .btn { margin-top: 12px; }
.banner { display: flex; gap: 12px; align-items: flex-start; background: #FFF6DC; border: 1px solid #F1DFA6; border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; font-size: .92rem; }
.banner b { color: var(--cocoa); }
.banner .btn { margin-top: 8px; }

/* Chart */
.chart-card { padding: 14px 12px 12px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 6px; }
.chart-head h3 { font-size: 1.3rem; }
.legend { display: flex; gap: 12px; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #EFE3DF; stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--sans); }
.chart .bar { cursor: pointer; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .sel { fill: var(--soft-2); }
.chart-detail { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; padding: 10px; border-radius: 12px; background: var(--cream); font-size: .82rem; color: var(--muted); }
.chart-detail b { display: block; color: var(--cocoa); font-size: 1rem; }
.chart-detail .neg { color: var(--bad); }

/* Bars list */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar .row { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 4px; }
.hbar .row span:first-child { font-weight: 500; }
.hbar .row span:last-child { color: var(--muted); }
.hbar .track { height: 10px; border-radius: 999px; background: #F4EAE7; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 999px; background: var(--accent); }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.day { font-weight: 600; font-size: .85rem; color: var(--muted); margin: 14px 4px 2px; }
.day:first-child { margin-top: 4px; }
.item { width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 13px 14px; cursor: pointer; }
.item:active { background: var(--soft-2); }
.item .t { font-weight: 600; color: var(--cocoa); font-size: 1rem; }
.item .a { font-weight: 700; text-align: right; color: var(--cocoa); }
.item .d { color: var(--muted); font-size: .88rem; line-height: 1.35; }
.item .pills { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: #F4EAE7; color: var(--cocoa-2); }
.pill.paid { background: #DFF2E3; color: var(--good); }
.pill.owe { background: var(--soft); color: var(--accent-d); }
.pill.ready { background: #FFF1C7; color: var(--warn); }
.pill.done { background: #E6E1F3; color: #4D3F7A; }
.pill.cancel { background: #EEE; color: #777; text-decoration: line-through; }
.pill.date { background: var(--cocoa); color: var(--cream); }
.item.cancelled .t, .item.cancelled .a { color: #9A8A86; text-decoration: line-through; }

/* Month switcher */
.month { display: flex; align-items: center; justify-content: space-between; background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.month b { font-weight: 600; }
.round { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--soft-2); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.round svg { width: 20px; height: 20px; fill: none; stroke: var(--cocoa); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.big-total { text-align: center; margin: 18px 0 6px; }
.big-total .v { font-family: var(--serif); font-weight: 700; font-size: 2.6rem; color: var(--cocoa); line-height: 1; }
.big-total .k { color: var(--muted); font-size: .9rem; }

/* Costing */
.recipe-card { width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; cursor: pointer; }
.recipe-card .t { font-family: var(--serif); font-weight: 700; font-size: 1.3rem; color: var(--cocoa); }
.recipe-card .d { color: var(--muted); font-size: .86rem; }
.recipe-card .p { text-align: right; }
.recipe-card .p b { display: block; font-family: var(--serif); font-size: 1.5rem; color: var(--accent); line-height: 1; }
.recipe-card .p span { font-size: .78rem; color: var(--muted); }
.costbar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; gap: 2px; margin: 10px 0 8px; }
.costkeys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: .86rem; }
.costkeys div { display: flex; justify-content: space-between; gap: 8px; }
.costkeys i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.costkeys span { color: var(--muted); }
.price-hero { text-align: center; padding: 14px; background: var(--soft-2); border-radius: 16px; margin-bottom: 12px; }
.price-hero .k { font-size: .88rem; color: var(--muted); }
.price-hero .v { font-family: var(--serif); font-weight: 700; font-size: 2.6rem; color: var(--accent); line-height: 1.05; }
.price-hero .s { font-size: .9rem; color: var(--cocoa-2); }
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.lines li span:last-child { color: var(--muted); white-space: nowrap; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: .9rem; color: var(--cocoa); }
.field small { color: var(--muted); font-weight: 400; }
.field input, .field select, .field textarea { width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--white); font-size: 1rem; }
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--cocoa); }
.field input.big { font-family: var(--serif); font-size: 2rem; font-weight: 700; text-align: center; min-height: 64px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three { display: grid; grid-template-columns: 1.4fr .8fr 1fr; gap: 8px; }
.line-row { display: grid; grid-template-columns: 1fr 76px 92px 36px; gap: 6px; align-items: center; margin-bottom: 8px; }
.line-row select, .line-row input { width: 100%; min-height: 46px; padding: 8px 10px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--white); font-size: .95rem; }
.line-row.recipe { grid-template-columns: 1fr 90px 36px; }
.line-row .unit { font-size: .8rem; color: var(--muted); }
.icon-x { width: 36px; height: 36px; border-radius: 50%; border: 0; background: #F4EAE7; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-x svg { width: 16px; height: 16px; fill: none; stroke: var(--cocoa); stroke-width: 2; stroke-linecap: round; }
.line-head { display: grid; grid-template-columns: 1fr 76px 92px 36px; gap: 6px; font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.line-head.recipe { grid-template-columns: 1fr 90px 36px; }
.sum-row { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0; border-top: 1px solid var(--line); margin-top: 4px; }
.sum-row b { font-family: var(--serif); font-size: 1.8rem; color: var(--cocoa); }
.hint { color: var(--muted); font-size: .85rem; margin: -6px 0 14px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 22px; border-radius: 999px; border: 2px solid transparent; font-weight: 600; font-size: 1rem; cursor: pointer; text-decoration: none; }
.btn.wide { width: 100%; }
.btn-main { background: var(--accent); color: var(--white); }
.btn-dark { background: var(--cocoa); color: var(--cream); }
.btn-line { background: var(--white); color: var(--cocoa); border-color: var(--cocoa); }
.btn-soft { background: var(--soft-2); color: var(--cocoa); }
.btn-wa { background: #25D366; color: #06331B; }
.btn-danger { background: var(--white); color: var(--bad); border-color: #EBC2C8; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-row { display: grid; gap: 10px; }
.btn-row.two-btn { grid-template-columns: 1fr 1fr; }
.add-line { width: 100%; border: 1.5px dashed var(--line); background: transparent; border-radius: 12px; min-height: 46px; font-weight: 600; color: var(--accent); cursor: pointer; margin: 2px 0 12px; }

/* Floating button */
.fab { position: fixed; z-index: 25; right: max(16px, calc(50% - 280px + 16px)); bottom: calc(86px + env(safe-area-inset-bottom)); display: inline-flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 22px 0 18px; border: 0; border-radius: 999px; background: var(--accent); color: var(--white); font-weight: 600; font-size: 1rem; box-shadow: 0 10px 26px rgba(176,58,90,.4); cursor: pointer; }
.fab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* Tabs */
.tabs { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--white); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; padding: 6px 0; font-size: .74rem; font-weight: 500; color: var(--muted); cursor: pointer; border-radius: 12px; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--accent); font-weight: 700; }
.tabs button.on svg { stroke-width: 2.2; }

/* Sheet */
dialog.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh; border-radius: 24px 24px 0 0; background: var(--cream); color: var(--ink); display: none; flex-direction: column; box-shadow: 0 -10px 40px rgba(47,26,22,.25); }
dialog.sheet[open] { display: flex; animation: up .25s ease; }
dialog.sheet::backdrop { background: rgba(47,26,22,.45); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog.sheet[open] { animation: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); background: var(--white); border-radius: 24px 24px 0 0; }
.sheet-head h2 { font-size: 1.6rem; }
.x { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--white); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.x svg { width: 18px; height: 18px; fill: none; stroke: var(--cocoa); stroke-width: 2; stroke-linecap: round; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px 18px 8px; }
.sheet-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--white); }
.sheet-foot:empty { display: none; }
.detail-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.detail-top .v { font-family: var(--serif); font-weight: 700; font-size: 2rem; color: var(--cocoa); line-height: 1; text-align: right; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: .95rem; margin: 6px 0 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--cocoa); font-weight: 500; }

/* More */
.menu-list { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.menu-list button, .menu-list label { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font-weight: 500; cursor: pointer; }
.menu-list > :last-child { border-bottom: 0; }
.menu-list span.v { color: var(--muted); font-weight: 400; font-size: .92rem; }
.note { font-size: .88rem; color: var(--muted); margin: 8px 4px 0; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translate(-50%, 16px); opacity: 0; background: var(--cocoa); color: var(--cream); padding: 11px 20px; border-radius: 999px; font-weight: 500; pointer-events: none; transition: opacity .2s ease, transform .2s ease; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Extras */
.view { padding-bottom: 100px; }
body:has(dialog[open]) { overflow: hidden; }
.search { width: 100%; min-height: 46px; padding: 10px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--white); margin: 8px 0 6px; font-size: .95rem; }
.search:focus { outline: none; border-color: var(--cocoa); }
.amt { position: relative; }
.amt input { padding-right: 38px !important; }
.amt .unit { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.costkeys b { display: flex; align-items: center; color: var(--ink); }
.round[disabled] { cursor: default; }
.seg + .stats { margin-top: 12px; }
.stat.owed .k { color: var(--accent-d); }
.costkeys { grid-template-columns: 1fr; gap: 8px; }
.costkeys span { white-space: nowrap; }
.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.field input, .field select { min-width: 0; }
.line-row.order { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; gap: 8px; padding: 10px; margin-bottom: 10px; background: var(--white); border: 1px solid var(--line); border-radius: 16px; }
.line-row.order .li-name { grid-column: 1 / -1; }
.pre { position: relative; display: block; min-width: 0; }
.pre span { position: absolute; left: 11px; top: 5px; font-size: .68rem; font-weight: 500; color: var(--muted); pointer-events: none; }
.line-row.order .pre input { padding: 18px 10px 4px; min-height: 50px; }
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.filters button { display: flex; flex-direction: column; align-items: center; padding: 8px 4px 9px; border: 1.5px solid var(--line); background: var(--white); border-radius: 14px; cursor: pointer; }
.filters b { font-family: var(--serif); font-size: 1.5rem; line-height: 1.05; color: var(--cocoa); }
.filters span { font-size: .78rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.filters button.on { background: var(--cocoa); border-color: var(--cocoa); }
.filters button.on b, .filters button.on span { color: var(--cream); }
