/*
 * Design „Signal Orange, abgerundet“
 * - Hell, starker Kontrast: draußen in der Sonne gut lesbar.
 * - Große, fette Schrift; Orange als Signalfarbe wie bei Warnwesten.
 * - Alles stark abgerundet (Pillen-Buttons, weiche Karten).
 * - Touch-Flächen min. 48px, weil auf der Baustelle evtl. mit Handschuhen bedient.
 *
 * Schriften liegen lokal im Ordner /fonts (nicht von Google geladen):
 * Ein Abruf von Google-Servern überträgt die IP-Adresse an Google, was in
 * Deutschland als DSGVO-Verstoß abgemahnt wurde (LG München, 2022).
 * Beide Schriften stehen unter der SIL Open Font License.
 */
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap; src: url('../fonts/Inter-Medium.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-display: swap; src: url('../fonts/Inter-Bold.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-weight: 900; font-display: swap; src: url('../fonts/Inter-Black.woff') format('woff'); }
@font-face { font-family: 'Archivo Black'; font-weight: 400; font-display: swap; src: url('../fonts/ArchivoBlack.woff') format('woff'); }

:root {
  --bg: #ffffff;
  --surface: #f4f4f2;        /* Felder, Karten */
  --line: #e4e4e0;
  --text: #111111;
  --muted: #555555;          /* 7.4:1 auf Weiß */
  --accent: #ff6a1a;         /* Signal-Orange */
  --ink: #111111;            /* Schwarz für Haupt-Buttons */
  --ok: #146c43;  --ok-bg: #dcf5e7;
  --warn: #8a4b00; --warn-bg: #ffecd9;
  --err: #b42318; --err-bg: #fde8e7;
  --r-sm: 16px;              /* Felder */
  --r-lg: 28px;              /* Karten */
  --pill: 999px;             /* Buttons, Chips */
  --tabbar-h: 68px;
  --display: 'Archivo Black', 'Inter', system-ui, sans-serif;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-size: 16px; /* 16px verhindert das automatische Hineinzoomen von iOS bei Eingabefeldern */
  font-weight: 500;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 0.9em; font-weight: 500; }
h2 {
  font-family: var(--display); font-weight: 400; text-transform: uppercase;
  font-size: clamp(1.7rem, 9vw, 2.3rem); line-height: 0.98; letter-spacing: -0.5px; margin: 0.4rem 0 1rem; overflow-wrap: anywhere;
}
h3 { font-size: 1.1rem; font-weight: 900; margin: 1.2rem 0 0.5rem; }

/* ---------- Kopfzeile: orange Block mit runden unteren Ecken ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 14px;
  background: var(--accent); color: var(--ink);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.topbar-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar-title strong { font-weight: 900; font-size: 1.05rem; }
.topbar-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); opacity: 0.8; font-size: 0.85rem; }
.sync-badge {
  border: 0; background: var(--ink); color: #fff; border-radius: var(--pill);
  padding: 8px 14px; font-size: 0.82rem; font-weight: 700; min-height: 36px; white-space: nowrap;
}
.sync-badge.online { background: var(--ink); color: #fff; }
.sync-badge.offline, .sync-badge.pending { background: #fff; color: var(--ink); }
.sync-badge.error { background: var(--err); color: #fff; }
.text-btn { border: 0; background: transparent; color: var(--ink); font-weight: 700; font-size: 0.85rem; min-height: 44px; padding: 0 4px; }

.demo-banner {
  background: var(--warn-bg); color: var(--warn); font-size: 0.85rem; font-weight: 700;
  margin: 10px 12px 0; padding: 8px 14px; text-align: center; border-radius: var(--pill);
}
.link-btn { background: none; border: 0; color: inherit; text-decoration: underline; font: inherit; padding: 0 4px; }

/* ---------- Layout ---------- */
.main { max-width: 640px; margin: 0 auto; padding: 16px 18px; }
.main.wide { max-width: 1100px; }
.card {
  background: var(--bg); border-radius: var(--r-lg); padding: 18px;
  border: 2px solid var(--line); margin-bottom: 14px;
}
/* Erfassen-Formular ohne Kartenrahmen: weniger Linien = ruhiger */
#capture-form.card { border: 0; padding: 0; }

/* ---------- Formulare ---------- */
label {
  display: block; font-weight: 700; font-size: 0.8rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.8px; margin: 18px 0 8px;
}
label .muted { text-transform: none; letter-spacing: 0; font-size: 0.95em; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 18px; font-weight: 700; color: var(--text);
  padding: 12px 18px; min-height: 56px;
  border: 2px solid transparent; border-radius: var(--r-sm); background: var(--surface);
  -webkit-appearance: none; appearance: none;
}
/* Uhrzeiten groß und fett – das Wichtigste auf dem Screen */
input[type="time"] { font-size: 30px; font-weight: 900; min-height: 72px; padding: 6px 16px; letter-spacing: -0.5px; }
/* Uhr-Symbol ausblenden: Antippen öffnet die Auswahl auf dem Handy ohnehin,
   und das Symbol frisst Platz für die großen Ziffern. */
input[type="time"]::-webkit-calendar-picker-indicator { display: none; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: #fff; }
textarea { min-height: 64px; resize: vertical; font-weight: 500; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* Grid-Kinder schrumpfen sonst nicht unter die Eigenbreite von Datums-/
   Zeitfeldern -> Felder liefen auf schmalen Handys über den Rand. */
.row > div, .filters > div { min-width: 0; }
input[type="date"], input[type="time"] { min-width: 0; display: block; }
input[type="checkbox"] { width: 26px; height: 26px; min-height: 0; padding: 0; accent-color: var(--ink); -webkit-appearance: checkbox; appearance: auto; }

button { font: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 52px; padding: 12px 20px; border-radius: var(--pill);
  border: 2px solid var(--ink); background: #fff; color: var(--ink); font-weight: 900;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.danger { color: var(--err); border-color: var(--err); background: #fff; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.btn-row .btn { flex: 1 1 140px; } /* umbrechen statt quetschen */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 2px solid var(--ink); background: #fff; border-radius: var(--pill);
  padding: 8px 16px; min-height: 44px; font-size: 0.95rem; font-weight: 700; color: var(--ink);
}
.chip.active { background: var(--ink); color: #fff; }
/* Pausen-Zeilen: von – bis – entfernen */
.break-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) 48px; gap: 8px; align-items: center; margin-bottom: 8px; }
.break-row input[type="time"] { font-size: 22px; min-height: 56px; }
.break-dash { font-weight: 900; font-size: 1.2rem; }
.break-del { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--line); background: #fff; font-size: 1rem; font-weight: 900; color: var(--muted); }
.no-break { margin: 0 0 4px; }
/* (alt) Pause-Auswahl: fünf gleich breite Pillen in einer Reihe */
[data-role="break-chips"] { flex-wrap: nowrap; }
[data-role="break-chips"] .chip { flex: 1; min-height: 54px; padding: 0; font-size: 1.15rem; font-weight: 900; }
[data-role="project-chips"]:not(:empty) { margin-top: 10px; }
[data-role="project-chips"] .chip { border-color: var(--line); font-weight: 700; }
.hint { margin-top: 10px; font-size: 0.92rem; font-weight: 700; color: var(--warn); }
.hint .chip { border-color: var(--accent); color: var(--ink); background: var(--warn-bg); }
.form-error { color: var(--err); font-size: 0.92rem; font-weight: 700; margin-top: 10px; min-height: 1.2em; }

.duration-preview {
  margin-top: 18px; padding: 14px 18px; border-radius: var(--r-sm); background: var(--surface);
  display: flex; justify-content: space-between; align-items: baseline;
}
.duration-preview strong { font-size: 1.5rem; font-weight: 900; }

/* Großer Speichern-Button, klebt über der Tabbar; Stunden in Orange */
.sticky-save {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  margin-top: 14px; min-height: 68px; font-size: 1.25rem; text-transform: uppercase; letter-spacing: 0.3px;
  justify-content: space-between; padding: 0 26px;
  box-shadow: 0 10px 24px rgba(17, 17, 17, 0.22);
}
.sticky-save [data-role="duration"] { color: var(--accent); text-transform: none; }
.sticky-save.saved { background: var(--ok); border-color: var(--ok); justify-content: center; opacity: 1; }
.link-add { margin-top: 16px; border: 0; background: none; padding: 8px 0; min-height: 44px; font: inherit; font-weight: 700; color: var(--muted); text-decoration: underline; }

/* ---------- Listen ---------- */
.day-group { margin-bottom: 18px; }
.day-head { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 700; color: var(--muted); margin: 0 6px 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.entry {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 0; border-radius: 22px;
  padding: 16px 18px; margin-bottom: 8px; width: 100%; text-align: left; color: var(--text);
}
button.entry { font: inherit; }
.entry-main { flex: 1; min-width: 0; }
.entry-time { font-weight: 900; font-size: 1.15rem; }
.entry-meta { font-size: 0.9rem; color: var(--muted); overflow-wrap: anywhere; }
.entry-hours { font-weight: 900; font-size: 1.15rem; white-space: nowrap; }
.badge { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 3px 10px; border-radius: var(--pill); margin-top: 6px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.open { background: #fff; color: var(--muted); }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.sub { background: #e5ecff; color: #2440a0; }

.summary { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 120px; background: var(--surface); border-radius: 22px; padding: 16px 18px; }
.stat:first-child { background: var(--accent); }
.stat:first-child .lbl { color: var(--ink); }
.stat .val { font-family: var(--display); font-size: 1.9rem; line-height: 1.05; }
.stat .lbl { font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-top: 4px; }

.segmented { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.segmented .chip { min-height: 40px; padding: 6px 14px; font-size: 0.88rem; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.tbl th, .tbl td { text-align: left; padding: 10px 8px; border-bottom: 2px solid var(--surface); vertical-align: top; }
.tbl th { font-size: 0.75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }

.empty { text-align: center; color: var(--muted); font-weight: 700; padding: 28px 8px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.filters label { margin-top: 10px; }
.filters input[type="date"] { font-size: 16px; }
@media (min-width: 760px) {
  .filters { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; gap: 6px; background: #fff; border-top: 2px solid var(--surface);
  padding: 6px 10px env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; height: calc(var(--tabbar-h) - 12px); border: 0; background: transparent; border-radius: var(--pill);
  color: var(--muted); font-size: 0.8rem; font-weight: 700; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
}
.tabbar button .ico { width: 24px; height: 24px; }
.tabbar button.active { color: var(--ink); background: var(--surface); font-weight: 900; }

/* ---------- Dialog ---------- */
.dialog {
  border: 0; border-radius: var(--r-lg); padding: 0; width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 48px); color: var(--text);
}
.dialog::backdrop { background: rgba(17, 17, 17, 0.5); }
.dialog .dialog-body { padding: 22px; overflow-y: auto; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--tabbar-h) + 96px + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: var(--pill);
  font-size: 0.95rem; font-weight: 700; opacity: 0; pointer-events: none; transition: all 0.2s ease;
  max-width: calc(100vw - 32px); z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--err); }

/* ---------- Login ---------- */
.login { max-width: 420px; margin: 6vh auto 0; }
.login .logo { width: 72px; height: 72px; border-radius: 22px; display: block; margin: 0 0 18px; }
/* Größe wächst mit der Bildschirmbreite, damit lange Wörter wie
   ZEITERFASSUNG auch auf kleinen Handys nicht über den Rand laufen. */
.login h1 { font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: clamp(1.7rem, 9vw, 2.8rem); line-height: 0.95; margin: 0 0 10px; overflow-wrap: anywhere; }
.login > p.muted { text-align: left !important; margin-bottom: 18px; }
#login-form.card { border: 0; padding: 0; }
#login-form .btn { margin-top: 8px; min-height: 64px; font-size: 1.1rem; text-transform: uppercase; }
details.install { margin-top: 22px; font-size: 0.95rem; background: var(--surface); border: 0; }
details.install summary { cursor: pointer; font-weight: 900; min-height: 32px; }
details.install ol { padding-left: 20px; margin: 6px 0; }
