/* Offene Punkte Liste – Gestaltung
   Farblogik: Blau = offen, Rot = überfällig, Grün = erledigt.
   Priorität: Rot (1–2) → Orange (3–4) → Gelb (5–6) → Blaugrün (7–8) → Grau (9–10). */
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --navy: #1e3a5f;
  --navy-2: #274b75;
  --primary: #2563eb;
  --primary-d: #1d4ed8;

  --open: #2563eb;      --open-bg: #dbeafe;
  --over: #dc2626;      --over-bg: #fee2e2;
  --done: #16a34a;      --done-bg: #dcfce7;
  --admin: #7c3aed;     --admin-bg: #ede9fe;

  --p-crit: #b91c1c; --p-high: #ea580c; --p-mid: #ca8a04; --p-low: #0d9488; --p-min: #94a3b8;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.right { text-align: right; }
.spacer { flex: 1; }

/* Kopfzeile */
header#topbar { background: linear-gradient(90deg, var(--navy), var(--navy-2)); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem; position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 6px rgba(0,0,0,.15); flex-wrap: wrap; }
header .brand { color: #fff; font-weight: 600; display: flex; align-items: center; gap: .6rem; font-size: 1.05rem; }
header .brand:hover { text-decoration: none; }
.logo { background: #4ade80; color: var(--navy); font-weight: 800; border-radius: 7px; padding: .1rem .45rem; font-size: .85rem; letter-spacing: .04em; }
header nav { margin-left: auto; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
header nav a:not(.btn) { color: #cbd5e1; padding: .35rem .7rem; border-radius: 7px; }
header nav a:not(.btn):hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
header nav a.active:not(.btn) { background: rgba(255,255,255,.16); color: #fff; }
#nav-user::before { content: "👤 "; }

main { max-width: 1280px; margin: 0 auto; padding: 1.25rem; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1rem; border: 1px solid var(--line); }
.narrow { max-width: 720px; margin-left: auto; margin-right: auto; }

/* Formulare */
label { display: block; font-weight: 500; margin-bottom: .9rem; font-size: .92rem; }
input, select, textarea { display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: var(--primary); }
input:disabled { background: #f8fafc; color: var(--muted); }
textarea { resize: vertical; }
label small { font-weight: 400; }
#inv label.check { margin-bottom: 1rem; }
label.check { display: flex; align-items: center; gap: .45rem; font-weight: 400; margin: 0; white-space: nowrap; }
label.check input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .75rem; margin: 0 0 1rem; }
legend { font-weight: 500; font-size: .92rem; padding: 0 .3rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 1rem; }
.form-error { background: var(--over-bg); color: #991b1b; border: 1px solid #fecaca; padding: .55rem .8rem; border-radius: 8px; margin-bottom: 1rem; }
.form-error[hidden] { display: none; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }

.pick { display: flex; flex-wrap: wrap; gap: .4rem; }
.pick-item { margin: 0; font-weight: 400; }
.pick-item input { position: absolute; opacity: 0; width: 0; }
.pick-item span { display: inline-block; padding: .3rem .75rem; border: 1px solid #cbd5e1; border-radius: 999px; cursor: pointer; background: #f8fafc; user-select: none; }
.pick-item input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.pick-item input:checked + span::before { content: "✓ "; }
.pick-item input:focus-visible + span { outline: 2px solid #93c5fd; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid #cbd5e1; background: #fff; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none !important; }
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-success { background: var(--done); border-color: var(--done); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #fff; border-color: #fca5a5; color: var(--over); }
.btn-danger:hover { background: var(--over-bg); }
.btn-sm { padding: .35rem .75rem; font-size: .9rem; }
.btn-block { width: 100%; margin-top: .25rem; }
header .btn-primary { background: #4ade80; border-color: #4ade80; color: var(--navy); }
header .btn-primary:hover { background: #86efac; }
button.link { background: none; border: 0; color: var(--primary); cursor: pointer; padding: .1rem .25rem; font: inherit; font-size: .88rem; }
button.link:hover { text-decoration: underline; }
button.link.danger { color: var(--over); }

/* Badges */
.badge { display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.st-offen { background: var(--open-bg); color: #1e40af; }
.badge.st-ueberfaellig { background: var(--over); color: #fff; }
.badge.st-erledigt { background: var(--done-bg); color: #166534; }
.badge.st-admin { background: var(--admin-bg); color: var(--admin); }
.badge.st-inactive { background: #e2e8f0; color: #475569; }
.prio { display: inline-flex; align-items: center; justify-content: center; min-width: 1.9rem; height: 1.9rem; border-radius: 7px; font-weight: 700; color: #fff; font-size: .9rem; }
.p-crit { background: var(--p-crit); } .p-high { background: var(--p-high); } .p-mid { background: var(--p-mid); }
.p-low { background: var(--p-low); } .p-min { background: var(--p-min); }
.chip { display: inline-block; background: #eef2ff; color: #3730a3; border-radius: 999px; padding: .05rem .55rem; font-size: .82rem; margin: .1rem 0; white-space: nowrap; }
.count { background: #e2e8f0; color: #334155; border-radius: 999px; padding: 0 .5rem; font-size: .85rem; font-weight: 600; }
.due-hint { display: block; font-weight: 600; }
.due-hint.over { color: var(--over); }
.due-hint.soon { color: var(--p-high); }

/* Kennzahlen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-left: 5px solid; border-radius: var(--radius); padding: .8rem 1rem; text-align: left; font: inherit; color: inherit; box-shadow: var(--shadow); display: flex; flex-direction: column; }
button.stat { cursor: pointer; }
button.stat:hover { transform: translateY(-1px); }
.stat b { font-size: 1.7rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .88rem; }
.stat.st-offen { border-left-color: var(--open); } .stat.st-offen b { color: var(--open); }
.stat.st-ueberfaellig { border-left-color: var(--over); } .stat.st-ueberfaellig b { color: var(--over); }
.stat.st-erledigt { border-left-color: var(--done); } .stat.st-erledigt b { color: var(--done); }
.stat.st-mine { border-left-color: #6366f1; } .stat.st-mine b { color: #4f46e5; }
.stat.st-total { border-left-color: var(--navy); } .stat.st-total b { color: var(--navy); }
.stat.sel { outline: 2px solid currentColor; background: #f8fafc; }
.stat.st-offen.sel { outline-color: var(--open); } .stat.st-ueberfaellig.sel { outline-color: var(--over); }
.stat.st-erledigt.sel { outline-color: var(--done); } .stat.st-mine.sel { outline-color: #6366f1; }

/* Werkzeugleiste */
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .75rem; }
.toolbar input, .toolbar select { margin: 0; width: auto; }
.toolbar input[type=search] { flex: 1; min-width: 220px; }

/* OPL-Tabelle */
table { width: 100%; border-collapse: collapse; }
table.opl { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
table.opl th { background: #f8fafc; text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .65rem .7rem; border-bottom: 1px solid var(--line); }
table.opl td { padding: .65rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.opl tbody tr { cursor: pointer; border-left: 5px solid transparent; }
table.opl tbody tr:hover { background: #f1f5ff; }
table.opl tbody tr:focus { outline: 2px solid #93c5fd; outline-offset: -2px; }
tr.row-offen td:first-child { box-shadow: inset 5px 0 0 var(--open); }
tr.row-ueberfaellig td:first-child { box-shadow: inset 5px 0 0 var(--over); }
tr.row-erledigt td:first-child { box-shadow: inset 5px 0 0 var(--done); }
tr.row-ueberfaellig { background: #fff5f5; }
tr.row-erledigt td { color: var(--muted); }
tr.row-erledigt .desc { text-decoration: line-through; text-decoration-color: #cbd5e1; }
td.num { font-weight: 700; white-space: nowrap; padding-left: 1rem !important; }
td.desc { white-space: pre-wrap; word-break: break-word; max-width: 420px; }
td.due { white-space: nowrap; }
td.cc { color: var(--muted); text-align: center; }
.empty { text-align: center; padding: 2.5rem; color: var(--muted); }
.empty .btn { margin-top: 1rem; }

/* Detail */
.back { display: inline-block; margin-bottom: .75rem; }
.detail { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1rem; align-items: start; }
.detail-main { border-top: 5px solid var(--open); }
.status-border-ueberfaellig { border-top-color: var(--over); }
.status-border-erledigt { border-top-color: var(--done); }
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.detail-head h1 { margin: 0; }
.detail-head div { display: flex; gap: .4rem; align-items: center; }
dl.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .5rem 1rem; margin: 0 0 1.25rem; padding: .75rem; background: #f8fafc; border-radius: 8px; }
dl.meta dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
dl.meta dd { margin: 0; font-weight: 500; }

.comment { border-left: 3px solid #cbd5e1; padding: .5rem .75rem; margin-bottom: .6rem; background: #f8fafc; border-radius: 0 8px 8px 0; }
.comment.mine { border-left-color: var(--primary); background: #eff6ff; }
.comment-head { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.comment-head button { margin-left: auto; }
.comment-body { white-space: pre-wrap; word-break: break-word; margin-top: .2rem; }
#cf textarea { margin-top: .5rem; }
.history { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.history summary { cursor: pointer; color: var(--muted); font-weight: 500; }
.history ul { list-style: none; padding: 0; margin: .5rem 0 0; font-size: .88rem; }
.history li { padding: .45rem 0; border-bottom: 1px dashed var(--line); }

/* Admin */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
table.simple th { text-align: left; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.simple td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users tr.inactive td { opacity: .55; }
td.acts { white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.linkbox { margin-top: 1rem; background: var(--done-bg); border: 1px solid #86efac; border-radius: 8px; padding: .75rem; }
.linkbox p { margin: 0 0 .5rem; }
.linkrow { display: flex; gap: .5rem; }
.linkrow input { margin: 0; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

/* Anmeldung */
.auth-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 420px; border-top: 5px solid var(--navy); }
.auth-logo { text-align: center; margin-bottom: .5rem; }
.auth-logo .logo { font-size: 1.3rem; padding: .25rem .7rem; background: var(--navy); color: #4ade80; }
.auth-card h1 { text-align: center; margin-bottom: .25rem; }
.auth-card > .muted { text-align: center; margin-top: 0; }

/* Hinweis-Toast */
#toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(calc(100% + 2rem)); visibility: hidden; background: var(--navy); color: #fff; padding: .65rem 1.1rem; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); transition: transform .25s, visibility .25s; z-index: 50; }
#toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
#toast.err { background: var(--over); }
#toast.warn { background: var(--p-high); }

/* Mobil: Tabelle als Karten */
@media (max-width: 860px) {
  .detail, .admin-grid { grid-template-columns: 1fr; }
  main { padding: .75rem; }
  table.opl, table.opl tbody, table.opl tr, table.opl td { display: block; }
  table.opl thead { display: none; }
  table.opl { background: none; box-shadow: none; border: 0; }
  table.opl tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .6rem; box-shadow: var(--shadow); padding: .4rem .6rem; }
  tr.row-offen { border-left: 5px solid var(--open) !important; }
  tr.row-ueberfaellig { border-left: 5px solid var(--over) !important; }
  tr.row-erledigt { border-left: 5px solid var(--done) !important; }
  table.opl td { border: 0; padding: .2rem 0; display: flex; gap: .5rem; max-width: none; }
  table.opl td:first-child { box-shadow: none !important; padding-left: 0 !important; }
  table.opl td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; min-width: 110px; }
  table.opl td.cc:empty { display: none; }
  td.due { white-space: normal; }
  .due-hint { display: inline; margin-left: .3rem; }
  .toolbar select { flex: 1; }
}
[hidden] { display: none !important; }
