:root {
  --bg: #f3f5f8; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #1e3a5f; --accent: #2563eb; --stop: #dc2626; --ok: #16a34a;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1220; --card: #141d2e; --ink: #e5e9f0; --muted: #8b98ad; --line: #24304a; --brand: #0f1a2c; }
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
.loading, .empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.empty.small { padding: .6rem; font-size: .9rem; }
.muted { color: var(--muted); }
.center { text-align: center; display: block; margin: .5rem auto; }

header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .5rem; padding: calc(var(--safe-t) + .5rem) .75rem .5rem; background: var(--brand); color: #fff; }
header.top h1 { flex: 1; margin: 0; font-size: 1.15rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { background: none; border: 0; color: inherit; font-size: 1.5rem; width: 2.5rem; height: 2.5rem; border-radius: 50%; cursor: pointer; }
.icon:disabled { opacity: .25; }
.icon-space { width: 2.5rem; }
main { padding: .75rem .75rem calc(6rem + var(--safe-b)); max-width: 640px; margin: 0 auto; }

nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
nav.tabs button { flex: 1; border: 0; background: none; padding: .45rem 0 .5rem; font-size: .7rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: .1rem; cursor: pointer; }
nav.tabs button span { font-size: 1.3rem; filter: grayscale(1); opacity: .7; }
nav.tabs button.on { color: var(--accent); font-weight: 600; }
nav.tabs button.on span { filter: none; opacity: 1; }

.card { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .9rem; margin-bottom: .75rem; }
.card h3 { margin: 0 0 .4rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: .6rem 1rem; cursor: pointer; text-decoration: none; font-weight: 500; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.stop { background: var(--stop); border-color: var(--stop); color: #fff; }
.btn.danger { color: var(--stop); background: none; }
.btn.big { width: 100%; padding: .85rem; font-size: 1.05rem; margin-top: .5rem; }
.btn:disabled { opacity: .6; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: .3rem; font-size: .95rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.row .btn { flex: 1; }

/* Timer */
.timer { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1rem; margin-bottom: .75rem; }
.timer-label { font-weight: 600; margin-bottom: .6rem; }
.timer.running { border: 2px solid var(--c); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 12%, var(--card)), var(--card)); }
.timer-top { display: flex; justify-content: space-between; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; }
.clock { font-size: 3rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; margin: .3rem 0 .5rem; letter-spacing: -.02em; }
.note { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: .65rem .8rem; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.qbtn { display: flex; align-items: center; gap: .5rem; text-align: left; border: 1px solid var(--line); border-left: 5px solid var(--c); background: var(--bg); border-radius: 10px; padding: .7rem .6rem; cursor: pointer; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.qbtn span { color: var(--c); font-size: .85rem; }

.weekbar { display: flex; align-items: center; justify-content: space-between; margin: .25rem 0 .5rem; }
.weekbar .icon { color: var(--accent); }
.weekbar div { text-align: center; }
.weekbar small { display: block; color: var(--muted); font-size: .8rem; }

.sum { text-align: center; }
.big-num { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.big-num small { font-size: 1rem; color: var(--muted); }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: .4rem 0 .2rem; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.bar i.over { background: var(--stop); }
.mini-days { display: flex; gap: .35rem; justify-content: center; margin-top: .7rem; height: 56px; }
.mini-days div { width: 26px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.mini-days i { display: block; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .8; }
.mini-days span { font-size: .7rem; color: var(--muted); }
.mini-days .now span { color: var(--accent); font-weight: 700; }

.day { margin-bottom: 1rem; }
.day h3 { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: .6rem .2rem .35rem; }
.day h3 span { font-variant-numeric: tabular-nums; }
.item { display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; margin-bottom: .4rem; cursor: pointer; }
.item.col { flex-direction: column; align-items: stretch; gap: .3rem; cursor: default; }
.rowline { display: flex; align-items: center; gap: .5rem; }
.item strong { display: block; }
.item small { display: block; color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; }
.grow { flex: 1; min-width: 0; }
.plain { background: none; border: 0; text-align: left; padding: 0; cursor: pointer; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.todo input[type=checkbox] { width: 1.3rem; height: 1.3rem; flex: none; accent-color: var(--ok); }
.todo.done span { text-decoration: line-through; color: var(--muted); }
.late { color: var(--stop) !important; font-weight: 600; }
.pre { white-space: pre-wrap; display: block; }
.rc { font-size: 1.3rem; }
.rc.off { color: var(--muted); width: 1.3rem; text-align: center; }
.hbar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.hbar i { display: block; height: 100%; }

.proj { display: flex; gap: .8rem; border-left: 5px solid var(--c); cursor: pointer; }
.proj.archived { opacity: .55; }
.proj small { display: block; color: var(--muted); font-size: .85rem; }
.nums { text-align: right; font-variant-numeric: tabular-nums; }
.nums span { display: block; font-weight: 700; font-size: 1.1rem; }
.nums .sub { font-weight: 400; font-size: .8rem; color: var(--muted); }
.phead { border-top: 5px solid var(--c); }
.pnote { white-space: pre-wrap; margin: .6rem 0 0; }
.stats, .stats4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: .5rem; margin: .6rem 0; text-align: center; }
.stats b, .stats4 b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stats small, .stats4 small { color: var(--muted); font-size: .75rem; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .2rem 0 .6rem; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .2rem; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .35rem .8rem; cursor: pointer; white-space: nowrap; font-size: .9rem; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.exports { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }

.fab { position: fixed; right: 1.1rem; bottom: calc(4.6rem + var(--safe-b)); z-index: 7; width: 3.6rem; height: 3.6rem; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 1.8rem; box-shadow: 0 6px 18px rgba(37, 99, 235, .4); cursor: pointer; }

/* Formulärbladet */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0); transition: background .2s; display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap.open { background: rgba(0, 0, 0, .45); }
.sheet { width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 18px 18px 0 0; padding: .5rem 1rem calc(1.2rem + var(--safe-b)); transform: translateY(100%); transition: transform .22s ease-out; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-head { display: grid; grid-template-columns: 5rem 1fr 5rem; align-items: center; position: sticky; top: -.5rem; background: var(--card); padding: .5rem 0; z-index: 1; }
.sheet-head h2 { margin: 0; font-size: 1.05rem; text-align: center; }
form label { display: block; font-size: .85rem; color: var(--muted); margin: .55rem 0 0; }
form input:not([type=checkbox]):not([type=radio]), form select, form textarea { display: block; width: 100%; margin-top: .25rem; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 16px; color: var(--ink); }
form textarea { resize: vertical; }
form label.check { display: flex; align-items: center; gap: .5rem; color: var(--ink); font-size: .95rem; margin: .8rem 0 .3rem; }
form label.check input { width: 1.2rem; height: 1.2rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.colors { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .3rem; }
.colors .sw { margin: 0; }
.colors input { display: none; }
.colors span { display: block; width: 2rem; height: 2rem; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.colors input:checked + span { border-color: var(--ink); }
.receipt { display: flex; flex-direction: column; gap: .5rem; align-items: stretch; margin-top: .4rem; }
.receipt img { max-width: 100%; max-height: 240px; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); }
.receipt .camera { margin: 0; color: var(--ink); font-size: 1rem; }
.settings h3 { margin-top: 0; }

.login { max-width: 340px; margin: 18vh auto 0; padding: 1rem; text-align: center; }
.login .logo { font-size: 3rem; }
.login h1 { margin: .3rem 0 1.2rem; }
.login input { width: 100%; padding: .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 16px; }

#toast { position: fixed; left: 50%; bottom: calc(6rem + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: #111827; color: #fff; padding: .6rem 1rem; border-radius: 10px; opacity: 0; transition: .2s; z-index: 30; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.error { background: var(--stop); }
