:root {
  --bg: #f3f5fa;
  --card: #ffffff;
  --ink: #141a33;
  --muted: #5f6680;
  --line: #dde2ee;
  --forest: #001098;      /* Härlövsblå */
  --forest-2: #1c2fa6;
  --navy-deep: #000a66;
  --orange: #ffc020;      /* Härlövsgul */
  --orange-soft: #fff5d6;
  --gold-ink: #6b4a00;
  --green: #2f9e44;
  --green-soft: #e6f5e9;
  --amber: #e8890c;
  --amber-soft: #fff4e0;
  --red: #d6336c;
  --red-soft: #fde8ef;
  --gray: #8a948f;
  --gray-soft: #eef0ee;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 16, 120, .06), 0 2px 8px rgba(0, 16, 120, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; line-height: 1.45; }
a { color: var(--forest-2); }
h1 { font-size: 1.55rem; margin: .4em 0 .5em; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.6em 0 .6em; color: var(--forest); }
h3 { font-size: 1.05rem; margin: 0; }
p { margin: .4em 0; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
code { background: var(--gray-soft); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }

/* ---------- Layout ---------- */
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.top-align { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
main#view { max-width: 980px; margin: 0 auto; padding: 1rem 1rem 5rem; }

/* ---------- Header ---------- */
header.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  background: var(--forest); color: #fff;
  border-bottom: 4px solid var(--orange);
  padding: .55rem 1rem; padding-top: max(.55rem, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; }
.brand b { display: block; font-size: 1rem; line-height: 1.1; }
.brand small { display: block; opacity: .75; font-size: .75rem; }
.flag {
  width: 28px; height: 28px; border-radius: 5px; flex: none;
  background: linear-gradient(135deg, #fff 50%, var(--orange) 50%);
  box-shadow: 0 0 0 2px rgba(255,255,255,.25);
}
.brand.big .flag { width: 44px; height: 44px; border-radius: 8px; box-shadow: none; border: 1px solid var(--line); }
.brand.big b { font-size: 1.25rem; }
.brand.big small { color: var(--muted); opacity: 1; font-size: .85rem; }
.nav { display: flex; gap: .2rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #dfe3ff; text-decoration: none; padding: .45rem .7rem; border-radius: 8px; white-space: nowrap; font-size: .95rem; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; box-shadow: inset 0 -3px 0 var(--orange); }
.badge { background: var(--orange); color: var(--navy-deep); border-radius: 99px; padding: 0 .45em; font-size: .75rem; font-weight: 700; margin-left: .2em; }
.me-link { text-decoration: none; }
.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--orange); color: var(--navy-deep); font-weight: 700; font-size: .85rem; flex: none;
}
.avatar.off { background: var(--gray); }
.demo-bar { background: var(--orange-soft); color: var(--gold-ink); text-align: center; font-size: .85rem; padding: .35rem 1rem; border-bottom: 1px solid #f3d98a; }

@media (max-width: 720px) {
  header.top { flex-wrap: wrap; gap: .4rem .8rem; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -1rem; padding: 0 .6rem; }
  .brand small { display: none; }
  .me-link { margin-left: auto; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- Cards & lists ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: .8rem; }
.card.empty { color: var(--muted); text-align: center; padding: 1.6rem 1rem; box-shadow: none; background: transparent; border-style: dashed; }
.card.notice { background: var(--orange-soft); border-color: #f3d98a; }
.alert { background: var(--red-soft); border: 1px solid #f4bfd2; color: #8a1840; padding: .6rem .8rem; border-radius: 8px; }
.list { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-row {
  display: flex; align-items: center; gap: .8rem; padding: .75rem 1rem; text-decoration: none; color: inherit;
  border: 0; border-bottom: 1px solid var(--line); background: none; font: inherit; text-align: left; width: 100%; cursor: pointer;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: #faf9f6; }
.list-row b { display: block; }
.list-row small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; }
.list-row .tags { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.date-box { width: 46px; text-align: center; border-radius: 8px; background: #e6e9fa; color: var(--forest); padding: .25rem 0; flex: none; }
.date-box b { font-size: 1.2rem; line-height: 1; }
.date-box small { color: var(--forest-2); font-size: .7rem; text-transform: uppercase; }

/* ---------- Pills & dots ---------- */
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15em .6em; border-radius: 99px; white-space: nowrap; vertical-align: middle; }
.s-confirmed { background: var(--green-soft); color: #1e6b2f; }
.s-maybe { background: var(--amber-soft); color: #8a5300; }
.s-pending { background: var(--gray-soft); color: #4f5954; }
.s-declined { background: var(--red-soft); color: #9c1d4e; }
.c-planning { background: var(--orange-soft); color: var(--gold-ink); }
.c-planned { background: #e3e7fb; color: var(--forest); }
.c-done { background: var(--gray-soft); color: #4f5954; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: none; }
.dot.s-confirmed { background: var(--green); }
.dot.s-maybe { background: var(--amber); }
.dot.s-pending { background: #333d38; }
.dot.s-declined { background: var(--red); }

/* ---------- Buttons & forms ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  padding: .55rem 1rem; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink); min-height: 40px;
}
.btn:hover { border-color: #c9c3b6; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--orange); border-color: #e9a800; color: var(--navy-deep); }
.btn.primary:hover { background: #ffb300; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--red); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; }
.btn.small { padding: .3rem .7rem; font-size: .85rem; min-height: 34px; }
.btn.on-confirmed { background: var(--green); border-color: var(--green); color: #fff; }
.btn.on-maybe { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn.on-declined { background: var(--red); border-color: var(--red); color: #fff; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 1rem; color: var(--muted); width: 32px; height: 32px; border-radius: 6px; }
.icon-btn:hover:not(:disabled) { background: var(--gray-soft); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }

label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
label.check input { width: 18px; height: 18px; accent-color: var(--forest); }
.pad-top { padding-top: 1.4rem; }
input, select, textarea {
  font: inherit; font-weight: 400; font-size: 1rem; padding: .6rem .7rem; border: 1px solid #d3cec2; border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--forest); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .9rem .9rem; display: flex; flex-direction: column; gap: .6rem; }
legend { font-weight: 700; font-size: .9rem; padding: 0 .3rem; }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
input[type=search] { margin: .4rem 0 .8rem; }

/* ---------- Auth ---------- */
body.auth-page {
  /* blå bakgrund med det diagonala bandet från loggan */
  background:
    linear-gradient(-38deg, transparent 0 calc(50% - 74px), var(--orange) calc(50% - 74px) calc(50% - 56px),
      rgba(255,255,255,.10) calc(50% - 56px) calc(50% + 56px), var(--orange) calc(50% + 56px) calc(50% + 74px), transparent calc(50% + 74px)),
    linear-gradient(160deg, var(--forest) 0%, var(--navy-deep) 100%);
  background-attachment: fixed;
}
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.auth-card { background: #fff; border-radius: 16px; padding: 1.8rem 1.5rem; width: 100%; max-width: 420px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.auth-card { border-top: 6px solid var(--orange); }
.auth-card h1 { margin-top: 1.2rem; color: var(--forest); }
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .5rem; }
.auth-brand b { font-size: 1.35rem; color: var(--forest); display: block; }
.auth-brand small { color: var(--muted); }
.logo.auth-logo { width: 104px; height: auto; filter: drop-shadow(0 3px 6px rgba(0,16,120,.25)); }
.demo-hint { margin-top: 1.3rem; padding: .8rem; border-radius: 8px; background: var(--orange-soft); font-size: .85rem; line-height: 1.6; }

/* ---------- Tasks ---------- */
.comp-group { margin-bottom: 1.2rem; }
.comp-label { display: inline-block; font-weight: 700; color: var(--muted); text-decoration: none; font-size: .9rem; margin-bottom: .4rem; }
.task h3 { flex: 1; }
.task .meta, p.meta { color: var(--forest-2); font-size: .9rem; }
.task.mine { border-left: 5px solid var(--gray); }
.task.mine.s-confirmed-edge { border-left-color: var(--green); }
.task.mine.s-maybe-edge { border-left-color: var(--amber); }
.task.mine.s-declined-edge { border-left-color: var(--red); }
.task.mine.s-pending-edge { border-left-color: #333d38; }
.answer-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-top: .8rem; }
.note { background: var(--orange-soft); border-radius: 6px; padding: .3rem .6rem; font-size: .9rem; }
.note.mine-comment { background: var(--gray-soft); }
details { margin: .5rem 0; }
details summary { cursor: pointer; font-weight: 600; color: var(--forest-2); font-size: .9rem; }
.instr { background: #f7f6f2; border-radius: 8px; padding: .7rem .8rem; margin-top: .4rem; font-size: .93rem; }
.contact b { font-weight: 600; }

.back { text-decoration: none; color: var(--muted); font-size: .9rem; }
.board-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.board-head > div:first-child { flex: 1; min-width: 240px; }
.admin-panel { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; background: #eef1fc; border-color: #cdd4f3; font-size: .92rem; }
.admin-panel small { display: block; margin-top: .2rem; }
.summary { margin: 1rem 0 .6rem; }
.meter { height: 8px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; flex: 1; }
.meter > div { height: 100%; background: var(--green); border-radius: 99px; transition: width .3s; }
.meter.big { height: 12px; margin-bottom: .4rem; }
.legend { display: flex; gap: .8rem; flex-wrap: wrap; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .3rem; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0 1rem; }
.chip { font: inherit; font-size: .85rem; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: .3rem .8rem; cursor: pointer; display: inline-flex; align-items: center; gap: .3rem; }
.chip.on { background: var(--forest); border-color: var(--forest); color: #fff; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 .2rem; }
fieldset .chips { margin: 0; }

.tasks { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: .8rem; align-items: start; }
.tasks .card { margin: 0; }
@media (max-width: 720px) { .tasks { grid-template-columns: 1fr; } }
.task-head { display: flex; align-items: flex-start; gap: .4rem; }
.task-head .tools { display: flex; margin: -6px -8px 0 0; }
.staff { display: flex; align-items: center; gap: .6rem; margin: .5rem 0; font-size: .9rem; }
.staff span { white-space: nowrap; }
.staff.low .meter > div { background: var(--red); }
.staff.almost .meter > div { background: var(--amber); }
.resp { color: var(--muted); }
.comments { background: #f7f6f2; border-radius: 8px; padding: .3rem .7rem; color: #4c5752; margin: .5rem 0; }
.people { list-style: none; padding: 0; margin: .7rem 0 .4rem; border-top: 1px solid var(--line); }
.people li { border-bottom: 1px solid #f0ede6; }
.person { display: flex; align-items: center; gap: .55rem; padding: .45rem .2rem; width: 100%; background: none; border: 0; font: inherit; text-align: left; color: inherit; flex-wrap: wrap; }
button.person { cursor: pointer; border-radius: 6px; }
button.person:hover { background: #faf8f4; }
.pname { font-weight: 500; }
.pname small { color: var(--muted); font-weight: 400; }
.struck { text-decoration: line-through; color: var(--muted); }
.pnote { color: var(--muted); }
.quote { font-style: italic; }
.also { background: var(--gray-soft); border-radius: 99px; padding: 0 .4rem; color: var(--muted); font-size: .75rem; }
.more { margin-left: auto; color: var(--muted); }
.task-actions { margin-top: .6rem; }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 4px var(--orange); } to { box-shadow: var(--shadow); } }

/* ---------- Picker ---------- */
.pick { list-style: none; padding: 0; margin: 0 0 .8rem; max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick li { border-bottom: 1px solid var(--line); }
.pick li:last-child { border-bottom: 0; }
.pick button { width: 100%; text-align: left; background: none; border: 0; padding: .6rem .8rem; font: inherit; cursor: pointer; display: flex; flex-direction: column; }
.pick button:hover { background: #eef0fc; }
.pick small { color: var(--muted); }
.pick small.ok { color: var(--green); }
.pick .muted { padding: .8rem; }

/* ---------- Log ---------- */
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters select { width: auto; }
.log { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.log-row { display: flex; gap: .7rem; align-items: flex-start; padding: .65rem .9rem; border-bottom: 1px solid var(--line); }
.log-row:last-child { border-bottom: 0; }
.log-row small { display: block; color: var(--muted); }
.log-row .ic { width: 1.4rem; text-align: center; flex: none; }
.log-row.removed .ic, .log-row.task_removed .ic { color: var(--red); }

/* ---------- Requests ---------- */
.req .quote { background: #f7f6f2; padding: .5rem .7rem; border-radius: 8px; }

/* ---------- Modal ---------- */
dialog.modal { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem); box-shadow: 0 20px 60px rgba(0,0,0,.3); color: var(--ink); }
dialog.modal.wide { width: min(720px, calc(100vw - 1.5rem)); }
dialog.modal::backdrop { background: rgba(15, 30, 22, .5); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-head h2 { margin: 0; font-size: 1.15rem; color: var(--ink); }
.modal-body { padding: 1rem 1.1rem 1.2rem; }
.logo { height: 38px; width: auto; flex: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }
.mail pre { white-space: pre-wrap; font-family: inherit; font-size: .88rem; background: #f7f6f2; padding: .8rem; border-radius: 8px; }
@media (max-width: 720px) {
  dialog.modal, dialog.modal.wide { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
}

/* ---------- Toast ---------- */
#toasts { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); display: flex; flex-direction: column; gap: .4rem; z-index: 1000; width: min(420px, calc(100vw - 2rem)); pointer-events: none; }
.toast { background: var(--forest); color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); opacity: 0; transform: translateY(10px); transition: all .25s; font-size: .93rem; }
.toast.err { background: #9c1d4e; }
.toast.show { opacity: 1; transform: none; }

/* ---------- Uppgiftsredigering som liknar kortet ---------- */
.ed-top { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .7rem; }
.ed-top .hint { margin: 0; font-size: .85rem; color: var(--muted); flex: 1; min-width: 200px; }
.seg { display: inline-flex; background: var(--gray-soft); border-radius: 99px; padding: 3px; }
.seg button { border: 0; background: none; font: inherit; font-size: .85rem; font-weight: 600; color: var(--muted); padding: .35rem .85rem; border-radius: 99px; cursor: pointer; }
.seg button.on { background: #fff; color: var(--forest); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.card.task.edit { margin: 0; }
.ed { display: block; position: relative; border: 1.5px dashed #c3cbe8; border-radius: 7px; padding: .35rem .5rem; margin: .8rem -.5rem .35rem; cursor: text; font-weight: 400; font-size: inherit; }
.ed:hover { border-color: var(--forest-2); background: #f8f9ff; }
.ed.focus { border-style: solid; border-color: var(--forest); background: #f6f7ff; box-shadow: 0 0 0 3px rgba(0,16,152,.12); }
.ed .lbl { position: absolute; top: -.62rem; left: .45rem; background: #fff; font-size: .66rem; font-weight: 700; color: var(--forest-2); padding: 0 .3rem; text-transform: uppercase; letter-spacing: .04em; line-height: 1.2; border-radius: 3px; }
.ed textarea, .ed input { border: 0; padding: 0; margin: 0; background: transparent; width: 100%; font: inherit; color: inherit; resize: none; overflow: hidden; outline: none; line-height: 1.45; display: block; }
.ed textarea::placeholder, .ed input::placeholder { color: #9aa1bd; font-style: italic; }
.ed.title input { font-size: 1.05rem; font-weight: 700; }
.ed.meta textarea { color: var(--forest-2); font-size: .9rem; }
.ed.instr { background: #f7f6f2; }
.ed.internal { background: #fffaf0; border-color: #ecd9a8; }
.ed-staff .num { width: 3.2em; display: inline-block; text-align: center; border: 1.5px dashed #c3cbe8; border-radius: 6px; padding: 0 .2rem; font-weight: 700; font-size: .9rem; -moz-appearance: textfield; }
.ed-staff .num:focus { border-style: solid; border-color: var(--forest); outline: none; }
.ed-details { margin-top: .6rem; }
.summary-like { font-weight: 600; color: var(--forest-2); font-size: .9rem; }
.ed-resp { margin: .7rem 0; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.ed-resp .chip { font-size: .8rem; padding: .2rem .6rem; }
.chip-input { width: auto; min-width: 11rem; border: 1.5px dashed #c3cbe8; border-radius: 99px; padding: .2rem .7rem; font-size: .8rem; color: var(--forest-2); background: #fff; }
.chip-input::placeholder { color: var(--forest-2); }
.chip-input:focus { outline: none; border-style: solid; border-color: var(--forest); }
.ed-comments { padding: .1rem .7rem .4rem; }
.ed-comments .ed { background: transparent; }
.ed-comments .ed .lbl { background: #f7f6f2; }
.btn.fake { pointer-events: none; opacity: .75; }
.tag { font-size: .75rem; background: var(--orange-soft); color: var(--gold-ink); border-radius: 99px; padding: .15rem .6rem; font-weight: 600; }
.ed-settings { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .9rem; display: grid; gap: .4rem; }
.ed-settings .ed { margin-left: 0; margin-right: 0; }
.ed-foot { margin-top: 1rem; }
[data-pane="preview"] .card { margin: 0; }
.internal { background: #fffaf0; border: 1px solid #ecd9a8; border-radius: 8px; padding: .35rem .7rem; color: #6b5420; margin: .5rem 0; }

/* ---------- Period för tävling ---------- */
.period-bar { display: grid; grid-template-columns: 18fr 60fr 10fr 12fr; gap: 3px; margin-top: .3rem; }
.period-bar span { height: 8px; border-radius: 99px; }
.period-bar .p-hidden, .period-bar .p-past { background: #dde2ee; }
.period-bar .p-active { background: var(--forest); }
.period-bar .p-after { background: var(--orange); }
.period-legend { display: grid; grid-template-columns: 18fr 60fr 10fr 12fr; gap: 3px; font-size: .72rem; }
.period-legend span:nth-child(3), .period-legend span:nth-child(4) { white-space: nowrap; }

/* ---------- Sett-status ---------- */
.seen-ic { font-size: .78rem; line-height: 1; }
.seen-bar { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .55rem .8rem; margin: -.3rem 0 1rem; color: var(--muted); }
.seen-bar .btn { margin-left: auto; }
.pick.remind label.check { align-items: flex-start; padding: .55rem .8rem; font-weight: 400; }
.pick.remind input { margin-top: .2rem; }
.pick.remind .warn { color: #9c1d4e; }
#addr { margin-top: .6rem; font-size: .85rem; }
