/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --color-primary: #1B2A4A;
  --color-accent:  #D4A017;
  --color-bg:      #F8F7F4;
  --color-surface: #FFFFFF;
  --color-border:  #E5E7EB;
  --color-text:    #1F2937;
  --color-muted:   #6B7280;
  --color-error:   #DC2626;
  --color-success: #16A34A;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
}

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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  font-size: 15px;
}

/* ============================================================
   Loading overlay
   ============================================================ */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ============================================================
   Header
   ============================================================ */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#header-username {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
}

/* ============================================================
   Login card
   ============================================================ */
#view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-brand-mark {
  width: 48px;
  height: 48px;
  background: var(--color-primary);
  border-radius: 12px;
  margin: 0 auto 14px;
  position: relative;
}

.login-brand-mark::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 3px;
  background: var(--color-accent);
  border-radius: 2px;
  box-shadow: 0 -7px 0 var(--color-accent), 0 7px 0 var(--color-accent);
}

.login-brand h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
}

.login-brand p {
  font-size: 13px;
  color: var(--color-muted);
  margin-top: 4px;
}

/* ============================================================
   Page wrapper (volunteer & admin views)
   ============================================================ */
.page-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 28px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--color-primary);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-accent);
}

.tab-panel h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 20px;
}

/* ============================================================
   Forms
   ============================================================ */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input,
.field select {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27,42,74,0.10);
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

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

.btn-primary:hover:not(:disabled) {
  opacity: 0.88;
}

.btn-full {
  width: 100%;
  margin-top: 8px;
}

.btn-outline-sm {
  background: transparent;
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.4);
  padding: 6px 14px;
  font-size: 13px;
}

.btn-outline-sm:hover {
  background: rgba(255,255,255,0.12);
}

/* ============================================================
   Status messages
   ============================================================ */
.error-msg {
  background: #FEF2F2;
  color: var(--color-error);
  border-left: 3px solid var(--color-error);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}

.success-msg {
  background: #F0FDF4;
  color: var(--color-success);
  border-left: 3px solid var(--color-success);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}

.success-msg.is-cancelled {
  background: #FEF2F2;
  color: var(--color-error);
  border-left-color: var(--color-error);
}

/* ============================================================
   Shift cards (Meine Schichten)
   ============================================================ */
.shift-cards {
  display: grid;
  gap: 12px;
}

.shift-card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.shift-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-Früh    { background: #FEF3C7; color: #92400E; }
.badge-Mittag  { background: #DBEAFE; color: #1E3A8A; }
.badge-Spät    { background: #EDE9FE; color: #4C1D95; }
.badge-Manuell { background: #F0FDFA; color: #115E59; }

.shift-info {
  flex: 1;
}

.shift-date {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-primary);
}

.shift-time {
  font-size: 13px;
  color: var(--color-muted);
  margin-top: 2px;
}

.btn-cancel-sm {
  background: transparent;
  color: var(--color-muted);
  border: 1.5px solid var(--color-border);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.btn-cancel-sm:hover:not(:disabled) {
  border-color: var(--color-error);
  color: var(--color-error);
}

.btn-cancel-sm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.shift-cancel-info {
  font-size: 12px;
  color: var(--color-muted);
  font-style: italic;
  flex-shrink: 0;
  max-width: 280px;
  text-align: right;
  line-height: 1.4;
}

.no-shifts {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-muted);
  background: var(--color-surface);
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
}

/* ============================================================
   Occupancy preview cards
   ============================================================ */
.occupancy-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin-bottom: 10px;
}

.occupancy-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.occ-card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.occ-name {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary);
}

.occ-time {
  display: block;
  font-size: 11px;
  color: var(--color-muted);
  margin: 3px 0 8px;
}

.occ-count {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: var(--color-accent);
  line-height: 1;
}

/* ============================================================
   Week grid
   ============================================================ */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

#week-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary);
}

.btn-week-nav {
  background: none;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.btn-week-nav:hover {
  background: var(--color-border);
}

#week-grid {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.week-grid-inner {
  display: grid;
  grid-template-columns: 130px repeat(7, minmax(90px, 1fr));
  gap: 6px;
  min-width: 700px;
}

/* Corner cell */
.wg-corner { /* empty */ }

/* Day header cells */
.wg-day-header {
  text-align: center;
  padding: 6px 4px 8px;
  border-radius: var(--radius-sm);
}

.wg-day-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wg-day-date {
  font-size: 11px;
  color: var(--color-muted);
  margin-top: 2px;
}

.wg-day-header.is-today {
  background: rgba(212, 160, 23, 0.12);
}

.wg-day-header.is-today .wg-day-name,
.wg-day-header.is-today .wg-day-date {
  color: #92670A;
}

/* Shift row label */
.wg-shift-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 12px 4px 0;
  min-height: 104px;
}

.wg-shift-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary);
}

.wg-shift-time {
  font-size: 10px;
  color: var(--color-muted);
  margin-top: 3px;
}

/* Grid cells */
.wg-cell {
  position: relative;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  padding: 7px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  cursor: default;
  transition: border-color 0.12s;
  user-select: none;
}

.wg-cell:hover:not(.is-past):not(.is-loading):not(.is-registered) {
  border-color: var(--color-primary);
}

.wg-cell.is-today-col {
  background: #FEFBF0;
  border-color: rgba(212, 160, 23, 0.4);
}

.wg-cell.is-today-col:hover:not(.is-past):not(.is-loading):not(.is-registered) {
  border-color: var(--color-accent);
}

.wg-cell.is-past {
  background: var(--color-bg);
  border-color: transparent;
  opacity: 0.45;
}

.wg-cell.is-registered {
  background: #F0FDF4;
  border-color: #86EFAC;
}

.wg-cell.is-loading {
  align-items: center;
  justify-content: center;
  cursor: wait;
}

/* Role rows — clickable (unregistered future cells) */
.wg-role-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
  padding: 7px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  border-radius: 4px;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-primary);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.wg-role-btn + .wg-role-btn {
  margin-top: 3px;
}

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

.wg-role-btn:hover .wg-role-count {
  color: #fff;
}

.wg-role-btn:active {
  transform: scale(0.96);
}

/* Role rows — display only (past / registered cells) */
.wg-role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 7px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  border-radius: 4px;
  color: var(--color-muted);
}

.wg-role-row + .wg-role-row {
  margin-top: 3px;
}

.wg-role-row.is-mine {
  color: #16A34A;
  background: rgba(22, 163, 74, 0.08);
}

.wg-role-row.is-full {
  opacity: 0.55;
}

.wg-role-row.is-full .wg-role-count {
  color: var(--color-error);
}

/* Count numbers inside role rows/buttons */
.wg-role-count {
  font-size: 13px;
  font-weight: 800;
  color: var(--color-accent);
  flex-shrink: 0;
}

.wg-role-row .wg-role-count {
  color: var(--color-muted);
}

.wg-role-row.is-mine .wg-role-count {
  color: #16A34A;
}

.wg-cell-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

/* ============================================================
   Volunteer management cards (Admin: Freiwillige verwalten)
   ============================================================ */
.volunteer-cards {
  display: grid;
  gap: 10px;
}

.volunteer-card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.volunteer-info {
  flex: 1;
  min-width: 0;
}

.volunteer-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.volunteer-meta {
  font-size: 13px;
  color: var(--color-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-danger-sm {
  background: transparent;
  color: var(--color-error);
  border: 1.5px solid var(--color-error);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.btn-danger-sm:hover:not(:disabled) {
  background: var(--color-error);
  color: #fff;
}

.btn-danger-sm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.volunteer-name-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--color-primary);
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s;
}

.volunteer-name-btn:hover {
  text-decoration-color: var(--color-accent);
}

.volunteer-card.is-expanded {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: var(--color-bg);
}

.volunteer-stats {
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: 14px 18px;
  margin-top: -4px;
}

.stats-totals {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.stats-total-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
}

.stats-total-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 6px;
}

.stats-breakdown {
  border-top: 1px solid var(--color-border);
  padding-top: 10px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats-th {
  text-align: left;
}

.stats-th:last-child {
  text-align: left;
}

.stats-shift-row:not(:last-child) .stats-td {
  border-bottom: 1px solid var(--color-border);
}

.stats-td {
  padding: 7px 10px 7px 0;
  color: var(--color-text);
  vertical-align: middle;
}

.stats-td-date {
  white-space: nowrap;
  color: var(--color-muted);
  font-size: 12px;
}

.stats-td-time {
  white-space: nowrap;
  color: var(--color-muted);
  font-size: 12px;
}

.stats-td-hours {
  white-space: nowrap;
  font-weight: 600;
}

.stats-rolle {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
}

.stats-notiz {
  display: block;
  font-size: 11px;
  font-style: italic;
  color: var(--color-muted);
  margin-top: 1px;
}

.stats-val {
  font-weight: 600;
  color: var(--color-text);
  min-width: 80px;
  text-align: right;
}

.stats-loading {
  font-size: 13px;
}

/* ============================================================
   Utility
   ============================================================ */
.muted {
  color: var(--color-muted);
  font-size: 14px;
}

/* ============================================================
   Field row (side-by-side fields)
   ============================================================ */
.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
}

/* Checkbox field */
.checkbox-field {
  margin-bottom: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}

.checkbox-label input[type="checkbox"]:checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.checkbox-label input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 45%;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg);
}

/* ============================================================
   Admin week grid (Schichtübersicht)
   ============================================================ */
.admin-grid-inner {
  display: grid;
  grid-template-columns: 130px repeat(7, minmax(110px, 1fr));
  gap: 6px;
  min-width: 900px;
}

.wg-cell-admin {
  position: relative;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 7px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
}

.wg-cell-admin.is-today-col {
  background: #FEFBF0;
  border-color: rgba(212, 160, 23, 0.4);
}

.wg-name-tag {
  display: block;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-bg);
  border-radius: 4px;
  line-height: 1.4;
}

.wg-name-tag + .wg-name-tag {
  margin-top: 2px;
}

.wg-name-tag.is-manual {
  border-left: 2px solid var(--color-accent);
  padding-left: 6px;
}

.wg-name-tag.is-ass {
  background: #FFEDD5;
  color: #7C2D12;
  border-left: 3px solid #EA580C;
  padding-left: 6px;
}

.wg-name-tag.is-manual.is-ass {
  border-left: 3px solid var(--color-accent);
  background: #FFEDD5;
  color: #7C2D12;
}

.wg-name-tag.is-praktikant {
  background: #DBEAFE;
  color: #1E3A8A;
  border-left: 3px solid #2563EB;
  padding-left: 6px;
}

.wg-name-tag.is-manual.is-praktikant {
  border-left: 3px solid var(--color-accent);
  background: #DBEAFE;
  color: #1E3A8A;
}

.vol-kat-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-left: 6px;
  vertical-align: middle;
}

.badge-ASS {
  background: #FFEDD5;
  color: #7C2D12;
  border: 1px solid #EA580C;
}

.badge-Praktikant {
  background: #DBEAFE;
  color: #1E3A8A;
  border: 1px solid #2563EB;
}

.wg-role-tag {
  font-weight: 400;
  color: var(--color-muted);
  margin-left: 4px;
}

.wg-time-tag {
  font-weight: 400;
  color: var(--color-accent);
  margin-left: 4px;
}

.wg-notiz-tag {
  display: block;
  font-weight: 400;
  font-style: italic;
  color: var(--color-muted);
  font-size: 10px;
  margin-top: 1px;
}


.wg-empty {
  color: var(--color-border);
  font-size: 16px;
  text-align: center;
  padding: 12px 0;
}

#admin-week-grid {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================================
   Unpublished & blocked cell states (volunteer grid)
   ============================================================ */
.wg-cell.is-unpublished {
  background: var(--color-bg);
  border: 1.5px dashed var(--color-border);
  opacity: 0.5;
}

.wg-cell.is-unpublished:hover {
  border-color: var(--color-border);
}

.wg-unpub-msg {
  font-size: 11px;
  color: var(--color-muted);
  text-align: center;
  padding: 8px 4px;
  font-style: italic;
}

.wg-cell.is-blocked {
  background: repeating-linear-gradient(
    -45deg,
    var(--color-bg),
    var(--color-bg) 4px,
    #E5E7EB 4px,
    #E5E7EB 5px
  );
  border-color: var(--color-border);
  opacity: 0.65;
}

.wg-cell.is-blocked:hover {
  border-color: var(--color-border);
}

.wg-blocked-msg {
  font-size: 11px;
  color: var(--color-muted);
  text-align: center;
  padding: 8px 4px;
  font-weight: 600;
}

.wg-day-header.is-unpublished {
  opacity: 0.5;
}

/* ============================================================
   Schedule editor (Admin: Dienstplan tab)
   ============================================================ */
.sched-pub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
}

.sched-pub-bar.is-implicit {
  background: var(--color-bg);
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}

.sched-pub-bar.is-published {
  background: #F0FDF4;
  color: var(--color-success);
  border: 1px solid #86EFAC;
}

.sched-pub-bar.is-unpublished {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
}

.btn-primary-sm {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary-sm:hover {
  opacity: 0.88;
}

.btn-outline-danger-sm {
  background: transparent;
  color: var(--color-error);
  border: 1.5px solid var(--color-error);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.btn-outline-danger-sm:hover {
  background: var(--color-error);
  color: #fff;
}

.sched-grid-inner {
  display: grid;
  grid-template-columns: 130px repeat(7, minmax(110px, 1fr));
  gap: 6px;
  min-width: 900px;
  overflow-x: auto;
}

#sched-grid {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sched-cell {
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sched-role-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sched-role-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary);
  width: 52px;
  flex-shrink: 0;
}

.sched-capacity-input {
  width: 48px;
  padding: 4px 6px;
  font-size: 13px;
  border: 1.5px solid var(--color-border);
  border-radius: 4px;
  text-align: center;
  background: var(--color-bg);
  color: var(--color-text);
}

.sched-capacity-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(27,42,74,0.10);
}

.sched-current-count {
  font-size: 11px;
  color: var(--color-muted);
}

.sched-block-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--color-border);
  padding-top: 6px;
  margin-top: 2px;
}

.sched-block-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
}

.sched-block-toggle {
  margin: 0;
  cursor: pointer;
}

.sched-block-reason {
  width: 100%;
  padding: 4px 6px;
  font-size: 11px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
}

.sched-block-reason:focus {
  outline: none;
  border-color: var(--color-primary);
}

.sched-cell.is-blocked {
  background: repeating-linear-gradient(
    -45deg,
    #FEF2F2,
    #FEF2F2 4px,
    #FECACA 4px,
    #FECACA 5px
  );
  border-color: #FCA5A5;
}

/* Admin overview: blocked cell */
.wg-cell-admin.is-blocked-admin {
  background: repeating-linear-gradient(
    -45deg,
    var(--color-bg),
    var(--color-bg) 4px,
    #E5E7EB 4px,
    #E5E7EB 5px
  );
  border-color: #D1D5DB;
}

.wg-blocked-tag {
  display: block;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--color-error);
  background: #FEF2F2;
  border-radius: 4px;
  border: 1px solid #FECACA;
  margin-bottom: 2px;
}

[hidden] {
  display: none !important;
}

/* ============================================================
   Mobile responsive — screens ≤ 768px
   ============================================================ */
@media (max-width: 768px) {

  /* --- Header --- */
  .header-inner {
    padding: 0 12px;
    height: 48px;
  }

  .header-logo {
    font-size: 13px;
  }

  #header-username {
    display: none;
  }

  /* --- Page wrapper --- */
  .page-wrapper {
    padding: 16px 12px 16px;
  }

  /* --- Tabs: scrollable with smaller touch targets --- */
  .tabs {
    gap: 0;
    margin-bottom: 20px;
    /* fade hint on the right edge */
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent 100%);
    mask-image: linear-gradient(to right, #000 85%, transparent 100%);
    padding-right: 24px;
  }

  .tab-btn {
    padding: 8px 12px;
    font-size: 12px;
  }

  /* --- Forms --- */
  .field-row {
    flex-direction: column;
    gap: 0;
  }

  /* --- Shift cards (Meine Schichten) --- */
  .shift-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }

  .shift-cancel-info {
    max-width: 100%;
    text-align: left;
  }

  /* --- Volunteer cards --- */
  .volunteer-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
  }

  .volunteer-meta {
    white-space: normal;
    word-break: break-word;
  }

  .btn-danger-sm {
    align-self: flex-end;
  }

  /* --- Volunteer stats table: horizontal scroll --- */
  .volunteer-stats {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
  }

  /* --- Week grids: scroll-snap for swipeable days --- */
  #week-grid,
  #admin-week-grid,
  #sched-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 0;
  }

  .week-grid-inner {
    grid-template-columns: 80px repeat(7, minmax(80px, 1fr));
    min-width: 660px;
  }

  .admin-grid-inner,
  .sched-grid-inner {
    grid-template-columns: 80px repeat(7, minmax(90px, 1fr));
    min-width: 720px;
  }

  /* Shrink shift labels in grid */
  .wg-shift-label {
    padding: 4px 6px 4px 0;
    min-height: 80px;
  }

  .wg-shift-name {
    font-size: 9.5px;
  }

  .wg-shift-time {
    font-size: 9px;
  }

  /* Grid cells — taller for stacked role layout */
  .wg-cell,
  .wg-cell-admin,
  .sched-cell {
    min-height: 90px;
    padding: 6px;
  }

  .wg-role-btn,
  .wg-role-row {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 6px 4px;
    font-size: 10px;
    gap: 2px;
  }

  .wg-role-count {
    font-size: 12px;
  }

  .wg-name-tag {
    font-size: 10px;
    padding: 3px 6px;
  }

  /* Day headers */
  .wg-day-name {
    font-size: 10px;
  }

  .wg-day-date {
    font-size: 9px;
  }

  .wg-day-header {
    padding: 4px 2px 6px;
  }

  /* --- Occupancy preview cards --- */
  .occupancy-cards {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }

  .occ-card {
    padding: 10px 6px;
  }

  /* --- Schedule publish bar --- */
  .sched-pub-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    font-size: 12px;
  }

  /* --- Schedule capacity inputs --- */
  .sched-role-row {
    gap: 4px;
  }

  .sched-role-label {
    width: 40px;
    font-size: 10px;
  }

  .sched-capacity-input {
    width: 40px;
    padding: 3px 4px;
    font-size: 12px;
  }

  /* --- Login card --- */
  .login-card {
    padding: 28px 20px;
  }

  /* --- Stats --- */
  .stats-totals {
    flex-wrap: wrap;
    gap: 6px;
  }

  .stats-total-num {
    font-size: 22px;
  }
}

/* ============================================================
   Extra-small screens — ≤ 400px
   ============================================================ */
@media (max-width: 400px) {
  .page-wrapper {
    padding: 12px 8px 40px;
  }

  .tab-btn {
    padding: 7px 9px;
    font-size: 11px;
  }

  .week-grid-inner {
    grid-template-columns: 60px repeat(7, minmax(60px, 1fr));
    min-width: 520px;
  }

  .admin-grid-inner,
  .sched-grid-inner {
    grid-template-columns: 60px repeat(7, minmax(70px, 1fr));
    min-width: 560px;
  }

  .wg-shift-label {
    padding: 2px 4px 2px 0;
    min-height: 60px;
  }

  .btn {
    padding: 8px 14px;
    font-size: 13px;
  }
}
