/* =====================================================================
 * Zeiterfassung Fastgarage - Feinschliff
 * ---------------------------------------------------------------------
 * Laedt NACH dem eingebetteten <style> der Anwendung und ueberschreibt
 * gezielt. Farbwelt und Aufbau bleiben: Fastgarage-Rot, DM Sans, dieselben
 * Karten und Abstaende. Geaendert wird, was die Oberflaeche aelter aussehen
 * liess als sie ist - Symbole, Schatten, Zustaende, Fokus.
 *
 * Wichtig: viele Stellen der Anwendung setzen Farben direkt im
 * style-Attribut. Die gewinnen immer gegen dieses Stylesheet, deshalb wird
 * hier nichts angefasst, was dort schon steht.
 * ===================================================================== */

:root {
  --fg-rot: #DC1E1E;
  --fg-rot-dunkel: #B01818;
  --fg-rot-hell: #FEF2F2;
  --fg-tinte: #17130F;
  --fg-stumpf: #6E6560;
  --fg-linie: #E4DFDB;
  --fg-linie-zart: #EFEBE8;
  --fg-flaeche: #FFFFFF;
  --fg-grund: #F5F2F0;

  /* Eine Schattenskala statt einzelner Werte - das haelt die Tiefe konsistent. */
  --fg-schatten-1: 0 1px 2px rgba(23, 19, 15, .04), 0 1px 1px rgba(23, 19, 15, .03);
  --fg-schatten-2: 0 1px 3px rgba(23, 19, 15, .05), 0 6px 16px -4px rgba(23, 19, 15, .07);
  --fg-schatten-3: 0 2px 6px rgba(23, 19, 15, .06), 0 16px 40px -8px rgba(23, 19, 15, .14);

  accent-color: var(--fg-rot);
}

::selection { background: rgba(220, 30, 30, .16); }

/* ── Symbole ─────────────────────────────────────────────────────── */

.i {
  width: 1.08em;
  height: 1.08em;
  flex: none;
  vertical-align: -.17em;
  stroke-width: 1.9;
}
/* In Ueberschriften darf das Symbol die Akzentfarbe tragen. */
.card h2 > .i,
.modal h3 > .i { color: var(--fg-rot); width: 1.12em; height: 1.12em; }

/* Leer-Zustaende: grosses, ruhiges Symbol statt Riesen-Emoji. */
.empty .i { width: 40px; height: 40px; stroke-width: 1.5; color: #CFC8C3; vertical-align: 0; }
.empty div { font-size: 0; line-height: 1; margin-bottom: 14px; }
.empty p { font-size: 14px; margin: 0; }

.approval-icon .i { width: 26px; height: 26px; stroke-width: 1.8; vertical-align: 0; }
.approval-icon { font-size: 0; line-height: 1; display: flex; }
.approval-banner .approval-icon .i { color: #B45309; }
.approval-banner.done  .approval-icon .i { color: #15803D; }
.approval-banner.done2 .approval-icon .i { color: #1D4ED8; }

.topbar-logo .i { width: 19px; height: 19px; color: var(--fg-rot); stroke-width: 2.1; }
.auth-logo-circle { font-size: 0; }
.auth-logo-circle .i { width: 30px; height: 30px; color: #fff; stroke-width: 2; vertical-align: 0; }

/* ── Schaltflaechen ──────────────────────────────────────────────── */

.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
  border-radius: 9px;
  padding: 6px 11px;
  transition: border-color .13s ease, color .13s ease, background .13s ease, transform .08s ease;
}
.btn-sm:active, .btn, .btn:active { transform: none; }
.btn-sm:hover { background: #FAF8F7; }
.btn-sm.primary:hover { background: var(--fg-rot-dunkel); border-color: var(--fg-rot-dunkel); }
.btn-sm.red:hover { background: #FDE7E7; border-color: #F5A9A9; }

.btn {
  font-weight: 500;
  border-radius: 10px;
  transition: border-color .13s ease, color .13s ease, background .13s ease, box-shadow .13s ease;
}
.btn:hover { background: #FAF8F7; border-color: #CFC8C3; }
.btn.primary { box-shadow: var(--fg-schatten-1); }
.btn.primary:hover { background: var(--fg-rot-dunkel); border-color: var(--fg-rot-dunkel); }
.btn.dark:hover { background: #2A2724; border-color: #2A2724; }
.btn.green:hover { background: #128A3E; border-color: #128A3E; }

.btn-primary { box-shadow: var(--fg-schatten-2); letter-spacing: -.005em; }
.big-btn { box-shadow: var(--fg-schatten-2); letter-spacing: -.01em; }
.big-btn .i { width: 21px; height: 21px; stroke-width: 2.2; vertical-align: 0; }

/* ── Reiter als Segmentschalter ──────────────────────────────────── */

.anav {
  background: #EAE6E3;
  border-radius: 12px;
  padding: 3px;
  gap: 0;
  box-shadow: inset 0 1px 2px rgba(23, 19, 15, .04);
}
.anav button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 9px;
  padding: 8px 15px;
  letter-spacing: -.005em;
  transition: color .14s ease, background .14s ease, box-shadow .14s ease;
}
.anav button:hover { color: #4A4340; }
.anav button.on {
  color: var(--fg-tinte);
  box-shadow: 0 1px 2px rgba(23, 19, 15, .09), 0 1px 1px rgba(23, 19, 15, .05);
}
.anav button.on .i { color: var(--fg-rot); }

/* ── Karten und Tafeln ───────────────────────────────────────────── */

.card {
  border-color: var(--fg-linie-zart);
  border-radius: 16px;
  box-shadow: var(--fg-schatten-1);
}
.card h2 { letter-spacing: -.02em; }
.scard, .today { box-shadow: var(--fg-schatten-1); border-radius: 16px; }
.auth-card { border-radius: 18px; box-shadow: var(--fg-schatten-3); }
.modal { border-radius: 18px; box-shadow: var(--fg-schatten-3); }
.scard2 { border-radius: 12px; }

/* ── Eingabefelder ───────────────────────────────────────────────── */

.input, .fg input, .fg select, .msel select {
  border-color: var(--fg-linie);
  border-radius: 10px;
  transition: border-color .13s ease, box-shadow .13s ease;
}
.input:hover, .fg input:hover, .fg select:hover, .msel select:hover { border-color: #CFC8C3; }
.input:focus, .fg input:focus, .fg select:focus, .msel select:focus {
  border-color: var(--fg-rot);
  box-shadow: 0 0 0 3.5px rgba(220, 30, 30, .13);
}

/* ── Abzeichen mit Statuspunkt ───────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 11.5px;
  letter-spacing: -.005em;
  line-height: 1.5;
}
.badge.green::before, .badge.red::before, .badge.gray::before,
.badge.yellow::before, .badge.blue::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
  opacity: .8;
}
.badge.green { background: #E7F8ED; color: #12703A; }
.badge.red { background: #FDEAEA; color: #A81B1B; }
.badge.gray { background: #F1EEEC; color: #6E6560; }
.badge.yellow { background: #FDF3DF; color: #8A5A08; }
.badge.blue { background: #E8F0FE; color: #1B4ED0; }

/* ── Tabellen ────────────────────────────────────────────────────── */

th {
  font-size: 10.5px;
  letter-spacing: .07em;
  color: #9A928D;
  border-bottom-color: var(--fg-linie);
  padding-bottom: 9px;
}
td { border-bottom-color: var(--fg-linie-zart); }
tr:hover td { background: #FBF9F8; }
table { font-variant-numeric: tabular-nums; }

/* ── Uhr und Zustandsanzeige ─────────────────────────────────────── */

.clock-time { letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.status-badge { padding: 6px 15px; letter-spacing: -.005em; box-shadow: var(--fg-schatten-1); }
.status-badge.in { background: #E7F8ED; color: #12703A; }
.status-badge .dot { box-shadow: 0 0 0 3px currentColor; opacity: .95; }
.status-badge.in .dot { animation: fg-puls 2.4s ease-in-out infinite; }
@keyframes fg-puls {
  0%, 100% { box-shadow: 0 0 0 3px rgba(18, 112, 58, .18); }
  50%      { box-shadow: 0 0 0 6px rgba(18, 112, 58, .07); }
}

/* ── Kurzmeldung ─────────────────────────────────────────────────── */

.toast {
  border-radius: 12px;
  padding: 12px 20px;
  font-weight: 500;
  letter-spacing: -.005em;
  box-shadow: var(--fg-schatten-3);
  background: #211D1A;
  max-width: calc(100vw - 32px);
  white-space: normal;
  text-align: center;
}

/* ── Bestaetigungskasten ─────────────────────────────────────────── */

.confirm-box { border-radius: 13px; border-color: var(--fg-linie); }
.confirm-box:has(input:checked) { box-shadow: 0 0 0 3px rgba(22, 163, 74, .1); }
.step-indicator { border-radius: 11px; border-color: var(--fg-linie-zart); }
.step-item { letter-spacing: -.005em; }

/* ── Fokus: sichtbar, ohne die Optik zu stoeren ──────────────────── */

:focus-visible {
  outline: 2.5px solid var(--fg-rot);
  outline-offset: 2px;
  border-radius: 6px;
}
.input:focus-visible, .fg input:focus-visible, .fg select:focus-visible, .msel select:focus-visible {
  outline: none;
}

/* ── Ruhige Darstellung, wenn der Nutzer das so eingestellt hat ──── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Schmale Geraete ─────────────────────────────────────────────── */

@media (max-width: 560px) {
  .anav { padding: 3px; }
  .anav button { padding: 8px 12px; font-size: 12.5px; }
  .card { border-radius: 14px; }
  th, td { padding-left: 9px; padding-right: 9px; }
}

/* =====================================================================
 * Handy: nichts darf breiter sein als das Display
 * ---------------------------------------------------------------------
 * Die Kopfzeile war der Grund, warum die ganze Seite seitlich scrollte:
 * Logo und rechte Seite durften beide nicht schrumpfen (white-space:nowrap
 * bzw. flex-shrink:0). Zusammen ergaben sie rund 378 px - mehr als ein
 * Handy breit ist. Weil die Kopfzeile sticky ist, hat sie das Dokument
 * mitgezogen, und dadurch scrollte alles.
 * ===================================================================== */

.topbar { padding: 0 14px; gap: 8px; }

/* Beide Seiten duerfen jetzt nachgeben. */
.topbar-logo { min-width: 0; }
.topbar-right { flex-shrink: 1; min-width: 0; }
/* Der Name wird gekuerzt, statt die Seite aufzuspannen. */
.user-badge { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Die Abmelde-Schaltflaeche behaelt ihre Groesse - sie muss treffbar bleiben. */
.topbar-right .btn-sm { flex: none; }

@media (max-width: 430px) {
  .topbar { padding: 0 10px; }
  /* Auf schmalen Geraeten bleibt vom Logo das Symbol - das spart 120 px
     und ist immer noch als Marke erkennbar. */
  .topbar-logo { font-size: 0; gap: 0; }
  .topbar-logo .i { width: 23px; height: 23px; }
}

/* ── Breite Inhalte scrollen im Kasten, nicht auf der Seite ───────── */

.admin-panel, .main { max-width: 100%; }

/* Oberhalb der Kartengrenze (ab 641px) scrollen breite Tabellen im Kasten.
   Der Schatten wandert mit und zeigt, auf welcher Seite noch etwas kommt. */
@media (min-width: 641px) {
.card > div[style*="overflow-x"] {
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(to right, var(--fg-flaeche) 34%, rgba(255, 255, 255, 0)),
    linear-gradient(to left, var(--fg-flaeche) 34%, rgba(255, 255, 255, 0)) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(23, 19, 15, .13), rgba(23, 19, 15, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(23, 19, 15, .13), rgba(23, 19, 15, 0)) 100% 0;
  background-repeat: no-repeat;
  background-size: 38px 100%, 38px 100%, 13px 100%, 13px 100%;
  background-attachment: local, local, scroll, scroll;
}
/* Kein eigener Hintergrund: der Schatten des Kastens muss durchscheinen. */
.card > div[style*="overflow-x"] > table { min-width: 100%; }
}

/* Der Bestaetigungsdialog des Mitarbeiters hatte nur overflow-y -
   seine Tabelle konnte den Dialog aufspannen. */
.modal div[style*="overflow-y:auto"] { overflow-x: auto; }

/* ── Mehr Inhalt pro Bildschirmbreite ────────────────────────────── */

@media (max-width: 560px) {
  .admin-panel { padding: 14px 8px; }
  .card { padding: 16px 14px; }
  table { font-size: 12px; }
  th { font-size: 10px; letter-spacing: .05em; }
  th, td { padding: 8px 7px; }
  /* Die Schaltflaechen in der Aktionsspalte duerfen umbrechen, statt die
     Tabelle in die Breite zu ziehen. */
  td[style*="display:flex"] { flex-wrap: wrap; }
  .btn-sm { padding: 5px 9px; }
  .msel { gap: 7px; }
  .msel select { font-size: 13px; padding: 7px 10px; max-width: 100%; }
  .modal { padding: 20px 16px; }
  .modal-overlay { padding: 12px; }
  .clock-time { font-size: 44px; }
}

/* Sehr schmal: Uhrzeit und Kacheln nachziehen. */
@media (max-width: 380px) {
  .clock-time { font-size: 39px; }
  .sgrid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .scard2 { padding: 12px 13px; }
  .scard2 .v { font-size: 19px; }
}


/* =====================================================================
 * Telefon: aus jeder Tabellenzeile wird eine Karte
 * ---------------------------------------------------------------------
 * Acht Spalten passen auf kein Telefon - seitliches Wischen ist keine
 * Loesung, sondern das Problem. Unter 640px wird die Tabelle deshalb
 * aufgeloest: Name gross oben, darunter "Bezeichnung — Wert", die
 * Schaltflaechen in einer Leiste am Fuss der Karte.
 *
 * Die Spaltennamen stehen als data-label an den Zellen; die setzt
 * app-mobile.js aus dem <thead>, damit die fuenf Tabellen der Anwendung
 * dafuer nicht angefasst werden muessen.
 * ===================================================================== */

@media (max-width: 640px) {

  /* Kein eigener Scrollbereich mehr - es gibt nichts mehr zu scrollen. */
  .card > div[style*="overflow-x"] { overflow-x: visible; background: none; }

  table, thead, tbody, tfoot, tr, th, td { display: block; }
  thead { display: none; }
  table { font-size: 13px; }

  tbody tr {
    background: var(--fg-flaeche);
    border: 1px solid var(--fg-linie-zart);
    border-radius: 13px;
    padding: 13px 15px 11px;
    margin-bottom: 10px;
    box-shadow: var(--fg-schatten-1);
  }
  tbody tr:hover td, tr:hover td { background: none; }
  tbody td {
    border: none;
    padding: 3px 0;
    /* Die Anwendung setzt an einigen Zellen max-width mit Auslassungspunkten,
       damit die Tabelle schmal bleibt. In einer Karte ist das falsch - dort ist
       Platz, und ein abgeschnittenes Wort sieht nach Fehler aus. Inline-Stile
       gewinnen normalerweise, deshalb hier ausnahmsweise !important. */
    max-width: none !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    word-break: break-word;
  }

  /* Leere Werte weglassen - sie sagen nichts und machen die Karte lang. */
  tbody td[data-leer="1"] { display: none; }

  /* Erste Spalte ist ueberall der Name: Kopf der Karte, ohne Beschriftung. */
  tbody td:first-child {
    font-size: 15px;
    line-height: 1.35;
    padding: 0 0 9px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--fg-linie-zart);
  }
  tbody td:first-child::before { display: none; }
  tbody td:first-child strong { font-size: 15px; }

  /* Alle uebrigen Werte als Paar: Bezeichnung links, Wert rechts. */
  tbody td:not(:first-child):not([data-aktionen]):not([data-leer])::before {
    content: attr(data-label);
    display: inline-block;
    width: 41%;
    min-width: 41%;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #9A928D;
    vertical-align: baseline;
  }
  tbody td:not(:first-child):not([data-aktionen]):not([data-leer]) {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-height: 22px;
  }
  tbody td:not(:first-child):not([data-aktionen]):not([data-leer])::before { flex: none; }

  /* Schaltflaechen als Leiste am Fuss der Karte. */
  tbody td[data-aktionen] {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--fg-linie-zart);
  }
  tbody td[data-aktionen]::before { display: none; }
  tbody td[data-aktionen] .btn-sm { padding: 7px 12px; font-size: 12.5px; }

  /* Zwischenzeilen (z. B. "2 min Pause zwischen den Stempelungen"). */
  tbody tr[data-spanne] {
    background: none;
    border: 0;
    box-shadow: none;
    padding: 0 0 6px;
    margin: -4px 0 0;
  }
  tbody tr[data-spanne] td { padding: 0 4px; border: 0; }

  /* Aufgeklappte Einzel-Stempelungen: eingerueckt und ruhiger. */
  tbody tr[style*="FBF9F8"] { background: #FBF9F8; margin-left: 14px; }

  /* Summenzeile bleibt eine Zeile. */
  tfoot tr {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 4px 0;
    border-top: 2px solid var(--fg-linie);
    font-weight: 700;
  }
  tfoot td { border: 0 !important; padding: 0; }
  tfoot td:empty { display: none; }

  /* Die Reiter brechen um, statt abgeschnitten zu werden. */
  .anav {
    flex-wrap: wrap;
    overflow-x: visible;
    gap: 3px;
  }
  .anav button {
    flex: 1 1 calc(50% - 3px);
    justify-content: center;
    padding: 9px 8px;
    font-size: 12.5px;
  }

  /* Filterzeile: jedes Feld auf ganzer Breite, damit man es treffen kann. */
  .msel { gap: 8px; }
  .msel select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .msel .seg { flex: 1 1 100%; }
  .msel .seg button { flex: 1; }
  .msel > .btn { flex: 1 1 100%; justify-content: center; }
}
