:root {
  --bg: #1b1d22;
  --bg-elev: #24262d;
  --bg-cell: #2a2d35;
  --border: #353841;
  --text: #e8e9ec;
  --text-dim: #9aa0aa;
  --accent: #ff8c2a;
  --green: #2f5d3a;
  --green-soft: #244031;
  --red: #5a2a2e;
  --red-soft: #3c1f23;
  --red-x: #d35454;
  --blue: #2a4d7a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

.view { width: 100%; min-height: 100vh; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.login-box h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.login-box .hint {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 14px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

input[type="password"],
input[type="text"] {
  background: var(--bg-cell);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
}
input:focus { border-color: var(--accent); }

button {
  background: var(--accent);
  color: #1b1d22;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button:active { transform: translateY(1px); }

.error {
  color: #ff8a8a;
  font-size: 14px;
  margin-top: 12px;
  min-height: 1.2em;
}

/* ---------- App ---------- */
#app-view {
  padding: 24px;
  max-width: 720px;
  margin: 0 auto;
}

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

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

.topbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

.week-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 6px;
}

.week-switch button {
  background: transparent;
  color: var(--text);
  padding: 4px 10px;
  font-size: 18px;
  border-radius: 6px;
}
.week-switch button:hover { background: var(--bg-cell); }

#week-label {
  font-size: 14px;
  min-width: 150px;
  text-align: center;
  color: var(--text-dim);
}

.logout {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
}
.logout:hover { background: var(--bg-cell); }

/* ---------- Card ---------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 16px 12px;
}

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

.card-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#emp-name {
  font-size: 18px;
  font-weight: 600;
}

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.skill-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-cell);
  color: var(--text);
  border: 1px solid var(--border);
}

.badge-soll { background: var(--bg-cell); }
.badge-max { background: var(--bg-cell); }

.badge-contract.fest { background: #c7e457; color: #1b1d22; border-color: transparent; }
.badge-contract.azubi { background: #5dbef0; color: #1b1d22; border-color: transparent; }
.badge-contract.mini { background: #b58cf0; color: #1b1d22; border-color: transparent; }

.skill {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #1b1d22;
}
.skill-service { background: #ff8c2a; }
.skill-kueche { background: #4cc77a; }
.skill-fahrer { background: #5da8ff; }
.skill-fahrradfahrer { background: #2a4d7a; color: #fff; }

.status {
  font-size: 12px;
  color: var(--text-dim);
  min-height: 1.2em;
}
.status.saved { color: #7cd28b; }
.status.saving { color: var(--accent); }
.status.error { color: #ff8a8a; }

/* ---------- Tabelle ---------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
}

thead th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
  padding: 6px 4px;
}

thead th:first-child { text-align: left; padding-left: 12px; }

tbody td {
  padding: 0;
  height: 44px;
  text-align: center;
  background: var(--bg-cell);
  border-radius: 6px;
  font-weight: 500;
}

tbody td.day-name {
  text-align: left;
  padding-left: 12px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  width: 35%;
}

tbody td.slot {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: filter 0.1s;
}
tbody td.slot:hover { filter: brightness(1.12); }

tbody td.slot.available {
  background: #dcfce7;
  border: 1px solid #b5e6c4;
}

tbody td.slot.unavailable {
  background: #fee2e2;
  border: 1px solid #fbb4b4;
  color: #c93535;
  font-size: 18px;
  font-weight: 700;
}

tbody td.slot.unavailable::after {
  content: "✗";
}

tbody.locked td.slot {
  cursor: not-allowed;
  opacity: 0.55;
}
tbody.locked td.slot:hover { filter: none; }

.lock-hint {
  display: none;
  margin: 10px 4px 0;
  padding: 8px 12px;
  background: #3a2d1a;
  border: 1px solid #6e5022;
  border-radius: 6px;
  color: #f0c674;
  font-size: 13px;
}
.lock-hint.show { display: block; }

.legend {
  margin: 14px 4px 4px;
  font-size: 12px;
  color: var(--text-dim);
}
.legend-ok {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #dcfce7;
  border: 1px solid #b5e6c4;
  color: #1b1d22;
  margin: 0 2px;
}
.legend-no {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #fee2e2;
  border: 1px solid #fbb4b4;
  color: #c93535;
  margin: 0 2px;
}

@media (max-width: 480px) {
  #app-view { padding: 12px; }
  .topbar h1 { font-size: 18px; }
  #week-label { min-width: 110px; font-size: 12px; }
  .card { padding: 12px; }
}
