:root {
  --primary: #6346d0;
  --primary-hover: #5237b7;
  --primary-light: #f3f1ff;
  --primary-accent: #7a5af8;
  --dark-bg: #222c39;
  --dark-surface: #1b232e;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --bg-page: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 12px rgba(34, 44, 57, 0.06);
  --shadow-lg: 0 10px 25px rgba(34, 44, 57, 0.1);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background-color: var(--dark-bg);
  color: #fff;
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-badge {
  background: linear-gradient(135deg, var(--primary-accent), var(--primary));
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 0.75rem;
  color: #cbd5e1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Nav Tabs */
.nav-bar {
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  overflow-x: auto;
  padding: 0 1rem;
}

.nav-item {
  padding: 0.85rem 1.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.nav-item:hover {
  color: var(--primary);
}

.nav-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
  width: 100%;
  flex: 1;
}

/* Cards & Layout */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--dark-bg);
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Form Styles */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group.full {
  grid-column: 1 / -1;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #4b5563;
}

input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-main);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 3px rgba(122, 90, 248, 0.18);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.btn-secondary:hover {
  background-color: #e2e8f0;
}

.btn-outline {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #475569;
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background-color: #ef4444;
  color: #fff;
}
.btn-danger:hover {
  background-color: #dc2626;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.quick-bar {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.quick-chip {
  background: var(--primary-light);
  color: var(--primary);
  appearance: none;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 9999px;
  cursor: pointer;
  border: 1px solid rgba(122, 90, 248, 0.2);
  transition: all 0.15s;
}

.quick-chip:hover {
  background: var(--primary);
  color: #fff;
}

/* Mobile-first quick entry controls */
.quick-entry-card {
  scroll-margin-top: 4.5rem;
}

.time-section {
  background: #fafaff;
  border: 1px solid #e8e4ff;
  border-radius: var(--radius-sm);
  padding: 0.85rem;
}

.time-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.time-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.time-field > span,
.preset-label {
  color: #475569;
  font-size: 0.78rem;
  font-weight: 700;
}

.time-input-row {
  display: flex;
  gap: 0.35rem;
}

.time-input-row input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

.time-input-row .btn {
  min-height: 38px;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}

.time-presets {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
  padding-top: 0.65rem;
  margin-top: 0.65rem;
  border-top: 1px solid #e8e4ff;
  overflow-x: auto;
  scrollbar-width: none;
}

.time-presets::-webkit-scrollbar {
  display: none;
}

.time-presets .quick-chip {
  min-height: 36px;
  flex: 0 0 auto;
}

.preset-label {
  flex: 0 0 auto;
}

.choice-grid {
  display: grid;
  gap: 0.55rem;
}

.category-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 660px;
}

.delegable-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-button {
  min-height: 48px;
  padding: 0.55rem 0.65rem;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #d8dee8;
  border-radius: var(--radius-sm);
  background: #fff;
  color: #334155;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.choice-button:hover {
  border-color: var(--primary-accent);
  color: var(--primary);
}

.choice-button:active {
  transform: scale(0.98);
}

.choice-button:focus-visible,
.quick-chip:focus-visible {
  outline: 3px solid rgba(122, 90, 248, 0.28);
  outline-offset: 2px;
}

.choice-button.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 5px 12px rgba(99, 70, 208, 0.2);
}

/* Delegierbarkeit: klare Ampel-Logik, auch ohne Auswahl eindeutig lesbar. */
.delegable-choice:nth-child(1) {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #166534;
}

.delegable-choice:nth-child(2) {
  background: #fffbeb;
  border-color: #fde68a;
  color: #a16207;
}

.delegable-choice:nth-child(3) {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}

.delegable-choice:nth-child(1).selected {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
  box-shadow: 0 5px 12px rgba(22, 163, 74, 0.22);
}

.delegable-choice:nth-child(2).selected {
  background: #eab308;
  border-color: #eab308;
  color: #fff;
  box-shadow: 0 5px 12px rgba(234, 179, 8, 0.22);
}

.delegable-choice:nth-child(3).selected {
  background: #e11d48;
  border-color: #e11d48;
  color: #fff;
  box-shadow: 0 5px 12px rgba(225, 29, 72, 0.22);
}

.choice-icon {
  font-size: 1rem;
}

.entry-submit-row {
  margin-top: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.entry-submit {
  min-width: 170px;
  min-height: 46px;
}

.entry-description {
  min-height: 72px;
  resize: vertical;
}

.entry-submit-save {
  background: #16a34a;
  color: #fff;
  border: 1px solid #16a34a;
  box-shadow: 0 5px 12px rgba(22, 163, 74, 0.2);
}

.entry-submit-save:hover {
  background: #15803d;
  border-color: #15803d;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.kpi-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.kpi-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--dark-bg);
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Table */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background: #f8fafc;
  padding: 0.75rem 0.85rem;
  font-weight: 700;
  color: #475569;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

.badge {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-chef {
  background: #fee2e2;
  color: #b91c1c;
}
.badge-schwer {
  background: #fef3c7;
  color: #b45309;
}
.badge-leicht {
  background: #dcfce7;
  color: #15803d;
}
.badge-cat {
  background: #f3f1ff;
  color: #6346d0;
}

/* Progress bar inside table */
.bar-container {
  background: #f1f5f9;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}
.bar-fill {
  background: var(--primary);
  height: 100%;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(34, 44, 57, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  max-width: 440px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--dark-bg);
  margin-bottom: 0.5rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.alert-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.alert-success {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .container {
    padding: 0.75rem;
  }
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
  .form-group.mobile-full {
    grid-column: 1 / -1;
  }
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .card {
    padding: 1rem;
  }
  .category-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: none;
    gap: 0.4rem;
  }
  .category-choice {
    min-height: 52px;
    padding: 0.35rem 0.25rem;
    gap: 0.2rem;
    font-size: 0.72rem;
  }
  .delegable-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .delegable-choice {
    min-height: 54px;
    padding: 0.4rem;
    font-size: 0.72rem;
  }
  .entry-submit-row {
    align-items: stretch;
    flex-direction: column;
  }
  .entry-submit {
    width: 100%;
    min-height: 52px;
    font-size: 1rem;
  }
  .time-pair {
    gap: 0.45rem;
  }
  .time-section {
    padding: 0.7rem;
  }
  .time-presets {
    gap: 0.32rem;
  }
  .time-presets .quick-chip {
    min-height: 34px;
    padding: 0.28rem 0.52rem;
  }
  .entry-description {
    min-height: 76px;
  }
  .day-entries-card {
    display: none;
  }
  .hide-mobile {
    display: none;
  }
}
