:root {
  color-scheme: light;
  --ink: #17231f;
  --muted: #68736e;
  --paper: #f3f0e8;
  --surface: #fffdf8;
  --green: #173f35;
  --green-soft: #dbe7df;
  --lime: #c9e46a;
  --line: #d9d7cf;
  --danger: #a33b32;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
button, select { min-height: 44px; }
button { cursor: pointer; }
.shell { max-width: 1080px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.topbar { padding: 22px 18px 16px; background: var(--green); color: white; border-radius: 0 0 28px 28px; }
.eyebrow { margin: 0 0 5px; color: #b9ccc3; text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 800; }
h1 { margin: 0; font-size: clamp(1.65rem, 7vw, 2.4rem); line-height: 1.08; }
.topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.icon-button { border: 1px solid rgba(255,255,255,.24); color: white; background: rgba(255,255,255,.08); border-radius: 14px; padding: 0 14px; }
.content { padding: 18px; }
.summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: -4px; }
.summary-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 15px; }
.summary-card strong { display: block; font-size: 1.5rem; }
.summary-card span { color: var(--muted); font-size: .86rem; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 2px 12px; }
.section-title h2 { margin: 0; font-size: 1.15rem; }
.event-list, .item-list { display: grid; gap: 11px; }
.event-card { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 17px; color: inherit; box-shadow: 0 4px 16px rgba(23,35,31,.04); }
.event-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.event-card h3 { margin: 0 0 5px; font-size: 1.08rem; }
.date, .muted { color: var(--muted); }
.header-date { margin-top: 7px; color: #c9d8d1; }
.progress { height: 7px; overflow: hidden; border-radius: 99px; margin-top: 14px; background: #e4e3dc; }
.progress > span { display: block; height: 100%; background: var(--lime); border-radius: inherit; }
.badge { white-space: nowrap; border-radius: 99px; padding: 5px 9px; background: var(--green-soft); color: var(--green); font-size: .78rem; font-weight: 800; }
.toolbar { display: grid; gap: 10px; margin: 18px 0; }
.shopping-filters { align-items: center; }
.buyer-filter { appearance: auto; }
.search { width: 100%; min-height: 48px; padding: 0 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { border: 1px solid var(--line); border-radius: 99px; background: var(--surface); padding: 0 15px; color: var(--ink); white-space: nowrap; }
.chip.active { background: var(--green); border-color: var(--green); color: white; }
.source-label { display: flex; justify-content: space-between; gap: 12px; margin: 16px 3px 8px; font-size: .77rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.source-label strong { color: var(--green); }
.source-group { overflow: hidden; margin: 18px 0 24px; border: 2px solid #c7d7cf; border-radius: 22px; background: var(--surface); box-shadow: 0 5px 16px rgba(20, 73, 60, .06); }
.source-group-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; background: var(--green); color: white; }
.source-group-head span, .source-group-head small { display: block; color: #c9d8d1; font-size: .7rem; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.source-group-head h2 { margin: 3px 0 0; font-size: 1.12rem; }
.source-group-head > div:last-child { text-align: right; }
.source-group-head strong { display: block; font-size: 1.05rem; }
.source-group .item-list { padding: 12px; }
.source-group .item { background: #fffdfa; }
.item { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 12px; align-items: stretch; border: 1px solid var(--line); border-radius: 18px; padding: 10px; background: var(--surface); }
.item.done { opacity: .62; }
.item.done h3 { text-decoration: line-through; }
.check { width: 54px; min-height: 64px; border: 0; border-radius: 13px; background: var(--green-soft); color: var(--green); font-size: 1.45rem; font-weight: 900; }
.done .check { background: var(--green); color: white; }
.item-body { min-width: 0; padding: 3px 2px; }
.item h3 { margin: 0 0 4px; font-size: 1rem; overflow-wrap: anywhere; }
.amount { font-weight: 800; }
.item-cost { margin-top: 5px; color: var(--green); font-weight: 900; }
.item-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.buyer-select { max-width: 150px; min-height: 38px; border: 1px solid var(--line); border-radius: 11px; background: white; padding: 0 9px; color: var(--ink); }
.back { border: 0; background: transparent; color: white; padding: 0; min-height: 36px; font-weight: 750; }
.empty { padding: 30px 20px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 18px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.metric { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.metric span, .metric small { display: block; color: var(--muted); font-size: .78rem; }
.metric strong { display: block; margin-top: 6px; font-size: clamp(1.05rem, 5vw, 1.5rem); overflow-wrap: anywhere; }
.metric small { margin-top: 4px; }
.primary-metric { background: var(--green); border-color: var(--green); color: white; }
.primary-metric span { color: #c9d8d1; }
.shopping-cta { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 14px; padding: 16px 18px; border: 0; border-radius: 18px; background: var(--lime); color: var(--ink); text-align: left; }
.shopping-cta span, .shopping-cta small { display: block; }
.shopping-cta small { margin-top: 3px; font-weight: 500; }
.dish-list { display: grid; gap: 11px; }
.dish-card { padding: 17px; border: 1px solid var(--line); border-radius: 19px; background: var(--surface); }
.dish-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dish-card h3 { margin: 0 0 5px; font-size: 1rem; }
.price { flex: 0 0 auto; padding: 6px 9px; border-radius: 10px; background: var(--green-soft); color: var(--green); font-weight: 900; }
.price-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); }
.price-row span, .price-row small, .price-row b { display: block; }
.price-row small { margin-bottom: 4px; color: var(--muted); }
.positive { color: var(--green); }
.ingredients-toolbar { display: block; }
.ingredient-list { display: grid; gap: 11px; }
.ingredient-card { width: 100%; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: inherit; text-align: left; }
.ingredient-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ingredient-head h3 { margin: 0 0 4px; font-size: 1rem; }
.ingredient-head strong { white-space: nowrap; color: var(--green); font-size: 1.05rem; }
.ingredient-package { margin-top: 12px; font-size: .9rem; font-weight: 750; }
.age { display: flex; align-items: center; gap: 7px; margin-top: 12px; font-size: .78rem; font-weight: 800; }
.age > span { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.age.fresh { color: #28734f; }
.age.old { color: var(--danger); }
.edit-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 12px; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.edit-form label { display: grid; gap: 7px; min-width: 0; color: var(--muted); font-size: .82rem; font-weight: 800; }
.edit-form input, .edit-form select, .edit-form textarea { width: 100%; min-height: 47px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--ink); }
.money-input { position: relative; }
.money-input input { padding-right: 42px; }
.money-input span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 900; pointer-events: none; }
.check-label { display: flex !important; grid-template-columns: none; align-items: center; gap: 12px !important; min-height: 52px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--green-soft); color: var(--ink) !important; }
.check-label input { width: 22px !important; min-height: 22px !important; flex: 0 0 22px; }
.hidden { display: none !important; }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { appearance: none; -webkit-appearance: none; margin: 0; }
.edit-form textarea { resize: vertical; }
.edit-form .wide { grid-column: 1 / -1; }
.updated-note { padding: 11px 13px; border-radius: 12px; background: var(--green-soft); color: var(--green); font-size: .84rem; }
.master-tabs { margin-bottom: 18px; }
.tabs-only { padding-bottom: 0; }
.persistent-tabs { scroll-padding-inline: 4px; }
.master-list { display: grid; gap: 11px; }
.unit-management { display: grid; gap: 28px; }
.master-subsection { min-width: 0; }
.master-card { padding: 17px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.recipe-link { width: 100%; color: inherit; text-align: left; }
.master-card.compact { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.master-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.master-card h3 { margin: 3px 0 0; font-size: 1rem; }
.master-head > strong { color: var(--green); white-space: nowrap; }
.type-label { color: var(--muted); font-size: .68rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.master-meta { display: flex; flex-wrap: wrap; gap: 6px 13px; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.manage-cta { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px; border: 0; border-radius: 18px; background: var(--green); color: white; text-align: left; }
.manage-cta span, .manage-cta small { display: block; }
.manage-cta small { margin-top: 4px; color: #c9d8d1; }
.recipe-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.component-list { display: grid; gap: 9px; }
.component { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.component h3 { margin: 3px 0 0; font-size: .96rem; }
.component > strong { white-space: nowrap; }
.notes-card { margin-top: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.notes-card p { margin: 7px 0 0; }
.add-button { width: 100%; min-height: 48px; margin: 0 0 14px; border: 1px dashed var(--green); border-radius: 14px; background: var(--green-soft); color: var(--green); font-weight: 850; }
.danger-button { min-height: 47px; border: 1px solid #e3b4ae; border-radius: 14px; background: #fff2f0; color: var(--danger); font-weight: 800; }
.recipe-editor { display: grid; gap: 20px; }
.recipe-base { align-self: start; }
.recipe-item-list { display: grid; gap: 9px; }
.recipe-item-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 105px; gap: 9px; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.recipe-item-name { grid-column: 1 / -1; }
.recipe-item-name h3 { margin: 3px 0; font-size: .95rem; }
.recipe-item-name small { color: var(--muted); }
.recipe-item-row input, .recipe-item-row select, .recipe-add input, .recipe-add select { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.row-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-actions button { border: 0; border-radius: 10px; background: var(--green-soft); color: var(--green); font-weight: 800; }
.row-actions .delete-small { background: #fff2f0; color: var(--danger); }
.recipe-add { display: grid; grid-template-columns: 1fr 100px 110px; gap: 9px; margin-top: 14px; padding: 13px; border-radius: 16px; background: #e8f0f7; }
.recipe-add > select:first-child, .recipe-add .primary { grid-column: 1 / -1; }
.event-editor { display: grid; gap: 22px; }
.event-tabs { margin-bottom: 18px; }
.analysis-list { display: grid; gap: 11px; }
.analysis-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 13px; align-items: end; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.analysis-row h3 { margin: 0 0 5px; font-size: 1rem; }
.analysis-row label { display: grid; gap: 6px; color: var(--muted); font-size: .78rem; font-weight: 800; }
.analysis-row input, .analysis-row textarea { width: 100%; min-height: 44px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--ink); }
.analysis-row textarea { resize: vertical; }
.analysis-row .difference { display: flex; align-items: baseline; gap: 8px; color: var(--muted); }
.analysis-row .difference small { margin-right: auto; }
.analysis-row .difference b { color: var(--ink); }
.analysis-row .comment { grid-column: 1 / -1; }
.analysis-save { min-height: 50px; }
.event-position-list { display: grid; gap: 9px; }
.event-position { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.event-position h3 { grid-column: 1 / -1; margin: 0; font-size: 1rem; }
.event-position label { display: grid; gap: 5px; color: var(--muted); font-size: .78rem; font-weight: 800; }
.event-position input { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; }
.event-position .row-actions { grid-column: 1 / -1; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: var(--green); }
.login-card { width: min(100%, 410px); padding: 28px; border-radius: 26px; background: var(--surface); box-shadow: 0 24px 70px rgba(0,0,0,.2); }
.login-mark { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; background: var(--lime); font-size: 1.6rem; }
.login h1 { margin: 18px 0 8px; }
.login p { color: var(--muted); margin: 0 0 24px; }
.login label { display: block; margin-bottom: 7px; font-weight: 750; }
.login input { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; }
.primary { width: 100%; border: 0; border-radius: 14px; margin-top: 12px; padding: 0 18px; background: var(--green); color: white; font-weight: 800; }
.form-error { min-height: 22px; margin-top: 10px; color: var(--danger); font-size: .9rem; }
.bottom-nav { position: fixed; z-index: 10; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 1080px); display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: rgba(255,253,248,.96); border-top: 1px solid var(--line); backdrop-filter: blur(14px); }
.nav-button { border: 0; background: transparent; color: var(--muted); border-radius: 13px; padding: 7px 4px; font-size: .76rem; font-weight: 750; }
.nav-button span { display: block; font-size: 1.15rem; margin-bottom: 2px; }
.nav-button.active { color: var(--green); background: var(--green-soft); }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 100px; transform: translate(-50%, 30px); padding: 11px 16px; border-radius: 13px; background: var(--ink); color: white; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 760px) {
  .topbar { margin: 18px 18px 0; border-radius: 28px; padding: 28px 30px; }
  .content { padding: 24px 30px; }
  .summary { grid-template-columns: repeat(4, 1fr); }
  .event-list { grid-template-columns: repeat(2, 1fr); }
  .item-list { grid-template-columns: repeat(2, 1fr); align-items: start; }
  .dish-list { grid-template-columns: repeat(2, 1fr); }
  .ingredient-list { grid-template-columns: repeat(2, 1fr); }
  .master-list { grid-template-columns: repeat(2, 1fr); }
  .recipe-editor { grid-template-columns: minmax(260px, .7fr) minmax(480px, 1.5fr); align-items: start; }
  .recipe-item-row { grid-template-columns: minmax(220px, 1fr) 105px 115px 190px; }
  .recipe-item-name, .row-actions { grid-column: auto; }
  .recipe-add { grid-template-columns: minmax(220px, 1fr) 105px 115px 150px; }
  .recipe-add > select:first-child, .recipe-add .primary { grid-column: auto; }
  .event-editor { grid-template-columns: minmax(260px, .65fr) minmax(500px, 1.5fr); align-items: start; }
  .event-position { grid-template-columns: minmax(200px, 1fr) 120px 130px 190px; align-items: end; }
  .event-position h3, .event-position .row-actions { grid-column: auto; }
  .analysis-row { grid-template-columns: minmax(210px, 1fr) 120px 190px minmax(230px, 1fr); align-items: center; }
  .analysis-row .comment { grid-column: auto; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: minmax(240px, 1fr) 2fr; align-items: center; }
  .shopping-filters { grid-template-columns: minmax(240px, .8fr) auto 1fr; }
}
@media print {
  body { background: white; }
  .topbar, .bottom-nav, .event-tabs, .toolbar, .print-shopping, .buyer-select { display: none !important; }
  .content { max-width: none; padding: 0; }
  .item-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .source-group { break-inside: avoid; border: 1px solid #999; box-shadow: none; }
  .source-group-head { background: white; color: black; border-bottom: 1px solid #999; }
  .item { break-inside: avoid; }
  .check { border: 1px solid var(--line); background: white; color: transparent; }
}
