/* Zeiterfassung – Stylesheet
   Systemschriften statt Google Fonts: schnell und ohne Datenübertragung an Dritte (DSGVO). */

:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --soft: #f5f7f9;
  --ink: #16263a;
  --muted: #5a6a7c;
  --line: #d6dde5;
  --signal: #f2b705;
  --go: #1b7a51;
  --stop: #b3381f;
  --focus: #2d6bd6;
  --clock-bg: #16263a;
  --clock-text: #d7e1ec;
  --r-s: 6px;
  --r-m: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1621;
    --surface: #152030;
    --soft: #1b2839;
    --ink: #e3eaf2;
    --muted: #93a3b5;
    --line: #27364a;
    --go: #2a9a69;
    --stop: #d0512f;
    --focus: #6d9cf0;
    --clock-bg: #0a111a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: inherit; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 1rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; line-height: 1.3; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.75rem 0 .5rem; }
p { margin: 0 0 .75rem; }
code { background: var(--soft); padding: .1rem .3rem; border-radius: 4px; }
.muted { color: var(--muted); }
.opt { font-weight: 400; color: var(--muted); }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 980px; margin: 0 auto; padding: 1.25rem clamp(1rem, 4vw, 2rem) 2.5rem; }
.narrow { max-width: 560px; }
.block { margin-bottom: 1.75rem; }

/* ---------- Kopfzeile & Navigation ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 980px; margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
  padding: .55rem clamp(1rem, 4vw, 2rem);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; text-decoration: none; }
.nav { display: flex; gap: .2rem; margin-left: auto; }
.nav a, .topbar-logout {
  display: flex; align-items: center; gap: .4rem;
  padding: .5rem .75rem; border-radius: var(--r-s);
  text-decoration: none; color: var(--muted); font-weight: 500;
}
.nav a:hover, .topbar-logout:hover { color: var(--ink); background: var(--soft); }
.nav a.active { color: var(--ink); background: var(--soft); box-shadow: inset 0 -2px 0 var(--signal); }
.nav svg, .topbar-logout svg { width: 20px; height: 20px; flex: none; }

@media (max-width: 759px) {
  .topbar-logout { margin-left: auto; }
  .topbar-logout span { display: none; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    margin: 0; gap: 0;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: .2rem .25rem calc(.2rem + env(safe-area-inset-bottom));
  }
  .nav a {
    flex: 1; flex-direction: column; justify-content: center; gap: .1rem;
    font-size: .72rem; padding: .45rem .25rem; min-height: 56px;
  }
  .nav a.active { background: none; box-shadow: inset 0 3px 0 var(--signal); }
}
@media (min-width: 760px) {
  body { padding-bottom: 0; }
}

/* ---------- Stoppuhr ---------- */
.clock {
  position: relative;
  background: var(--clock-bg); color: var(--clock-text);
  border-radius: var(--r-m);
  padding: 1.6rem clamp(1rem, 4vw, 1.75rem) 1.5rem;
  margin-bottom: 1.75rem;
}
/* Zeitskala am oberen Rand – wandert langsam, solange die Uhr läuft */
.clock-scale { position: absolute; left: 0; right: 0; top: 0; height: 12px; overflow: hidden; pointer-events: none; border-radius: var(--r-m) var(--r-m) 0 0; }
.clock-scale::before {
  content: ""; position: absolute; top: 0; left: 0;
  width: calc(100% + 60px); height: 100%;
  background:
    repeating-linear-gradient(90deg, var(--signal) 0 2px, transparent 2px 60px) 0 0 / 100% 12px no-repeat,
    repeating-linear-gradient(90deg, rgba(242, 183, 5, .45) 0 1px, transparent 1px 12px) 0 0 / 100% 6px no-repeat;
  opacity: .35;
}
.is-running .clock-scale::before { opacity: 1; animation: scale-slide 60s linear infinite; }
@keyframes scale-slide { to { transform: translateX(-60px); } }

.clock-meta { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: .92rem; }
.clock-time {
  font-size: clamp(3.4rem, 16vw, 6.25rem);
  font-weight: 700; line-height: 1; letter-spacing: -0.035em;
  color: var(--signal);
  margin: .4rem 0 .8rem;
}
.clock-time.is-idle { color: rgba(215, 225, 236, .22); }
.clock-what { margin: 0 0 .25rem; color: var(--clock-text); }
.clock-what strong { display: block; font-size: 1.15rem; color: #fff; }
.clock-empty { max-width: 46ch; }
.clock label { color: var(--clock-text); }
.clock input[type=text], .clock select, .clock textarea {
  background: rgba(255, 255, 255, .07);
  border-color: rgba(255, 255, 255, .2);
  color: #fff;
}
.clock input[type=text]::placeholder, .clock textarea::placeholder { color: rgba(215, 225, 236, .5); }
.clock option, .clock optgroup { color: #16263a; background: #fff; }
.clock .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .28); }
.clock .btn-ghost:hover { background: rgba(255, 255, 255, .08); }

.pulse { width: 10px; height: 10px; border-radius: 50%; background: #34c77f; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

@media (prefers-reduced-motion: reduce) {
  .is-running .clock-scale::before, .pulse { animation: none; }
}

/* ---------- Formulare ---------- */
label { display: block; font-size: .875rem; font-weight: 600; margin: .95rem 0 .3rem; }
input[type=text], input[type=password], input[type=date], input[type=time], select, textarea {
  display: block; width: 100%;
  font: inherit; font-size: 16px; /* verhindert Zoom auf iOS */
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-s);
  padding: .6rem .75rem; min-height: 46px;
}
textarea { min-height: 0; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 500; margin-top: 1rem; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.check-inline { margin-top: 2.1rem; }
.hint { font-size: .85rem; color: var(--muted); margin: .4rem 0 0; }
.clock .hint { color: var(--clock-text); }

.grid-2, .grid-3 { display: grid; gap: 0 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 480px) { .grid-3 { grid-template-columns: 1fr 1fr; } .grid-3 > :last-child { grid-column: 1 / -1; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--r-s);
  padding: .55rem 1rem; min-height: 44px;
  background: var(--ink); color: var(--bg);
}
.btn:hover { filter: brightness(1.12); }
.btn-go { background: var(--go); color: #fff; }
.btn-stop { background: var(--stop); color: #fff; }
.btn-signal { background: var(--signal); color: #16263a; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--soft); filter: none; }
.btn-danger { background: transparent; color: var(--stop); border-color: currentColor; }
.btn-lg { min-height: 54px; font-size: 1.08rem; padding: .7rem 1.6rem; }
.btn-block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: 1.25rem; }
.actions .push { margin-left: auto; }

/* ---------- Bausteine ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 1.1rem clamp(1rem, 3vw, 1.4rem) 1.25rem; margin-bottom: 1.25rem;
}
.panel > h2:first-child, .panel > label:first-of-type { margin-top: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1, .page-head h2 { margin: 0; }

.flash { padding: .7rem 1rem; border-radius: var(--r-s); margin-bottom: 1rem; border: 1px solid; }
.flash-ok  { border-color: var(--go);   background: color-mix(in srgb, var(--go) 10%, var(--surface)); }
.flash-err { border-color: var(--stop); background: color-mix(in srgb, var(--stop) 10%, var(--surface)); }

.empty {
  padding: 1.5rem; text-align: center; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-m);
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1.75rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); padding: .6rem .8rem; }
.stat span { display: block; font-size: .8rem; color: var(--muted); }
.stat strong { font-size: 1.35rem; }

.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem; }
.quick form { margin: 0; }
.quick button {
  width: 100%; height: 100%; text-align: left; cursor: pointer;
  font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--signal);
  border-radius: var(--r-s); padding: .55rem .75rem;
}
.quick button:hover { background: var(--soft); }
.quick button:disabled { opacity: .5; cursor: default; border-left-color: var(--go); }
.quick span { display: block; font-weight: 600; }
.quick small { display: block; color: var(--muted); font-size: .82rem; }

/* Eintragsliste */
.entries { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
.entries li + li { border-top: 1px solid var(--line); }
.entry {
  display: grid; grid-template-columns: 6.2rem 1fr auto; gap: .2rem 1rem; align-items: baseline;
  padding: .75rem 1rem; text-decoration: none;
}
.entry:hover, .entry.is-selected { background: var(--soft); }
.entry-simple { grid-template-columns: 1fr auto; }
.entry-time { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.entry-main strong { display: block; font-weight: 600; }
.entry-main > span { color: var(--muted); font-size: .9rem; }
.entry-main .entry-desc { display: block; color: var(--ink); overflow-wrap: anywhere; }
.entry-dur { font-weight: 700; text-align: right; white-space: nowrap; }
.entry.is-running .entry-dur, .entry.is-running .entry-time { color: var(--go); }
@media (max-width: 520px) {
  .entry { grid-template-columns: 1fr auto; }
  .entry-time { grid-column: 1 / -1; }
}
.day-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 1rem; margin: 1.5rem 0 .5rem; }
.day-head span { color: var(--muted); }
.badge { font-size: .75rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); color: var(--muted); margin-right: .35rem; }

.split { display: grid; gap: 1.25rem; }
@media (min-width: 860px) { .split { grid-template-columns: minmax(300px, 380px) 1fr; align-items: start; } }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--signal); }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 1rem; align-items: end; }
.filters label { margin-top: .6rem; }
.filters-go { padding-top: .9rem; }

.presets { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .9rem; }
.presets a { font-size: .9rem; padding: .35rem .8rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; background: var(--surface); }
.presets a.active { border-color: var(--ink); font-weight: 600; }

.month-nav { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin: .25rem 0 .5rem; font-size: .92rem; }
.month-nav a { text-decoration: none; color: var(--muted); }
.month-nav a:hover { color: var(--ink); }

/* Tabellen */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; font-weight: 600; color: var(--muted); }
.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: none; }
.table-details { min-width: 640px; }

/* Bericht */
.report { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: clamp(1rem, 4vw, 2rem); margin-top: 1.25rem; }
.report-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem 2rem; padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 3px solid var(--signal); }
.report-head h2 { font-size: 1.6rem; margin-bottom: .35rem; }
.report-head p { margin: 0; }
.report-sender { font-style: normal; font-size: .9rem; text-align: right; }
.report-actions { margin: 0 0 .5rem; }
.report-foot { margin-top: 2rem; font-size: .8rem; color: var(--muted); }

/* Anmeldung */
.auth { max-width: 400px; margin: 8vh auto 0; }
.auth-brand { text-align: center; margin-bottom: 1rem; }

/* ---------- Druck / PDF ---------- */
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  :root { --bg: #fff; --surface: #fff; --soft: #fff; --ink: #000; --muted: #444; --line: #bbb; }
  body { background: #fff; color: #000; padding: 0; font-size: 10pt; }
  .topbar, .nav, .no-print, .flash { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .report { border: 0; padding: 0; margin: 0; }
  .report-head { border-bottom-color: #000; }
  .table-scroll { overflow: visible; }
  .table-details { min-width: 0; }
  table { font-size: 9pt; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  h3 { break-after: avoid; }
}

/* ---------- Passkeys ---------- */
[hidden] { display: none !important; }
.btn-passkey svg { width: 22px; height: 22px; }
.passkey-msg { margin: .75rem 0 0; }
.divider { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0 .25rem; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.passkey-list { margin-bottom: 1rem; }
.passkey-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1rem; }
.passkey-item form { margin: 0; flex: none; }
@media (max-width: 480px) {
  .tabs { gap: 0; }
  .tabs a { padding: .6rem .55rem; font-size: .92rem; flex: 1; text-align: center; }
}

/* ---------- Import ---------- */
input[type=file] { display: block; width: 100%; font: inherit; padding: .6rem; border: 1px dashed var(--line); border-radius: var(--r-s); background: var(--soft); color: var(--ink); }
.steps { margin: 0 0 1rem; padding-left: 1.25rem; }
.steps li { margin-bottom: .3rem; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 1rem; }
.map-grid label { margin-top: .7rem; }
.select-auto { max-width: 420px; }
.plain { margin: .25rem 0 1rem; padding-left: 1.1rem; }
.plain li { margin-bottom: .25rem; overflow-wrap: anywhere; }
.badge-new { background: color-mix(in srgb, var(--signal) 25%, var(--surface)); border-color: var(--signal); color: var(--ink); }
.text-err { color: var(--stop); }
.errors { margin: .5rem 0 1rem; border: 1px solid var(--stop); border-radius: var(--r-s); padding: .5rem .8rem; }
.errors summary { cursor: pointer; font-weight: 600; color: var(--stop); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

/* ---------- System / Updates ---------- */
.version-big { font-size: 2.4rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1; margin: .25rem 0 1rem; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1.25rem; margin: 0; font-size: .92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.update-ready { border: 2px solid var(--signal); }
.version-jump { display: flex; align-items: center; gap: .75rem; font-size: 1.8rem; font-weight: 700; margin: .25rem 0 .5rem; }
.version-jump span { color: var(--muted); font-weight: 600; }
.version-jump svg { width: 28px; height: 28px; color: var(--signal); }
.changelog-entry { padding: .75rem 0; border-top: 1px solid var(--line); }
.changelog-entry:first-of-type { border-top: 0; padding-top: 0; }
.changelog-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; margin: 0 0 .35rem; }
.changelog-entry ul { margin: 0; padding-left: 1.15rem; }
.changelog-entry li { margin-bottom: .3rem; }

/* ---------- Kunde / Projekt / Tätigkeit ---------- */
.assign { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 1rem; }
.assign .field-customer { grid-column: 1 / -1; }
@media (min-width: 760px) { .assign .field-customer { grid-column: auto; } }
.hint-top { margin: -.25rem 0 .25rem; }

/* Kundensuche */
.combo { position: relative; }
.combo-input { padding-left: 2.4rem !important; padding-right: 2.6rem !important; }
.combo-icon { position: absolute; left: .75rem; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.combo-icon svg { width: 100%; height: 100%; display: block; }
.combo-clear {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent;
  font-size: 1.4rem; line-height: 1; color: var(--muted); cursor: pointer;
}
.combo-clear:hover { background: var(--soft); color: var(--ink); }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  list-style: none; margin: 0; padding: .3rem 0;
  max-height: min(55vh, 360px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-s);
  box-shadow: 0 12px 28px rgba(10, 20, 35, .22);
}
.combo-head { padding: .5rem .9rem .2rem; font-size: .78rem; font-weight: 600; color: var(--muted); }
.combo-option { padding: .6rem .9rem; cursor: pointer; border-left: 3px solid transparent; }
.combo-option strong { display: block; font-weight: 600; }
.combo-option span { display: block; font-size: .85rem; color: var(--muted); }
.combo-option.is-active, .combo-option:hover { background: var(--soft); border-left-color: var(--signal); }
.combo-option[aria-selected="true"] strong::after { content: " ✓"; color: var(--go); }
.combo-empty { padding: .75rem .9rem; color: var(--muted); font-size: .92rem; }
.clock .combo-icon { color: rgba(215, 225, 236, .6); }
.clock .combo-clear { color: rgba(255, 255, 255, .7); }
.clock .combo-clear:hover { background: rgba(255, 255, 255, .1); color: #fff; }

/* Listensuche in den Stammdaten */
.list-filter { display: block; width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); padding: .6rem .75rem; min-height: 44px; margin-bottom: .75rem; }
