:root { --green: #1f6f43; --bg: #f5f5f1; --card: #fff; --text: #1c1f1d; --muted: #6a716c; --line: #e3e5df; --red: #b3261e; }
@media (prefers-color-scheme: dark) {
  :root { --green: #58b884; --bg: #141614; --card: #1e211f; --text: #ecefec; --muted: #9aa39d; --line: #303430; --red: #f08a82; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text);
  max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 4px; padding-top: max(12px, env(safe-area-inset-top)); }
h1 { margin: 0; font-size: 1.3rem; white-space: nowrap; }
header span { display: flex; flex: none; }
header button.ghost { padding: 8px 6px; font-size: .9rem; white-space: nowrap; }
h2 { margin: 0; font-size: 1.1rem; }
button, .btn { font: inherit; border: 0; border-radius: 10px; padding: 10px 14px; background: var(--green); color: #fff; cursor: pointer; text-decoration: none; display: inline-block; font-weight: 600; }
@media (prefers-color-scheme: dark) { button, .btn { color: #10130f; } }
button.secondary { background: transparent; color: var(--green); box-shadow: inset 0 0 0 2px var(--green); }
button.ghost { background: transparent; color: var(--green); padding: 8px 10px; font-weight: 600; }
input:not([type=checkbox]) { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); width: 100%; min-width: 0; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--green); flex: none; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }

#addForm { display: flex; gap: 8px; padding: 8px 16px 12px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
#addForm button { flex: none; }
main { flex: 1; padding: 0 16px 16px; }
ul { list-style: none; margin: 0; padding: 0; }
#items li { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 8px 6px 8px 12px; margin-bottom: 8px; }
#items li.done { opacity: .5; }
#items li.done strong { text-decoration: line-through; }
.prod, .result { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: none; color: inherit; padding: 0; text-align: left; font-weight: 400; border-radius: 8px; }
.prod img, .result img, .noimg { width: 44px; height: 44px; flex: none; border-radius: 8px; object-fit: contain; background: #fff; }
.noimg { background: var(--line); }
.txt { min-width: 0; display: flex; flex-direction: column; flex: 1; }
.txt strong, .txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
small { color: var(--muted); font-size: .8rem; }
.pickme { color: var(--green); font-weight: 600; }
.right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.line { font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.qty { display: flex; align-items: center; gap: 2px; }
.qty b { min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.qty button { width: 32px; height: 32px; padding: 0; background: var(--line); color: var(--text); border-radius: 8px; }
.del { background: none; color: var(--muted); padding: 8px; font-size: 1.2rem; line-height: 1; }
#empty, .muted { color: var(--muted); }
#empty { text-align: center; margin-top: 40px; }

footer { position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
#summary { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-bottom: 8px; }
#summary:empty { display: none; }
#summary span { color: var(--muted); font-size: .85rem; }
.actions { display: flex; gap: 8px; }
.actions button { flex: 1; }

dialog { border: 0; padding: 0; background: var(--card); color: var(--text); width: 100%; max-width: 640px; max-height: 88dvh; margin: auto auto 0; border-radius: 16px 16px 0 0; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.sheet { padding: 12px 16px 24px; }
.sheetHead { display: flex; gap: 8px; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--card); padding: 4px 0 8px; z-index: 1; }
.row { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; font-size: .9rem; }
.result { width: 100%; padding: 8px 4px; border-bottom: 1px solid var(--line); border-radius: 0; }
.result.sel { box-shadow: inset 3px 0 0 var(--green); padding-left: 8px; }
.price { flex: none; text-align: right; display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.promo { color: var(--red); font-weight: 600; }
ol { padding-left: 20px; }
ol li { margin-bottom: 14px; }
.bm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.bmLink { border: 2px dashed var(--green); border-radius: 10px; padding: 8px 12px; color: var(--green); font-weight: 600; text-decoration: none; }
#icaDlg label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 12px; }
#icaDlg label input { margin-top: 4px; }
#icaItems li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
#icaItems a { flex: 1; color: var(--green); font-weight: 600; padding: 8px 0; }

#toast { position: fixed; left: 50%; bottom: 130px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 20px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; text-align: center; z-index: 10; }
#toast.show { opacity: 1; }
.prod .txt small:first-of-type { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* vanliga varor och orderimport */
h3 { font-size: 1rem; margin: 20px 0 4px; }
textarea { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); margin-bottom: 8px; }
details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
summary { font-weight: 600; color: var(--green); cursor: pointer; padding: 6px 0; }
#popularList li, #orderList li, #previewItems li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
#popularList .txt, #orderList span { flex: 1; min-width: 0; }
#popularList button { flex: none; width: 40px; height: 40px; padding: 0; font-size: 1.3rem; }
#popularList button.added { background: var(--line); color: var(--muted); }
#previewItems input[type=text] { flex: 1; }
#previewItems input[type=number] { width: 64px; flex: none; }
#orderPreview .row input { width: auto; }
#saveOrder { margin-top: 12px; width: 100%; }

/* konto och inloggning */
#app { display: flex; flex-direction: column; flex: 1; }
#app[hidden], #auth[hidden] { display: none; }
.avatar { width: 32px; height: 32px; padding: 0; border-radius: 50%; margin-left: 4px; font-size: .9rem; flex: none; align-self: center; }
#auth { padding: 15vh 24px 24px; display: flex; flex-direction: column; gap: 8px; }
#auth h1 { font-size: 1.8rem; }
#authForm { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
#authForm label { font-size: .9rem; color: var(--muted); }
#authForm label[hidden] { display: none; }
#authForm input { margin-top: 4px; }
.error { color: var(--red); margin: 0; }
#popularList img, #popularList .noimg { width: 40px; height: 40px; flex: none; border-radius: 8px; object-fit: contain; background: #fff; }
#popularList .noimg { background: var(--line); }
#authForm label[hidden], #auth button[hidden] { display: none; }
#authInfo { margin: 0; }
