/* Måltid · gemensamt designsystem */
@font-face { font-family: "MaltidSans"; font-weight: 400; font-display: swap; src: url(fonts/maltidsans-400.woff2) format("woff2"); }
@font-face { font-family: "MaltidSans"; font-weight: 600 700; font-display: swap; src: url(fonts/maltidsans-700.woff2) format("woff2"); }
@font-face { font-family: "MaltidSans"; font-weight: 800 900; font-display: swap; src: url(fonts/maltidsans-800.woff2) format("woff2"); }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --red: #E3000B; --red-600: #C40009; --red-50: #FDEDEE; --red-100: #FAD5D7;
  --ink: #16181D; --ink-2: #3C4048; --muted: #7B808A; --faint: #A9ADB4;
  --line: #E9E6E1; --line-2: #F1EFEB; --bg: #F6F4F0; --card: #FFFFFF; --sunk: #FAF9F7;
  --green: #138A4B; --green-50: #E8F5EE; --amber: #B86E00; --amber-50: #FFF4E0; --blue: #1F5FD6; --blue-50: #EAF1FE;
  --r-sm: 10px; --r: 14px; --r-lg: 20px; --r-xl: 28px;
  --sh-1: 0 1px 2px rgba(22,24,29,.05), 0 1px 1px rgba(22,24,29,.03);
  --sh-2: 0 2px 6px rgba(22,24,29,.05), 0 10px 30px -12px rgba(22,24,29,.18);
  --sh-3: 0 20px 60px -20px rgba(22,24,29,.35), 0 4px 14px rgba(22,24,29,.08);
  --head: "ICARubrik", "ICA Rubrik", "MaltidSans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: "ICAText", "ICA Text", "MaltidSans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2,.8,.2,1);
}
html { -webkit-text-size-adjust: 100%; }
body { font: 15px/1.5 var(--body); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }
:focus-visible { outline: 2.5px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, h4 { font-family: var(--head); font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hide { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Knappar ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 12px;
  font-weight: 650; font-size: 14.5px; white-space: nowrap; transition: transform .12s var(--ease), background .15s, box-shadow .15s, opacity .15s;
  background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line), var(--sh-1); }
.btn:hover { box-shadow: inset 0 0 0 1px #D9D5CE, var(--sh-1); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--red); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 6px 16px -6px rgba(227,0,11,.55); }
.btn.primary:hover { background: var(--red-600); }
.btn.dark { background: var(--ink); color: #fff; box-shadow: none; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover { background: rgba(22,24,29,.05); }
.btn.danger { color: var(--red); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn.xs { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.lg { height: 56px; padding: 0 26px; font-size: 17px; border-radius: 16px; }
.btn.icon { width: 42px; padding: 0; }
.btn.icon.sm { width: 34px; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ── Fält ── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 12.5px; font-weight: 650; color: var(--ink-2); letter-spacing: .01em; }
.hint { font-size: 12.5px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; height: 42px; padding: 0 13px; border-radius: 11px; border: 1px solid var(--line); background: var(--card);
  transition: border-color .15s, box-shadow .15s; outline: none; font-size: 14.5px; }
textarea.input { height: auto; min-height: 90px; padding: 10px 13px; line-height: 1.45; resize: vertical; }
.input:focus { border-color: #B9C8E8; box-shadow: 0 0 0 4px rgba(31,95,214,.12); }
.input.sm { height: 34px; font-size: 13.5px; border-radius: 9px; padding: 0 10px; }
select.input.sm { padding-right: 30px; background-position: right 10px center; }
.input::placeholder { color: var(--faint); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%237B808A' stroke-width='1.8'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.input-wrap > .input { padding-left: 40px; }
.addon { display: flex; } .addon .input { border-top-right-radius: 0; border-bottom-right-radius: 0; } .addon .unit { display: grid; place-items: center; padding: 0 11px; border: 1px solid var(--line); border-left: 0; border-radius: 0 11px 11px 0; background: var(--sunk); color: var(--muted); font-size: 13px; }

/* Brytare */
.switch { position: relative; width: 42px; height: 25px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #D8D5D0; transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(17px); }

/* Segmentväljare */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: #ECE9E4; border-radius: 12px; }
.seg button { height: 32px; padding: 0 13px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--sh-1); }

/* Kort, märken */
.card { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--sh-1), inset 0 0 0 1px rgba(22,24,29,.04); }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.badge.red { background: var(--red-50); color: var(--red-600); } .badge.green { background: var(--green-50); color: var(--green); }
.badge.amber { background: var(--amber-50); color: var(--amber); } .badge.blue { background: var(--blue-50); color: var(--blue); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: #18B25F; box-shadow: 0 0 0 3px rgba(24,178,95,.18); } .dot.off { background: #D9363E; box-shadow: 0 0 0 3px rgba(217,54,62,.15); }
.chip { height: 36px; padding: 0 15px; border-radius: 99px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; font-size: 14px; white-space: nowrap; color: var(--ink-2); transition: all .15s; }
.chip.on { background: var(--ink); color: #fff; box-shadow: none; }

/* Laddare */
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { background: linear-gradient(90deg, #EEEBE6 25%, #F6F4F0 50%, #EEEBE6 75%); background-size: 200% 100%; animation: skel 1.3s infinite; border-radius: 12px; }
@keyframes skel { to { background-position: -200% 0; } }

/* Toast */
.toasts { position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; pointer-events: none; width: min(92vw, 440px); }
.toast { pointer-events: auto; background: var(--ink); color: #fff; padding: 13px 16px; border-radius: 14px; box-shadow: var(--sh-3); font-weight: 550; display: flex; gap: 10px; align-items: center; animation: toastIn .3s var(--ease); }
.toast.err { background: #B5121B; } .toast.ok { background: #0E6E3B; }
.toast svg { width: 20px; height: 20px; flex: none; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* Modal / ark */
.scrim { position: fixed; inset: 0; background: rgba(22,24,29,.42); backdrop-filter: blur(2px); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--card); border-radius: var(--r-xl); box-shadow: var(--sh-3); width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .28s var(--ease); overflow: hidden; }
.modal.wide { width: min(980px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.modal-h { display: flex; align-items: center; gap: 12px; padding: 20px 22px 14px; }
.modal-h h2 { font-size: 20px; flex: 1; }
.modal-b { padding: 4px 22px 18px; overflow: auto; }
.modal-f { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line-2); background: var(--sunk); }

/* Tabeller */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--sunk); position: sticky; top: 0; z-index: 1; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr.click { cursor: pointer; } .table tr.click:hover td { background: #FBFAF8; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; color: var(--faint); margin-bottom: 10px; }
.empty h3 { color: var(--ink); font-size: 17px; margin-bottom: 4px; }

/* Etikettförhandsvisning */
.label-prev { display: flex; flex-direction: column; gap: 6px; }
.label-prev canvas { display: block; width: 100%; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 0 0 1px rgba(22,24,29,.08), 0 6px 18px -8px rgba(22,24,29,.25); image-rendering: auto; }
.label-prev .seg-lbl { font-size: 10.5px; color: var(--faint); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.warn { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--amber); background: var(--amber-50); padding: 9px 12px; border-radius: 10px; }
.warn svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }

/* Logga */
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--red); display: grid; place-items: center; box-shadow: 0 4px 10px -4px rgba(227,0,11,.6); flex: none; }
.logo svg { width: 20px; height: 20px; color: #fff; }
.brand { font-family: var(--head); font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
