:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --border: #e4e7ef;
  --text: #1b1f2e;
  --muted: #6b7288;
  /* MedNota: Teal = primary color (surfaces, buttons, focus), blue = secondary color (links, text accents) */
  --primary: #17a5ae;
  --primary-hover: #1294a0;
  --primary-soft: #e2f4f5;
  --primary-ink: #0b6a71;       /* teal text on a light background (contrast ≥ 4.5) */
  --on-primary: #06262a;        /* text on teal surfaces */
  --ring: rgba(23, 165, 174, .28);
  --secondary: #135f97;
  --secondary-hover: #0e4a77;
  --secondary-soft: #e4eef7;
  --danger: #dc2626;
  --muss: #dc2626;     --muss-bg: #fee9e9;
  --sollte: #a16207;   --sollte-bg: #fdf0b8;
  --kann: #1d4ed8;     --kann-bg: #dbe8ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 16px rgba(20, 24, 40, .05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1c202b;
    --border: #2a2f3d;
    --text: #e8eaf2;
    --muted: #8d95ab;
    --primary: #22b5be;
    --primary-hover: #3ec6ce;
    --primary-soft: #0f3236;
    --primary-ink: #6fd6dc;
    --on-primary: #041b1e;
    --ring: rgba(34, 181, 190, .38);
    --secondary: #6aa9dd;
    --secondary-hover: #8dbfe9;
    --secondary-soft: #14283b;
    --muss: #ff7a7a;   --muss-bg: #3a1c20;
    --sollte: #fbd34d; --sollte-bg: #3a3112;
    --kann: #8ab4ff;   --kann-bg: #1a2a4d;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #171a23;
  --surface-2: #1c202b;
  --border: #2a2f3d;
  --text: #e8eaf2;
  --muted: #8d95ab;
  --primary: #22b5be;
  --primary-hover: #3ec6ce;
  --primary-soft: #0f3236;
  --primary-ink: #6fd6dc;
  --on-primary: #041b1e;
  --ring: rgba(34, 181, 190, .38);
  --secondary: #6aa9dd;
  --secondary-hover: #8dbfe9;
  --secondary-soft: #14283b;
  --muss: #ff7a7a;   --muss-bg: #3a1c20;
  --sollte: #fbd34d; --sollte-bg: #3a3112;
  --kann: #8ab4ff;   --kann-bg: #1a2a4d;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.logo {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 20%, var(--secondary)); color: #fff;
}
.user {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 14px 4px 4px; cursor: pointer;
}
.user:hover { background: var(--surface-2); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-ink); font-weight: 650; font-size: 13px;
}

/* Layout */
.container { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }
.toolbar { display: flex; gap: 12px; align-items: center; }
.search {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0 14px; color: var(--muted);
}
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.search input { flex: 1; border: 0; outline: 0; background: none; padding: 11px 0; color: var(--text); }
.meta { color: var(--muted); font-size: 13px; margin: 14px 4px 8px; min-height: 20px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 10px 16px; cursor: pointer; font-weight: 550; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--muss-bg); }

/* List */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
table.list { width: 100%; border-collapse: collapse; }
.list th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; padding: 12px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.list td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.list tr:last-child td { border-bottom: 0; }
.c-drag { width: 32px; padding-right: 0 !important; }
.c-id { width: 120px; white-space: nowrap; }
.c-prio { width: 100px; }
.c-status { width: 140px; }
.c-who { width: 140px; }
.c-date { width: 130px; }
.c-act { width: 84px; }

tr.cat td {
  background: var(--surface-2); padding: 10px 14px;
  font-weight: 650; font-size: 13px; letter-spacing: .01em;
}
tr.cat .count {
  margin-left: 8px; font-weight: 550; color: var(--muted);
  background: var(--border); border-radius: 999px; padding: 1px 8px; font-size: 12px;
}
tr.cat.drop-target td { background: var(--primary-soft); outline: 2px dashed var(--primary); outline-offset: -3px; }

tr.req { cursor: pointer; transition: background .12s; }
tr.req:hover { background: var(--surface-2); }
tr.req.dragging { opacity: .35; }
tr.req.drop-before td { box-shadow: inset 0 3px 0 var(--primary); }
tr.req.drop-after td { box-shadow: inset 0 -3px 0 var(--primary); }
.no-drag .handle { display: none; }

.handle { color: var(--muted); cursor: grab; display: inline-grid; padding: 2px; opacity: .5; }
tr.req:hover .handle { opacity: 1; }
.handle:active { cursor: grabbing; }

.id { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; font-weight: 550; }
.req-text { font-weight: 500; white-space: pre-wrap; word-break: break-word; }
.req-remark { color: var(--muted); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px; }
.date { font-size: 13px; color: var(--muted); }
.date small { display: block; font-size: 12px; opacity: .85; }
mark { background: #fde68a; color: #1b1f2e; border-radius: 3px; padding: 0 1px; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 650;
}
.badge.muss   { color: var(--muss);   background: var(--muss-bg); }
.badge.sollte { color: var(--sollte); background: var(--sollte-bg); }
.badge.kann   { color: var(--kann);   background: var(--kann-bg); }

.actions { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
tr.req:hover .actions, tr.req:focus-within .actions { opacity: 1; }
.icon-btn {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.icon-btn.danger:hover { background: var(--muss-bg); color: var(--danger); }

.empty { padding: 56px 24px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* Dialog */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(580px, calc(100vw - 32px));
  background: var(--surface); color: var(--text);
  box-shadow: 0 24px 64px rgba(10, 12, 24, .35);
  max-height: calc(100vh - 48px); overflow: hidden;
}
dialog::backdrop { background: rgba(15, 17, 28, .5); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 4px; }
.modal-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.modal-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.modal-body { padding: 14px 24px 8px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px 22px; }
.modal-foot .spacer { flex: 1; }

.detail-text { font-size: 15px; font-weight: 500; white-space: pre-wrap; word-break: break-word; margin: 6px 0 18px; }
.facts { display: grid; grid-template-columns: 120px 1fr; gap: 10px 16px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field > small { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; outline: 0;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.error { color: var(--danger); font-size: 13px; margin: 0 0 8px; min-height: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .topbar { padding: 12px 16px; }
  .container { padding: 16px 12px 48px; }
  .c-who, .c-date, .c-drag, .c-status { display: none; }
  .actions { opacity: 1; }
  .row2 { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
}

/* Status, Version */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 550; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, #8d95ab); }
.status.offen { --dot: #8d95ab; }
.status.todo { --dot: #8b5cf6; }
.status.in_bearbeitung { --dot: #f97316; }
.status.abgeschlossen { --dot: #16a34a; }
.ver { margin-left: 6px; font-size: 11px; font-weight: 650; color: var(--secondary); background: var(--secondary-soft); border-radius: 6px; padding: 1px 6px; }
.opt { font-weight: 400; color: var(--muted); font-style: normal; }
.opt-hint { margin-left: 10px; color: var(--muted); font-size: 13px; }

/* More fields */
.more-link {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; cursor: pointer;
  color: var(--secondary); font-weight: 600; font-size: 14px; padding: 2px 0; margin: -4px 0 14px;
}
.more-link:hover { color: var(--secondary-hover); }
.more-link .chev { transition: transform .15s; }
.more-link[aria-expanded="true"] .chev { transform: rotate(180deg); }
.extra { border-top: 1px dashed var(--border); padding-top: 16px; }
.extra[hidden] { display: none; }
.field input:disabled { background: var(--surface-2); color: var(--muted); }

/* Dropdowns */
.dd { position: relative; }
.dd-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left;
  padding: 9px 12px; min-height: 42px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; outline: 0;
}
.dd-btn:focus, .dd.open .dd-btn, .combo input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.chev { color: var(--muted); flex: none; }
.combo input { padding-right: 38px; }
.dd-toggle {
  position: absolute; right: 4px; top: 4px; width: 34px; height: 34px; border: 0; background: none;
  border-radius: 8px; cursor: pointer; display: grid; place-items: center;
}
.dd-toggle:hover { background: var(--surface-2); }
.dd-pop {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(10, 12, 24, .25); padding: 4px; max-height: 220px; overflow: auto;
}
.dd.open .dd-pop { display: block; }
.dd.up .dd-pop { top: auto; bottom: calc(100% + 4px); }
.dd-opt { padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.dd-opt:hover, .dd-opt.active { background: var(--primary-soft); }
.dd-opt.sel { background: var(--surface-2); font-weight: 600; }
.dd-opt.new { color: var(--secondary); font-weight: 600; }
.dd-empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* Placeholders, filters, checkbox, detail texts */
.ph { color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.filters .dd { flex: 0 1 190px; min-width: 150px; }
.filters .dd-btn { min-height: 38px; padding: 5px 12px; font-size: 14px; }
.filters .dd.filter .dd-pop { min-width: 190px; }
.link-btn { background: none; border: 0; color: var(--secondary); font-weight: 600; font-size: 14px; cursor: pointer; padding: 6px 4px; }
.link-btn:hover { color: var(--secondary-hover); }
.link-btn[hidden] { display: none; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.modal-foot { align-items: center; }
h3.sec { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.detail-remark { margin: 0 0 18px; white-space: pre-wrap; word-break: break-word; color: var(--text); }

/* Requirement text: max. 3 lines, then "…" */
.req-text {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3;
  overflow: hidden; overflow-wrap: anywhere;
}

/* Sortable column headers */
.th-sort {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; border-radius: 4px;
}
.th-sort:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.th-sort:hover { color: var(--text); }
.arrow::after { content: "↕"; opacity: 0; font-size: 13px; }
.th-sort:hover .arrow::after { opacity: .45; }
th[aria-sort="ascending"] .arrow::after { content: "↑"; opacity: 1; color: var(--secondary); }
th[aria-sort="descending"] .arrow::after { content: "↓"; opacity: 1; color: var(--secondary); }
th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--text); }

/* Lazy loading, highlighting */
.sentinel { height: 1px; }
.sentinel span { display: none; }
.sentinel.loading { height: auto; padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.sentinel.loading span { display: block; }
tr.req.flash td { animation: flash 1.8s ease-out; }
@keyframes flash { from { background: var(--primary-soft); } to { background: transparent; } }
.meta .link-btn { padding: 0 2px; font-size: 13px; }

/* Dialog: fixed header and footer, scrolling content */
dialog[open] { display: flex; flex-direction: column; }
#dialogBody { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-head, .modal-foot { flex: none; }
.modal-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.modal-foot { border-top: 1px solid var(--border); margin-top: 8px; }
.modal-foot .warn { color: var(--danger); font-weight: 600; font-size: 14px; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-solid:hover { filter: brightness(.92); background: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary:disabled:hover { background: var(--primary); }

/* Input elements in the modal */
.ctl {
  width: 100%; padding: 10px 12px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; outline: 0;
}
.ctl:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
textarea.ctl { resize: vertical; min-height: 84px; }

/* Blocks (requirement, remarks) and facts */
.fact.editing .lbl { color: var(--text); font-weight: 600; }
.facts { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.fact { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; align-items: start; padding: 4px 0; }
.fact .lbl { display: flex; align-items: center; gap: 6px; color: var(--muted); padding-top: 6px; }
.fact.editing .lbl { padding-top: 11px; font-weight: 600; }
.fact.ro .lbl { padding-top: 6px; }
.fact.ro .val { padding: 6px 0; }
.fact .val .dd { max-width: 340px; }
.extra { display: flex; flex-direction: column; gap: 2px; }
.extra[hidden] { display: none; }
.facts .more-link { margin: 4px 0 6px; align-self: flex-start; }

/* Clickable values */
.pen { display: inline-grid; color: var(--muted); opacity: 0; transition: opacity .12s; }
.pen svg { width: 13px; height: 13px; }
.fact:hover .pen, .view:focus-visible .pen, .is-empty .pen { opacity: .8; }
.view {
  cursor: pointer; border: 1px solid transparent; border-radius: 8px; outline: 0;
  padding: 5px 8px; margin: -5px -8px; transition: background .12s;
}
.view:hover { background: var(--surface-2); }
.view:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.view .detail-text, .view .detail-remark { display: block; margin: 0; white-space: pre-wrap; word-break: break-word; }
.is-empty .view .ph { font-style: italic; }

/* Keyboard shortcut hints */
kbd {
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: 3px 6px; margin-left: 4px;
}
.btn.primary kbd { background: rgba(0, 0, 0, .1); border-color: rgba(0, 0, 0, .28); color: var(--on-primary); }
.search:focus-within kbd, .search:has(input:not(:placeholder-shown)) kbd { display: none; }
.link-btn kbd { margin-left: 6px; }

/* Header, theme switch */
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn.theme { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 999px; }

/* Status line with "Expand all" */
.meta-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.meta-row .meta { flex: 1; }
#expandBtn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; margin: 6px 4px 0 0; }
.c-id { width: 150px; }
.clip { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 600; vertical-align: middle; }
.clip svg { width: 13px; height: 13px; }

/* Expand all: complete text, wider table */
body.expanded .req-text { display: block; -webkit-line-clamp: unset; line-clamp: unset; overflow: visible; }

/* Multi-select in the filters */
.multi .dd-opt { display: flex; align-items: center; gap: 10px; }
.multi .dd-opt.sel { background: transparent; font-weight: inherit; }
.multi .dd-opt.active { background: var(--primary-soft); }
.dd-opt .box {
  flex: none; width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid var(--muted);
  display: grid; place-items: center; transition: background .1s;
}
.multi .dd-opt.sel .box { background: var(--primary); border-color: var(--primary); }
.multi .dd-opt.sel .box::after {
  content: ""; width: 8px; height: 4px; border: solid var(--on-primary); border-width: 0 0 2px 2px; transform: rotate(-45deg) translate(1px, -1px);
}
.multi-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-size: 12px; font-weight: 650; }

/* File attachments */
.files { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.files li { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.file-link { display: inline-flex; align-items: center; gap: 6px; color: var(--secondary); text-decoration: none; font-weight: 550; min-width: 0; }
.file-link span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-link:hover span.name { text-decoration: underline; }
.file-link svg { flex: none; width: 15px; height: 15px; }
.files .size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.files .tag { font-size: 11px; font-weight: 650; color: var(--secondary); background: var(--secondary-soft); border-radius: 6px; padding: 1px 6px; }
.files li.gone .name, .files li.gone .size { text-decoration: line-through; color: var(--muted); }
.files li .spacer { flex: 1; }
.files .icon-btn { width: 26px; height: 26px; }
.files .undo { font-size: 12px; padding: 0 4px; }
.drop {
  border: 1.5px dashed var(--border); border-radius: 10px; padding: 16px; text-align: center; cursor: pointer;
  color: var(--muted); font-size: 14px; outline: 0; transition: .12s;
}
.drop strong { color: var(--text); font-weight: 600; }
.drop u { color: var(--secondary); text-underline-offset: 2px; }
.drop small { display: block; margin-top: 4px; font-size: 12px; }
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--primary); background: var(--primary-soft); }
.val .link-btn.add-file { padding: 4px 0; }

/* Expand all: more room for the text */
body.expanded .c-id { width: 130px; }
body.expanded .c-prio { width: 95px; }
body.expanded .c-status { width: 125px; }
body.expanded .c-who { width: 110px; }
body.expanded .c-date { width: 100px; }
body.expanded .c-act { width: 76px; }
@media (max-width: 1100px) { body.expanded .c-who, body.expanded .c-date { display: none; } }

/* ---------- General ---------- */
[hidden] { display: none !important; }
.btn.block { width: 100%; justify-content: center; padding: 11px 16px; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn:disabled:hover { background: none; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.ph { color: var(--muted); }

/* Notices */
.notice { padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 0 0 14px; border: 1px solid transparent; }
.notice.ok { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 45%, transparent); }
.notice.warn { background: var(--sollte-bg); color: var(--text); border-color: color-mix(in srgb, var(--sollte) 40%, transparent); }
.notice.err { background: var(--muss-bg); color: var(--text); border-color: color-mix(in srgb, var(--muss) 40%, transparent); }

/* ---------- Header: project, user menu ---------- */
.brand { min-width: 0; }
.crumb {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 2px; padding: 4px 12px;
  border: 1px solid var(--border); border-radius: 999px; font-size: 14px; font-weight: 550;
  color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw;
}
button.crumb { font-family: inherit; background: none; cursor: pointer; }
button.crumb:not(.static):hover, button.crumb[aria-expanded="true"] { background: var(--surface-2); border-color: var(--primary); }
button.crumb.static { cursor: default; }
.crumb-wrap { position: relative; display: inline-flex; min-width: 0; }
.menu.left { right: auto; left: 0; max-height: 60vh; overflow: auto; }
.menu-item.current { font-weight: 650; color: var(--secondary); }
.crumb.static { border-color: transparent; padding-left: 4px; color: var(--muted); }
.crumb:not(.admin-tag)::before { content: "/"; color: var(--muted); margin-right: 2px; }
.crumb:not(.static)::before { content: none; }
.crumb.admin-tag { background: var(--secondary-soft); color: var(--secondary); border-color: transparent; padding: 2px 10px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.user-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(10, 12, 24, .22);
}
.menu-head { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); font-size: 13px; }
.menu-head span { color: var(--muted); }
.menu-item {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font-size: 14px; cursor: pointer; text-decoration: none;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--primary-soft); outline: 0; }

/* ---------- Notice without a project ---------- */
#pickerView { padding-top: 7vh; }

/* ---------- Sign-in ---------- */
.auth-body {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 420px at 8% -10%, color-mix(in srgb, var(--primary) 16%, transparent), transparent),
    radial-gradient(800px 420px at 100% 110%, color-mix(in srgb, var(--secondary) 14%, transparent), transparent),
    var(--bg);
}
.auth-card {
  width: min(430px, 100%); padding: 34px 32px 28px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 24px 64px rgba(10, 12, 24, .12);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand h1 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.auth-card h2 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.01em; }
.auth-sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.auth-links { margin: 16px 0 0; text-align: center; }
.auth-theme { position: fixed; top: 16px; right: 16px; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.error:empty { display: none; }
.auth-card .error { margin: -4px 0 12px; }

/* ---------- Admin area ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; padding: 10px 16px;
  color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); }
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-head h2 { margin: 0 0 2px; font-size: 20px; letter-spacing: -.01em; }
.admin-head .meta { margin: 0; min-height: 0; }
table.admin td { vertical-align: middle; }
.sub-line { color: var(--muted); font-size: 13px; margin-top: 1px; }
.c-act.wide { width: 140px; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.pill.on { background: var(--primary-soft); color: var(--primary-ink); }
.pill.wait { background: var(--sollte-bg); color: var(--sollte); }
.pill.off { background: var(--muss-bg); color: var(--muss); }
.chip { display: inline-block; margin: 1px 2px 1px 0; padding: 1px 9px; border-radius: 999px; background: var(--secondary-soft); color: var(--secondary); font-size: 12px; font-weight: 600; }
.you { margin-left: 4px; padding: 1px 6px; border-radius: 6px; background: var(--primary-soft); color: var(--primary-ink); font-size: 11px; font-weight: 650; }
.checks { display: flex; flex-direction: column; gap: 2px; max-height: 200px; overflow: auto; padding: 6px; border: 1px solid var(--border); border-radius: 10px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.check-row:hover { background: var(--primary-soft); }
.check-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.copy-row { display: flex; gap: 8px; }
select.ctl { appearance: auto; }
@media (max-width: 760px) {
  .tabs { overflow-x: auto; }
  .admin .c-act.wide { width: auto; }
  .crumb { max-width: 30vw; }
}

.auth-switch { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--border); text-align: center; font-size: 13px; }
.auth-switch a { color: var(--muted); text-decoration: none; }
.auth-switch a:hover { color: var(--secondary); text-decoration: underline; }

/* Wider requirement modal */
dialog.wide { width: min(986px, calc(100vw - 32px)); }
.fact[data-key="text"] textarea.ctl { min-height: 120px; }

/* Expand all: only the table gets wider, search and filters stay */
body.expanded .card { width: min(1760px, calc(100vw - 48px)); margin-left: calc((100% - min(1760px, 100vw - 48px)) / 2); }

/* Required fields */
.req-star { margin-left: 3px; color: var(--danger); font-weight: 700; }
.req-note { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.invalid .ctl, .invalid .dd-btn { border-color: var(--danger); }
.invalid .ctl:focus, .invalid .dd-btn:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }

/* Moving categories */
tr.cat[draggable="true"] { cursor: grab; }
tr.cat .cat-handle { margin-right: 8px; vertical-align: middle; }
body.no-cat-drag tr.cat .cat-handle { display: none; }
tr.cat.dragging { opacity: .45; }
tr.cat.drop-before td { box-shadow: inset 0 3px 0 var(--primary); }
tr.cat.drop-after td { box-shadow: inset 0 -3px 0 var(--primary); }
tr.cat.flash td { animation: flash 1.8s ease-out; }
body.dragging-cat tr.req { display: none; }

/* Admin: rows are clickable */
table.admin tbody tr { cursor: pointer; transition: background .12s; }
table.admin tbody tr:hover { background: var(--surface-2); }

/* MedNota logo */
.mn-logo { display: inline-block; height: 30px; aspect-ratio: 1987 / 454; flex: none; }
.mn-logo svg { display: block; width: 100%; height: 100%; }
.brand-sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px 0 4px; }
.auth-brand .mn-logo { height: 40px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --logo-blue: #5aa2dc; --logo-blue-2: #86b4de; --logo-teal-1: #3fb5bd; --logo-teal-2: #35a3ab; }
}
:root[data-theme="dark"] { --logo-blue: #5aa2dc; --logo-blue-2: #86b4de; --logo-teal-1: #3fb5bd; --logo-teal-2: #35a3ab; }

/* Language switch */
.lang-switch { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.lang-switch button { border: 0; background: none; padding: 5px 11px; border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .03em; cursor: pointer; }
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-ink); }
.auth-tools { position: fixed; top: 16px; right: 16px; display: flex; align-items: center; gap: 8px; }
.auth-tools .theme { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }

/* Requirement dialog: blue title with priority badge, requirement text with a colored label */
dialog.wide .modal-head h2 { display: flex; align-items: center; gap: 12px; font-size: 26px; font-weight: 750; letter-spacing: -.02em; color: var(--secondary); }
dialog.wide .modal-head .sub { margin-top: 4px; }
.head-prio { all: unset; display: inline-flex; cursor: pointer; border-radius: 999px; }
.head-prio:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.head-prio .badge, .head-prio > * { font-size: 13px; letter-spacing: 0; }
.fact[hidden] { display: none; }

/* Requirement and remarks: label above, full width */
.fact[data-key="text"], .fact[data-key="remark"] { display: block; padding: 0; }
.fact[data-key="text"] .lbl, .fact[data-key="remark"] .lbl,
.fact[data-key="text"].editing .lbl, .fact[data-key="remark"].editing .lbl { padding: 0 0 6px; }
.fact[data-key="text"] .lbl { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--primary-ink); }
.fact[data-key="text"] .val, .fact[data-key="remark"] .val { padding: 0; }

.fact[data-key="text"] {
  margin: 4px 0 14px;
}
.fact[data-key="text"] .detail-text { font-size: 14px; line-height: 1.5; font-weight: 400; color: var(--text); }

.fact[data-key="remark"] { margin-bottom: 14px; }
.fact[data-key="remark"] .detail-remark { color: var(--muted); font-size: 14px; line-height: 1.55; }

/* "More fields": whole row is clickable */
.facts > .more-link { margin: 8px 0 6px; align-self: stretch; width: 100%; padding: 8px 0; }
