@font-face { font-family: 'Noto Sans Lao'; src: url('/static/fonts/NotoSansLao-Regular.ttf'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Noto Sans Lao'; src: url('/static/fonts/NotoSansLao-Bold.ttf'); font-weight: 700; font-display: swap; }

:root {
  --bg: #FAFAF9; --card: #FFFFFF; --ink: #1C1917; --ink2: #44403C; --muted: #57534E; --soft: #78716C;
  --line: #E7E5E4; --line2: #F0EFED; --field: #D6D3D1; --hover: #F5F5F4;
  --ok: #166534; --okbg: #F0FDF4; --warn: #9A3412; --warnbg: #FFF7ED; --warnline: #FED7AA; --bad: #B91C1C;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Lao', sans-serif; font-variant-numeric: tabular-nums; -webkit-text-size-adjust: 100%; }
html:lang(lo) body { font-family: 'Noto Sans Lao', system-ui, sans-serif; }
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 16px; font-weight: 700; }
p { margin: 0; }
a { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); } .sm { font-size: 13px; } small { font-size: 12px; } .big2 { font-size: 17px; }
.num { text-align: right; white-space: nowrap; } .grow { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; white-space: nowrap; }
.r { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 14px; } .sm-gap { gap: 8px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.inl { display: inline-flex; align-items: center; gap: 8px; }
.ok-t { color: var(--ok); } .warn-t { color: var(--warn); } .danger-t { color: var(--bad) !important; }

/* page */
#page { max-width: 640px; margin: 0 auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 16px; }
#page.has-tabs { padding-bottom: 150px; } #page.has-foot { padding-bottom: 110px; }
#page.login { min-height: 100vh; justify-content: center; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.head > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.bar { display: flex; align-items: center; gap: 6px; margin: -20px -16px 0; padding: 6px 10px; min-height: 56px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar-t { flex: 1; font-size: 17px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.list.pad { padding: 16px; }
.lhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.lrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line2); text-decoration: none; color: var(--ink); min-height: 60px; }
a.lrow:hover { background: var(--hover); }
.lrow b, .right b { font-size: 15px; font-weight: 600; }
.empty { padding: 18px 14px; color: var(--muted); font-size: 14px; }
.link { font-size: 12px; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--field); background: var(--card); font-weight: 600; text-decoration: none; color: var(--ink); cursor: pointer; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #FFF; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #FFF; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #FFF; min-height: 40px; font-size: 14px; }
.btn.ghost { background: var(--card); }
.btn.dashed { border: 1px dashed #A8A29E; margin: 4px 14px 14px; width: calc(100% - 28px); }
.list.pad .btn.dashed, fieldset .btn.dashed { margin: 4px 0 0; width: 100%; }
.btn.big { min-height: 52px; font-size: 16px; width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; background: transparent; border-radius: 10px; color: var(--ink); cursor: pointer; }
.iconbtn:hover { background: var(--hover); } .iconbtn.sm { width: 36px; height: 36px; color: var(--soft); } .iconbtn:disabled { opacity: 0.3; }
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink2); border: 0; padding: 0; margin: 0; min-width: 0; }
.fld legend { padding: 0; margin-bottom: 6px; }
.fld.sub { font-weight: 400; color: var(--muted); font-size: 12px; }
.fld small { font-weight: 400; }
input, select, textarea { min-height: 46px; padding: 0 12px; border: 1px solid var(--field); border-radius: 12px; background: #FFF; font-size: 16px; font-weight: 400; width: 100%; min-width: 0; }
textarea { padding: 10px 12px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.w64 { width: 64px; text-align: center; } .w96 { width: 110px; }
.bigin { font-size: 20px; font-weight: 600; min-height: 52px; }
.search { display: flex; align-items: center; gap: 8px; padding-left: 12px; background: #FFF; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); }
.search input { border: 0; padding-left: 0; } .search input:focus-visible { outline: 0; } .search:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.chips, .langs { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: #FFF; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #FFF; font-weight: 600; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--hover); color: var(--ink2); white-space: nowrap; }
.pill.ok { background: var(--okbg); color: var(--ok); } .pill.warn { background: var(--warnbg); color: var(--warn); }
.alert { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--warnbg); border: 1px solid var(--warnline); border-radius: 14px; color: var(--warn); font-size: 13px; }
.kv { font-size: 22px; font-weight: 700; } .kv.xl { font-size: 28px; } .kv.xxl { font-size: 34px; letter-spacing: -0.02em; }

/* bottom tabs + fixed footer */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); height: calc(68px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #FFF; border-top: 1px solid var(--line); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; color: var(--soft); text-decoration: none; }
.tab.on { color: var(--ink); font-weight: 700; }
.fab { position: fixed; right: max(16px, calc(50% - 304px)); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 6; display: inline-flex; align-items: center; gap: 8px; min-height: 50px; padding: 0 18px; border-radius: 14px; background: var(--ink); color: #FFF; text-decoration: none; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,0.18); }
.foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 12px max(16px, calc(50% - 304px)) calc(16px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.foot.two { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; } .foot .full { grid-column: 1 / -1; }

/* recipe lines */
.lgrid { display: grid; grid-template-columns: minmax(0, 1fr) 112px 68px 36px; gap: 8px; align-items: center; padding: 8px 6px 8px 14px; }
.lgrid.lhead { padding-top: 10px; padding-bottom: 6px; }
.lrow2 { border-top: 1px solid var(--line2); }
.nm { display: flex; flex-direction: column; min-width: 0; } .nm b { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.qty { display: flex; align-items: center; gap: 4px; } .qty input { min-height: 40px; padding: 0 8px; text-align: right; } .qty small { width: 26px; color: var(--muted); }
.makes { padding: 0 2px; }
.split { display: flex; gap: 2px; height: 10px; border-radius: 999px; overflow: hidden; background: var(--line2); } .split i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid rgba(0,0,0,0.08); }

/* price */
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 4px; background: var(--line2); border-radius: 12px; }
.seg button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--ink2); cursor: pointer; }
.seg button.on { background: #FFF; color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.lbl { font-size: 13px; font-weight: 600; color: var(--ink2); }
.pchips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.pchip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #FFF; cursor: pointer; font-size: 16px; }
.pchip small { color: var(--muted); font-size: 11px; }
.pchip.on { border: 2px solid var(--ink); }
.pchip.other { border-style: dashed; border-color: #A8A29E; } .pchip.other.on { border: 2px solid var(--ink); }
.pchip.other input { min-height: 30px; padding: 0 4px; border: 0; text-align: center; font-size: 15px; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #FFF; }
.stat small { color: var(--muted); font-size: 11px; } .stat b { font-size: 16px; }
.stat.good { background: var(--okbg); border-color: var(--okbg); } .stat.good small, .stat.good b { color: var(--ok); }
.stat.bad b { color: var(--bad); } .stat.warnbox { background: var(--warnbg); border-color: var(--warnline); } .stat.warnbox b { color: var(--warn); }

/* settings */
.catrow { display: grid; grid-template-columns: minmax(0, 1fr) auto 36px; gap: 8px; align-items: center; font-weight: 400; }

/* dialog, toast, loading */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(440px, calc(100% - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
dialog::backdrop { background: rgba(28,25,23,0.45); }
.dlg { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; }
.pick { max-height: min(80vh, 640px); }
.plist { overflow-y: auto; min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; margin: 0 -18px -18px; border-top: 1px solid var(--line2); }
.prow { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 56px; padding: 8px 18px; border: 0; border-bottom: 1px solid var(--line2); background: #FFF; text-align: left; cursor: pointer; }
.prow span:first-child { display: flex; flex-direction: column; } .prow:hover { background: var(--hover); }
.toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: var(--ink); color: #FFF; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
.toast.bad { background: var(--bad); }
body.loading::after { content: ''; position: fixed; left: 0; top: 0; height: 3px; width: 100%; background: linear-gradient(90deg, transparent, var(--ink), transparent); animation: ld 1s linear infinite; z-index: 60; }
@keyframes ld { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { body.loading::after { animation: none; } }
