/* =========================================================================
   Skadeappen 2.0 — designsystem
   Lys + mørk modus via [data-theme] på <html>
   ========================================================================= */

:root, html[data-theme="light"] {
  --bg: #f2f5f9;
  --card: #ffffff;
  --elev: #ffffff;
  --ink: #101623;
  --muted: #5b6779;
  --faint: #8b96a6;
  --line: #e4e9f0;
  --input-bg: #f5f7fa;

  --primary: #2b62c4;
  --primary-ink: #ffffff;
  --primary-soft: #e8effb;
  --primary-grad: linear-gradient(135deg, #1f4e78 0%, #2b62c4 100%);

  --urgent: #d43f3f;
  --urgent-soft: #fdeaea;
  --maint: #3a7fa0;
  --maint-soft: #e7f1f5;
  --ok: #1f9d63;
  --ok-soft: #e2f5ec;
  --warn: #b07708;
  --warn-soft: #fdf3d8;

  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  --nav-bg: rgba(255, 255, 255, .92);
}

html[data-theme="dark"] {
  --bg: #0d1117;
  --card: #161d28;
  --elev: #1c2533;
  --ink: #e8edf4;
  --muted: #94a0b1;
  --faint: #6b7688;
  --line: #242e3d;
  --input-bg: #1b2431;

  --primary: #6ba1ff;
  --primary-ink: #0b1524;
  --primary-soft: #1d2c47;
  --primary-grad: linear-gradient(135deg, #24466b 0%, #2f5fb0 100%);

  --urgent: #f07470;
  --urgent-soft: #3a1d1f;
  --maint: #6db5d6;
  --maint-soft: #16303c;
  --ok: #4cc38a;
  --ok-soft: #143327;
  --warn: #e2b93b;
  --warn-soft: #34290e;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  --nav-bg: rgba(18, 24, 33, .92);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; touch-action: manipulation; }
img { max-width: 100%; display: block; }
a { color: var(--primary); }

input, textarea, select {
  background: var(--input-bg);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 15px;
  color: var(--ink);
  width: 100%;
  -webkit-appearance: none; appearance: none;
  outline: none;
  transition: border-color .15s, background .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); background: var(--card); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; min-height: 76px; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b96a6' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ---- App-skall ---- */
.app-shell {
  max-width: 520px;
  margin: 0 auto;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  display: flex; flex-direction: column; position: relative;
}
@media (min-width: 560px) {
  .app-shell { box-shadow: var(--shadow); }
}

/* ---- Toppbar ---- */
.topbar {
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 21px; font-weight: 800; letter-spacing: -0.3px; }
.topbar .sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.topbar .left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.topbar .right { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.iconbtn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line);
  transition: transform .1s;
}
.iconbtn:active { transform: scale(.92); }
.iconbtn svg { width: 19px; height: 19px; }
.iconbtn.avatar {
  background: var(--primary-grad); color: #fff; border: 0;
  font-size: 15px; font-weight: 700;
}
.back-btn {
  width: 38px; height: 38px; border-radius: 50%; margin-left: -6px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); flex-shrink: 0;
}
.back-btn svg { width: 22px; height: 22px; }
.back-btn:active { background: var(--line); }

/* ---- Innhold ---- */
.view {
  flex: 1;
  min-height: 0;
  padding: 4px 18px 110px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---- Bunnmeny ---- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 520px; margin: 0 auto;
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  display: flex;
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
}
.bottomnav .item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 9.5px; font-weight: 600; color: var(--faint);
  padding: 5px 0 2px; min-width: 0; border-radius: 10px;
  transition: color .15s;
}
.bottomnav .item svg { width: 21px; height: 21px; }
.bottomnav .item.active { color: var(--primary); }

/* ---- FAB ---- */
.fab {
  position: fixed;
  right: max(18px, calc((100vw - 520px) / 2 + 18px));
  bottom: calc(78px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 20px;
  background: var(--primary-grad); color: #fff;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center;
  z-index: 25;
  transition: transform .12s;
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.9); }

/* ---- Statistikk-fliser ---- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.tile {
  padding: 16px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
  text-align: left;
}
.tile .num { font-size: 27px; font-weight: 800; line-height: 1.1; letter-spacing: -0.5px; }
.tile .lbl { font-size: 12px; margin-top: 5px; font-weight: 600; color: var(--muted); }
.tile .tico {
  width: 32px; height: 32px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.tile .tico svg { width: 17px; height: 17px; }
.tile.urgent .tico { background: var(--urgent-soft); color: var(--urgent); }
.tile.urgent .num { color: var(--urgent); }
.tile.maint .tico { background: var(--maint-soft); color: var(--maint); }
.tile.maint .num { color: var(--maint); }
.tile.cost { grid-column: span 2; background: var(--primary-grad); border: 0; color: #fff; }
.tile.cost .num { font-size: 23px; color: #fff; }
.tile.cost .lbl { color: rgba(255,255,255,.75); }
.tile.cost .tico { background: rgba(255,255,255,.15); color: #fff; }
.tile.tap:active { transform: scale(.98); }

/* ---- Seksjonstitler ---- */
.section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--faint); font-weight: 700;
  margin: 22px 0 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.section-title:first-child { margin-top: 10px; }
.section-title .link { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--primary); font-weight: 600; }

/* ---- Kort (saker, innkjøp, verktøy) ---- */
.task-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  transition: transform .1s;
  position: relative;
  overflow: hidden;
}
.task-card.tap { cursor: pointer; }
.task-card.tap:active { transform: scale(.985); }
.task-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  border-radius: 4px 0 0 4px;
}
.task-card.urgent::before { background: var(--urgent); }
.task-card.maintenance::before { background: var(--maint); }
.task-card.completed { opacity: .68; }
.task-card.completed::before { background: var(--ok); }

.task-card .thumb {
  width: 64px; height: 64px; border-radius: 12px; flex-shrink: 0;
  background-color: var(--input-bg);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: var(--faint);
}
.task-card .thumb svg { width: 22px; height: 22px; }
.task-card .meta { flex: 1; min-width: 0; }
.task-card .ttl {
  font-size: 15px; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.task-card .loc {
  font-size: 12.5px; color: var(--muted); margin: 2px 0 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.task-card .row { display: flex; gap: 5px; flex-wrap: wrap; }
.task-card .chev { color: var(--faint); flex-shrink: 0; }
.task-card .chev svg { width: 17px; height: 17px; }

/* ---- Piller ---- */
.pill {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--input-bg); color: var(--muted);
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap;
}
.pill.urgent { background: var(--urgent-soft); color: var(--urgent); }
.pill.maint { background: var(--maint-soft); color: var(--maint); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn, .pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.kr { background: var(--primary-soft); color: var(--primary); }
.pill.fag { background: var(--primary-soft); color: var(--primary); }

/* ---- Segmentert kontroll / filterbar ---- */
.seg {
  display: flex; gap: 4px;
  background: var(--input-bg);
  border: 1px solid var(--line);
  padding: 4px; border-radius: 14px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg .s {
  flex: 1; padding: 8px 10px; border-radius: 10px;
  font-size: 13px; font-weight: 650; color: var(--muted);
  white-space: nowrap;
  transition: all .15s;
}
.seg .s.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.filter-bar {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-bar .f {
  padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--card); color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap; flex-shrink: 0;
  transition: all .12s;
}
.filter-bar .f.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* ---- Søkefelt ---- */
.searchbar {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: 13px; padding: 9px 13px; margin-bottom: 12px;
  color: var(--faint);
}
.searchbar svg { width: 17px; height: 17px; flex-shrink: 0; }
.searchbar input { border: 0; background: none; padding: 0; border-radius: 0; font-size: 14.5px; }
.searchbar input:focus { background: none; }
.searchbar .clear { color: var(--faint); display: flex; }
.searchbar .clear svg { width: 16px; height: 16px; }

/* ---- Knapper ---- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  background: var(--primary); color: var(--primary-ink);
  padding: 14px 18px; border-radius: 14px;
  font-size: 15px; font-weight: 700;
  transition: transform .1s, opacity .15s;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; }
.btn.secondary {
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 600;
}
.btn.ok { background: var(--ok); color: #fff; }
.btn.danger { background: var(--urgent-soft); color: var(--urgent); }
.btn.sm { padding: 10px 14px; font-size: 13.5px; border-radius: 12px; width: auto; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.btn-row .btn { flex: 1 1 45%; }
.btn-row .btn.full { flex: 1 1 100%; }

/* ---- Skjemafelter ---- */
.field { margin-bottom: 15px; }
.field .label {
  font-size: 12.5px; font-weight: 700; color: var(--muted);
  margin-bottom: 6px;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- Chips (kategori-valg) ---- */
.cat-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 9px 14px; border-radius: 12px;
  background: var(--card); border: 1.5px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: all .12s;
}
.chip.sel { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip.sel.urgent { background: var(--urgent-soft); border-color: var(--urgent); color: var(--urgent); }
.chip.sel.maint { background: var(--maint-soft); border-color: var(--maint); color: var(--maint); }
.chip.sel.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.toggle-row { display: flex; gap: 7px; }
.toggle-row .chip { flex: 1; text-align: center; }

/* ---- Switch ---- */
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line);
  padding: 13px 15px; border-radius: 14px;
}
.switch-row .name { font-size: 14.5px; font-weight: 650; }
.switch-row .desc { font-size: 12px; color: var(--muted); margin-top: 1px; }
.switch {
  width: 48px; height: 29px; border-radius: 999px;
  background: var(--ok); position: relative; cursor: pointer; flex-shrink: 0;
  transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 22px;
  width: 23px; height: 23px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: left .2s;
}
.switch.off { background: var(--line); }
.switch.off::after { left: 3px; }

/* ---- Foto-opplasting ---- */
.photo-area {
  border: 2px dashed var(--line);
  border-radius: 16px;
  padding: 26px 16px;
  text-align: center;
  position: relative;
  background: var(--card);
  color: var(--muted);
  transition: border-color .15s;
}
.photo-area:active { border-color: var(--primary); }
.photo-area svg { width: 30px; height: 30px; margin: 0 auto 8px; color: var(--faint); }
.photo-area .lbl { font-size: 14.5px; font-weight: 650; color: var(--ink); }
.photo-area .small { font-size: 12px; color: var(--muted); margin-top: 3px; }
.photo-area input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.thumbs-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs-row .mini {
  width: 66px; height: 66px; border-radius: 12px;
  background-color: var(--input-bg);
  background-size: cover; background-position: center;
  position: relative;
  border: 1px solid var(--line);
}
.thumbs-row .mini .x {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: var(--bg);
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.thumbs-row .mini.add {
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--faint); cursor: pointer;
  border-style: dashed;
}

/* ---- Detaljside ---- */
.hero-img {
  width: 100%; height: 240px;
  border-radius: 18px;
  background-color: var(--input-bg);
  background-size: cover; background-position: center;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.hero-img.empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--faint); height: 130px; cursor: default;
}
.hero-img.empty svg { width: 34px; height: 34px; }
.hero-img .badge {
  position: absolute; bottom: 10px; right: 12px;
  background: rgba(0,0,0,.55); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.hero-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,.4); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.hero-nav.left { left: 10px; }
.hero-nav.right { right: 10px; }

.detail-title { font-size: 20px; font-weight: 800; letter-spacing: -0.3px; margin-bottom: 3px; }
.detail-sub { font-size: 13.5px; color: var(--muted); margin-bottom: 12px; }
.pills-row { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }

.desc-box {
  background: var(--card); border: 1px solid var(--line);
  padding: 13px 15px; border-radius: 14px;
  font-size: 14px; line-height: 1.55;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.kv-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 4px 15px; margin-bottom: 14px;
}
.kv {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); flex-shrink: 0; }
.kv .v { font-weight: 650; text-align: right; word-break: break-word; }

/* ---- Kommentarer ---- */
.comment {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 14px; margin-bottom: 8px;
}
.comment .who { font-size: 11.5px; color: var(--muted); font-weight: 650; margin-bottom: 3px; }
.comment .txt { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.comment-row { display: flex; gap: 8px; margin-top: 10px; }
.comment-row input { flex: 1; }
.comment-row .btn { width: auto; padding: 10px 16px; }

/* ---- Tomtilstand ---- */
.empty {
  text-align: center; padding: 44px 20px;
  color: var(--muted);
}
.empty .em {
  width: 62px; height: 62px; margin: 0 auto 14px;
  border-radius: 20px; background: var(--card); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--faint);
}
.empty .em svg { width: 26px; height: 26px; }
.empty .em-ttl { font-size: 15.5px; font-weight: 700; color: var(--ink); }
.empty .em-sub { font-size: 13px; margin-top: 4px; }

/* ---- Handlingsliste (dashboard) ---- */
.action-item {
  display: flex; align-items: center; gap: 11px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 13px; margin-bottom: 8px;
  cursor: pointer;
  transition: transform .1s;
}
.action-item:active { transform: scale(.985); }
.action-item .aico {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.action-item .aico svg { width: 17px; height: 17px; }
.action-item .aico.red { background: var(--urgent-soft); color: var(--urgent); }
.action-item .aico.yellow { background: var(--warn-soft); color: var(--warn); }
.action-item .aico.blue { background: var(--primary-soft); color: var(--primary); }
.action-item .aico.green { background: var(--ok-soft); color: var(--ok); }
.action-item .atxt { flex: 1; min-width: 0; }
.action-item .attl { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-item .asub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-item .chev { color: var(--faint); display: flex; }
.action-item .chev svg { width: 16px; height: 16px; }

/* ---- Hurtigvalg (dashboard) ---- */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 14px;
  font-size: 13.5px; font-weight: 650; color: var(--ink);
  transition: transform .1s;
  text-align: left;
}
.quick:active { transform: scale(.97); }
.quick svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }

/* ---- Rapport ---- */
.summary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px;
}
.stat .lbl { font-size: 11.5px; color: var(--muted); font-weight: 650; }
.stat .num { font-size: 19px; font-weight: 800; margin-top: 3px; letter-spacing: -0.3px; }
.bar-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 9px; font-size: 12.5px;
}
.bar-row .name { width: 84px; flex-shrink: 0; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar {
  flex: 1; height: 10px; background: var(--input-bg); border-radius: 999px; overflow: hidden;
}
.bar-row .bar > div { height: 100%; border-radius: 999px; min-width: 3px; transition: width .4s; }
.bar-row .val { width: 76px; text-align: right; font-weight: 700; flex-shrink: 0; font-size: 12px; }

/* ---- Kalender ---- */
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.cal-head .month { font-size: 14.5px; font-weight: 750; text-transform: capitalize; }
.cal-head button {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.cal-head button svg { width: 17px; height: 17px; }
.cal-week {
  display: grid; grid-template-columns: 34px repeat(5, 1fr);
  gap: 3px; margin-bottom: 4px;
}
.cal-week .day {
  text-align: center; font-size: 11px; font-weight: 700; color: var(--muted);
  padding: 5px 0; border-radius: 8px;
}
.cal-week .day.today { background: var(--primary); color: var(--primary-ink); }
.cal-grid {
  display: grid; grid-template-columns: 34px repeat(5, 1fr);
  gap: 3px;
}
.cal-time {
  font-size: 10px; color: var(--faint); text-align: right; padding: 3px 5px 0 0;
  font-weight: 600;
}
.cal-cell {
  min-height: 42px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--line);
  padding: 2px;
  cursor: pointer;
}
.cal-cell.placing { border-color: var(--primary); border-style: dashed; background: var(--primary-soft); }
.cal-event {
  font-size: 9.5px; font-weight: 700; line-height: 1.25;
  border-radius: 6px; padding: 3px 5px; margin-bottom: 2px;
  overflow: hidden; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.cal-event.urg { background: var(--urgent-soft); color: var(--urgent); }
.cal-event.mnt { background: var(--maint-soft); color: var(--maint); }

.hint-bar {
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: 12px; padding: 10px 13px;
  font-size: 12.5px; font-weight: 600;
  margin: 12px 0;
}
.hint-bar.info { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }

.unsch-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 10px 13px; margin-bottom: 7px;
  font-size: 13px; cursor: pointer;
}
.unsch-item .ttl { font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unsch-item.selected { border-color: var(--primary); background: var(--primary-soft); }

/* ---- Innlogging ---- */
.login-screen {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; justify-content: safe center;
  padding: 32px 26px calc(32px + env(safe-area-inset-bottom));
  max-width: 420px; margin: 0 auto; width: 100%;
}
.login-screen .brand { text-align: center; margin-bottom: 30px; }
.login-screen .logo {
  width: 84px; height: 84px; margin: 0 auto 16px;
  border-radius: 26px;
  background: var(--primary-grad);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
  color: #fff;
}
.login-screen .logo svg { width: 42px; height: 42px; }
.login-screen h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.login-screen .brand p { color: var(--muted); font-size: 13.5px; margin-top: 5px; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: calc(88px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 11px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 650;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  max-width: 86vw; text-align: center;
  animation: toast-in .22s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- Lightbox ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.93);
  display: flex; align-items: center; justify-content: center;
  animation: fade-in .15s;
}
.lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
.lightbox .close {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff;
  font-size: 20px; display: flex; align-items: center; justify-content: center;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- Bunn-ark (sheet) ---- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(8, 12, 20, .5);
  animation: fade-in .18s;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 81;
  max-width: 520px; margin: 0 auto;
  background: var(--elev);
  border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  animation: sheet-up .22s ease-out;
  max-height: 86vh; overflow-y: auto;
}
.sheet .grip {
  width: 40px; height: 4.5px; border-radius: 999px;
  background: var(--line); margin: 4px auto 14px;
}
.sheet h3 { font-size: 17px; font-weight: 750; margin-bottom: 14px; }
@keyframes sheet-up {
  from { transform: translateY(40%); opacity: .5; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---- Skeleton ---- */
.skel {
  border-radius: 14px;
  background: linear-gradient(100deg, var(--input-bg) 40%, var(--line) 50%, var(--input-bg) 60%);
  background-size: 200% 100%;
  animation: skel 1.2s infinite linear;
}
@keyframes skel { from { background-position: 120% 0; } to { background-position: -80% 0; } }

/* ---- Pull-to-refresh ---- */
.ptr-indicator {
  position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%);
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; z-index: 50;
  pointer-events: none;
}
.ptr-spinner {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--primary);
}
.ptr-indicator.spinning .ptr-spinner { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Tema-velger ---- */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-opt {
  border: 2px solid var(--line); border-radius: 14px;
  padding: 12px 8px; text-align: center;
  font-size: 12.5px; font-weight: 650; color: var(--muted);
  background: var(--card);
}
.theme-opt svg { width: 20px; height: 20px; margin: 0 auto 6px; display: block; }
.theme-opt.sel { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* ---- Diverse ---- */
.notice {
  border-radius: 14px; padding: 12px 15px; margin-bottom: 14px;
  font-size: 13px; line-height: 1.5;
}
.notice.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent); }
.notice.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); }
.notice.err { background: var(--urgent-soft); color: var(--urgent); border: 1px solid color-mix(in srgb, var(--urgent) 25%, transparent); }

.fade-in { animation: view-in .18s ease-out; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================================
   Utskrift
   ========================================================================= */
.print-toolbar { margin-bottom: 16px; }
.print-page {
  background: #fff; color: #111;
  border: 1px solid var(--line); border-radius: 14px;
  padding: 22px;
}
html[data-theme="dark"] .print-page { border-color: #333; }
.print-header { border-bottom: 2.5px solid #111; padding-bottom: 10px; margin-bottom: 16px; }
.print-header h1 { font-size: 20px; font-weight: 800; }
.print-header p { font-size: 12px; color: #555; margin-top: 2px; }
.print-page h2 { font-size: 15px; margin: 18px 0 8px; border-bottom: 1px solid #ccc; padding-bottom: 4px; }
.print-task {
  display: flex; gap: 10px; padding: 9px 0;
  border-bottom: 1px dashed #ddd;
  page-break-inside: avoid;
}
.print-photo { width: 58px; height: 58px; object-fit: cover; border-radius: 7px; flex-shrink: 0; }
.print-photo-empty { width: 58px; height: 58px; background: #f0f0f0; border-radius: 7px; flex-shrink: 0; }
.print-checkbox { font-size: 22px; width: 58px; text-align: center; flex-shrink: 0; }
.print-content { flex: 1; min-width: 0; }
.print-title { font-size: 13.5px; font-weight: 700; }
.print-time { font-weight: 600; color: #444; font-size: 12px; margin-left: 6px; }
.print-loc { font-size: 11.5px; color: #555; margin-top: 1px; }
.print-desc { font-size: 11.5px; color: #333; margin-top: 3px; line-height: 1.4; }
.print-meta-row { display: flex; gap: 12px; font-size: 11px; color: #555; margin-top: 4px; flex-wrap: wrap; }
.print-claimed { font-size: 11.5px; font-weight: 700; color: #1f9d63; margin-top: 4px; }
.print-name-line { font-size: 11.5px; color: #333; margin-top: 6px; }
.print-summary {
  background: #f4f6f8; padding: 12px 16px; border-radius: 8px;
  margin-bottom: 16px; font-size: 12.5px;
}
.print-summary > div { margin: 3px 0; }
.print-total { border-top: 1px solid #bbb; padding-top: 7px; margin-top: 7px !important; }

@media print {
  html, body, .app-shell { background: #fff !important; max-width: none !important; box-shadow: none !important; }
  .topbar, .bottomnav, .fab, .print-toolbar, .ptr-indicator { display: none !important; }
  .view { padding: 0 !important; overflow: visible !important; }
  .print-page { border: none !important; padding: 0 !important; border-radius: 0 !important; }
}
