/* ── Variablen ─────────────────────────────────────────────────────────── */
:root {
  --navy:      #0f172a;
  --navy-mid:  #1e293b;
  --amber:     #f59e0b;
  --amber-h:   #fbbf24;
  --text:      #1e293b;
  --secondary: #475569;
  --muted:     #94a3b8;
  --border:    #e2e8f0;
  --bg:        #f8fafc;
  --bg-alt:    #f1f5f9;
  --card:      #ffffff;
  --radius:    6px;
  --shadow:    0 1px 3px rgba(0,0,0,.08);
  --success:   #16a34a;
  --danger:    #dc2626;
  --sidebar-w: 220px;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: Arial, Helvetica, sans-serif; background: var(--bg);
       color: var(--text); line-height: 1.55; min-height: 100vh; }
a { color: var(--amber); text-decoration: none; }
a:hover { color: var(--amber-h); }

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar-toggle { display: none; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 99;
}

.sidebar {
  width: var(--sidebar-w); background: var(--navy);
  position: fixed; left: 0; top: 0; bottom: 0;
  display: flex; flex-direction: column; z-index: 100;
}

.sidebar-brand {
  padding: 1rem 1.25rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,.08); flex-shrink: 0;
}
.sidebar-brand a {
  color: #fff; font-weight: bold; font-size: .95rem; text-decoration: none;
}
.sidebar-brand a:hover { color: var(--amber-h); }
.sidebar-brand .brand-at { color: var(--amber); }
.sidebar-brand .brand-sub {
  display: block; color: var(--muted); font-weight: 400;
  font-size: .72rem; margin-top: .15rem; letter-spacing: .01em;
}

.sidebar-nav {
  flex: 1; display: flex; flex-direction: column;
  padding: .6rem 0; overflow-y: auto;
}

.sidebar-section { margin-bottom: .1rem; }

.sidebar-section-label {
  display: block; font-size: .63rem; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); padding: .65rem 1.25rem .2rem;
}

details.sidebar-section { border: none; }
details.sidebar-section > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; justify-content: space-between; align-items: center;
}
details.sidebar-section > summary::-webkit-details-marker { display: none; }
details.sidebar-section > summary::after {
  content: '›'; font-size: .8rem; margin-right: 1.25rem;
  color: var(--muted); transition: transform .15s;
}
details.sidebar-section[open] > summary::after { transform: rotate(90deg); }

.sidebar-link {
  display: block; padding: .42rem 1.25rem;
  color: var(--muted); font-size: .875rem;
  transition: color .15s, background .15s;
}
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar-link.active { color: var(--amber); background: rgba(245,158,11,.08); }

.bug-melden-link {
  color: var(--amber) !important;
  font-weight: 500;
  border-left: 2px solid var(--amber);
  padding-left: calc(1.25rem - 2px);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.bug-melden-link:hover { background: rgba(245,158,11,.08) !important; }

.sidebar-sep { height: 1px; background: rgba(255,255,255,.08); margin: .4rem .75rem; }

.sidebar-bottom {
  flex-shrink: 0; border-top: 1px solid rgba(255,255,255,.08); padding: .5rem 0;
}

.sidebar-logout-btn {
  display: block; width: 100%; padding: .42rem 1.25rem;
  color: var(--muted); font-size: .875rem;
  background: none; border: none; cursor: pointer;
  font-family: inherit; text-align: left;
  transition: color .15s, background .15s;
}
.sidebar-logout-btn:hover { color: #fff; background: rgba(255,255,255,.06); }

/* ── Haupt-Wrapper + Mobile Header ─────────────────────────────────────── */
.main-wrapper { margin-left: var(--sidebar-w); min-height: 100vh; }
.mobile-header { display: none; }

/* ── Mobile Sidebar ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%); transition: transform .25s ease; z-index: 110;
  }
  .sidebar-toggle:checked ~ .sidebar-overlay { display: block; }
  .sidebar-toggle:checked ~ .sidebar         { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .mobile-header {
    display: flex; align-items: center; gap: .75rem;
    background: var(--navy); padding: .6rem 1rem;
    position: sticky; top: 0; z-index: 90;
    border-bottom: 1px solid rgba(255,255,255,.08);
  }
  .hamburger-btn {
    color: var(--muted); cursor: pointer; padding: .25rem;
    border-radius: var(--radius); display: flex; align-items: center;
    transition: color .15s;
  }
  .hamburger-btn:hover { color: #fff; }
  .mobile-brand {
    color: #fff; font-weight: bold; font-size: .95rem; text-decoration: none;
  }
  .mobile-brand .brand-at  { color: var(--amber); }
  .mobile-brand .brand-sub { color: var(--muted); font-weight: 400; }
  #toast { top: 4rem; }
}

/* ── Layout ────────────────────────────────────────────────────────────── */
.page { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem;
}
.page-header h1 { font-size: 1.4rem; color: var(--navy); }

/* ── Karten ────────────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.card-header {
  padding: .9rem 1.25rem; border-bottom: 1px solid var(--border);
  font-weight: bold; font-size: .95rem; color: var(--navy);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 1.25rem; }

/* Grid für Dashboard */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }
.grid-6040 { display: grid; grid-template-columns: 3fr 2fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .grid-6040 { grid-template-columns: 1fr; } }
.grid-6040-right { display: flex; flex-direction: column; gap: 0.5rem; }

/* ── Tabellen ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  background: var(--navy); color: #fff; font-weight: 600;
  padding: .6rem 1rem; text-align: left; white-space: nowrap;
}
td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f1f5f9; }
tr.tr-link:hover td { background: #e8f0fe; }
.td-right { text-align: right; white-space: nowrap; }
.td-center { text-align: center; }
.td-actions { white-space: nowrap; text-align: right; }
.row-muted td { opacity: .55; }

/* Mobile: card-style rows */
@media (max-width: 640px) {
  table, thead, tbody, th, td, tr { display: block; }
  table { width: 100%; }
  thead { display: none; }
  td {
    padding: .4rem 1rem;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: none;
    white-space: normal; overflow-wrap: break-word; word-break: break-word;
  }
  td::before {
    content: attr(data-label);
    font-weight: 600; color: var(--secondary); font-size: .8rem;
    flex: 0 0 45%; margin-right: .5rem;
  }
  tr { border: 1px solid var(--border); border-radius: var(--radius);
       margin: .75rem; background: var(--card); }
  tr:hover td { background: transparent; }
  .td-actions { justify-content: flex-end; padding-top: .5rem; }
  .td-actions::before { content: none; }
  td > div { flex: 1; min-width: 0; }
  td::before { text-align: left; }
  .tr-total { display: flex !important; justify-content: space-between; align-items: center;
              padding: .65rem .75rem; }
  .tr-total::before { content: 'Gesamt'; font-weight: bold; }
  .tr-total td { display: none !important; }
  .tr-total td[data-label="Betrag"] { display: block !important; padding: 0; border: none;
                                      font-weight: bold; white-space: nowrap; }
  .tr-total td[data-label="Betrag"]::before { content: none; }
}

/* Key-Value-Tabellen (Rechnungsdetails etc.) */
.kv-table { width: 100%; border-collapse: collapse; }
.kv-table td { padding: .35rem 0; border-bottom: none; color: var(--secondary); font-size: .875rem; }
.kv-table tr:not(:last-child) { border-bottom: 1px solid var(--border); }
.kv-table td:last-child { color: var(--text); text-align: right; }
@media (max-width: 640px) {
  .kv-table, .kv-table tbody { display: block; }
  .kv-table tr { display: flex !important; justify-content: space-between; align-items: center;
                 padding: .5rem 0; margin: 0;
                 border: none; border-bottom: 1px solid var(--border);
                 border-radius: 0; background: transparent; }
  .kv-table tr:last-child { border-bottom: none; }
  .kv-table td { display: block; padding: 0; border: none; }
  .kv-table td:first-child { font-size: .8rem; font-weight: 600; color: var(--secondary); flex: 0 0 45%; margin-right: .5rem; }
  .kv-table td:last-child { text-align: right; color: var(--text); flex: 1; }
  .kv-table td::before { content: none !important; }
  .kv-table tr:hover td { background: transparent; }
}

/* ── Formulare ─────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-grid, .form-grid-3 { grid-template-columns: 1fr; } }
.form-grid .full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: .3rem; }
label { font-size: .85rem; font-weight: 600; color: var(--secondary); }
input, select, textarea {
  padding: .55rem .75rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .95rem; font-family: inherit;
  color: var(--text); background: #fff; width: 100%;
  box-sizing: border-box;
  transition: border-color .15s;
}
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; border: none; background: none; }
input:not([type="checkbox"]):not([type="radio"]), select { height: 2.6rem; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(245,158,11,.15);
}
textarea { min-height: 80px; resize: vertical; height: auto; }
.form-hint { font-size: .78rem; color: var(--muted); }
.tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--border); color: var(--secondary);
  font-size: .6rem; font-weight: 700; font-style: normal;
  cursor: help; vertical-align: middle; margin-left: 4px;
  flex-shrink: 0; user-select: none;
}
.tip:hover { background: var(--secondary); color: #fff; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: var(--radius); font-size: .875rem;
  font-weight: 600; cursor: pointer; border: none; transition: background .15s;
  white-space: nowrap; line-height: 1;
}
.btn-primary   { background: var(--amber); color: var(--navy); }
.btn-primary:hover { background: var(--amber-h); color: var(--navy); }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-mid); color: #fff; }
.btn-ghost {
  background: transparent; color: var(--secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }
.icon { display: inline-block; width: 1em; height: 1em; vertical-align: -.125em; flex-shrink: 0; }
.btn.is-loading {
  opacity: .65; cursor: not-allowed; pointer-events: none;
}
.btn.is-loading::before {
  content: '';
  display: inline-block; width: .85em; height: .85em;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin .6s linear infinite;
  flex-shrink: 0;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; vertical-align: middle;
  padding: .15rem .55rem; border-radius: 99px;
  font-size: .75rem; font-weight: 600; line-height: 1; white-space: nowrap;
}
.badge-offen       { background: #fef3c7; color: #92400e; }
.badge-verschickt  { background: #dbeafe; color: #1e3a8a; }
.badge-bezahlt     { background: #dcfce7; color: #14532d; }
.badge-verrechnet  { background: #e0e7ff; color: #3730a3; }
.badge-nein        { background: #f1f5f9; color: var(--secondary); }
.badge-storniert   { background: #fee2e2; color: #7f1d1d; }

/* ── Aktivitäten-Feed ──────────────────────────────────────────────────── */
.aktivitaet-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.aktivitaet-row:last-child { border-bottom: none; }
.akt-icon {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
}
.typ-rechnung .akt-icon { background: #fef3c7; border-color: #f59e0b; }
.typ-zeit     .akt-icon { background: #e0f2fe; border-color: #0ea5e9; }
.typ-kunde    .akt-icon { background: #f0fdf4; border-color: #22c55e; }
.typ-system   .akt-icon { background: #f1f5f9; border-color: var(--border); }
.akt-body { flex: 1; min-width: 0; }
.akt-beschreibung { font-weight: 500; color: var(--text); overflow: hidden; word-break: break-word; }
.akt-beschreibung a { color: var(--text); text-decoration: none; }
.akt-beschreibung a:hover { text-decoration: underline; }
.akt-meta { font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.akt-zeit { flex-shrink: 0; font-size: .78rem; color: var(--muted); white-space: nowrap; }

/* ── Filter-Bar ────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 1.25rem;
}
.filter-bar .form-group { flex: 1 1 160px; }
.filter-bar input[type="date"] { max-width: 160px; }
.filter-bar .btn { align-self: flex-end; }
@media (max-width: 600px) { .filter-bar .form-group { flex: 1 1 100%; } .filter-bar input[type="date"] { max-width: 100%; } }

/* ── Dashboard Quick-Entry ─────────────────────────────────────────────── */
.quick-form .form-grid { grid-template-columns: repeat(3, 1fr); }
.quick-form input[type="date"] { max-width: 160px; }
.time-row { display: flex; gap: .5rem; }
.time-row input[type="time"] { flex: 1; min-width: 0; max-width: 130px; }
@media (max-width: 720px) {
  .quick-form .form-grid { grid-template-columns: 1fr; }
  .quick-form input[type="date"] { max-width: 100%; }
  .time-row input[type="time"] { max-width: 100%; }
}

/* ── Offene Stunden Karten ─────────────────────────────────────────────── */
.offen-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.offen-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow);
}
.offen-card .name { font-weight: 700; margin-bottom: .25rem; }
.offen-card .hours { font-size: 1.5rem; font-weight: 700; color: var(--amber); }
.offen-card .amount { color: var(--secondary); font-size: .9rem; }

/* ── Alerts ────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-warn    { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

/* ── Amber Trennlinie ──────────────────────────────────────────────────── */
.amber-line {
  height: 3px; background: var(--amber); border: none;
  border-radius: 2px; margin: 1.5rem 0;
}

/* ── Fortschrittsbalken ────────────────────────────────────────────────── */
.progress-wrap { background: var(--border); border-radius: 99px; height: 10px; overflow: hidden; }
.progress-bar  { height: 100%; border-radius: 99px; transition: width .4s; background: var(--amber); }
.progress-bar.warn   { background: #f97316; }
.progress-bar.danger { background: var(--danger); }

/* ── Leere Zustände ────────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: 3rem 1rem; color: var(--muted);
}
.empty p { margin-top: .5rem; font-size: .9rem; }

/* ── Zahlen-Inputs: Spinner entfernen ──────────────────────────────────── */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* ── Date/Time: WebKit Shadow-DOM-Pseudo-Elemente normalisieren ─────────── */
input[type="date"], input[type="time"] {
  -webkit-appearance: none; appearance: none;
  height: 2.6rem !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
input[type="date"]::-webkit-datetime-edit,
input[type="time"]::-webkit-datetime-edit { padding: 0; line-height: 1; margin-bottom: -2px; }
input[type="date"]::-webkit-datetime-edit-fields-wrapper,
input[type="time"]::-webkit-datetime-edit-fields-wrapper { padding: 0; }
input[type="date"]::-webkit-datetime-edit-text,
input[type="time"]::-webkit-datetime-edit-text,
input[type="date"]::-webkit-datetime-edit-hour-field,
input[type="time"]::-webkit-datetime-edit-hour-field,
input[type="date"]::-webkit-datetime-edit-minute-field,
input[type="time"]::-webkit-datetime-edit-minute-field,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-year-field { padding: 0; }
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value { height: 1.5em; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
#toast {
  display: none;
  position: fixed; top: 1rem; right: 1.1rem; z-index: 9999;
  max-width: 380px; padding: .75rem 1rem; border-radius: 10px;
  font-size: .88rem; line-height: 1.45;
  align-items: flex-start; gap: .6rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
#toast.visible { display: flex; animation: toastIn 200ms ease; }
#toast.fading  { opacity: 0; transition: opacity 1s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@media (max-width: 480px) {
  #toast { left: .5rem; right: .5rem; max-width: none; }
}

/* ── Inline-Pair (Straße/Nr., PLZ/Ort) ────────────────────────────────── */
.pair { display: flex; gap: .5rem; }
@media (max-width: 400px) {
  .pair { flex-direction: column; gap: .3rem; }
  .pair > input, .pair > select { flex: 1 1 auto !important; }
}

/* ── Mobile: Touch-Targets + Card-Header ───────────────────────────────── */
@media (max-width: 600px) {
  input:not([type=checkbox]):not([type=radio]),
  select, textarea { padding: .7rem .75rem; font-size: 16px; }
  .card-header { flex-wrap: wrap; gap: .3rem; }
  .page { padding-top: 1rem; }
}

/* ── FAQ-Modal ─────────────────────────────────────────────────────────── */
#faq-modal {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  align-items: flex-start; justify-content: center;
  padding: 2rem 1rem; background: rgba(0,0,0,.55); overflow-y: auto;
}
#faq-modal.visible { display: flex; }
