/* Zeiterfassung – das gesamte Aussehen der App.
   Farben und Abstände stehen als Variablen ganz oben und lassen sich dort zentral ändern. */

:root {
  /* Farben (heller Modus) */
  --primary: #1f6f78;        /* Hauptfarbe: Buttons, Links, aktive Navigation */
  --primary-text: #ffffff;
  --bg: #f3f5f6;             /* Seitenhintergrund */
  --surface: #ffffff;        /* Karten */
  --surface-2: #eaeef0;      /* abgesetzte Flächen */
  --text: #1b2428;
  --muted: #5b6970;
  --border: #d5dcdf;
  --pos: #1c7a45;            /* Plus-Stunden */
  --neg: #b3362b;            /* Minus-Stunden, Löschen */
  --warn-bg: #fff3d6;
  --warn-text: #6b4a00;
  --info-bg: #e2f0f2;
  --error-bg: #fbe4e1;
  --ok-bg: #e0f3e7;

  /* Maße */
  --radius: 14px;
  --gap: 16px;
  --touch: 44px;             /* Mindestgröße für alles, was man antippt */
  --nav-height: 60px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #58b9c4;
    --primary-text: #06282c;
    --bg: #12181b;
    --surface: #1b2428;
    --surface-2: #243035;
    --text: #e7edef;
    --muted: #9fb0b7;
    --border: #33434a;
    --pos: #6fd39a;
    --neg: #ff8f84;
    --warn-bg: #4a3a10;
    --warn-text: #ffe2a0;
    --info-bg: #1d3a40;
    --error-bg: #4a2320;
    --ok-bg: #1c3b29;
  }
}

/* ---------- Grundlagen ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
h1 { font-size: 1.4rem; margin: 0 0 var(--gap); line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 20px 0 10px; }
p { margin: 0 0 12px; }
a { color: var(--primary); }
small, .small { font-size: 0.85rem; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.hint { color: var(--muted); font-size: 0.88rem; }
.spaced { margin-top: var(--gap); }
/* Zahlen untereinander bündig (tabellarische Ziffern) */
.num, .stats dd, .rows dd, .tile-value, .punch-clock, td.r { font-variant-numeric: tabular-nums; }

.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 8px; top: 8px; z-index: 10; background: var(--surface); padding: 8px; }

/* ---------- Seitenaufbau ---------- */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--gap) var(--gap) calc(var(--nav-height) + 32px + env(safe-area-inset-bottom));
}
main.narrow { max-width: 520px; }
main.wide { max-width: 1200px; }
main.centered { text-align: center; padding-top: 8vh; }
main.centered form { text-align: left; }

.topbar {
  display: flex; align-items: center; gap: var(--gap);
  padding: 10px var(--gap);
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topnav, .topbar-logout { display: none; }

/* Untere Navigation (Handy) */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-height);
  font-size: 0.75rem; color: var(--muted); text-decoration: none;
}
.bottomnav svg {
  width: 24px; height: 24px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.bottomnav a[aria-current="page"] { color: var(--primary); font-weight: 600; }

/* Ab Tablet/Desktop: Navigation oben */
@media (min-width: 800px) {
  .bottomnav { display: none; }
  main { padding-bottom: 48px; }
  .topnav { display: flex; gap: 4px; flex: 1; }
  .topnav a {
    padding: 8px 12px; border-radius: 8px;
    color: var(--text); text-decoration: none;
  }
  .topnav a:hover { background: var(--surface-2); }
  .topnav a[aria-current="page"] { background: var(--primary); color: var(--primary-text); }
  .topbar-logout { display: flex; align-items: center; gap: 12px; }
}

.only-desktop { display: none; }
@media (min-width: 800px) {
  .only-desktop { display: block; }
  .only-mobile { display: none !important; }
}

/* ---------- Karten und Raster ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
  margin: 0 0 var(--gap);
}
.dash-grid { display: grid; gap: var(--gap); align-items: start; }
.dash-grid > .card { margin: 0; }
.dash-grid { margin-bottom: var(--gap); }
@media (min-width: 800px) { .dash-grid { grid-template-columns: 1fr 1fr; } }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: var(--gap); }
@media (min-width: 800px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; color: var(--text); text-decoration: none;
}
.tile-label { font-size: 0.8rem; color: var(--muted); }
.tile-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.tile-sub { font-size: 0.8rem; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--touch); padding: 8px 16px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { color: var(--neg); border-color: var(--neg); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-small { min-height: 36px; padding: 4px 10px; font-size: 0.9rem; }
.btn-block { width: 100%; }

/* Der große Stempel-Button */
.btn-punch {
  width: 100%; min-height: 72px; font-size: 1.35rem; border-radius: 16px; border: none;
  color: #fff;
}
.btn-in { background: #1c7a45; }
.btn-out { background: #b3362b; }
.btn-punch:hover { filter: brightness(1.08); }
.btn-in:hover { background: #1c7a45; }
.btn-out:hover { background: #b3362b; }

/* ---------- Formulare ---------- */
.stack > * + * { margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-small { max-width: 110px; }
label, legend { font-size: 0.88rem; font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: var(--touch); padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
input[type="checkbox"], input[type="radio"] {
  width: 22px; min-height: 0; height: 22px; padding: 0; accent-color: var(--primary); flex: none;
}
input[type="color"] { padding: 4px; width: 64px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: var(--touch); font-weight: 400; font-size: 1rem; }
fieldset.checks { border: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
fieldset.checks legend { padding: 0; margin-bottom: 2px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: var(--gap); }
.card > .toolbar:last-child, form > .toolbar { margin-bottom: 0; }
.inline-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.inline-form:last-child { border-bottom: none; }
.inline-form.archived { opacity: 0.6; }
.filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.filter .field { flex: 1; min-width: 140px; }
details > summary { cursor: pointer; min-height: var(--touch); display: flex; align-items: center; }
details[open] > summary { margin-bottom: 12px; }

/* Umschalter Arbeitszeit / Abwesenheit */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: var(--gap);
}
.segmented a {
  display: flex; align-items: center; justify-content: center; min-height: 40px;
  border-radius: 9px; color: var(--text); text-decoration: none; font-weight: 600;
}
.segmented a[aria-selected="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }

/* ---------- Meldungen und Marken ---------- */
.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 var(--gap); background: var(--ok-bg); }
.flash-error { background: var(--error-bg); }
.flash-warn { background: var(--warn-bg); color: var(--warn-text); }
.flash-warn a { color: inherit; font-weight: 600; }
.flash-info { background: var(--info-bg); }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.badge-info { background: var(--info-bg); color: var(--text); }
.badge-lock { background: var(--warn-bg); color: var(--warn-text); }
.dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--c, var(--muted)); vertical-align: baseline;
}

/* ---------- Dashboard ---------- */
.page-date { font-size: 1.15rem; }
.punch { text-align: center; }
.punch form { text-align: left; }
.punch-status { display: flex; align-items: center; justify-content: center; gap: 8px; }
.punch-clock { font-size: 2.6rem; font-weight: 700; margin: 0 0 12px; line-height: 1.1; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--pos); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 12px; text-align: center; }
.stats dt { font-size: 0.8rem; color: var(--muted); }
.stats dd { margin: 0; font-size: 1.25rem; font-weight: 700; }

.rows { margin: 0 0 12px; }
.rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.rows > div:last-child { border-bottom: none; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-weight: 600; text-align: right; }
.rows .total dt, .rows .total dd { color: var(--text); font-weight: 700; }
.rows .total dd.pos { color: var(--pos); }
.rows .total dd.neg { color: var(--neg); }

.entry-list { list-style: none; margin: 0 0 12px; padding: 0; }
.entry-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.entry-list li:last-child { border-bottom: none; }
.entry-list-big li { min-height: var(--touch); }
.entry-list .pause-row { justify-content: center; padding: 4px 0; font-size: 0.88rem; }
.card.entry-list { padding-top: 6px; padding-bottom: 6px; margin-bottom: var(--gap); }

.menu { padding: 0; overflow: hidden; }
.menu a {
  display: flex; align-items: center; min-height: 52px; padding: 0 var(--gap);
  color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border);
}
.menu a:last-child { border-bottom: none; }
.menu a::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 1.3rem; }

.subnav { display: flex; gap: 6px; overflow-x: auto; margin-bottom: var(--gap); padding-bottom: 4px; }
.subnav a {
  flex: none; padding: 8px 14px; border-radius: 999px; min-height: 40px; display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 0.92rem;
}
.subnav a[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pager h1 { margin: 0; text-align: center; font-size: 1.2rem; }
.pager .btn { font-size: 1.6rem; min-width: var(--touch); padding: 0 12px; }

.login-card { padding: 28px 20px; }
.login-card h1 { text-align: center; }
.login-logo { border-radius: 14px; margin-bottom: 8px; }

/* ---------- Monatsübersicht ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { color: var(--muted); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.table .r { text-align: right; white-space: nowrap; }
.table tr.free td { background: var(--surface-2); color: var(--muted); }
.table tr.is-today td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.table tfoot th { border-bottom: none; border-top: 2px solid var(--border); }
.table .notes { color: var(--muted); font-size: 0.85rem; max-width: 280px; }
.month-table td:first-child { white-space: nowrap; }

.day-list { list-style: none; padding: 0; overflow: hidden; }
.day-list li { border-bottom: 1px solid var(--border); }
.day-list li:last-child { border-bottom: none; }
.day-list li.free { background: var(--surface-2); }
.day-list li.is-today { box-shadow: inset 3px 0 0 var(--primary); }
.day-list a {
  display: grid; grid-template-columns: 7.4em 1fr auto; align-items: center; gap: 8px;
  min-height: 52px; padding: 6px 12px; color: var(--text); text-decoration: none;
}
.day-date { font-size: 0.9rem; font-weight: 600; }
.day-main { display: flex; flex-direction: column; gap: 2px; font-size: 0.85rem; align-items: flex-start; min-width: 0; }
.day-num { display: flex; flex-direction: column; align-items: flex-end; font-weight: 600; }

/* ---------- Protokoll ---------- */
.audit-list { list-style: none; padding: 0 var(--gap); }
.audit-list li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.audit-list li:last-child { border-bottom: none; }
.audit-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin-bottom: 6px; }
.audit-values { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 0.88rem; }
.audit-values dl { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }
.audit-values dl > div { display: flex; gap: 8px; }
.audit-values dt { color: var(--muted); min-width: 5.5em; }
.audit-values dd { margin: 0; }
.audit-values .old { text-decoration: line-through; text-decoration-color: var(--muted); opacity: 0.8; }
.audit-values .changed dd { font-weight: 700; color: var(--primary); }
.audit-values .arrow { font-size: 1.2rem; color: var(--muted); }
