/* ==========================================================================
   Zeiterfassung – Design-System
   Farbpalette abgeleitet von luger.de (Teal), glasige Karten, weiche Verläufe,
   22px Radius, System-Schriftstapel. Keine externen Fonts/CDNs (CSP-konform).
   ========================================================================== */

:root {
  --teal-900: #0f5b58;
  --teal-700: #16766e;
  --teal-500: #1f8b8b;
  --teal-400: #2ba4a4;
  --teal-300: #4fb8b8;
  --teal-100: #d6efee;

  --ink: #1a2b2b;
  --ink-soft: #465858;
  --muted: #6b7a7a;
  --line: rgba(31, 139, 139, 0.14);

  --bg-1: #eef4f4;
  --bg-2: #f8fbfb;

  --danger: #b3413a;
  --danger-bg: #fbeceb;
  --success: #1f7a52;
  --success-bg: #e8f6ef;
  --warning: #93650f;
  --warning-bg: #fbf1de;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --shadow-card:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 30px 60px -30px rgba(15, 91, 88, 0.28),
    0 8px 20px -12px rgba(15, 91, 88, 0.18);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --card-bg: rgba(255, 255, 255, 0.82);
  --card-border: rgba(255, 255, 255, 0.65);
  --tile-bg: rgba(255, 255, 255, 0.7);
  --input-bg: #fff;
  --list-bg: #fff;

  --heading: var(--teal-900);
  --link: var(--teal-700);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --teal-100: #143633;

    --ink: #e7f2f1;
    --ink-soft: #b7cbca;
    --muted: #8aa3a1;
    --line: rgba(79, 184, 184, 0.22);

    --bg-1: #0d1a19;
    --bg-2: #0a1413;

    --danger: #ff8c82;
    --danger-bg: #3a1917;
    --success: #6fdba9;
    --success-bg: #12301f;
    --warning: #f0c473;
    --warning-bg: #3a2c0e;

    --shadow-card:
      0 1px 0 rgba(255, 255, 255, 0.04) inset,
      0 30px 60px -30px rgba(0, 0, 0, 0.6),
      0 8px 20px -12px rgba(0, 0, 0, 0.45);

    --card-bg: rgba(20, 36, 35, 0.72);
    --card-border: rgba(255, 255, 255, 0.08);
    --tile-bg: rgba(255, 255, 255, 0.05);
    --input-bg: #102220;
    --list-bg: #142826;

    --heading: #6fe0d4;
    --link: #5fd1c7;

    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --teal-100: #143633;

  --ink: #e7f2f1;
  --ink-soft: #b7cbca;
  --muted: #8aa3a1;
  --line: rgba(79, 184, 184, 0.22);

  --bg-1: #0d1a19;
  --bg-2: #0a1413;

  --danger: #ff8c82;
  --danger-bg: #3a1917;
  --success: #6fdba9;
  --success-bg: #12301f;
  --warning: #f0c473;
  --warning-bg: #3a2c0e;

  --shadow-card:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 30px 60px -30px rgba(0, 0, 0, 0.6),
    0 8px 20px -12px rgba(0, 0, 0, 0.45);

  --card-bg: rgba(20, 36, 35, 0.72);
  --card-border: rgba(255, 255, 255, 0.08);
  --tile-bg: rgba(255, 255, 255, 0.05);
  --input-bg: #102220;
  --list-bg: #142826;

  --heading: #6fe0d4;
  --link: #5fd1c7;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(43, 164, 164, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(22, 118, 110, 0.14), transparent 55%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 100%);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4 {
  color: var(--heading);
  line-height: 1.2;
  margin: 0 0 0.5em;
}

p {
  margin: 0 0 1em;
}

/* ---------- Layout ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--teal-700) 0%, var(--teal-500) 60%, var(--teal-400) 100%);
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
  color: #fff;
}
.sidebar .brand img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff;
  padding: 3px;
}
.sidebar .brand-text {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}
.sidebar .brand-text small {
  display: block;
  font-weight: 400;
  opacity: 0.85;
  font-size: 11px;
}

.sidebar-close,
.hamburger-btn,
.sidebar-backdrop {
  display: none;
}

.hamburger-btn {
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--tile-bg);
  color: var(--heading);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.sidebar-close {
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-left: auto;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.92);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.14);
  text-decoration: none;
}
.nav-link.active {
  background: rgba(255, 255, 255, 0.22);
}

.nav-spacer {
  flex: 1;
}

.app-version {
  padding: 6px 12px 0;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 22px;
  margin: 0;
}

.container-narrow {
  max-width: 720px;
}

/* ---------- Karten ---------- */

.card {
  background: var(--card-bg);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 26px;
  margin-bottom: 20px;
}

.card h2, .card h3 {
  margin-top: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-tile {
  background: var(--tile-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.stat-tile .value {
  font-size: 26px;
  font-weight: 700;
  color: var(--heading);
}
.stat-tile .label {
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Formulare ---------- */

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.field {
  margin-bottom: 18px;
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--input-bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--teal-400);
  box-shadow: 0 0 0 3px rgba(43, 164, 164, 0.18);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-row label {
  margin: 0;
  font-weight: 500;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.05s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  color: #fff;
  box-shadow: 0 10px 20px -10px rgba(15, 91, 88, 0.55);
}
.btn-primary:hover {
  filter: brightness(1.05);
  text-decoration: none;
}

.btn-ghost {
  background: var(--tile-bg);
  border-color: var(--line);
  color: var(--heading);
}
.btn-ghost:hover {
  background: var(--input-bg);
  text-decoration: none;
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(179, 65, 58, 0.25);
}
.btn-danger:hover {
  background: #f7dcda;
  text-decoration: none;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* ---------- Tabellen ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  padding: 8px 12px;
  border-bottom: 1.5px solid var(--line);
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

.table-wrap {
  overflow-x: auto;
}

/* ---------- Badges / Pills ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted { background: var(--bg-1); color: var(--muted); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

/* ---------- Downloaded/sent checkmark toggle ---------- */

.check-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--success);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.check-toggle:hover { border-color: var(--success); }
.check-toggle.is-checked {
  background: var(--success-bg);
  border-color: var(--success);
}

.check-toggle-labeled {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.check-toggle-labeled svg { flex: none; }
.check-toggle-labeled:hover { border-color: var(--success); }
.check-toggle-labeled.is-checked {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

/* ---------- Alerts / Flash ---------- */

.alert {
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(31,122,82,0.2); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: rgba(179,65,58,0.2); }
.alert-info { background: var(--teal-100); color: var(--heading); border-color: var(--line); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(147,101,15,0.2); }

/* ---------- Recovery-Codes ---------- */

.code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 18px 0;
}
.code-grid code {
  display: block;
  text-align: center;
  padding: 10px;
  background: var(--tile-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  letter-spacing: 0.5px;
}

/* ---------- Balkendiagramm (Dashboard) ---------- */

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bar-row .bar-label {
  flex: 0 0 140px;
  font-size: 13px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-row .bar-track {
  flex: 1;
  height: 10px;
  background: var(--bg-1);
  border-radius: 999px;
  overflow: hidden;
}
.bar-row .bar-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--teal-400), var(--teal-700));
  border-radius: 999px;
}
.bar-row .bar-fill-success {
  background: var(--success);
}
.bar-row .bar-value {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--heading);
  min-width: 60px;
  text-align: right;
}

/* ---------- Auth-Seiten ---------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}
.auth-logo img {
  height: 46px;
}

/* ---------- Timer-Widget ---------- */

.timer-widget {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.timer-display {
  font-variant-numeric: tabular-nums;
  font-size: 32px;
  font-weight: 700;
  color: var(--heading);
  min-width: 130px;
}

.timer-running .timer-display {
  color: var(--link);
}

.timer-customer-name {
  color: var(--muted);
  font-size: 13px;
}

.items-end {
  align-items: flex-end;
}

.w-full {
  width: 100%;
}

/* ---------- Autocomplete ---------- */

.autocomplete {
  position: relative;
}
.autocomplete-list {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--list-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 20px 40px -20px rgba(15, 91, 88, 0.35);
  max-height: 240px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 6px;
}
.autocomplete-list li {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: var(--teal-100);
}
.autocomplete-list li.has-description {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 2px;
}
.autocomplete-list .hint {
  color: var(--muted);
  font-size: 12px;
}
.autocomplete-description {
  color: var(--muted);
  font-size: 12px;
  white-space: pre-line;
}

/* ---------- Utilities ---------- */

.muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-end { align-items: flex-end; }
.flex-inline { display: inline; }
.flex-center { display: flex; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-10 { margin-bottom: 10px; }
.mb-22 { margin-bottom: 22px; }
.my-18 { margin: 18px 0; }
.grow-1 { flex: 1; }
.min-w-150 { min-width: 150px; }
.min-w-180 { min-width: 180px; }
.min-w-220 { min-width: 220px; }

.link-button {
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }

  .hamburger-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 82vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 0 40px -12px rgba(0, 0, 0, 0.45);
    z-index: 70;
    overflow-y: auto;
  }
  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar .brand {
    padding-right: 2px;
  }
  .sidebar-close {
    display: inline-flex;
  }

  .sidebar-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 20, 20, 0.4);
    z-index: 65;
  }

  .main {
    padding: 18px 16px 40px;
  }

  .topbar h1 {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .card {
    padding: 18px;
  }

  .stack-sm {
    flex-direction: column;
  }

  /* ---- Tabellen als Karten ---- */
  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
  }
  .table-wrap thead {
    display: none;
  }
  .table-wrap tr {
    margin-bottom: 12px;
    padding: 12px 14px;
    background: var(--tile-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
  }
  .table-wrap tbody tr:last-child {
    margin-bottom: 0;
  }
  .table-wrap td {
    border-bottom: none;
    padding: 6px 0;
  }
  .table-wrap td[data-label] {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    text-align: right;
  }
  .table-wrap td[data-label]::before {
    content: attr(data-label);
    flex-shrink: 0;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
  }
  .table-wrap td.table-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    text-align: left;
    margin-top: 4px;
  }
  .table-wrap td.cell-date-spacer {
    display: none;
  }
  .table-wrap tr.day-header {
    background: none;
    border: none;
    padding: 0;
    margin-bottom: 4px;
  }
  .table-wrap tr.day-header td {
    padding: 10px 4px 4px;
  }
}

/* ---------- Zeit-Eingabe (Ziffern statt nativem Dialog) ---------- */

input.time-input {
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

/* ---------- Navigations-Ladeoverlay (für Seiten mit langsamem Server-Request) ---------- */

.nav-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.nav-loading-overlay.is-visible {
  opacity: 1;
  pointer-events: all;
}

.nav-loading-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--line);
  border-top-color: var(--teal-700);
  border-radius: 50%;
  animation: nav-loading-spin 0.7s linear infinite;
}

@keyframes nav-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.nav-loading-text {
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 280px;
  text-align: center;
}
