:root {
  --ink: #434343;          /* koksgrå — fra FlexCare-logoet */
  --ink-soft: #5d5d5f;
  --muted: #8c8c8e;
  --line: #e3e2de;
  --paper: #f1f0ed;
  --surface: #ffffff;
  --bar: #8fb0bb;          /* steel-blå — logoets bjælker (dekorativ) */
  --bar-soft: #e9f0f2;
  --accent: #4a7886;       /* dybere steel — knapper/links */
  --accent-ink: #3a606c;
  --shadow: 0 1px 2px rgba(20,23,28,.06), 0 8px 24px -12px rgba(20,23,28,.18);
  --radius: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
h1, h2, h3, .display { font-family: 'Space Grotesk', system-ui, sans-serif; letter-spacing: -.02em; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }
a { color: var(--accent-ink); }

.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 80% -10%, #dbe8ec 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 110%, #e7eef0 0%, transparent 50%),
    var(--paper);
}
.logo { display: block; height: auto; }
.login-logo { width: 230px; max-width: 78%; margin-bottom: 8px; }
.login-card .tagline { color: var(--muted); font-size: 12.5px; letter-spacing: .02em; margin-bottom: 26px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 34px 30px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.brand .mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--ink); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 19px;
  font-family: 'Space Grotesk', sans-serif;
}
.brand b { font-size: 18px; font-family: 'Space Grotesk', sans-serif; letter-spacing: -.02em; }
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; letter-spacing: .02em; }
.login-card h1 { font-size: 23px; margin-bottom: 4px; }
.login-card p.sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: #fbfaf7; color: var(--ink); transition: border-color .15s, background .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); background: #fff;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border: none; border-radius: 10px;
  font-weight: 600; font-size: 14.5px;
  background: var(--ink); color: #fff; transition: transform .06s, opacity .15s, background .15s;
}
.btn:hover { background: #000; }
.btn:active { transform: translateY(1px); }
.btn.full { width: 100%; }
.btn.accent { background: var(--accent); }
.btn.accent:hover { background: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.ghost:hover { background: #fff; border-color: #cfccc2; }
.btn.danger { background: #fff; color: #c2342b; border: 1.5px solid #f0c9c5; }
.btn.danger:hover { background: #fdf2f1; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.remember { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--ink-soft); margin: 4px 0 18px; cursor: pointer; user-select: none; }
.remember input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

.err { color: #c2342b; font-size: 13.5px; margin-top: 8px; min-height: 18px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 16px; text-align: center; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 11px 18px;
  background: var(--surface); color: var(--ink);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(67,67,67,.02);
}
.topbar .topbar-logo { height: 30px; width: auto; }
.topbar .spacer { flex: 1; }
.who { text-align: right; line-height: 1.25; }
.who b { font-size: 14px; font-family: 'Inter', sans-serif; font-weight: 600; }
.who small { display: block; color: var(--muted); font-size: 11.5px; }

/* Klokke / indbakke-knap */
.icon-btn {
  position: relative; flex: none; width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); font-size: 19px;
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--bar-soft); border-color: #cfccc2; }
.nbadge {
  position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px;
  background: #c2342b; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px;
  display: grid; place-items: center; border: 2px solid var(--surface);
}

.tabs { display: flex; gap: 4px; padding: 10px 14px 0; max-width: 1100px; margin: 0 auto; }

/* Admin = fuld PC-bredde · Montør = mobil-bredde (også på desktop) */
.role-admin .tabs, .role-admin main { max-width: 1600px; }
.role-montor .tabs, .role-montor main { max-width: 520px; }
.role-montor .grid { grid-template-columns: 1fr; }
.tab {
  padding: 9px 16px; border: none; background: transparent; color: var(--muted);
  font-weight: 600; font-size: 14px; border-radius: 9px 9px 0 0;
}
.tab.active { color: var(--ink); background: var(--surface); box-shadow: 0 -2px 0 var(--accent) inset; }

main { max-width: 1100px; margin: 0 auto; padding: 18px 14px 60px; }

.bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.bar h2 { font-size: 20px; }
.bar .spacer { flex: 1; }
.count-pill { background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }

/* status filter chips */
.chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 6px 13px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #fff; color: var(--ink-soft); font-size: 13px; font-weight: 600;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Task groups (pr. lokation) ---------- */
.task-groups { display: flex; flex-direction: column; gap: 26px; }
.group-head {
  display: flex; align-items: center; gap: 13px; margin-bottom: 14px;
  padding: 13px 18px;
  background: linear-gradient(180deg, #ffffff 0%, var(--bar-soft) 100%);
  border: 1px solid var(--line);
  border-left: 5px solid var(--bar);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.group-pin {
  flex: none; width: 36px; height: 36px; border-radius: 9px;
  background: var(--bar); color: #fff;
  display: grid; place-items: center; font-size: 18px;
}
.group-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.group-title b {
  font-family: 'Space Grotesk', sans-serif; font-size: 21px; font-weight: 700;
  letter-spacing: -.02em; color: var(--ink);
}
.group-dept {
  font-size: 13.5px; font-weight: 600; color: var(--accent-ink);
  text-transform: uppercase; letter-spacing: .04em; margin-top: 2px;
}
.group-count {
  margin-left: auto; flex: none; background: var(--ink); color: #fff;
  font-size: 13px; font-weight: 700; padding: 5px 13px; border-radius: 999px;
}
@media (max-width: 560px) {
  .group-title b { font-size: 18px; }
  .group-head { padding: 11px 14px; gap: 11px; }
}

/* ---------- Task grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .1s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 10px;
}
.card:hover { transform: translateY(-2px); border-color: #d4d0c5; box-shadow: 0 4px 8px rgba(20,23,28,.07), 0 16px 32px -16px rgba(20,23,28,.25); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drag-handle {
  flex: none; cursor: grab; color: var(--muted); font-size: 20px; line-height: 1;
  min-width: 38px; min-height: 38px; display: inline-flex; align-items: center; justify-content: center;
  margin: -8px 2px -8px -8px; border-radius: 8px;
  touch-action: none; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; letter-spacing: -2px;
}
.drag-handle:hover { background: var(--bar-soft); color: var(--accent-ink); }
.drag-handle:active { cursor: grabbing; background: var(--bar-soft); }
.card-top .case-no { margin-right: auto; }
/* Sortable-tilstande */
.card-ghost { opacity: .35; background: var(--bar-soft); }
.card-chosen { box-shadow: 0 0 0 2px var(--bar), var(--shadow); }
.card-drag { opacity: 0; }
.card-fallback {
  transform: rotate(1.5deg); opacity: .97 !important;
  box-shadow: 0 8px 28px rgba(20,23,28,.28); cursor: grabbing;
}
.case-no { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 13px; color: var(--accent-ink); letter-spacing: .01em; }
.card h3 { font-size: 16.5px; line-height: 1.3; font-weight: 600; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.card .meta span { display: inline-flex; align-items: center; gap: 4px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.assignee { font-size: 12.5px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; }
.assignee.none { color: var(--muted); font-style: italic; }

/* status badges */
.status { font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; letter-spacing: .02em; white-space: nowrap; }
.status.ny           { background: var(--bar-soft); color: #3a606c; }
.status.igangvaerende{ background: #fff3df; color: #b06a00; }
.status.afventer     { background: #f2edff; color: #6b3fc0; }
.status.faerdig      { background: #e6f6ec; color: #1f8a4c; }
.prio { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: #f1efe9; color: var(--ink-soft); }
.prio.høj, .prio.high, .prio.critical, .prio.kritisk { background: #fde8e6; color: #c2342b; }

/* Dato-badge på kort */
.date-badge { font-weight: 600; color: var(--ink-soft) !important; }

/* Alders-glow: 6–10 dage = amber, >10 dage = rød */
.card.age-warn { border-color: #f0cd8a; animation: glowWarn 2.4s ease-in-out infinite; }
@keyframes glowWarn {
  0%, 100% { box-shadow: 0 0 0 1px #f0cd8a, 0 0 9px -2px rgba(214,158,46,.4), var(--shadow); }
  50%      { box-shadow: 0 0 0 1px #e6b052, 0 0 18px 1px rgba(214,158,46,.65), var(--shadow); }
}
.card.age-crit { border-color: #e7837a; animation: glowCrit 1.8s ease-in-out infinite; }
@keyframes glowCrit {
  0%, 100% { box-shadow: 0 0 0 1px #e7837a, 0 0 10px -2px rgba(194,52,43,.45), var(--shadow); }
  50%      { box-shadow: 0 0 0 1px #d6483c, 0 0 20px 1px rgba(194,52,43,.7), var(--shadow); }
}
.card.age-crit .date-badge { color: #c2342b !important; }
.card.age-warn .date-badge { color: #a96f00 !important; }

/* Ulæst-indikator på kort */
.unread-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #c2342b; box-shadow: 0 0 0 0 rgba(194,52,43,.5); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(194,52,43,.5); } 70% { box-shadow: 0 0 0 7px rgba(194,52,43,0); } 100% { box-shadow: 0 0 0 0 rgba(194,52,43,0); } }
.card.has-unread { border-left: 4px solid #c2342b; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .big { font-size: 44px; margin-bottom: 8px; }

/* ---------- Detail overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20,23,28,.5); backdrop-filter: blur(3px); display: flex; justify-content: flex-end; }
.sheet {
  width: min(620px, 100%); height: 100%; background: var(--paper);
  display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,.25);
  animation: slidein .22s ease;
}
@keyframes slidein { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-head { position: sticky; top: 0; background: var(--ink); color: #fff; padding: 16px 18px; display: flex; align-items: flex-start; gap: 12px; }
.sheet-head .case-no { color: #b9d2da; }
.sheet-head h2 { font-size: 18px; line-height: 1.3; margin-top: 3px; }
.sheet-head .x { margin-left: auto; background: rgba(255,255,255,.12); border: none; color: #fff; width: 34px; height: 34px; border-radius: 9px; font-size: 18px; flex: none; }
.sheet-head .x:hover { background: rgba(255,255,255,.22); }
.sheet-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 12px; font-family: 'Inter', sans-serif; font-weight: 700; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { color: var(--ink); word-break: break-word; }
.kv dd a { word-break: break-all; }
.desc { font-size: 14.5px; white-space: pre-wrap; color: var(--ink-soft); }
.worknotes { font-size: 13.5px; white-space: pre-wrap; color: var(--ink-soft); max-height: 220px; overflow-y: auto; background: #faf9f5; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }

.statusrow { display: flex; gap: 7px; flex-wrap: wrap; }
.statusrow .sbtn {
  flex: 1; min-width: 90px; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line);
  background: #fff; font-weight: 600; font-size: 13px; color: var(--ink-soft);
}
.statusrow .sbtn[data-on="1"].ny           { background: var(--bar-soft); color: #3a606c; border-color: #b9d2da; }
.statusrow .sbtn[data-on="1"].igangvaerende { background: #fff3df; color: #b06a00; border-color: #f2d49b; }
.statusrow .sbtn[data-on="1"].afventer      { background: #f2edff; color: #6b3fc0; border-color: #d8c9f7; }
.statusrow .sbtn[data-on="1"].faerdig       { background: #e6f6ec; color: #1f8a4c; border-color: #aee0c1; }

.pdf-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.pdf-actions .btn { text-decoration: none; }

.notes-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.note { background: #faf9f5; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; }
.note .nh { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.note .nh b { color: var(--ink-soft); font-weight: 600; }
.note .nb { font-size: 14px; white-space: pre-wrap; }
.note-form { display: flex; flex-direction: column; gap: 9px; margin-bottom: 6px; }
.note-form textarea { width: 100%; min-height: 70px; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 10px; background: #fbfaf7; resize: vertical; }
.note-form textarea:focus { outline: none; border-color: var(--accent); background: #fff; }

/* ---------- Montør table ---------- */
.users-grid { display: grid; gap: 12px; }
.user-row { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; display: flex; align-items: center; gap: 13px; box-shadow: var(--shadow); }
.user-row .avatar { width: 38px; height: 38px; font-size: 14px; }
.user-row .avatar.admin { background: var(--ink); }
.user-row .uinfo { flex: 1; min-width: 0; }
.user-row .uinfo b { font-size: 15px; }
.user-row .uinfo small { display: block; color: var(--muted); font-size: 12.5px; }
.role-tag { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--bar-soft); color: var(--accent-ink); text-transform: uppercase; letter-spacing: .03em; }
.role-tag.admin { background: var(--ink); color: #fff; }
.inactive-tag { font-size: 11px; color: #c2342b; font-weight: 600; }

/* ---------- Modal (forms) ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(20,23,28,.5); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 18px; }
.modal { width: 100%; max-width: 420px; background: var(--surface); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.96); opacity: .5; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 19px; margin-bottom: 16px; }
.modal .row { display: flex; gap: 10px; margin-top: 18px; }
.modal .row .btn { flex: 1; }

.dropzone {
  border: 2px dashed #cfccc2; border-radius: 14px; padding: 30px 18px; text-align: center;
  color: var(--muted); background: #fbfaf7; transition: border-color .15s, background .15s; cursor: pointer;
}
.dropzone.over { border-color: var(--accent); background: var(--bar-soft); color: var(--accent-ink); }
.dropzone .big { font-size: 34px; margin-bottom: 6px; }
.dropzone b { color: var(--ink); }
.filechip { display: inline-flex; align-items: center; gap: 8px; background: var(--bar-soft); color: var(--accent-ink); font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 8px; margin-top: 12px; }

/* ---------- Indbakke ---------- */
.inbox-sheet { width: min(440px, 100%); }
.inbox-list { display: flex; flex-direction: column; gap: 8px; }
.notif {
  display: flex; align-items: flex-start; gap: 11px; padding: 12px 13px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow);
}
.notif[data-task] { cursor: pointer; }
.notif[data-task]:hover { border-color: #cfccc2; }
.notif.unread { background: #fbfaf7; border-left: 3px solid var(--accent); }
.notif-ico { font-size: 18px; flex: none; line-height: 1.3; }
.notif-body { flex: 1; min-width: 0; }
.notif-msg { font-size: 14px; color: var(--ink); }
.notif-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.notif-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 5px; }

/* ---------- Aktivitetslog ---------- */
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); }
.log-row.clickable { cursor: pointer; }
.log-row.clickable:hover { border-color: #cfccc2; }
.log-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--bar); color: #fff; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; }
.log-avatar.admin { background: var(--ink); }
.log-main { flex: 1; min-width: 0; }
.log-line { font-size: 14px; color: var(--ink-soft); }
.log-line b { color: var(--ink); font-weight: 600; }
.log-detail { color: var(--accent-ink); font-weight: 600; }
.log-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 11px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: #c2342b; }

.ref-ico { display: inline-block; font-size: 16px; line-height: 1; }
.ref-ico.spin-ico { animation: spin .7s linear infinite; }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  main { padding: 14px 12px 70px; }
  .grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 96px 1fr; }
  .who small { display: none; }
  .sheet-head h2 { font-size: 16.5px; }
}
