:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #1f2933;
  --muted: #6b7785;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Topbar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
.brand { font-weight: 600; color: var(--text); font-size: 16px; }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-link { padding: 6px 10px; border-radius: var(--radius); color: var(--text); }
.nav-link:hover { background: var(--bg); text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }

main.container { padding-top: 20px; padding-bottom: 60px; }

/* Headings */
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 6px; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }

/* Grids */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display:block; color:inherit; text-decoration:none; transition:background .15s, border-color .15s, transform .15s; }
a.kpi:hover { background:#eef3f7; border-color:#b9c5d1; transform:translateY(-1px); }
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 24px; font-weight: 600; margin-top: 4px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 14px; }
.table th { background: #f9fafb; font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table tr.row-overdue td { background: #fff7f5; }

.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 10px 4px 0; width: 200px; }
.kv td { padding: 4px 0; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.checkbox { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
select, textarea {
  font: inherit; color: var(--text); background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Buttons */
.btn { display: inline-block; padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  background: #fff; color: var(--text); cursor: pointer; font: inherit; text-decoration: none; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.95); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); }
.btn-small { padding: 4px 8px; font-size: 13px; }
.btn.active { background: var(--text); color: #fff; border-color: var(--text); }

/* Filterbar */
.filterbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; line-height: 1.6; border: 1px solid transparent; }
.badge-open    { background: #eff6ff; color: #1e40af; border-color: #dbeafe; }
.badge-progress{ background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-done    { background: #ecfdf5; color: #065f46; border-color: #d1fae5; }
.badge-archived{ background: #f3f4f6; color: #4b5563; border-color: #e5e7eb; }
.badge-low     { background: #f3f4f6; color: #4b5563; }
.badge-normal  { background: #eef2ff; color: #3730a3; }
.badge-high    { background: #fef3c7; color: #92400e; }
.badge-urgent  { background: #fee2e2; color: #991b1b; }

/* Flash */
.flash { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 12px; border: 1px solid var(--border); }
.flash-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-error   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.flash ul { margin: 4px 0 0 18px; }

/* Misc */
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.action-stack { display: flex; flex-direction: column; gap: 8px; }
.action-stack form { display: block; }
.action-stack .btn, .action-stack form .btn { width: 100%; text-align: center; }
.prose { white-space: normal; }
.prose.internal { background: #fffbea; border-left: 3px solid var(--warning); padding: 8px 12px; border-radius: 4px; }

/* Pagination */
.pagination { margin-top: 12px; display: flex; gap: 4px; flex-wrap: wrap; }
.pagination a, .pagination .page-current { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--text); }
.pagination .page-current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Footer */
.footer { padding: 20px 0; color: var(--muted); border-top: 1px solid var(--border); margin-top: 40px; background: var(--surface); }

/* Auth */
.auth-body { background: var(--bg); display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.auth-card { background: var(--surface); padding: 24px; border-radius: 8px; border: 1px solid var(--border); width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.auth-card h1 { margin-top: 0; font-size: 20px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card .btn { width: 100%; text-align: center; }

/* Kommentare */
.comment-list { list-style:none; padding:0; margin:0 0 1rem 0; }
.comment { padding:.6rem .8rem; border-left:3px solid #4a90e2; background:#f6f9fc; margin-bottom:.6rem; border-radius:0 4px 4px 0; }
.comment-meta { font-size:.85em; color:#555; margin-bottom:.25rem; }
.comment-body { white-space:pre-wrap; }
.comment-form textarea { width:100%; box-sizing:border-box; }

/* Warn / Danger Buttons & Flash */
.btn-warn { background:#f0ad4e; color:#fff; border-color:#eea236; }
.btn-warn:hover { background:#ec971f; }
.btn-danger { background:#d9534f; color:#fff; border-color:#d43f3a; }
.btn-danger:hover { background:#c9302c; }
.flash-warn { background:#fcf8e3; color:#8a6d3b; border:1px solid #faebcc; padding:.6rem .8rem; border-radius:4px; margin:.5rem 0; }

/* Vorschlagsbausteine fuer Beschreibungen */
.description-suggestions { margin: -.25rem 0 .5rem; }
.description-suggestions__title { font-size: .85rem; color: #666; margin-bottom: .35rem; }
.description-suggestions__list { display: flex; flex-wrap: wrap; gap: .35rem; }
.description-suggestion {
  display: inline-flex; align-items: center; gap: .4rem;
  background: #f0f4f8; border: 1px solid #d6dde3; color: #243; cursor: pointer;
  padding: .25rem .55rem; border-radius: 999px; font-size: .85rem;
  max-width: 100%; line-height: 1.2;
}
.description-suggestion:hover { background: #e3ecf3; border-color: #b8c6d0; }
.description-suggestion__count { font-weight: 600; color: #4a708b; font-size: .75rem; }
.description-suggestion__text  { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28rem; }

/* Standort-Panel im Aufgabenformular */
.sites-panel { margin: .5rem 0 1rem; }
.sites-panel--empty { color:#777; font-size:.9rem; padding:.4rem .6rem; background:#fafbfc; border:1px dashed #d6dde3; border-radius:6px; }
.sites-panel__title { font-weight:600; margin-bottom:.4rem; color:#243; }
.site-card { border:1px solid #d6dde3; background:#f7fafc; padding:.6rem .8rem; border-radius:6px; margin-bottom:.5rem; }
.site-card__head { font-size:1rem; margin-bottom:.25rem; }
.site-card__head code { background:#fff; padding:.05rem .35rem; border-radius:4px; border:1px solid #e1e6eb; }
.site-card__info { font-size:.9rem; margin-bottom:.25rem; }
.site-card__actions { margin-top:.4rem; }
.milestones { width:100%; border-collapse:collapse; margin:.3rem 0; font-size:.85rem; background:#fff; }
.milestones th, .milestones td { padding:.3rem .5rem; border-bottom:1px solid #eef1f4; text-align:left; }
.milestones th { background:#eef3f7; }
.milestones td:nth-child(4) { text-align:right; white-space:nowrap; }
.btn.btn-small { padding:.15rem .5rem; font-size:.8rem; }
.badge.badge-quartal { background:#e8f1fb; color:#1c4480; border:1px solid #cfe0f5; }
.site-card__planner { margin-top: 4px; }
.site-card__planner-ok   { color: #1a7f37; }
.site-card__planner-miss { color: #b54708; }
.site-card__gu { margin-top: 2px; color:#243; }
.site-card__gu strong { color:#1c4480; }
.milestones-toggle { margin:.4rem 0; }
.milestones-toggle > summary { cursor:pointer; user-select:none; font-size:.85rem; padding:.25rem .5rem; background:#eef3f7; border:1px solid #d6dde3; border-radius:4px; display:inline-block; }
.milestones-toggle[open] > summary { background:#dde7f0; }
.bulk-steps { list-style: decimal inside; padding: 0; }
.bulk-step { margin-bottom: 16px; }
.bulk-step h2 { margin-top: 0; }
.code-area { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.table-compact th, .table-compact td { padding: 4px 8px; font-size: 13px; vertical-align: top; }
.badge.badge-om { background:#fde68a; color:#7c2d12; border:1px solid #f59e0b; }
.table-wrap { overflow-x: auto; }
.table-compact tr.row-has-active td { background:#f1f5f9; color:#64748b; }
.table-compact tr.row-has-active code { color:#64748b; }

/* Allgemeine Mobile-Anpassungen für breite Tabellen */
.table { width: 100%; }
@media (max-width: 800px) {
  .table-responsive, table.table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Inline-Aktionen (z.B. Passwort zurücksetzen pro Benutzer) */
.inline-actions { display:inline-block; margin-right:6px; }
.inline-actions[open] summary { background:#e0e7ff; }
.inline-actions .form-inline { margin-top:6px; display:flex; flex-wrap:wrap; gap:4px; padding:6px; background:#f8fafc; border:1px solid #e5e7eb; border-radius:6px; }
.inline-actions .form-inline input { font-size:12px; padding:4px 6px; }
form.inline { display:inline; }
.right { text-align:right; }

/* === Bulk-Aktionen / Papierkorb / Vorlagen / Pause ====================== */
.bulkbar {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
  background: #fff8e6; border: 1px solid #f5d97a; border-radius: 6px;
  padding: .5rem .75rem; margin-bottom: .75rem;
  position: sticky; top: 0; z-index: 5;
}
.bulkbar .bulk-inline { display: inline-flex; align-items: center; gap: .25rem; }
.bulkbar select, .bulkbar input[type=date] { padding: .2rem .4rem; }
.btn.btn-warn { background: #fde2e2; color: #8a1f11; border-color: #f3b6b1; }
.btn.btn-warn:hover { background: #f8c2bd; }
.row-muted { opacity: .55; }
.badge.badge-paused { background: #eef3f7; color: #1c4480; border: 1px solid #c7d6e8; }
.table-wrap { overflow-x: auto; }
.page-header-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
hr.full { grid-column: 1 / -1; border: 0; border-top: 1px solid #e5e7eb; margin: .5rem 0; }
/* Reminder-Overlay (Dialog für neuen Erinnerungstermin) */
.reminder-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.reminder-dialog {
  background: var(--surface); border-radius: 8px; padding: 20px 22px;
  max-width: 460px; width: 100%; box-shadow: 0 20px 40px rgba(0,0,0,.25);
}
.reminder-dialog h2 { margin: 0 0 .4rem; font-size: 1.1rem; }
.reminder-dialog p  { margin: 0 0 1rem; color: var(--muted); font-size: .9rem; }
.reminder-dialog__field { display: block; font-size: .85rem; color: var(--muted); }
.reminder-dialog__field input[type="date"] {
  display: block; margin-top: .25rem; width: 100%;
  padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 6px;
  font-size: 1rem;
}
.reminder-dialog__quick { display: flex; flex-wrap: wrap; gap: .35rem; margin: .75rem 0 1rem; }
.reminder-dialog__quick button {
  background: #eef3f7; border: 1px solid #d6dde3; color: var(--text);
  padding: .25rem .6rem; border-radius: 4px; font-size: .8rem; cursor: pointer;
}
.reminder-dialog__quick button:hover { background: #dde7f0; }
.reminder-dialog__actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* Eskalation: dicke rote Banderole + auffälliges Badge + Zeilen-Hervorhebung */
.escalation-banner {
  background: #b91c1c;
  color: #fff;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 14px 18px;
  border-radius: 6px;
  margin: 0 0 16px;
  border: 3px solid #7f1d1d;
  box-shadow: 0 2px 6px rgba(185, 28, 28, .25);
  text-transform: uppercase;
  font-size: 1rem;
}
.badge.badge-escalation {
  background: #b91c1c;
  color: #fff;
  border: 2px solid #7f1d1d;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
tr.row-escalated > td {
  background: #fef2f2;
  box-shadow: inset 6px 0 0 0 #b91c1c;
}
tr.row-escalated.row-overdue > td { background: #fee2e2; }

/* Laufzeit-Statistik */
.stats-filter { display: flex; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.stats-bars th { text-align: left; width: 9rem; font-weight: 500; }
.stats-bar-cell { width: 100%; }
.stats-bar-num  { white-space: nowrap; text-align: right; }
.stats-bar {
  background: #eef2f7; border-radius: 4px; height: 14px; overflow: hidden;
}
.stats-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}
