:root {
    --green: #3A7D44;
    --green-dark: #2F6838;
    --bg: #F5F7FA;
    --card: #FFFFFF;
    --text: #23272B;
    --text-2: #3A3F44;
    --muted: #6B737B;
    --faint: #8A939B;
    --danger: #C53B3B;
    --amber: #E8A33D;
    --line: #E3E6EA;
    --focus: #2E86AB;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}
body.modal-open { overflow: hidden; }
[hidden], .hidden { display: none !important; }
.phone-only { display: none !important; }
.grow { flex: 1; }
h2, h3 { font-weight: 700; }

/* Focus is always visible for keyboard users. */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Buttons */
button { font: inherit; cursor: pointer; border: none; border-radius: 9px; padding: 10px 16px; color: inherit; background: none; }
button:disabled { cursor: default; opacity: .55; }
button[aria-busy="true"] { cursor: progress; }
button.primary { background: var(--green); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--green-dark); }
button.primary.sm, button.ghost.sm { padding: 7px 12px; font-size: 14px; }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { background: var(--line); color: var(--text); }
button.ghost.toggle[aria-pressed="true"] { background: var(--line); color: var(--text); }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.link { background: none; color: var(--green); padding: 4px 8px; font-size: 14px; }
.link.del { color: var(--danger); }
.link.restore { font-weight: 600; }

/* Inputs: 16px minimum — smaller makes iOS Safari zoom the page on focus. */
input, select, textarea { font: inherit; font-size: 16px; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], select, textarea {
    padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; min-width: 0; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: #fff; padding: 34px; border-radius: 16px; width: min(360px, 100%);
    box-shadow: 0 10px 40px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 8px; }
.login-card label { font-size: 13px; color: var(--muted); margin-top: 6px; }
.login-card button { margin-top: 6px; }
.brand { color: var(--green); text-align: center; margin: 0; font-size: 32px; }
.subtitle { text-align: center; color: var(--muted); margin: -2px 0 0; font-size: 15px; }
.tagline { text-align: center; color: #5D6D7E; font-style: italic; margin: 6px 0 8px; }
.error { color: var(--danger); font-size: 14px; margin: 4px 0 0; min-height: 18px; }
.privacy-link { text-align: center; font-size: 13px; color: var(--muted); margin-top: 8px; }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px;
    background: #fff; border-bottom: 1px solid var(--line); }
.logo { font-weight: 700; color: var(--green); font-size: 18px; flex: none; }
.tabs { display: flex; gap: 4px; background: var(--line); border-radius: 10px; padding: 3px;
    min-width: 0; overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: transparent; color: var(--text-2); font-weight: 600; font-size: 14px; padding: 7px 14px;
    border-radius: 8px; white-space: nowrap; flex: none; }
.tab.active { background: #fff; }
.who { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#logout-btn { flex: none; }

/* Board toolbar (search / filters / sort / new) */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 18px 0; }
.toolbar .search { width: 220px; max-width: 100%; }
.filter { color: var(--text-2); max-width: 100%; }

/* Board */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 14px 18px 18px; align-items: start; }
.column { background: #fff; border-radius: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.05); overflow: hidden; min-height: 120px; min-width: 0; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px; color: #fff; }
.col-title { font-size: 15px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-head .count { background: rgba(255,255,255,.28); border-radius: 10px; padding: 2px 9px; font-size: 12px; font-weight: 700; }
.col-head .count.over { background: var(--danger); }
.col-head .plus { color: #fff; font-size: 20px; font-weight: 700; line-height: 1; padding: 4px 8px; border-radius: 8px; }
.col-head .plus:hover { background: rgba(255,255,255,.2); }
.col-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.col-body.drop-end { box-shadow: inset 0 -3px 0 var(--green); }
.empty { color: var(--faint); font-size: 14px; text-align: center; padding: 14px 0; }

/* Card */
.card { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--line);
    border-radius: 9px; padding: 9px 11px; cursor: pointer; display: flex; align-items: center; gap: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06); min-width: 0; }
.card:hover { border-color: #CDD2D8; }
.card.overdue { border-left-color: var(--danger); }
.card.dragging { opacity: .45; }
.card.drop-before { box-shadow: 0 -3px 0 var(--green); }
.tbadge { width: 22px; height: 22px; border-radius: 5px; color: #fff; font-size: 11px; font-weight: 700;
    display: grid; place-items: center; flex: 0 0 auto; }
.card .who { color: #5D6D7E; font-weight: 700; font-size: 13px; flex: none; }
.card .title { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .lock { font-size: 12px; }
.card .dl { font-size: 12px; color: var(--muted); white-space: nowrap; }
.card .dl.overdue, .drill-row .dl.overdue { color: var(--danger); font-weight: 600; }
.card .clip { font-size: 13px; padding: 2px 4px; border-radius: 6px; }
.card .clip:hover { background: var(--bg); }
.card .subs { font-size: 11px; color: var(--muted); white-space: nowrap; }
.card .subs.done { color: var(--green); font-weight: 600; }

/* Overblik (dashboard) */
.dashboard { padding: 14px 18px 20px; display: flex; flex-direction: column; gap: 20px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { background: #fff; border-radius: 14px; padding: 18px; box-shadow: 0 2px 10px rgba(0,0,0,.05);
    text-align: left; display: flex; flex-direction: column; transition: transform .06s, box-shadow .12s; }
.stat:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.10); }
.stat .n { font-size: 32px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.warn .n { color: var(--danger); }
.panel { background: #fff; border-radius: 14px; padding: 18px; box-shadow: 0 2px 10px rgba(0,0,0,.05); min-width: 0; }
.panel h3, .ptitle { margin: 0 0 14px; font-size: 16px; }
.bar-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 4px 0; margin-bottom: 5px; text-align: left; border-radius: 6px; }
.bar-row .lab { width: 130px; flex: none; font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { flex: 1; background: var(--bg); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-row .fill { display: block; height: 100%; border-radius: 6px; }
.bar-row .val { width: 30px; text-align: right; font-size: 13px; font-weight: 600; color: var(--muted); }
.bar-row:hover .lab { color: var(--green); }
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.drill-head { display: flex; align-items: center; gap: 14px; }
.drill-head h3 { margin: 0; font-size: 17px; }
.drill-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 4px; text-align: left;
    border-bottom: 1px solid var(--bg); border-radius: 0; }
.drill-row:hover { background: var(--bg); border-radius: 8px; }
.drill-row .tbadge { width: 24px; height: 24px; }
.drill-row .who { color: #5D6D7E; font-weight: 700; font-size: 13px; width: 34px; flex: none; }
.drill-row .title { flex: 1; min-width: 0; font-size: 14px; }
.drill-row .ph { font-size: 12px; color: var(--muted); }
.drill-row .dl { font-size: 12px; color: var(--muted); width: 64px; text-align: right; flex: none; }

/* Modal — the OVERLAY scrolls, never the modal itself. Centered while it
   fits (margin:auto in flex), grows from the top when taller than the
   screen — same behavior in every browser, no clipped top, one scrollbar. */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4);
    display: flex; justify-content: center; align-items: flex-start;
    overflow-y: auto; padding: 28px 14px; z-index: 50; overscroll-behavior: contain; }
.modal { background: #fff; border-radius: 16px; padding: 22px 22px 0;
    width: min(640px, 100%); margin: auto;
    display: flex; flex-direction: column; gap: 6px; }
.m-heading { margin: 0 0 4px; font-size: 18px; outline: none; }
.modal label, .modal .flabel { font-size: 13px; color: var(--muted); margin-top: 10px; }
.modal label.row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.modal input[type=text], .modal input[type=date], .modal textarea, .modal select { width: 100%; }
.modal .row input[type=text], .modal .row select { width: auto; }
/* Textareas grow with their content via JS autosize (the drag handle is
   missing on iOS/Android); vertical resize stays for desktop mice. */
.modal textarea { resize: vertical; min-height: 76px; overflow: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); border-radius: 16px; padding: 7px 14px; font-size: 14px; font-weight: 600;
    background: #fff; color: var(--text-2); }
.chip.sel { color: #fff; border-color: transparent; }
.prereqs { display: flex; flex-direction: column; gap: 4px; }
.prereqs .pr { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.actions { margin-top: 14px; }
/* Sticky footer: Slet/Arkivér/Annuller/Gem stay reachable while the overlay scrolls. */
.modal-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    position: sticky; bottom: 0; background: #fff; z-index: 1;
    margin: 18px -22px 0; padding: 12px 22px 18px;
    border-top: 1px solid var(--line); border-radius: 0 0 16px 16px; }

/* Links on a task (modal) */
.mlinks { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.mlinks .lrow { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; }
.mlinks .lrow a, .mlinks .lrow .badlink { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: #22708F; text-decoration: none; }
.mlinks .lrow .badlink { color: var(--danger); }
.mlinks .lrow a:hover { text-decoration: underline; }
.mlinks .lrow .ren { color: var(--muted); }
.mhelp { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

/* Delopgaver — checklist in the modal */
.msubs { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.msubs .srow { display: flex; align-items: center; gap: 8px; }
.msubs .srow input[type="checkbox"] { width: 20px; height: 20px; margin: 0; accent-color: var(--green); flex: none; }
.modal .msubs .srow input[type="text"] { flex: 1; width: auto; min-width: 0; border: 1px solid transparent; background: transparent; padding: 4px 6px; }
.modal .msubs .srow input[type="text"]:hover, .modal .msubs .srow input[type="text"]:focus { border-color: var(--line); background: #fff; }
.msubs .srow.done input[type="text"] { text-decoration: line-through; color: var(--muted); }

/* Profil */
.profile { padding: 20px; display: flex; flex-direction: column; gap: 18px; max-width: 640px; }
.profile .panel { display: flex; flex-direction: column; gap: 4px; }
.profile label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.type-row, .arch-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--bg); min-width: 0; }
.swatch { width: 20px; height: 20px; border-radius: 5px; flex: 0 0 auto; }
.tname { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.type-form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.cswatch { width: 32px; height: 32px; padding: 0; border-radius: 8px; border: 3px solid transparent; }
.cswatch.sel { border-color: var(--text); }
.more { align-self: center; margin-top: 8px; }

/* Møde */
.meeting { padding: 20px; display: flex; flex-direction: column; gap: 16px; max-width: 860px; margin: 0 auto; width: 100%; }
.mhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.mtitle { margin: 0; font-size: 17px; }
.mnote { color: var(--muted); font-size: 13px; }
.mtoolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 4px 0 10px; }
.mtoolbar button { border: 1px solid var(--line); background: #fff; color: var(--text-2);
    border-radius: 8px; padding: 6px 11px; font-size: 14px; }
.mtoolbar button:hover:not(:disabled) { background: var(--bg); }
.agdoc { min-height: 360px; outline: none; border: 1px solid var(--line); border-radius: 10px;
    padding: 14px 16px; font-size: 16px; line-height: 1.55; overflow-wrap: anywhere; }
.agdoc:focus { border-color: var(--green); }
.agdoc h3 { margin: 14px 0 6px; font-size: 18px; }
.agdoc ul, .agdoc ol { margin: 6px 0; padding-left: 26px; }
.agdoc li { margin: 3px 0; }
/* Word-like level markers: • ◦ ▪ and 1. a. i. */
.agdoc ul ul { list-style-type: circle; }
.agdoc ul ul ul { list-style-type: square; }
.agdoc ol ol { list-style-type: lower-alpha; }
.agdoc ol ol ol { list-style-type: lower-roman; }
.agdoc blockquote { margin: 4px 0 4px 26px; }
.agdoc s, .agdoc strike, .agdoc del { color: var(--faint); }
.agdoc[contenteditable="false"] { background: var(--bg); color: var(--muted); }
.mlock { color: #8A5200; font-size: 14px; background: #FCEBD6; border-radius: 8px; padding: 7px 11px; margin: 0 0 8px; }

/* Idébank */
.ideas { padding: 20px; display: flex; flex-direction: column; gap: 18px; max-width: 760px; margin: 0 auto; width: 100%; }
.idea-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--bg); min-width: 0; }
.idea-row[draggable="true"] { cursor: grab; }
.idea-row.drag-over { box-shadow: 0 -2px 0 var(--green); }
.idea-row .prio { display: flex; flex-direction: column; flex: none; }
.idea-row .arrow { padding: 0 8px; font-size: 15px; line-height: 1.35; color: var(--muted); border-radius: 6px; }
.idea-row .arrow:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.idea-row .arrow:disabled { visibility: hidden; }
.idea-row .who { color: #5D6D7E; font-weight: 700; font-size: 13px; width: 30px; flex: 0 0 auto; }
.idea-row .itext { flex: 1; min-width: 0; font-size: 15px; overflow-wrap: anywhere; }
.idea-row .idate, .arch-row .idate { font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.idea-row .iactions { display: flex; flex: none; }
.idea-row .open { font-weight: 600; white-space: nowrap; }
.idea-row .promote { white-space: nowrap; }

/* Toast — always in the DOM (aria-live), shown by opacity. */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(8px);
    max-width: calc(100vw - 32px); background: #23272B; color: #fff; padding: 12px 20px; border-radius: 10px;
    font-size: 14px; z-index: 60; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { background: #8E2727; }
.toast:empty { padding: 0; }

@media (max-width: 900px) {
    .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .panels { grid-template-columns: 1fr; }
}

/* ---- Offline sync (OFFLINE-DESIGN §6) ------------------------------------------ */
.sync-chip { flex: 0 1 auto; min-width: 0; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 13px; font-weight: 600; border-radius: 14px; padding: 5px 12px; border: 1px solid transparent; }
.sync-chip.neutral { background: #E8EEF3; color: #34495E; }
.sync-chip.amber { background: #FCEBD6; color: #8A5200; border-color: #F2C98F; }
.sync-chip.red { background: #FBE3E3; color: #8E2727; border-color: #EDB4B4; }
.card .sync-mark { font-size: 13px; line-height: 1; flex: none; }
.card .sync-mark.pending { color: var(--muted); }
.card .sync-mark.issue { color: var(--danger); font-weight: 700; }
.sync-modal { gap: 10px; }
.sd-section h3 { font-size: 15px; margin: 6px 0; }
.sd-head h3 { margin: 6px 0; }
.sd-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 8px; }
.sd-title { font-size: 14px; overflow-wrap: anywhere; }
.sd-versions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sd-side { min-width: 0; }
.sd-label { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.sd-val { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border-radius: 6px; padding: 6px 8px; }
.sd-val.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.sd-actions { flex-wrap: wrap; }
.sd-pending { margin: 0; padding-left: 18px; font-size: 14px; display: flex; flex-direction: column; gap: 3px; overflow-wrap: anywhere; }
.sd-foot { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.sd-warn { background: #FBE3E3; color: #8E2727; border-radius: 8px; padding: 8px 11px; margin: 0; font-size: 14px; }
.ask-modal { width: min(440px, 100%); }
.ask-modal p { margin: 4px 0 0; }
.login-note { color: #8A5200; font-size: 14px; margin: 6px 0 0; min-height: 0; }
.login-note:empty { display: none; }
.mlock.draft { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: space-between; }
.offscreen { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }
/* Online-only actions are greyed offline; a tap still explains why (§3.3). */
body.is-offline .needs-online { opacity: .5; }

/* ---- PWA: update prompt + install hint (§8) --------------------------------------- */
.update-bar { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 80;
    display: flex; align-items: center; gap: 12px; background: #23272B; color: #fff;
    padding: 8px 10px 8px 16px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25);
    font-size: 14px; max-width: calc(100% - 20px); }
.install-hint { display: flex; align-items: center; gap: 10px; padding: 8px 20px; background: #E9F3EB;
    color: #24502B; font-size: 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.install-hint .link { color: #24502B; }

/* Phones */
@media (max-width: 560px) {
    .topbar { padding: 8px 12px; gap: 8px; }
    /* The status chip wraps to its own line under the tabs. */
    .topbar { flex-wrap: wrap; }
    .sync-chip { order: 10; flex: 1 1 100%; max-width: none; text-align: center; }
    .sd-versions { grid-template-columns: minmax(0, 1fr); }
    .install-hint { padding: 8px 12px; }
    /* Phones: the five tabs get the whole bar; "Log ud" lives under Profil. */
    .topbar .logo, .topbar .who, .topbar .grow, #logout-btn { display: none; }
    .tabs { flex: 1 1 auto; }
    .tab { flex: 1 1 auto; padding: 7px 6px; }
    .phone-only { display: flex !important; }
    .toolbar { padding: 10px 12px 0; }
    .toolbar .search { width: 100%; }
    .toolbar .filter { flex: 1 1 40%; }
    .board { grid-template-columns: minmax(0, 1fr); padding: 10px 12px 16px; }
    .dashboard, .profile, .meeting, .ideas { padding: 12px; }
    .panel { padding: 14px; }
    .bar-row .lab { width: 96px; }
    .drill-row .ph { display: none; }
    .idea-row { flex-wrap: wrap; }
    .idea-row .arrow { padding: 4px 12px; } /* thumb-sized priority buttons */
    .idea-row .itext { flex-basis: calc(100% - 90px); }
    .idea-row .idate { margin-left: 74px; }
    .idea-row .iactions { margin-left: auto; }
    .agdoc { min-height: 260px; padding: 12px; }
    /* Full-width sheet — no floating card to fight the keyboard. */
    .modal-overlay { padding: 0; }
    .modal { width: 100%; min-height: 100%; border-radius: 0; padding: 16px 16px 0; }
    .modal-actions { margin: 18px -16px 0; border-radius: 0;
        padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); }
}
