/* ---------- Färger: mörkt (standard) och ljust läge ---------- */
:root {
  --bg: #121212; --surface: #1c1c1e; --surface2: #26262a; --line: #34343a; --line-soft: #26262b;
  --text: #f2f2f2; --muted: #9a9aa2; --red: #b11d2c; --red-hi: #e0485a;
  --johan: #f0953a; --johan-soft: rgba(240,149,58,.24); --on-johan: #111;
  --kris: #3fa7b8; --kris-soft: rgba(63,167,184,.24); --on-kris: #111;
  --ok: #3fae6a; --ok-soft: rgba(63,174,106,.18); --warn: #e0485a; --warn-soft: rgba(224,72,90,.14);
  --closed: #171719; --today: #2a2822; --hover: #202024;
  --bar: rgba(18,18,18,.92); --tabbar: rgba(24,24,26,.96);
  --hero: linear-gradient(160deg, #232326, #1c1c1e); --hero-line: #3a3a40;
  --stripe: rgba(224,72,90,.10);
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f3f1; --surface: #ffffff; --surface2: #f0efec; --line: #dcdad5; --line-soft: #ebe9e5;
    --text: #1b1b1d; --muted: #6b6a70; --red: #b11d2c; --red-hi: #b11d2c;
    --johan: #b35c00; --johan-soft: rgba(179,92,0,.13); --on-johan: #fff;
    --kris: #1f7f90; --kris-soft: rgba(31,127,144,.13); --on-kris: #fff;
    --ok: #2a8a52; --ok-soft: rgba(42,138,82,.12); --warn: #b11d2c; --warn-soft: rgba(177,29,44,.08);
    --closed: #eceae6; --today: #f6f0de; --hover: #f7f6f3;
    --bar: rgba(244,243,241,.92); --tabbar: rgba(255,255,255,.96);
    --hero: linear-gradient(160deg, #f1f0ec, #ffffff); --hero-line: #dcdad5;
    --stripe: rgba(177,29,44,.07);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f3f1; --surface: #ffffff; --surface2: #f0efec; --line: #dcdad5; --line-soft: #ebe9e5;
  --text: #1b1b1d; --muted: #6b6a70; --red: #b11d2c; --red-hi: #b11d2c;
  --johan: #b35c00; --johan-soft: rgba(179,92,0,.13); --on-johan: #fff;
  --kris: #1f7f90; --kris-soft: rgba(31,127,144,.13); --on-kris: #fff;
  --ok: #2a8a52; --ok-soft: rgba(42,138,82,.12); --warn: #b11d2c; --warn-soft: rgba(177,29,44,.08);
  --closed: #eceae6; --today: #f6f0de; --hover: #f7f6f3;
  --bar: rgba(244,243,241,.92); --tabbar: rgba(255,255,255,.96);
  --hero: linear-gradient(160deg, #f1f0ec, #ffffff); --hero-line: #dcdad5;
  --stripe: rgba(177,29,44,.07);
  color-scheme: light;
}

/* ---------- Grund ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
a { color: var(--text); }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ic.fl { width: 13px; height: 13px; color: var(--warn); stroke-width: 2.4; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bar);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text); display: inline-block; }
.topright { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 14px; }
.bell { position: relative; display: inline-flex; color: var(--muted); padding: 4px; }
.badge { position: absolute; top: -2px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.badge.inline { position: static; }
main { max-width: 760px; margin: 0 auto; padding: 12px 12px 0; }
h1 { font-size: 20px; margin: 0; text-align: center; flex: 1; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 16px 0 8px; color: var(--muted); }
h2.johan, b.johan, span.johan { color: var(--johan); }
h2.kris, b.kris, span.kris { color: var(--kris); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card.hero { border-color: var(--hero-line); background: var(--hero); }
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.cardhead h2 { margin: 0; }
.big { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.muted { color: var(--muted); } .center { text-align: center; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 2px; }
.err { color: var(--red-hi); }
.flash { padding: 10px 14px; border-radius: 10px; background: var(--ok-soft); border: 1px solid var(--ok); margin: 8px 0; }
.flash.err { background: var(--warn-soft); border-color: var(--red-hi); }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.danger { background: var(--warn-soft); color: var(--red-hi); font-weight: 600; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.btns form { margin: 0; }

/* Banderoller */
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 12px; margin: 8px 0; text-decoration: none; font-size: 14px; border: 1px solid var(--line); background: var(--surface); }
.banner.flag, .banner.warn { border-color: var(--warn); background: var(--warn-soft); }
.banner.fk { border-color: var(--warn); background: var(--warn-soft); }
.banner.block { border-color: var(--warn); background: repeating-linear-gradient(135deg, var(--stripe) 0 8px, transparent 8px 16px); justify-content: center; }
.banner.warn { justify-content: center; font-weight: 600; }
.banner .ic { flex: 0 0 auto; margin-top: 1px; }

.monthbar { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.legend { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; font-size: 13px; color: var(--muted); }

/* Vyväljare */
.viewswitch { display: flex; gap: 6px; margin: 0 0 10px; }
.viewswitch a { flex: 1; text-align: center; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; font-size: 14px; color: var(--muted); }
.viewswitch a.on { background: var(--surface); color: var(--text); font-weight: 600; border-color: var(--muted); }
.viewswitch a.today { flex: 0 0 auto; }

/* ---------- Kalender ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.wd { text-align: center; color: var(--muted); font-size: 12px; padding: 2px 0 4px; text-transform: capitalize; }
.day { min-height: 64px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 3px; text-decoration: none; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.day .n { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.day.out { opacity: .4; }
.day.closed { background: var(--closed); }
.day.closed .n { color: var(--muted); }
.day.today { border-color: var(--text); }
.day.today .n { color: var(--text); font-weight: 700; }
.day.block { background-image: repeating-linear-gradient(135deg, var(--stripe) 0 6px, transparent 6px 12px); }
.hol { font-size: 9px; color: var(--muted); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chip { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; line-height: 1.2; border-radius: 5px; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; background: var(--surface2); color: var(--text); border: 0; font-family: inherit; }
.chip b { font-weight: 800; }
.chip.johan { background: var(--johan-soft); } .chip.johan b { color: var(--johan); }
.chip.kris { background: var(--kris-soft); } .chip.kris b { color: var(--kris); }
.chip.k-dag.johan:not(.half) { background: var(--johan); color: var(--on-johan); } .chip.k-dag.johan:not(.half) b { color: var(--on-johan); }
.chip.k-dag.kris:not(.half) { background: var(--kris); color: var(--on-kris); } .chip.k-dag.kris:not(.half) b { color: var(--on-kris); }
.chip.extra { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.chip.k-not { background: transparent; color: var(--muted); }
.chip.k-vab, .chip.k-pl, .chip.k-sjuk { background: transparent; border: 1px solid currentColor; }
.chip.k-vab.johan, .chip.k-pl.johan, .chip.k-sjuk.johan { color: var(--johan); }
.chip.k-vab.kris, .chip.k-pl.kris, .chip.k-sjuk.kris { color: var(--kris); }
.list .chip, .legend .chip { font-size: 13px; padding: 2px 7px; }
@media (min-width: 600px) { .day { min-height: 92px; padding: 5px; } .chip { font-size: 12px; } .hol { font-size: 11px; } }

/* ---------- Listor ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); padding: 9px 0; }
.list li:first-child { border-top: 0; }
.list a { text-decoration: none; display: block; }
.list .date { display: inline-block; min-width: 108px; color: var(--muted); font-size: 14px; }
.list li.withdel { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.list small { display: block; margin-top: 2px; font-size: 12px; }
.entryrow .er-main { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.entryrow form.inline, details form.inline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-top: 8px; }
.entryrow form.inline input, details form.inline input { width: 76px; display: inline-block; margin: 0; min-height: 36px; padding: 6px 8px; }
.er-actions { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
details summary { color: var(--muted); cursor: pointer; font-size: 13px; padding: 6px 0; display: flex; align-items: center; gap: 4px; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: '›'; display: inline-block; width: 10px; transition: transform .15s; }
details[open] summary::before { transform: rotate(90deg); }
details form { padding: 0 0 8px 14px; }
.flagcard { border-color: var(--warn); background: var(--warn-soft); }
.flagcard p { margin: 0 0 8px; }
.flagcard.resolved { opacity: .6; background: var(--surface); border-color: var(--line); }
.warncard { border-color: var(--warn); }
.warncard ul { padding-left: 20px; }
.notices li.unread b::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 6px; vertical-align: middle; }
.notices a span { display: block; font-size: 14px; }
.menu { padding: 4px 16px; }
.menu a { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); text-decoration: none; }
.menu a:first-child { border-top: 0; }
.menu a::after { content: '›'; color: var(--muted); font-size: 20px; margin-left: 8px; }
.menu a span:first-child { flex: 1; }

/* ---------- Formulär ---------- */
form { margin: 0; }
label { display: block; margin: 10px 0; font-size: 14px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date], textarea {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font-size: 16px; color: var(--text); font-family: inherit;
  background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; min-height: 44px;
}
input[type=date] { -webkit-appearance: none; appearance: none; }
input:focus, textarea:focus { outline: 2px solid var(--text); outline-offset: 1px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row.three { grid-template-columns: 1.3fr 1fr 1fr; }
.row > * { min-width: 0; }
.row label { margin: 10px 0 0; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
label.check input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--text); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.seg label { margin: 0; flex: 1 1 auto; }
.seg.three label { flex: 1 1 30%; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); color: var(--text); font-size: 14px; cursor: pointer; min-height: 44px; }
.seg input:checked + span { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--text); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); color: var(--text); font-size: 15px; text-decoration: none; cursor: pointer; font-family: inherit; }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; width: 100%; margin-top: 8px; }
.btn.primary.inline { width: auto; margin-top: 0; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.monthbar .btn.nav { width: 44px; padding: 0; font-size: 22px; }
[hidden] { display: none !important; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip.route { font-size: 13px; padding: 7px 10px; border-radius: 999px; cursor: pointer; border: 1px solid var(--line); }
.chip.route.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.paidrow { margin-top: 10px; display: flex; align-items: center; gap: 8px; }

/* ---------- Tidbank ---------- */
.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv td { padding: 6px 0; border-top: 1px solid var(--line); vertical-align: top; }
.kv td:last-child { text-align: right; }
.kv tr:first-child td { border-top: 0; }
.kv tr.sum td { font-weight: 700; }
.kv tr.dim td { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.grid2.tight { gap: 14px; }
@media (min-width: 600px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.semtop { display: flex; justify-content: space-between; font-size: 15px; }
.bar { height: 10px; background: var(--surface2); border-radius: 5px; overflow: hidden; margin: 6px 0 4px; }
.bar span { display: block; height: 100%; border-radius: 5px; }
.bar span.johan { background: var(--johan); } .bar span.kris { background: var(--kris); }

/* Årsöversikt */
.yg { display: grid; grid-template-columns: 28px repeat(31, minmax(0, 1fr)) 30px; gap: 2px; align-items: center; }
.yh { font-size: 9px; color: var(--muted); text-align: center; }
.yh.sum, .ysum { text-align: right; font-size: 11px; color: var(--muted); }
.ym { font-size: 11px; color: var(--muted); text-decoration: none; }
.sq { display: block; aspect-ratio: 1; border-radius: 2px; background: var(--surface2); }
.sq.none { background: transparent; }
.sq.closed { background: var(--closed); outline: 1px solid var(--line-soft); }
.sq.now { outline: 2px solid var(--text); }
.legend .sq { width: 12px; display: inline-block; }
.yearcard h2.johan ~ .yg .sq.full { background: var(--johan); }
.yearcard h2.johan ~ .yg .sq.part { background: var(--johan-soft); outline: 1px solid var(--johan); }
.yearcard h2.kris ~ .yg .sq.full { background: var(--kris); }
.yearcard h2.kris ~ .yg .sq.part { background: var(--kris-soft); outline: 1px solid var(--kris); }
.sq.care { background: var(--surface2); outline: 1px dashed var(--text); }
.sq.extra { background: transparent; outline: 1px dashed var(--muted); }
.legend .sq.full { background: var(--muted); } .legend .sq.part { background: var(--surface2); outline: 1px solid var(--muted); }

/* VAB/FK */
.fkp { border-top: 1px solid var(--line); padding: 12px 0; }
.fkp:first-of-type { border-top: 0; padding-top: 4px; }
.fkp.done { opacity: .7; }
.fkhead { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.fklines { list-style: none; padding: 0; margin: 8px 0 0; font-size: 14px; }
.fklines li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; padding: 3px 0; }
.fklines li small { flex-basis: 100%; }
.card.info ol { padding-left: 20px; margin: 8px 0; }
.card.info li { margin: 4px 0; }

/* ---------- Månadslista (Excel-stil) ---------- */
.mtable { padding: 6px 4px; overflow: hidden; }
.mtable h2 { padding: 8px 10px 0; }
.ml { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
.ml th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.ml th.johan { color: var(--johan); } .ml th.kris { color: var(--kris); }
.ml th.v, .ml td.v { width: 26px; text-align: center; color: var(--muted); font-size: 11px; }
.ml th.d, .ml td.d { width: 66px; }
.ml td { padding: 4px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.ml tbody tr { cursor: pointer; }
.ml tbody tr:hover td { background: var(--hover); }
.ml tr.week td { border-top: 1px solid var(--line); }
.ml td.d a { text-decoration: none; font-weight: 600; }
.ml td.d span { color: var(--muted); font-weight: 400; text-transform: uppercase; font-size: 11px; }
.ml td small { display: block; color: var(--muted); font-size: 11px; line-height: 1.25; overflow-wrap: anywhere; }
.ml td.d small { color: var(--muted); }
.ml td.d small.warn { color: var(--warn); font-weight: 600; }
.ml td.cell .chip { margin: 0 3px 2px 0; font-size: 12px; }
.ml td.cell .chip b { display: none; }
.ml tr.closed td { background: var(--closed); }
.ml tr.closed td.d a { color: var(--muted); }
.ml tr.today td { background: var(--today); }
.ml tr.block td.d { background-image: repeating-linear-gradient(135deg, var(--stripe) 0 6px, transparent 6px 12px); }
.ml tfoot td { padding: 6px 4px; font-size: 13px; border-bottom: 0; border-top: 1px solid var(--line); }
.ml tfoot tr.dim td { color: var(--muted); }
.ml tfoot tr.bank td { padding-top: 10px; }
.months { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.extra-month, .only-wide { display: none; }
@media (min-width: 1100px) {
  main:has(.months) { max-width: 1400px; }
  .months { grid-template-columns: repeat(3, 1fr); }
  .extra-month, .only-wide { display: block; }
}

.linkrow { margin: 12px 0; }
.linkrow input { font-size: 13px; }

/* ---------- Flikar ---------- */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; justify-content: space-around; align-items: center; background: var(--tabbar); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabs a { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px 0; }
.tabs a.on { color: var(--text); }
.tabs .ic { width: 24px; height: 24px; }
.tabs a.add { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 50%; background: var(--text); color: var(--bg); justify-content: center; margin-top: -22px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.tabs a.add .ic { width: 28px; height: 28px; stroke-width: 2.4; }

/* ---------- Tydligare val och menyer ---------- */
.seg.who input[value=johan]:checked + span { background: var(--johan); border-color: var(--johan); color: var(--on-johan); }
.seg.who input[value=kris]:checked + span { background: var(--kris); border-color: var(--kris); color: var(--on-kris); }
.seg.kinds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.menuhead { margin: 18px 4px 6px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.menuhead + .menu { margin-top: 0; }
.menu a small { display: block; font-size: 13px; }
.btns.centered { justify-content: center; }
.small { font-size: 14px; font-weight: 400; }
.ml th.num, .ml td.num { text-align: right; width: 64px; }
.colorlabel { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.seg.swatches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg.swatches span { gap: 6px; justify-content: flex-start; }
.seg.swatches i { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; background: var(--sw-d); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .seg.swatches i { background: var(--sw-l); } }
:root[data-theme="light"] .seg.swatches i { background: var(--sw-l); }

/* ---------- Öppettider ---------- */
.hoursrow { display: grid; grid-template-columns: 44px 1fr 1fr; gap: 8px; align-items: center; margin: 6px 0; }
.hoursrow.head { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.hoursrow input { margin: 0; min-width: 0; }
.hoursrow .wdname { text-transform: capitalize; font-weight: 600; }
.center-details { margin: -4px 0 8px; }
.center-details summary { justify-content: center; }
.center-details form { padding: 0 0 8px; }
.inline-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-row label { flex: 1 1 160px; margin-bottom: 0; }
input[type=time] { display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font-size: 16px; color: var(--text); font-family: inherit; background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; min-height: 44px; -webkit-appearance: none; appearance: none; }
.hint.warnhint { color: var(--red-hi); }
