:root {
  --petrol: #00646e;
  --petrol-dark: #00444c;
  --accent: #00a3a3;
  --bg: #eef1f3;
  --card: #ffffff;
  --text: #1c2529;
  --muted: #6a7880;
  --line: #d9dfe3;
  --danger: #c0392b;
  --st-offen: #c0392b;
  --st-in_bearbeitung: #d98200;
  --st-erledigt: #2e7d32;
  --st-fertig: #1565c0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

h1, h2 { margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--petrol); margin-bottom: 12px; }
.muted { color: var(--muted); font-size: .9rem; }

/* Kopfzeile */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
  padding: 10px 24px;
  background: var(--petrol-dark); color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.brand { color: #fff; text-decoration: none; font-size: 1.25rem; font-weight: 600; margin-right: auto; }
.brand-mark { background: var(--accent); padding: 2px 8px; border-radius: 3px; margin-right: 4px; letter-spacing: .05em; }
.project-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.project-picker label { font-size: .85rem; opacity: .8; }
.project-picker select { min-width: 240px; width: auto; max-width: 360px; }

main { max-width: 1500px; margin: 0 auto; padding: 20px 24px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 18px 20px; margin-bottom: 20px; }
.empty { text-align: center; padding: 60px 20px; }
.empty h2 { text-transform: none; letter-spacing: 0; font-size: 1.3rem; }

/* Formularelemente */
input, select, textarea {
  font: inherit; color: var(--text);
  padding: 7px 9px; border: 1px solid #b9c3c9; border-radius: 4px; background: #fff;
  width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--muted); }
label > * { font-weight: 400; color: var(--text); font-size: 15px; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  padding: 7px 14px; border-radius: 4px; border: 1px solid transparent;
}
.btn-primary { background: var(--petrol); color: #fff; }
.btn-primary:hover { background: var(--petrol-dark); }
.btn-light { background: #fff; color: var(--petrol-dark); border-color: #b9c3c9; }
.btn-light:hover { background: #f1f5f6; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-small { padding: 4px 10px; font-size: .85rem; }

.add-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; margin-bottom: 14px; }
.span-all { grid-column: 1 / -1; }

.employee-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-hint { margin-left: 12px; }
.notice { border-left: 5px solid var(--st-in_bearbeitung); margin-top: 0; }
#employees-view { max-width: 1080px; }
.tag { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .85rem; background: #e3eef0; color: var(--petrol-dark); }
.tag.extern { background: #fdebd0; color: #8a5200; }
a.btn { text-decoration: none; display: inline-block; }

/* Dashboard */
.topnav { display: flex; gap: 8px; }
#dashboard-view { max-width: 1200px; }
#dashboard-view h2 { margin-bottom: 12px; }
.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 24px; justify-content: space-between; }
.dash-head label { min-width: 260px; }
.stat-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-top: 5px solid var(--muted); border-radius: 6px; padding: 12px 16px; }
.stat strong { display: block; font-size: 2rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat[data-status=offen] { border-top-color: var(--st-offen); }
.stat[data-status=in_bearbeitung] { border-top-color: var(--st-in_bearbeitung); }
.stat[data-status=erledigt] { border-top-color: var(--st-erledigt); }
.stat[data-status=fertig] { border-top-color: var(--st-fertig); }
.dash-mine-head { margin-bottom: 12px; }
#dashboard-view .dash-mine-head h2 { margin: 0 auto 0 0; }
.inline-label { flex-direction: row; align-items: center; gap: 8px; }
.inline-label select { width: auto; min-width: 200px; }
.inline-check { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
.inline-check input { width: auto; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num.zero { color: #a9b4ba; }
.col-bar { width: 28%; min-width: 160px; }
.bar { display: flex; height: 14px; border-radius: 3px; overflow: hidden; background: #edf1f3; gap: 2px; }
.bar span[data-status=offen] { background: var(--st-offen); }
.bar span[data-status=in_bearbeitung] { background: var(--st-in_bearbeitung); }
.bar span[data-status=erledigt] { background: var(--st-erledigt); }
.bar span[data-status=fertig] { background: var(--st-fertig); }
tr.is-me td:first-child { font-weight: 700; }
tr.sum-row td { border-top: 2px solid var(--line); font-weight: 700; }
@media (max-width: 900px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Tabelle */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar input[type=search] { width: 260px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: .85rem; cursor: pointer;
  padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--text);
}
.chip.active { background: var(--petrol); border-color: var(--petrol); color: #fff; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #f6f8f9; white-space: nowrap; }
tbody tr:hover { background: #f6fafa; }
.col-nr { width: 60px; font-variant-numeric: tabular-nums; font-weight: 600; }
.col-date { width: 110px; white-space: nowrap; }
.col-desc { min-width: 200px; white-space: pre-wrap; overflow-wrap: anywhere; }
.col-status { width: 175px; }
.col-actions { width: 1%; white-space: nowrap; }
.col-actions .btn + .btn { margin-left: 6px; }
tr.editing, tbody tr.editing:hover { background: #eef7f7; }
tr.editing input { min-width: 110px; }
.badge { font-size: .75rem; color: var(--muted); margin-left: 6px; }

select.status {
  font-weight: 600; color: #fff; border: none; cursor: pointer; min-width: 155px;
  background-color: var(--muted);
}
select.status option { background: #fff; color: var(--text); }
select.status[data-status=offen] { background-color: var(--st-offen); }
select.status[data-status=in_bearbeitung] { background-color: var(--st-in_bearbeitung); }
select.status[data-status=erledigt] { background-color: var(--st-erledigt); }
select.status[data-status=fertig] { background-color: var(--st-fertig); }

/* Detailansicht: eine Lesespalte, oben die Aufgabe, darunter die Anhänge */
#detail-view { max-width: 1080px; }
#detail-view h2 { text-transform: none; letter-spacing: 0; font-size: 1.15rem; color: var(--text); margin: 0 0 8px; }
#detail-view h3 { font-size: .95rem; margin: 0 0 10px; color: var(--petrol-dark); }

.detail-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.detail-bar #save-state { margin-left: auto; }
.detail-title { margin-bottom: 16px; }
.detail-title h1 { font-size: 1.9rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.detail-title p { margin: 2px 0 0; }

.task { border-left: 5px solid var(--petrol); }
.description-field {
  font-size: 1.3rem; line-height: 1.4; font-weight: 600;
  border-color: transparent; padding: 6px 8px; margin: 0 -8px; width: calc(100% + 16px);
  resize: none; overflow: hidden;
}
.description-field:hover { border-color: var(--line); }
.autogrow { resize: none; overflow: hidden; }

.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
#detail-view .section-head h2 { margin: 0 auto 0 0; }
.section-head .hint { flex-basis: 100%; margin: 0; }
.block { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; }
.count {
  display: inline-block; min-width: 22px; padding: 0 7px; margin-left: 4px; border-radius: 999px;
  background: #e3eef0; color: var(--petrol-dark); font-size: .8rem; text-align: center;
}

.gallery { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.shot { margin: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.shot-open { display: block; width: 100%; padding: 0; border: none; background: #edf1f3; cursor: zoom-in; }
.shot-open:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.shot img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; }
.shot-foot { display: flex; gap: 6px; padding: 6px; border-top: 1px solid var(--line); }
.shot-foot input { flex: 1; min-width: 0; border-color: transparent; padding: 5px 6px; font-size: .9rem; }
.shot-foot input:hover { border-color: var(--line); }

.file-list { display: grid; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.file-row:last-child { border-bottom: none; padding-bottom: 0; }
.file-ext {
  flex: none; width: 46px; padding: 6px 0; text-align: center; border-radius: 4px;
  background: var(--petrol); color: #fff; font-size: .7rem; font-weight: 700; text-transform: uppercase; overflow: hidden;
}
.file-info { flex: 1 1 220px; min-width: 0; }
.file-info a { display: block; color: var(--petrol-dark); font-weight: 600; overflow-wrap: anywhere; }
.file-row input { flex: 2 1 200px; min-width: 0; }

.icon-btn {
  flex: none; width: 32px; height: 32px; border-radius: 4px; border: 1px solid transparent;
  background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer;
}
.icon-btn:hover, .icon-btn:focus-visible { color: var(--danger); border-color: var(--danger); outline: none; }

.drop-overlay {
  position: fixed; inset: 12px; z-index: 40; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  border: 3px dashed var(--accent); border-radius: 10px; background: rgba(230, 246, 246, .92);
  color: var(--petrol-dark); font-size: 1.4rem; font-weight: 600;
}

.lightbox {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; }

dialog { border: none; border-radius: 8px; padding: 22px 24px; width: min(460px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.3);
}
.toast.error { background: var(--danger); }

@media (max-width: 900px) {
  .add-grid { grid-template-columns: 1fr; }
  .file-row { flex-wrap: wrap; }
  main { padding: 16px 12px 40px; }
  .topbar { padding: 10px 12px; }
  .project-picker select { min-width: 160px; flex: 1; }
}

#dash-employees .tag { margin-left: 8px; }

/* Anmeldung */
.userbox { display: flex; align-items: center; gap: 8px; padding-left: 16px; border-left: 1px solid rgba(255,255,255,.25); }
#user-name { font-weight: 600; }
#login-view { max-width: 440px; padding-top: 8vh; }
.login-card { padding: 28px; }
.login-card h1 { margin-bottom: 6px; }
.login-brand { margin: 0 0 18px; font-size: 1.25rem; font-weight: 600; color: var(--petrol-dark); }
.login-brand .brand-mark { color: #fff; }
.login-fields { display: grid; gap: 12px; margin: 14px 0; }
.login-card .btn { width: 100%; padding: 10px; }
#employees-view { max-width: 1280px; }
#employee-table .col-actions { white-space: normal; width: 44%; text-align: right; }
#employee-table .col-actions .btn { margin: 2px 0 2px 6px; }

/* Handy: Kopfzeile in Zeilen, Tabellen als Karten */
@media (max-width: 700px) {
  body { font-size: 16px; }
  /* 16px verhindert, dass iOS beim Antippen eines Feldes hineinzoomt */
  input, select, textarea, label > * { font-size: 16px; }
  main { padding: 12px 10px 40px; }
  .card { padding: 14px; margin-bottom: 14px; }
  h1 { font-size: 1.35rem; }

  .topbar { position: static; gap: 8px; padding: 8px 10px; }
  .topbar .btn { padding: 7px 10px; font-size: .9rem; }
  .brand { order: 1; font-size: 1.1rem; }
  .userbox { order: 2; border-left: none; padding-left: 0; }
  #user-name { display: none; }
  .project-picker { order: 3; flex: 1 1 100%; flex-wrap: nowrap; min-width: 0; }
  .project-picker label { display: none; }
  .project-picker select { min-width: 0; max-width: none; flex: 1; }
  .topnav { order: 4; flex: 1 1 100%; }
  .topnav .btn { flex: 1; text-align: center; }

  .btn { padding: 9px 14px; }
  .btn-small { padding: 7px 12px; font-size: .9rem; }
  .toolbar input[type=search] { width: 100%; }
  .form-hint { display: block; margin: 10px 0 0; }
  .dash-head label { min-width: 0; flex: 1 1 100%; }
  .inline-label { flex: 1 1 100%; }
  .detail-bar { flex-wrap: wrap; }
  .detail-title h1 { font-size: 1.5rem; }
  .description-field { font-size: 1.15rem; }
  .toast { left: 10px; right: 10px; transform: none; text-align: center; }

  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: auto; }
  thead { display: none; }
  tbody tr { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 10px; }
  tbody tr:hover { background: none; }
  td { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 8px; align-items: start; padding: 4px 0; border: none; }
  td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; padding-top: 2px; }
  td.col-nr, td.col-date, td.col-desc, td.col-status, td.col-bar, td.num { width: auto; min-width: 0; text-align: left; }
  td.col-bar { align-items: center; }
  select.status { min-width: 0; }
  td.col-actions, #employee-table td.col-actions {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    width: auto; white-space: normal; text-align: left; margin-top: 8px;
  }
  td.col-actions::before { content: none; }
  td.col-actions:empty { display: none; }
  .col-actions .btn + .btn, #employee-table .col-actions .btn { margin: 0; }
  .badge { margin-left: 0; }
  tr.sum-row td { border-top: none; }
  tr.sum-row { border-width: 2px; }
  tr.editing input { min-width: 0; }
  .stat-row .stat:last-child { grid-column: 1 / -1; }
  td > .tag { justify-self: start; }
}
