:root{
  --paper:#EDE6D6; --card:#FFFDF7; --ink:#26261F; --muted:#8C8570;
  --green:#4C7A3D; --green-dark:#365828; --red:#A63A2E; --line:#D9D0BC;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;}
html,body{margin:0;padding:0;}
body{
  background:var(--paper);
  background-image: radial-gradient(circle at 1px 1px, rgba(38,38,31,0.05) 1px, transparent 0);
  background-size:14px 14px;
  color:var(--ink); font-family:'Inter',sans-serif; min-height:100vh;
  display:flex; justify-content:center; padding-bottom:84px;
}
#app{ width:100%; max-width:480px; min-height:100vh; position:relative; }
header.top{ padding:28px 20px 18px; position:sticky; top:0; z-index:5; background:var(--paper); border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:flex-start; gap:10px;}
header.top h1{ font-family:'Fraunces',serif; font-weight:700; font-size:28px; margin:0; letter-spacing:-0.01em; }
header.top .sub{ font-size:12.5px; color:var(--muted); margin-top:4px; text-transform:uppercase; letter-spacing:.08em; }
.status-pill{ font-size:10.5px; font-weight:700; padding:5px 9px; border-radius:20px; text-transform:uppercase; letter-spacing:.04em; white-space:nowrap; margin-top:4px;}
.status-pill.online{ background:rgba(76,122,61,0.15); color:var(--green-dark); }
.status-pill.offline{ background:rgba(166,58,46,0.15); color:var(--red); }
main{ padding:18px 16px 20px; }
section.view{ display:none; }
section.view.active{ display:block; animation:fadeIn .25s ease; }
@keyframes fadeIn{ from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:translateY(0);} }

nav.tabbar{ position:fixed; bottom:0; left:50%; transform:translateX(-50%); width:100%; max-width:480px; background:var(--ink); display:flex; z-index:20; padding:8px 10px calc(8px + env(safe-area-inset-bottom)); gap:6px; }
nav.tabbar button{ flex:1; background:transparent; border:none; color:#B8B29E; font-size:11px; font-weight:600; letter-spacing:.03em; padding:8px 4px 6px; border-radius:10px; display:flex; flex-direction:column; align-items:center; gap:4px; cursor:pointer; position:relative; }
nav.tabbar button.active{ color:#FFFDF7; background:rgba(255,255,255,0.08); }
nav.tabbar svg{ width:20px; height:20px; }
.tab-badge{ position:absolute; top:2px; right:calc(50% - 22px); min-width:17px; height:17px; padding:0 4px; border-radius:9px; background:var(--red); color:#fff; font-size:10px; font-weight:700; display:flex; align-items:center; justify-content:center; line-height:1; }

.card{ background:var(--card); border:1px solid var(--line); border-radius:14px; padding:16px; margin-bottom:14px; }
h2.section-title{ font-family:'Fraunces',serif; font-weight:600; font-size:19px; margin:0 0 12px; }
.btn{ display:inline-flex; align-items:center; justify-content:center; gap:8px; font-weight:600; font-size:14.5px; padding:13px 16px; border-radius:10px; border:none; cursor:pointer; width:100%; }
.btn:active{ transform:scale(0.98); }
.btn-primary{ background:var(--green); color:#fff; }
.btn-outline{ background:transparent; color:var(--ink); border:1.5px solid var(--line); }
.btn-danger{ background:transparent; color:var(--red); border:1.5px solid rgba(166,58,46,0.35); }
.btn-row{ display:flex; gap:10px; }
.btn-row .btn{ width:auto; flex:1; }
.btn:disabled{ opacity:.5; }

.segmented{ display:flex; background:var(--paper); border:1px solid var(--line); border-radius:10px; padding:3px; margin-bottom:16px; }
.segmented button{ flex:1; border:none; background:transparent; padding:9px 8px; border-radius:8px; font-weight:600; font-size:13px; color:var(--muted); cursor:pointer; }
.segmented button.active{ background:var(--card); color:var(--ink); box-shadow:0 1px 2px rgba(0,0,0,0.08); }

textarea{ width:100%; min-height:130px; border:1.5px solid var(--line); border-radius:10px; padding:12px; font-size:14.5px; resize:vertical; background:var(--card); color:var(--ink); font-family:inherit;}
input[type=text], input[type=number], input[type=password]{ border:1.5px solid var(--line); border-radius:8px; padding:9px 10px; font-size:14px; background:var(--card); color:var(--ink); font-family:inherit;}
label.field-label{ font-size:12px; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; display:block; margin:0 0 6px; }
.hint{ font-size:12.5px; color:var(--muted); line-height:1.5; margin-top:8px; }
input[type=file]{ display:none; }

.spinner{ width:16px; height:16px; border-radius:50%; border:2.5px solid rgba(255,255,255,0.4); border-top-color:#fff; animation:spin .7s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg);} }

.empty{ text-align:center; padding:36px 12px; color:var(--muted); }
.empty svg{ width:44px; height:44px; opacity:.5; margin-bottom:10px; }
.empty .big{ font-family:'Fraunces',serif; font-size:17px; color:var(--ink); margin-bottom:4px; }

table.review{ width:100%; border-collapse:collapse; }
table.review th{ text-align:left; font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; padding:0 4px 6px; }
table.review td{ padding:5px 3px; vertical-align:middle; }
table.review input{ width:100%; padding:7px 8px; font-size:13.5px; }
table.review td.qty{ width:62px; } table.review td.unit{ width:92px; } table.review td.del{ width:30px; text-align:center; }
.row-del{ background:none; border:none; color:var(--red); font-size:18px; cursor:pointer; line-height:1; padding:4px; }

.recipe-item{ display:flex; align-items:center; gap:12px; padding:13px 4px; border-bottom:1px solid var(--line); }
.recipe-item:last-child{ border-bottom:none; }
.toggle{ width:42px; height:25px; border-radius:20px; background:var(--line); position:relative; flex:none; cursor:pointer; border:none; }
.toggle.on{ background:var(--green); }
.toggle.loading{ opacity:.5; }
.toggle .knob{ position:absolute; top:2.5px; left:3px; width:20px; height:20px; border-radius:50%; background:#fff; transition:left .15s; box-shadow:0 1px 3px rgba(0,0,0,0.25); }
.toggle.on .knob{ left:19px; }
.recipe-info{ flex:1; min-width:0; }
.recipe-info .name{ font-family:'Fraunces',serif; font-weight:600; font-size:15.5px; }
.recipe-info .meta{ font-size:11.5px; color:var(--muted); margin-top:1px; }
.recipe-del{ background:none; border:none; color:var(--muted); cursor:pointer; padding:6px; }
.recipe-del svg{ width:17px; height:17px; }
.recipe-edit{ background:none; border:none; color:var(--muted); cursor:pointer; padding:6px; }
.recipe-edit svg{ width:17px; height:17px; }
.recipe-block{ border-bottom:1px solid var(--line); }
.recipe-block:last-child{ border-bottom:none; }
.recipe-block .recipe-item{ border-bottom:none; }
.recipe-info.expandable{ cursor:pointer; }
.recipe-info .chevron{ color:var(--muted); font-size:11px; }
.ingredient-detail{ padding:0 4px 14px 54px; }
.ingredient-row{ display:flex; justify-content:space-between; gap:10px; padding:5px 0; font-size:13.5px; border-bottom:1px dashed var(--line); }
.ingredient-row:last-child{ border-bottom:none; }
.ingredient-row .ing-name{ text-transform:capitalize; }
.ingredient-row .ing-note{ color:var(--muted); text-transform:none; font-size:12px; }
.ingredient-row .ing-qty{ font-family:'JetBrains Mono',monospace; color:var(--muted); white-space:nowrap; }

.ticket{ background:var(--card); border:1.5px dashed var(--line); border-radius:4px; padding:6px 4px; }
.category-header{ font-family:'Fraunces',serif; font-weight:600; font-size:12.5px; text-transform:uppercase; letter-spacing:.05em; color:var(--green-dark); padding:14px 12px 6px; }
.category-header:first-child{ padding-top:8px; }
.ticket-item{ display:flex; align-items:flex-start; gap:11px; padding:12px 12px; border-bottom:1px dashed var(--line); }
.ticket-item:last-child{ border-bottom:none; }
.ticket-item.resolved{ opacity:.55; }
.ticket-item.resolved .iname{ text-decoration:line-through; color:var(--muted); }
.owned-btn{ flex:none; width:26px; height:26px; border-radius:6px; border:1.5px solid var(--line); background:var(--card); color:var(--muted); display:flex; align-items:center; justify-content:center; cursor:pointer; padding:0; margin-top:-2px; }
.owned-btn svg{ width:14px; height:14px; }
.owned-btn.on{ background:rgba(76,122,61,0.15); border-color:var(--green); color:var(--green-dark); }
.edit-btn{ flex:none; width:26px; height:26px; border-radius:6px; border:none; background:transparent; color:var(--muted); display:flex; align-items:center; justify-content:center; cursor:pointer; padding:0; margin-top:-2px; }
.edit-btn svg{ width:14px; height:14px; }
.iqty-total{ color:var(--muted); font-weight:500; font-size:11.5px; }
.checkbox{ width:21px; height:21px; border-radius:5px; border:1.8px solid var(--muted); flex:none; margin-top:1px; display:flex; align-items:center; justify-content:center; cursor:pointer; background:var(--card); }
.checkbox.on{ background:var(--green); border-color:var(--green); }
.checkbox svg{ width:13px; height:13px; opacity:0; }
.checkbox.on svg{ opacity:1; }
.icontent{ flex:1; min-width:0; }
.iname{ font-size:14.5px; font-weight:500; text-transform:capitalize; }
.isources{ font-size:11px; color:var(--muted); margin-top:2px; }
.iqty{ font-family:'JetBrains Mono',monospace; font-size:13.5px; font-weight:700; white-space:nowrap; padding-top:1px; }
.iqty.approx{ color:var(--muted); font-weight:500; }

.stat-row{ display:flex; gap:10px; margin-bottom:14px; }
.stat{ flex:1; background:var(--card); border:1px solid var(--line); border-radius:12px; padding:12px 14px; }
.stat .n{ font-family:'Fraunces',serif; font-weight:700; font-size:22px; }
.stat .l{ font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; }

.toast{ position:fixed; bottom:96px; left:50%; transform:translateX(-50%) translateY(20px); background:var(--ink); color:#FFFDF7; padding:11px 18px; border-radius:10px; font-size:13.5px; opacity:0; transition:all .25s ease; z-index:50; max-width:88%; text-align:center; pointer-events:none; }
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
.toast.err{ background:var(--red); }

.login-wrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px; }
.login-card{ background:var(--card); border:1px solid var(--line); border-radius:16px; padding:28px 24px; width:100%; max-width:360px; }
.login-card h1{ font-family:'Fraunces',serif; font-size:24px; margin:0 0 6px; }
.login-card p{ color:var(--muted); font-size:13.5px; margin:0 0 18px; }
.login-card input{ width:100%; margin-bottom:14px; padding:12px; }
