:root {
  --bg: #f7f7fb;
  --side: #fbfbfd;
  --card: #ffffff;
  --row: #f3f3f8;
  --line: #ececf3;
  --text: #17171f;
  --muted: #6b6b7b;
  --faint: #a3a3b2;
  --accent: #5b4bdb;
  --accent-soft: #eeecfd;
  --shadow: 0 1px 2px rgba(20, 20, 40, .04), 0 8px 24px rgba(20, 20, 40, .05);
  --radius: 24px;
  --A: #4f6bed;
  --B: #d6409f;
  --t-purple: #efedfd; --c-purple: #5b4bdb;
  --t-blue: #e8f0fe; --c-blue: #3b6fe0;
  --t-pink: #fde8f2; --c-pink: #d6407f;
  --t-yellow: #fef4d8; --c-yellow: #c98a06;
  --t-green: #e3f6ec; --c-green: #1f9d5c;
  --t-orange: #ffece3; --c-orange: #e0602a;
  --t-teal: #e2f5f6; --c-teal: #158a91;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111117; --side: #15151c; --card: #1c1c25; --row: #24242f; --line: #2c2c38;
    --text: #f1f1f6; --muted: #a2a2b4; --faint: #6e6e80;
    --accent: #8b7df5; --accent-soft: #2a2648;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    --t-purple: #2a2648; --t-blue: #1d2a45; --t-pink: #3d1f30; --t-yellow: #3a3018;
    --t-green: #173327; --t-orange: #3d2519; --t-teal: #163536;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 290px; flex: none; position: sticky; top: 0; height: 100vh;
  background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 16px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 21px; padding: 2px 8px 20px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #7c6cf7, #5b4bdb);
  box-shadow: 0 4px 12px rgba(91, 75, 219, .3);
}
.logo svg.i { width: 22px; height: 22px; stroke-width: 2.2; }
.search-box {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; margin-bottom: 14px;
  background: var(--row); border: 1px solid var(--line); border-radius: 14px; color: var(--muted); cursor: pointer; text-align: left;
}
.search-box span { flex: 1; }
kbd { font-family: inherit; font-size: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 14px; padding: 7px 10px; border-radius: 14px; font-weight: 500; font-size: 16px;
}
.nav a:hover { background: var(--row); }
.nav a.active { background: var(--accent-soft); font-weight: 600; }
.nav a.active .tile { box-shadow: 0 0 0 2px var(--accent) inset; background: var(--card); color: var(--accent); }
.nav .badge { margin-left: auto; font-size: 12px; font-weight: 700; background: var(--accent); color: #fff; border-radius: 99px; padding: 1px 8px; }
.tile { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.tile.sm { width: 34px; height: 34px; border-radius: 10px; }
.tile.sm svg.i { width: 18px; height: 18px; }
.purple { background: var(--t-purple); color: var(--c-purple); }
.blue { background: var(--t-blue); color: var(--c-blue); }
.pink { background: var(--t-pink); color: var(--c-pink); }
.yellow { background: var(--t-yellow); color: var(--c-yellow); }
.green { background: var(--t-green); color: var(--c-green); }
.orange { background: var(--t-orange); color: var(--c-orange); }
.teal { background: var(--t-teal); color: var(--c-teal); }
.side-foot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.me-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; font-weight: 600; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex: none; }
.avatar.xs { width: 22px; height: 22px; font-size: 11px; }

.main { flex: 1; min-width: 0; padding: 40px 60px 60px; }
.mobilebar { display: none; }
.scrim { display: none; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.eyebrow { color: var(--muted); font-weight: 600; font-size: 15px; margin-bottom: 6px; }
h1 { font-size: 38px; line-height: 1.1; margin: 0; font-weight: 800; letter-spacing: -.02em; }
.head-actions { display: flex; gap: 8px; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 10px 14px; border-radius: 12px;
  font-weight: 600; font-size: 16px; cursor: pointer;
}
.ghost-btn:hover { background: var(--row); }

/* ---------- Banner ---------- */
.banner {
  display: inline-flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 22px;
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow); cursor: pointer; max-width: 100%;
  border: 2px solid var(--line);
}
.banner.festive {
  border: 6px dashed transparent;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    repeating-linear-gradient(-45deg, #e23b3b 0 12px, #fff 12px 24px) border-box;
}
.banner b { display: block; font-size: 17px; }
.banner small { color: var(--muted); font-size: 14px; }
.banner .emoji { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--t-green); }

/* ---------- Dashboard grid ---------- */
.grid { display: grid; grid-template-columns: 1.45fr 1fr 1fr; gap: 22px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px 24px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.card-head h2 { font-size: 20px; margin: 0; font-weight: 700; }
.card-head .link { margin-left: auto; color: var(--accent); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 2px; background: none; border: 0; cursor: pointer; padding: 4px; }
.card-head .link svg.i { width: 16px; height: 16px; }
.card-head .chip { margin-left: auto; }

/* Day rows */
.rows { display: flex; flex-direction: column; gap: 10px; }
.day-row {
  display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 12px;
  background: var(--row); border-radius: 14px; padding: 14px 16px; border-left: 4px solid var(--c, var(--A));
}
.day-row .when { color: var(--muted); font-weight: 600; font-size: 14px; }
.day-row .when b { display: block; color: var(--text); font-size: 15px; }
.day-row .what b { display: block; font-size: 17px; font-weight: 700; }
.day-row .what span { color: var(--c); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.day-row .what span svg.i { width: 16px; height: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--A)); flex: none; }

/* Inputs */
.field, .input {
  width: 100%; padding: 13px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); outline: none; font-size: 16px;
}
.field:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 80px; }
.inline-form { display: flex; gap: 10px; }
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(91, 75, 219, .25); display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn:hover { filter: brightness(1.07); }
.btn.secondary { background: var(--row); color: var(--text); box-shadow: none; }
.btn.danger { background: var(--t-pink); color: var(--c-pink); box-shadow: none; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; color: var(--muted); cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--row); color: var(--text); }
.icon-btn svg.i { width: 18px; height: 18px; }
label.lbl { display: block; font-weight: 600; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* Messages */
.msgs { display: flex; flex-direction: column; margin-top: 16px; }
.msg { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); align-items: start; }
.msg:last-child { border-bottom: 0; }
.msg .dot { margin-top: 7px; }
.msg p { margin: 0; font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg small { grid-column: 2; color: var(--muted); font-size: 14px; }

/* Checklist */
.check { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.check:last-child { border-bottom: 0; }
.check .box { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--faint); display: grid; place-items: center; flex: none; color: #fff; }
.check.done .box { background: var(--accent); border-color: var(--accent); }
.check.done span { color: var(--faint); text-decoration: line-through; }
.check .box svg.i { width: 14px; height: 14px; stroke-width: 3; }
.check span { flex: 1; }
.check .icon-btn { opacity: 0; }
.check:hover .icon-btn { opacity: 1; }

/* Handover / status */
.big { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.meta { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.meta div { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.meta svg.i { color: var(--muted); width: 18px; height: 18px; }
.handover-flow { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 12px; background: var(--row); border-radius: 14px; font-weight: 600; }
.handover-flow svg.i { color: var(--muted); }
.ring-wrap { display: flex; align-items: center; gap: 20px; }
.ring { width: 96px; height: 96px; flex: none; }
.pill { display: inline-block; font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 99px; margin-top: 8px; }
.chip { white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--row); color: var(--muted); }
.chip svg.i { width: 13px; height: 13px; }

/* Week strip */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wd { border-radius: 12px; padding: 8px 2px; text-align: center; background: color-mix(in srgb, var(--c) 14%, var(--card)); position: relative; }
.wd small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.wd b { font-size: 16px; }
.wd.today { box-shadow: 0 0 0 2px var(--c) inset; }
.wd .sw { position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--text); opacity: .5; }

/* Balance */
.balance { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.pos { color: var(--c-green); }
.neg { color: var(--c-pink); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .grow small { color: var(--muted); font-size: 13px; }
.list-row .amt { font-weight: 700; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 26px 0 10px; }
.empty svg.i { width: 30px; height: 30px; color: var(--faint); display: block; margin: 0 auto 10px; }

/* Calendar */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.cal-head h2 { font-size: 22px; margin: 0 8px 0 0; text-transform: capitalize; min-width: 170px; }
.legend { display: flex; gap: 16px; margin-left: auto; font-weight: 600; font-size: 14px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); padding: 4px 0; text-transform: capitalize; }
.cell {
  min-height: 92px; border-radius: 14px; padding: 8px 10px; cursor: pointer; position: relative; border: 0; text-align: left;
  background: color-mix(in srgb, var(--c) 13%, var(--card)); display: flex; flex-direction: column; gap: 4px;
}
.cell:hover { background: color-mix(in srgb, var(--c) 22%, var(--card)); }
.cell.out { opacity: .4; }
.cell.today { box-shadow: 0 0 0 2px var(--c) inset; }
.cell .n { font-weight: 700; font-size: 16px; }
.cell .who { font-size: 12px; font-weight: 600; color: var(--c); }
.cell .tag { font-size: 11px; font-weight: 700; background: var(--card); border-radius: 6px; padding: 2px 6px; align-self: flex-start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .swap { position: absolute; top: 8px; right: 8px; color: var(--text); opacity: .55; }
.cell .swap svg.i { width: 15px; height: 15px; }

/* Two-column pages */
.split { display: grid; grid-template-columns: 1.5fr 1fr; gap: 22px; align-items: start; }
.kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px; }
.kid-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.kid-head .avatar { width: 52px; height: 52px; font-size: 20px; }
.kid-head b { font-size: 20px; display: block; }
.stack { display: flex; flex-direction: column; gap: 22px; }

/* Modal */
#modal:empty { display: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 15, 30, .35); display: grid; place-items: start center; padding: 10vh 16px 16px; z-index: 50; animation: fade .15s; }
.modal { background: var(--card); border-radius: 22px; width: min(520px, 100%); padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.2); max-height: 80vh; overflow: auto; }
.modal h3 { margin: 0 0 4px; font-size: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.search-results a { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; }
.search-results a:hover, .search-results a.sel { background: var(--row); }
@keyframes fade { from { opacity: 0; } }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--card); padding: 12px 18px; border-radius: 14px; font-weight: 600; z-index: 60; animation: fade .2s; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .grid .col:nth-child(3) { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1000px) {
  .main { padding: 24px 28px 48px; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15,15,30,.3); z-index: 30; }
  .mobilebar { display: flex; align-items: center; justify-content: space-between; margin: -8px -4px 16px; }
  .mobilebar-title { font-weight: 700; font-size: 18px; }
  .mobilebar .icon-btn svg.i { width: 22px; height: 22px; }
  .main { padding: 16px 16px 40px; }
  .grid, .grid .col:nth-child(3) { grid-template-columns: 1fr; display: grid; }
  .head-actions { display: none; }
  h1 { font-size: 30px; }
  .card { padding: 18px; }
  .cell { min-height: 62px; padding: 6px; }
  .cell .who, .cell .tag { display: none; }
  .day-row { grid-template-columns: 76px 1fr auto; padding: 12px; }
}

/* ---------- Innlogging ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--card); border-radius: 28px; box-shadow: var(--shadow); padding: 40px 32px; width: min(420px, 100%); text-align: center; }
.login-card h1 { margin: 18px 0 8px; }
.login-card p { margin: 0 0 26px; line-height: 1.5; }
.logo.xl { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto; }
.logo.xl svg.i { width: 32px; height: 32px; }
.btn.wide { width: 100%; padding: 14px 16px; font-size: 16px; }
.btn.ms { background: #2f2f2f; box-shadow: none; gap: 12px; }
@media (prefers-color-scheme: dark) { .btn.ms { background: #fff; color: #2f2f2f; } }

/* ---------- Lesetilgang ---------- */
.readonly form[data-form],
.readonly [data-act^="del-"],
.readonly [data-act="settle"],
.readonly [data-act="reset-pack"],
.readonly [data-act="reset"],
.readonly .cal-hint { display: none !important; }
.readonly .check, .readonly .cell { cursor: default; }
