/* Enkel, robust CSS – fungerer i Safari 12+ (gammel MacBook Air) og iPhone */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: #F4F6F5; color: #1F2A2B;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: #2F5D62; }
h1 { font-size: 1.4em; margin: 0; }
h2 { font-size: 1.15em; margin: 1.6em 0 .6em; }
h3 { font-size: 1em; margin: 1.2em 0 .4em; }
.small { font-size: .85em; }
.muted { color: #6B7778; }
.center { text-align: center; }
.r { text-align: right; }

/* Topplinje */
.top {
  background: #2F5D62; color: #fff;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-flex-wrap: wrap; flex-wrap: wrap; -webkit-align-items: center; align-items: center;
}
.top .brand { color: #fff; font-weight: 700; text-decoration: none; margin-right: auto; padding: 4px 0; }
.top nav a { color: #DDEBE8; text-decoration: none; margin-left: 14px; padding: 4px 0; display: inline-block; }
.top nav a:first-child { margin-left: 0; }
.top nav a:hover { color: #fff; }

main { max-width: 980px; margin: 0 auto; padding: 16px; }

/* Meldinger */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.flash.ok { background: #DDF1E4; color: #1D5A33; }
.flash.error { background: #F9DCDC; color: #7A1E1E; }

/* Navigasjon måned/dag */
.monthnav {
  display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center; -webkit-justify-content: space-between; justify-content: space-between;
}
.monthnav h1 { text-align: center; -webkit-flex: 1; flex: 1; padding: 0 8px; }

/* Knapper */
.btn {
  display: inline-block; padding: 9px 14px; border-radius: 8px; border: 1px solid #C9D3D1;
  background: #fff; color: #1F2A2B; text-decoration: none; font-size: 15px; cursor: pointer;
  -webkit-appearance: none; margin: 4px 4px 4px 0; line-height: 1.2;
}
.btn:hover { background: #EEF3F2; }
.btn.primary { background: #2F5D62; border-color: #2F5D62; color: #fff; }
.btn.ok { background: #2E8B57; border-color: #2E8B57; color: #fff; }
.btn.no { background: #C0392B; border-color: #C0392B; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.monthnav .btn { font-size: 22px; padding: 4px 16px; margin: 0; }
.actions { margin: 12px 0; }

/* Kalender */
.cal { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.cal th { font-size: .8em; color: #6B7778; font-weight: 600; padding: 4px 0; }
.cal td { background: #fff; border-radius: 8px; padding: 0; vertical-align: top; height: 72px; }
.cal td a { display: block; height: 100%; min-height: 72px; padding: 5px 6px; color: inherit; text-decoration: none; }
.cal td:hover { background: #EEF3F2; }
.cal td.out { background: transparent; }
.cal td.out .dn { color: #A9B3B2; }
.cal td.today { box-shadow: inset 0 0 0 2px #2F5D62; }
.cal td.worked { background: #E3EFEC; }
.cal .wk { width: 34px; background: transparent; font-size: .75em; color: #9AA5A4; text-align: center; vertical-align: middle; }
.cal .dn { font-weight: 600; display: block; }
.cal .hrs { display: block; font-size: .8em; color: #2F5D62; font-weight: 600; white-space: nowrap; }
.cal .dots { display: block; margin-top: 2px; line-height: 8px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 2px 2px 0; vertical-align: middle; }
.dot.sokt { background: #E0A526; }
.dot.innvilget { background: #2E8B57; }
.dot.avslag { background: #C0392B; }
.legend { text-align: center; color: #6B7778; }

/* Statistikk-kort */
.stats { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -4px; }
.stat {
  background: #fff; border-radius: 10px; padding: 10px 12px; margin: 4px;
  -webkit-flex: 1 1 110px; flex: 1 1 110px; border-top: 4px solid #2F5D62;
}
.stat .num { display: block; font-size: 1.5em; font-weight: 700; }
.stat .lbl { font-size: .8em; color: #6B7778; }
.stat.ok { border-color: #2E8B57; } .stat.no { border-color: #C0392B; } .stat.wait { border-color: #E0A526; }
.stat.big { -webkit-flex: 2 1 220px; flex: 2 1 220px; }
.bar { height: 8px; background: #EAD7D4; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.bar .fill { height: 100%; background: #2E8B57; }

/* Tabeller */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.list { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; font-size: .92em; }
.list th, .list td { padding: 8px 10px; border-bottom: 1px solid #E5EAE9; text-align: left; }
.list th.r, .list td.r { text-align: right; }
.list thead th { background: #2F5D62; color: #fff; font-weight: 600; white-space: nowrap; }
.list tfoot td { font-weight: 700; background: #E6EEEC; }
.list tr.empty td { color: #A9B3B2; }
.tag { font-size: .8em; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.tag.sokt { background: #FBEFD3; color: #7A5600; }
.tag.innvilget { background: #DDF1E4; color: #1D5A33; }
.tag.avslag { background: #F9DCDC; color: #7A1E1E; }

/* Skjema */
.cols { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -8px; }
.card { background: #fff; border-radius: 12px; padding: 14px 16px; margin: 8px; -webkit-flex: 1 1 320px; flex: 1 1 320px; }
.card h2 { margin-top: 0; }
.narrow { max-width: 480px; }
.row { display: -webkit-box; display: -webkit-flex; display: flex; margin: 0 -4px; }
.row label { -webkit-flex: 1; flex: 1; margin: 0 4px; min-width: 0; }
label { display: block; font-size: .85em; color: #4C5859; margin-bottom: 10px; }
label.check { font-size: .9em; }
input[type=text], input[type=number], input[type=time], input[type=date], select {
  display: block; width: 100%; margin-top: 3px; padding: 9px 10px; font-size: 16px; /* 16px hindrer zoom på iPhone */
  border: 1px solid #C9D3D1; border-radius: 8px; background: #fff; color: #1F2A2B; -webkit-appearance: none;
  min-height: 42px;
}
select { background-image: none; }
input[type=file] { margin: 8px 0; font-size: 15px; }
form.inline { display: inline; }
.items { list-style: none; padding: 0; margin: 0; }
.items li { padding: 10px 0; border-bottom: 1px solid #E5EAE9; }
.items li:last-child { border-bottom: 0; }
.items.card { padding: 4px 16px; }
.items form.inline { display: block; margin-top: 4px; }

/* Mobil */
@media (max-width: 600px) {
  main { padding: 10px; }
  .top nav { width: 100%; margin-top: 4px; }
  .cal { border-spacing: 2px; }
  .cal .wk { display: none; }
  .cal td, .cal td a { height: 58px; min-height: 58px; }
  .cal td a { padding: 3px; }
  .cal .hrs { font-size: .7em; }
  .dot { width: 7px; height: 7px; margin-right: 1px; }
  .list { font-size: .85em; }
  .list th, .list td { padding: 7px 6px; }
}

@media print {
  .top, .actions, .monthnav .btn { display: none; }
  body { background: #fff; }
}

/* Normaltimer, ikke tilgjengelig, backup-liste */
.stat .num small { font-size: .55em; font-weight: 600; color: #6B7778; }
.bar.norm { background: #E3E8E7; }
.bar.norm .fill { background: #2F5D62; }
.stat.blue { border-color: #2F6FB5; }
.cal td.unavail { background: #D6E6F8; }
.cal td.unavail.worked { background: #C9DDF4; }
.cal td.unavail:hover { background: #C4D9F2; }
.sq { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: middle; }
.sq.unavail { background: #D6E6F8; border: 1px solid #9DBFE8; }
.btn.blue { background: #2F6FB5; border-color: #2F6FB5; color: #fff; }
.blue-card { border-top: 4px solid #2F6FB5; }
section.narrow.blue-card { margin: 16px 0; }
.nowrap { white-space: nowrap; }
.nowrap .btn { margin: 2px 0 2px 4px; }
code { font-size: .9em; background: #EEF3F2; padding: 1px 4px; border-radius: 4px; }

/* ---- Kompakt sammendrag (v3) ---- */
.sum-grid { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -6px; }
.sum-card {
  -webkit-flex: 1 1 340px; flex: 1 1 340px; margin: 6px; background: #fff; border-radius: 14px;
  padding: 14px 16px 12px; box-shadow: 0 1px 2px rgba(31,42,43,.06), 0 4px 14px rgba(31,42,43,.05);
  border-left: 5px solid #2F5D62;
}
.sum-card.shifts { border-left-color: #2E8B57; }
.sum-head { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-justify-content: space-between; justify-content: space-between; -webkit-align-items: center; align-items: center; }
.sum-title { font-size: .78em; text-transform: uppercase; letter-spacing: .06em; color: #6B7778; font-weight: 600; }
.pill { font-size: .85em; font-weight: 700; padding: 3px 10px; border-radius: 20px; background: #E3EFEC; color: #2F5D62; white-space: nowrap; }
.pill.green { background: #DDF1E4; color: #1D5A33; }
.sum-big { font-size: 2em; font-weight: 700; line-height: 1.15; margin: 4px 0 8px; letter-spacing: -.01em; }
.sum-big small { font-size: .45em; font-weight: 600; color: #6B7778; letter-spacing: 0; }
.meter { height: 10px; border-radius: 6px; background: #E6EBEA; overflow: hidden; white-space: nowrap; font-size: 0; }
.meter-fill { height: 100%; border-radius: 6px; background: #2F5D62; }
.meter.stacked .seg { display: inline-block; height: 100%; }
.seg.ok { background: #2E8B57; } .seg.no { background: #C0392B; } .seg.wait { background: #E0A526; }
.sum-text { margin: 10px 0 8px; font-size: .92em; color: #3A4647; }
.chips { margin: 0 -3px; }
.chip { display: inline-block; font-size: .8em; padding: 3px 9px; margin: 3px; border-radius: 14px; background: #F0F3F2; color: #4C5859; white-space: nowrap; }
.chip b { color: #1F2A2B; }
.chip.ok { background: #DDF1E4; } .chip.no { background: #F9DCDC; } .chip.wait { background: #FBEFD3; } .chip.blue { background: #DCE9F8; }
@media (max-width: 600px) {
  .sum-card { -webkit-flex-basis: 100%; flex-basis: 100%; padding: 12px 14px 10px; }
  .sum-big { font-size: 1.7em; }
}

/* ---- Flerbruker (v4) ---- */
.top .me { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center;
  color: #fff; text-decoration: none; margin-left: 16px; padding: 2px 0; }
.top .me-name { margin-left: 8px; font-size: .95em; }
.avatar { border-radius: 50%; object-fit: cover; background: #DDEBE8; vertical-align: middle; }
.avatar.xs { width: 22px; height: 22px; }
.avatar.sm { width: 30px; height: 30px; border: 2px solid rgba(255,255,255,.6); }
.avatar.lg { width: 56px; height: 56px; }
.avatar.xl { width: 84px; height: 84px; box-shadow: 0 2px 10px rgba(31,42,43,.15); }

.viewbar { background: #E3EFEC; padding: 6px 16px; font-size: .9em; color: #2F5D62;
  display: -webkit-box; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; }
.viewbar.other { background: #FBEFD3; color: #7A5600; }
.viewbar label { display: inline; margin: 0 8px; font-size: 1em; color: inherit; }
.viewbar select { display: inline-block; width: auto; min-height: 32px; padding: 4px 10px; margin: 0; font-size: 15px; }

.login-wrap { min-height: 70vh; display: -webkit-box; display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; }
.card.login { max-width: 360px; width: 100%; -webkit-flex: 0 1 360px; flex: 0 1 360px; text-align: left; padding: 24px; }
.card.login h1 { text-align: center; margin: 8px 0 16px; }
.login-logo { display: block; width: 64px; height: 64px; border-radius: 16px; margin: 0 auto; }
.btn.wide { width: 100%; padding: 12px; font-size: 16px; }

.profile-head { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center;
  margin: 8px 0 12px; }
.profile-head > div { -webkit-flex: 1; flex: 1; margin-left: 16px; min-width: 0; }
.profile-head p { margin: 4px 0 0; }
.profile-head .logout { margin-left: 8px; }

.row.wrap { -webkit-flex-wrap: wrap; flex-wrap: wrap; }
.row.wrap label { -webkit-flex: 1 1 200px; flex: 1 1 200px; }

.user-grid { display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -6px 12px; }
.user-card { -webkit-flex: 1 1 300px; flex: 1 1 300px; margin: 6px; background: #fff; border-radius: 14px; padding: 12px 14px;
  display: -webkit-box; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center;
  color: inherit; text-decoration: none; box-shadow: 0 1px 2px rgba(31,42,43,.06), 0 4px 14px rgba(31,42,43,.05); }
.user-card:hover { background: #F7FAF9; }
.user-card.inactive { opacity: .6; }
.uc-body { margin-left: 12px; min-width: 0; }
.uc-name { font-weight: 700; }
.uc-meta { font-size: .85em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag.admin { background: #E3EFEC; color: #2F5D62; }
.card.narrow-wide { max-width: 720px; margin: 12px 0; }
.card.notice { border-left: 5px solid #E0A526; margin: 12px 0; }
.card.danger { border-left: 5px solid #C0392B; }
input[readonly] { background: #F0F3F2; color: #6B7778; }
input[type=email], input[type=tel], input[type=password] {
  display: block; width: 100%; margin-top: 3px; padding: 9px 10px; font-size: 16px;
  border: 1px solid #C9D3D1; border-radius: 8px; background: #fff; color: #1F2A2B; -webkit-appearance: none; min-height: 42px; }

@media (max-width: 600px) {
  .top { position: relative; }
  .top .me { position: absolute; right: 16px; top: calc(8px + env(safe-area-inset-top)); margin: 0; }
  .top .me-name { display: none; }
  .top nav a { margin-left: 12px; font-size: 15px; }
  .viewbar { padding: 6px 10px; }
  .profile-head { -webkit-flex-wrap: wrap; flex-wrap: wrap; }
  .profile-head .logout { margin: 10px 0 0; }
}
.cal td a { overflow: hidden; }
.cal .dots { max-height: 30px; overflow: hidden; }
