:root {
  --cream: #fff9f5;
  --surface: #fffefd;
  --rose: #d8a09b;
  --terracotta: #b87975;
  --terracotta-dark: #935b58;
  --brown: #51443e;
  --muted: #786a64;
  --sand: #e8d7cf;
  --soft: #f7ebe7;
  --line: #eadbd5;
  --danger: #9b4545;
  --danger-soft: #fff0ef;
  --shadow: 0 14px 38px rgba(81, 68, 62, .09);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { color-scheme: light; background: var(--cream); }
body {
  margin: 0; min-height: 100vh; color: var(--brown); background:
    radial-gradient(circle at 92% 1%, rgba(216,160,155,.16), transparent 25rem), var(--cream);
  font-family: Inter, ui-rounded, "Nunito Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45; -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--terracotta-dark); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .35rem; font-size: clamp(1.85rem, 7vw, 2.55rem); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin-bottom: .35rem; line-height: 1.15; letter-spacing: -.02em; }

.topbar {
  min-height: 62px; padding: 9px max(12px, env(safe-area-inset-right)) 9px max(12px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-bottom: 1px solid rgba(232,215,207,.8); background: rgba(255,249,245,.98); position: sticky; top: 0; z-index: 20;
}
.brand { flex: 0 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--brown); text-decoration: none; line-height: 1; }
.brand-mark, .login-logo { display: grid; place-items: center; color: white; background: var(--terracotta); border-radius: 14px; font-weight: 900; }
.brand-mark { flex: 0 0 auto; width: 39px; height: 39px; font-size: 1.25rem; box-shadow: 0 6px 16px rgba(184,121,117,.22); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; }
.brand small { margin-top: 2px; color: var(--muted); font-size: .7rem; }
.top-actions { min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.user-identity { max-width: 30vw; overflow: hidden; padding: 6px 8px; border-radius: 999px; color: var(--brown); background: var(--soft); font-size: .74rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.logout-form { flex: 0 0 auto; }
.logout-button { min-height: 40px; padding: 7px 8px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: 0; border-radius: 11px; color: var(--terracotta-dark); background: transparent; font-size: .75rem; font-weight: 800; cursor: pointer; }
.logout-button:hover, .logout-button:focus-visible { background: var(--soft); }
.logout-icon, .nav-icon { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.app-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 6px max(10px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0;
  background: rgba(255,254,253,.97); box-shadow: 0 -8px 28px rgba(81,68,62,.13); backdrop-filter: blur(16px);
}
.app-nav a { min-height: 54px; padding: 7px 8px; display: flex; align-items: center; justify-content: center; gap: 7px; border-radius: 13px; color: var(--muted); font-size: .78rem; font-weight: 800; text-decoration: none; }
.app-nav a.active { color: var(--terracotta-dark); background: var(--soft); }
.app-nav a:focus-visible, .brand:focus-visible, .logout-button:focus-visible { outline: 3px solid rgba(184,121,117,.35); outline-offset: 2px; }

.page-shell { width: min(100%, 1060px); margin: 0 auto; padding: 28px 16px calc(122px + env(safe-area-inset-bottom)); }
.page-heading { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; margin-bottom: 25px; }
.page-heading .primary-button { width: 100%; }
.eyebrow { margin-bottom: 6px; color: var(--terracotta-dark); font-size: .72rem; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.muted, .helper, .modal-intro { color: var(--muted); }
.muted { margin-bottom: 0; }
.helper { margin: 8px 3px 18px; font-size: .8rem; }

.primary-button, .secondary-button, .quiet-button, .text-button, .danger-text-button, .danger-button, .icon-button, .row-menu-button {
  border: 0; cursor: pointer; font-weight: 760;
}
.primary-button, .secondary-button, .danger-button { min-height: 48px; padding: 11px 18px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.primary-button { color: white; background: var(--terracotta); box-shadow: 0 8px 20px rgba(184,121,117,.2); }
.primary-button:hover { background: var(--terracotta-dark); }
.secondary-button { color: var(--terracotta-dark); background: var(--soft); border: 1px solid #e6c8c3; }
.danger-button { color: white; background: var(--danger); }
.quiet-button, .text-button, .danger-text-button { padding: 9px 10px; background: transparent; }
.quiet-button { color: var(--muted); }
.text-button { color: var(--terracotta-dark); }
.danger-text-button { color: var(--danger); }
.full { width: 100%; }

input, select { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #d9c9c2; border-radius: 12px; color: var(--brown); background: white; outline: none; }
input:focus, select:focus { border-color: var(--terracotta); box-shadow: 0 0 0 3px rgba(184,121,117,.12); }
label { color: #655751; font-size: .79rem; font-weight: 750; }
label input, label select { margin-top: 6px; font-weight: 500; }

.recipe-grid { display: grid; gap: 12px; }
.recipe-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card-main { display: block; padding: 19px 19px 13px; color: inherit; text-decoration: none; }
.card-main h2 { margin: 12px 0 4px; font-size: 1.22rem; }
.card-main p { margin-bottom: 10px; color: var(--muted); }
.card-main small { color: var(--muted); }
.card-action { padding: 4px 9px 7px; display: flex; justify-content: flex-end; align-items: center; border-top: 1px solid #f2e7e2; }
.status-pill { display: inline-flex; padding: 5px 9px; border-radius: 999px; color: #7b5552; background: #f6dfdc; font-size: .7rem; font-weight: 800; }
.status-pill.ready { color: #6f4b48; background: var(--sand); }
.list-footer { padding: 26px 4px; text-align: center; font-size: .88rem; }

.empty-state { max-width: 540px; margin: 6vh auto; padding: 34px 22px; border: 1px dashed #d9c3bb; border-radius: 26px; text-align: center; background: rgba(255,255,255,.56); }
.empty-state.compact-empty { margin-top: 2vh; }
.empty-state p { color: var(--muted); margin-bottom: 20px; }
.empty-icon { display: block; margin-bottom: 10px; color: var(--rose); font-size: 2.4rem; }

.back-link { display: inline-flex; margin-bottom: 18px; color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 700; }
.recipe-header { margin-bottom: 18px; }
.recipe-title-form { display: flex; flex-direction: column; gap: 12px; }
.recipe-title-input { width: 100%; padding: 0; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--brown); background: transparent; box-shadow: none; font-size: clamp(1.72rem, 8vw, 2.55rem); font-weight: 850; letter-spacing: -.04em; }
.recipe-title-input:focus { border-color: var(--rose); box-shadow: none; }
.gentle-note { margin: 12px 0 0; color: var(--muted); font-size: .86rem; }

.work-panel { padding: 20px 14px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,254,253,.88); box-shadow: var(--shadow); }
.supplies-panel { display: grid; gap: 18px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 2px; }
.panel-title { margin: 0; font-size: 1.55rem; }
.count-badge { min-width: 32px; height: 32px; padding: 0 9px; display: grid; place-items: center; border-radius: 50%; color: var(--terracotta-dark); background: var(--soft); font-size: .82rem; font-weight: 800; }

.supply-picker { position: relative; }
.supply-picker > label { display: block; margin-bottom: 7px; }
.search-box { display: flex; align-items: center; gap: 7px; min-height: 48px; padding-left: 12px; border: 1px solid #d9c9c2; border-radius: 14px; background: white; }
.search-box:focus-within { border-color: var(--terracotta); box-shadow: 0 0 0 3px rgba(184,121,117,.11); }
.search-box > span { color: var(--muted); font-size: 1.4rem; transform: rotate(-15deg); }
.search-box input { min-height: 46px; padding-left: 0; border: 0; box-shadow: none; background: transparent; }
.search-box input:focus { box-shadow: none; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 15; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: white; box-shadow: 0 14px 35px rgba(81,68,62,.16); }
.search-result { width: 100%; min-height: 54px; padding: 9px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 0; border-bottom: 1px solid #f1e5e0; color: var(--brown); background: white; text-align: left; cursor: pointer; }
.search-result:last-child { border-bottom: 0; }
.search-result:hover, .search-result:focus { background: var(--soft); }
.search-result span, .search-result small { display: block; }
.search-result small { color: var(--muted); }
.search-result.create-result { color: var(--terracotta-dark); font-weight: 800; }

.supply-list, .catalog-table { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.supply-table-head, .catalog-table-head { display: none; }
.supply-row { padding: 12px; display: grid; grid-template-columns: minmax(0,1fr) auto 34px; grid-template-areas: "name cost menu" "quantity price price"; gap: 8px 9px; align-items: center; border-bottom: 1px solid #efe3de; }
.supply-row:last-of-type { border-bottom: 0; }
.supply-name-cell { grid-area: name; min-width: 0; }
.supply-name-cell strong, .supply-name-cell small { display: block; overflow: hidden; text-overflow: ellipsis; }
.supply-name-cell strong { white-space: nowrap; }
.supply-name-cell small { margin-top: 2px; color: var(--muted); font-size: .68rem; }
.editable-value { min-height: 38px; padding: 7px 9px; border: 0; border-radius: 10px; color: var(--terracotta-dark); background: #f8efec; font-size: .78rem; font-weight: 820; text-align: center; cursor: pointer; }
.editable-value:hover, .editable-value:focus { background: #f2dedb; }
.editable-value.missing { color: var(--terracotta-dark); border: 1px dashed var(--rose); background: transparent; }
.supply-row > [data-quantity-label] { grid-area: quantity; }
.supply-row > [data-price-label] { grid-area: price; }
.row-cost { grid-area: cost; text-align: right; }
.row-cost strong { display: block; color: var(--brown); font-size: .94rem; }
.row-cost em { display: block; max-width: 95px; color: var(--danger); font-size: .61rem; font-style: normal; font-weight: 750; }
.mobile-cell-label { display: block; margin-bottom: 1px; color: var(--muted); font-size: .6rem; font-weight: 650; text-transform: uppercase; }
.row-menu-button { grid-area: menu; width: 34px; height: 34px; padding: 0; border-radius: 50%; color: var(--muted); background: transparent; font-size: 1rem; }
.row-menu-button:hover { color: var(--danger); background: var(--danger-soft); }
.inline-empty { margin: 0; padding: 20px 8px; color: var(--muted); text-align: center; font-size: .86rem; }

.packaging-section { margin-top: 2px; border-top: 1px solid var(--line); }
.packaging-section > summary { min-height: 70px; padding: 14px 3px 2px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--terracotta-dark); list-style: none; cursor: pointer; }
.packaging-section > summary::-webkit-details-marker, .create-supply > summary::-webkit-details-marker { display: none; }
.packaging-section > summary strong, .packaging-section > summary small { display: block; }
.packaging-section > summary small { margin-top: 3px; color: var(--muted); font-size: .73rem; font-weight: 500; }
.packaging-content { display: grid; gap: 17px; padding-top: 14px; }

.cost-summary { margin-top: 17px; padding: 21px 17px; border-radius: 23px; color: var(--cream); background: var(--brown); box-shadow: 0 15px 36px rgba(81,68,62,.18); }
.cost-summary .eyebrow { color: #e9b9b5; }
.summary-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.summary-heading h2 { margin: 0; font-size: 1.18rem; }
.total-highlight { flex: 0 0 auto; font-size: 1.4rem; }
.cost-lines { margin: 17px 0; }
.cost-lines div { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.13); }
.cost-lines dt, .cost-lines dd { margin: 0; }
.cost-lines dt { color: rgba(255,249,245,.76); }
.cost-lines dd { font-weight: 800; }
.pending-note { margin: 14px 0; padding: 11px 12px; border-radius: 13px; color: #654744; background: #f2d8d5; }
.pending-note p { margin: 3px 0 0; font-size: .79rem; }
.sale-form { margin-top: 18px; }
.sale-form > label { display: block; margin-bottom: 7px; color: var(--cream); }
.money-input { display: flex; align-items: center; border-radius: 13px; color: var(--brown); background: white; }
.money-input span { padding-left: 13px; font-weight: 850; }
.money-input input { border: 0; box-shadow: none; }
.profit-box { margin-top: 16px; padding-top: 16px; display: grid; gap: 10px; border-top: 1px solid rgba(255,255,255,.17); }
.profit-box > div { display: flex; justify-content: space-between; gap: 13px; }
.profit-box span { color: rgba(255,249,245,.76); }
.profit-box strong { text-align: right; }
.profit-box small { color: rgba(255,249,245,.59); line-height: 1.35; }
.profit-box.muted-result strong { color: #ecc2be; font-size: .83rem; }
.recipe-danger-zone { padding: 22px 3px 0; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 4px; }

.catalog-heading { margin-bottom: 17px; }
.catalog-tools { display: grid; gap: 9px; margin-bottom: 16px; }
.catalog-search { width: 100%; }
.create-supply { position: relative; }
.create-supply > summary { width: 100%; list-style: none; cursor: pointer; }
.create-supply[open] > summary { margin-bottom: 8px; }
.inline-form, .modal-fields { display: grid; grid-template-columns: 1fr; gap: 10px; }
.inline-form { padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: var(--shadow); }
.wide-field { grid-column: 1 / -1; }
.catalog-table-head { grid-template-columns: minmax(0,1fr) 175px 90px 42px; }
.catalog-row { min-height: 64px; padding: 10px 11px; display: grid; grid-template-columns: minmax(0,1fr) auto 34px; grid-template-areas: "name usage menu" "price price price"; gap: 7px 10px; align-items: center; border-bottom: 1px solid #efe3de; }
.catalog-row:last-of-type { border-bottom: 0; }
.catalog-name-button { grid-area: name; min-width: 0; padding: 0; border: 0; color: var(--brown); background: transparent; text-align: left; cursor: pointer; }
.catalog-name-button strong, .catalog-name-button small { display: block; overflow: hidden; text-overflow: ellipsis; }
.catalog-name-button strong { white-space: nowrap; }
.catalog-name-button small { margin-top: 2px; color: var(--muted); font-size: .68rem; }
.catalog-row .catalog-price { grid-area: price; }
.archived-value { padding: 6px 2px; color: var(--muted); font-size: .8rem; }
.recipe-usage { grid-area: usage; text-align: right; font-weight: 800; }
.catalog-row .row-menu-button { grid-area: menu; }

.app-modal { width: min(92vw, 520px); max-height: min(88dvh, 720px); padding: 0; overflow: auto; border: 0; border-radius: 22px; color: var(--brown); background: var(--surface); box-shadow: 0 24px 80px rgba(81,68,62,.28); }
.app-modal::backdrop { background: rgba(55,43,39,.48); backdrop-filter: blur(3px); }
.modal-form { padding: 20px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.modal-header h2 { margin: 0; font-size: 1.35rem; }
.modal-header .eyebrow { margin-bottom: 4px; }
.modal-close { flex: 0 0 auto; width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--muted); background: var(--soft); font-size: 1.35rem; cursor: pointer; }
.modal-intro { margin: -5px 0 15px; font-size: .86rem; }
.shared-hint { margin: 11px 0 0; color: var(--muted); font-size: .76rem; }
.modal-actions { margin-top: 18px; display: flex; justify-content: flex-end; align-items: center; gap: 7px; }
.modal-error { margin: 14px 0 0; padding: 10px 11px; border-radius: 11px; color: var(--danger); background: var(--danger-soft); font-size: .82rem; }
.manage-actions { display: grid; gap: 9px; }
.manage-actions button { width: 100%; }
body.modal-open { overflow: hidden; }

.save-toast { position: fixed; right: 15px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 60; max-width: calc(100% - 30px); padding: 9px 13px; border-radius: 999px; color: white; background: var(--brown); box-shadow: 0 8px 30px rgba(55,43,39,.23); font-size: .8rem; font-weight: 750; }
.save-toast.success { background: var(--terracotta-dark); }
.save-toast.pending { background: #8b6863; }
.save-toast.error { background: var(--danger); border-radius: 13px; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 21px; }
.login-card { width: min(100%, 410px); padding: 29px 23px; border: 1px solid var(--line); border-radius: 27px; background: rgba(255,254,253,.92); box-shadow: var(--shadow); }
.admin-create-card { margin: 0 auto; }
.login-logo { width: 58px; height: 58px; margin-bottom: 20px; font-size: 1.8rem; }
.stack-form { display: grid; gap: 14px; margin-top: 22px; }
.form-message { padding: 10px 12px; border-radius: 11px; color: var(--danger); background: var(--danger-soft); font-size: .86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (min-width: 760px) {
  .topbar { min-height: 70px; padding: 11px max(17px, env(safe-area-inset-right)) 11px max(17px, env(safe-area-inset-left)); background: rgba(255,249,245,.9); backdrop-filter: blur(16px); }
  .brand { gap: 10px; }
  .brand-mark { width: 42px; height: 42px; font-size: 1.35rem; }
  .brand strong { font-size: 1.05rem; }
  .brand small { margin-top: 3px; font-size: .74rem; }
  .top-actions { gap: 8px; }
  .user-identity { max-width: 180px; padding: 7px 10px; font-size: .78rem; }
  .logout-button { padding: 8px 10px; font-size: .8rem; }
  .page-shell { padding: 46px 28px 68px; }
  .page-heading { flex-direction: row; justify-content: space-between; align-items: end; }
  .page-heading .primary-button { width: auto; }
  .app-nav { position: static; display: flex; padding: 4px; border: 0; border-radius: 16px; box-shadow: none; background: var(--soft); }
  .app-nav a { min-height: 38px; padding: 7px 12px; }
  .recipe-grid { grid-template-columns: repeat(2, 1fr); }
  .work-panel { padding: 26px; }
  .supply-picker { max-width: 540px; }
  .supply-table-head { min-height: 38px; padding: 0 12px; display: grid; grid-template-columns: minmax(0,1fr) 130px 170px 110px 36px; gap: 10px; align-items: center; color: var(--muted); background: #faf3f0; font-size: .68rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
  .supply-row { min-height: 58px; padding: 8px 12px; grid-template-columns: minmax(0,1fr) 130px 170px 110px 36px; grid-template-areas: "name quantity price cost menu"; gap: 10px; }
  .supply-name-cell small { display: none; }
  .mobile-cell-label { display: none; }
  .editable-value { width: 100%; min-height: 36px; }
  .row-cost { text-align: right; }
  .cost-summary { padding: 27px 29px; }
  .catalog-tools { grid-template-columns: 1fr auto; align-items: start; }
  .create-supply > summary { width: auto; }
  .create-supply .inline-form { position: absolute; right: 0; z-index: 10; width: 430px; grid-template-columns: 1fr 1fr; }
  .catalog-table-head { min-height: 38px; padding: 0 11px; display: grid; align-items: center; gap: 10px; color: var(--muted); background: #faf3f0; font-size: .68rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
  .catalog-row { min-height: 58px; padding: 7px 11px; grid-template-columns: minmax(0,1fr) 175px 90px 42px; grid-template-areas: "name price usage menu"; gap: 10px; }
  .catalog-row .catalog-price { width: 100%; }
  .recipe-usage { text-align: center; }
  .modal-fields.two-fields { grid-template-columns: 1fr 1fr; }
  .save-toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
}

@media (max-width: 359px) {
  .topbar { padding-left: 8px; padding-right: 8px; }
  .brand { gap: 6px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand small { display: none; }
  .user-identity { max-width: 25vw; padding-left: 6px; padding-right: 6px; }
  .logout-button { padding-left: 6px; padding-right: 6px; }
}

@media (max-width: 759px) {
  input, select, button { scroll-margin-bottom: calc(92px + env(safe-area-inset-bottom)); }
}

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