*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-bg: #1e2535;
  --sidebar-w: 240px;
  --accent: #3b82f6;
  --accent-dark: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --bg: #f1f5f9;
  --card: #fff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s;
}
.sidebar-logo {
  padding: 1.4rem 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-logo h1 { font-size: 0.95rem; font-weight: 700; color: #fff; line-height: 1.3; }
.sidebar-logo p  { font-size: 0.75rem; color: #94a3b8; margin-top: 0.2rem; }

nav { flex: 1; padding: 0.75rem 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1.2rem;
  color: #94a3b8;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s, color .15s;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }
.nav-item.active { background: rgba(59,130,246,0.2); color: #fff; border-left: 3px solid var(--accent); }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 0.78rem;
  color: #64748b;
}
.sidebar-footer span { color: #94a3b8; }
.logout-btn {
  margin-top: 0.5rem;
  background: none;
  border: none;
  color: #ef4444;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
}
.logout-btn:hover { text-decoration: underline; }

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h2 { font-size: 1.05rem; font-weight: 700; }
.topbar-actions { display: flex; gap: 0.6rem; align-items: center; }

.content { padding: 1.5rem; flex: 1; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { opacity: 0.85; }
.btn-ghost   { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover   { background: var(--bg); color: var(--text); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.78rem; }
.btn svg { width: 15px; height: 15px; }

/* ── Cards / List ── */
.card {
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.job-list { display: flex; flex-direction: column; gap: 0.6rem; }
.job-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.job-item:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.1); border-color: #c7d2e0; }
.job-item-info h3 { font-size: 0.95rem; font-weight: 700; }
.job-item-info p  { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.job-item-meta { text-align: right; font-size: 0.78rem; color: var(--muted); }

/* ── Search ── */
.search-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.2rem;
  align-items: center;
}
.search-input {
  flex: 1;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.9rem;
  background: var(--card);
  outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }

/* ── Forms ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 0.8rem; font-weight: 600; color: #374151; }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.55rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 70px; }
.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

/* ── Job Detail ── */
.detail-header {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.detail-header h2 { font-size: 1.2rem; font-weight: 700; }
.detail-meta { display: flex; flex-direction: column; gap: 0.3rem; }
.detail-meta span { font-size: 0.82rem; color: var(--muted); }
.detail-meta strong { color: var(--text); }
.detail-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.section-header h3 { font-size: 0.95rem; font-weight: 700; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  padding: 0.55rem 0.75rem;
  background: #f8fafc;
  font-weight: 600;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
tbody td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
.totals-row td { font-weight: 700; background: #f1f5f9; border-top: 2px solid var(--border); }
.table-actions { display: flex; gap: 0.4rem; }

/* ── Tab bar ── */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 1.2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  width: fit-content;
}
.tab-btn {
  padding: 0.55rem 1.4rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab-btn:hover { background: var(--bg); color: var(--text); }
.tab-btn.active { background: var(--accent); color: #fff; }

/* ── Month group ── */
.month-group { margin-bottom: 1.5rem; }
.month-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.5rem;
  padding-left: 0.2rem;
}

/* ── Autocomplete ── */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--card);
  border: 1.5px solid var(--accent);
  border-top: none;
  border-radius: 0 0 7px 7px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 300;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.autocomplete-item {
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background .1s;
}
.autocomplete-item:hover { background: #f1f5f9; }

/* ── Signature section ── */
.sig-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin-top: 1rem;
}
.sig-box {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}
.sig-box h4 { font-size: 0.82rem; font-weight: 600; color: var(--muted); margin-bottom: 0.5rem; }
.sig-img {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  border-radius: 6px;
  background: #f8fafc;
}
.sig-placeholder {
  height: 80px;
  background: #f8fafc;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
}
.sig-date { font-size: 0.78rem; color: var(--muted); margin-top: 0.4rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--card);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem 0.4rem;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.4rem; }
.modal-lg { max-width: 720px; }

/* ── Signature Pad ── */
.sig-pad-wrap {
  border: 2px dashed var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
#sigCanvas { display: block; cursor: crosshair; touch-action: none; }
.sig-pad-actions { display: flex; gap: 0.6rem; margin-top: 0.75rem; }

/* ── Settings / Admin tables ── */
.simple-list { display: flex; flex-direction: column; gap: 0.5rem; }
.simple-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  gap: 1rem;
}
.simple-item span { font-size: 0.9rem; }
.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
}
.badge.admin { background: #fef3c7; color: #92400e; }
.badge-done { background: #dcfce7; color: #15803d; margin-left: 0.5rem; vertical-align: middle; }

.job-item.job-done { border-left: 4px solid var(--success); background: #f0fdf4; }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  animation: slideIn .2s ease;
  max-width: 300px;
}
.toast.success { background: #16a34a; }
.toast.error   { background: #dc2626; }
.toast.info    { background: #2563eb; }
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-state p { font-size: 0.9rem; margin-top: 0.5rem; }

/* ── Back link ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 1rem;
}
.back-link:hover { color: var(--text); }

/* ── Responsive ── */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem;
}

/* ── Tablet & Mobil (bis 1024px): Sidebar als Burger-Menü/Overlay ── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .content { padding: 1.1rem; }
  /* Sidebar-Overlay abdunkeln */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
  }
}

/* ── Mobil (bis 767px) ── */
@media (max-width: 767px) {
  .form-grid { grid-template-columns: 1fr; }
  .sig-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0.75rem 1rem; flex-wrap: wrap; row-gap: 0.6rem; }
  .topbar-actions { width: 100%; justify-content: flex-end; }
  .content { padding: 0.85rem; }
  .detail-header { flex-direction: column; }
  /* Größere Touch-Targets auf Mobil */
  .btn { padding: 0.6rem 1rem; }
  .btn-sm { padding: 0.45rem 0.8rem; font-size: 0.8rem; }
  .nav-item { padding: 0.9rem 1.2rem; font-size: 0.9rem; }
  tbody td { padding: 0.7rem 0.6rem; }
}

/* Safe-area für iPhone mit Notch */
@supports (padding: env(safe-area-inset-bottom)) {
  .sidebar { padding-bottom: env(safe-area-inset-bottom); }
  .topbar  { padding-top: calc(0.9rem + env(safe-area-inset-top)); }
}
