/* ── Variables ── */
:root {
  --primary: #993333;
  --primary-light: #fdf6f6;
  --bg: #f5f2ef;
  --card: #fff;
  --text: #333;
  --text-light: #717171;
  --border: #e0dbd5;

  --offen: #c4880d;
  --offen-bg: #fef3e0;
  --in-arbeit: #2563eb;
  --in-arbeit-bg: #dbeafe;
  --fertig: #16803c;
  --fertig-bg: #dcfce7;
  --geprueft: #6d28d9;
  --geprueft-bg: #ede9fe;

  --priorsbau: #b8ddb0;
  --altbau: #f0b0b0;
  --neubau: #fde68a;
  --verbindungsbau: #d5c8e8;
  --esh: #d9d9d9;
  --morimond: #c8d8e8;
  --extern: #e8e8e8;

  --header-h: 48px;
  --radius: 8px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: Calibri, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ── Login Overlay ── */
.overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.login-box { width: 100%; max-width: 320px; }
.login-header { text-align: center; margin-bottom: 28px; }
.login-brand {
  font-family: Georgia, serif;
  font-size: 12px; letter-spacing: 3px;
  color: var(--text-light);
}
.login-title {
  font-family: Georgia, serif;
  font-size: 20px; color: var(--text);
  margin-top: 4px;
}
.login-step[hidden] { display: none; }
.login-label {
  font-size: 12px; color: var(--text-light);
  text-align: center; margin-bottom: 10px;
}

/* User List */
.user-list { display: flex; flex-direction: column; gap: 6px; }
.user-btn {
  width: 100%; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; font-family: inherit;
  transition: border-color 0.15s;
}
.user-btn:active { border-color: var(--primary); }
.user-role-tag {
  font-size: 10px; color: var(--text-light);
  background: #f0ede9; padding: 2px 8px;
  border-radius: 4px;
}

/* PIN Pad */
.pin-user-name { font-size: 14px; text-align: center; margin-bottom: 8px; }
.pin-dots {
  font-size: 22px; letter-spacing: 10px;
  text-align: center; margin-bottom: 6px;
  font-family: monospace;
}
.pin-error {
  font-size: 11px; color: var(--primary);
  text-align: center; margin-bottom: 6px;
}
.pin-error[hidden] { display: none; }
.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 5px; max-width: 220px; margin: 0 auto;
}
.pin-key {
  height: 46px; border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card); font-size: 18px;
  cursor: pointer; font-family: inherit;
  transition: background 0.1s;
}
.pin-key:active { background: #f0ede9; }
.pin-key--action { font-size: 13px; }
.pin-key--primary {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
}
.pin-key--primary:active { background: #7a2929; }
.pin-back {
  display: block; margin: 10px auto 0;
  background: none; border: none;
  color: var(--text-light); font-size: 12px;
  cursor: pointer; font-family: inherit;
}
.lockout-msg {
  text-align: center; color: var(--primary);
  font-size: 13px; padding: 20px;
}

/* ── App Header ── */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--card);
  border-bottom: 3px solid var(--primary);
  padding: 8px 12px;
  display: flex; justify-content: space-between; align-items: center;
  height: var(--header-h);
}
.header-left { display: flex; align-items: center; gap: 8px; }
.header-title { font-family: Georgia, serif; font-size: 14px; }
.header-user { font-size: 10px; color: var(--text-light); }
.header-right { display: flex; align-items: center; gap: 8px; }
.badge {
  background: var(--offen); color: #fff;
  border-radius: 10px; padding: 2px 7px;
  font-size: 11px; font-weight: 700;
  min-width: 22px; text-align: center;
}
.badge[hidden] { display: none; }
.offline-tag {
  background: var(--primary); color: #fff;
  border-radius: 4px; padding: 2px 6px;
  font-size: 9px; font-weight: 600;
}
.offline-tag[hidden] { display: none; }
.btn-logout {
  background: none; border: 1px solid var(--border);
  border-radius: 5px; padding: 4px 10px;
  font-size: 11px; cursor: pointer;
  color: var(--text-light); font-family: inherit;
}

/* ── Notification Banner ── */
.notify-banner {
  background: var(--in-arbeit-bg);
  border-bottom: 1px solid var(--in-arbeit);
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  animation: slideDown 0.3s ease-out;
}
.notify-banner[hidden] { display: none; }
.notify-icon {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--in-arbeit); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; flex-shrink: 0;
}
.notify-title { font-size: 13px; font-weight: 600; color: var(--in-arbeit); }
.notify-body { font-size: 10px; color: var(--text-light); }
.notify-close {
  margin-left: auto; background: none; border: none;
  font-size: 18px; cursor: pointer; color: var(--text-light);
}
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Main Content ── */
.app-content { padding: 10px; }

/* ── Status Bar ── */
.status-bar { display: flex; gap: 5px; margin-bottom: 10px; }
.status-card {
  flex: 1; border-radius: 6px; padding: 6px;
  text-align: center;
}
.status-card--offen { background: var(--offen-bg); color: var(--offen); }
.status-card--in_arbeit { background: var(--in-arbeit-bg); color: var(--in-arbeit); }
.status-card--fertig { background: var(--fertig-bg); color: var(--fertig); }
.status-count { font-size: 18px; font-weight: 700; }
.status-label { font-size: 9px; }

/* ── Progress Card (Leitung) ── */
.progress-card {
  background: var(--card); border-radius: 10px;
  padding: 14px; border: 1px solid var(--border);
  margin-bottom: 10px; text-align: center;
}
.progress-pct { font-size: 32px; font-weight: 700; }
.progress-sub { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.progress-bar {
  height: 6px; background: #eee;
  border-radius: 3px; margin-top: 8px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.3s;
}
.progress-warn {
  margin-top: 6px; font-size: 11px;
  color: var(--offen); font-weight: 600;
}

/* ── Legend ── */
.legend { display: flex; gap: 6px; flex-wrap: wrap; font-size: 9px; margin-bottom: 8px; }
.legend-item { display: flex; align-items: center; gap: 3px; }
.legend-dot {
  width: 8px; height: 8px; border-radius: 2px;
  border: 1px solid transparent;
}

/* ── Plan Section ── */
.plan-section {
  border-radius: 6px; padding: 6px;
  margin-bottom: 5px;
}
.plan-section--priorsbau { background: var(--priorsbau); }
.plan-section--altbau { background: var(--altbau); }
.plan-section--neubau { background: var(--neubau); }
.plan-section--verbindungsbau { background: var(--verbindungsbau); }
.plan-section--esh { background: var(--esh); }
.plan-section--morimond { background: var(--morimond); }
.plan-section--extern { background: var(--extern); }

.plan-section-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 4px;
}
.plan-section-label { font-size: 10px; font-weight: 700; color: #555; }
.plan-section-bulk {
  font-size: 9px; padding: 2px 7px;
  border-radius: 3px; border: 1px solid rgba(0,0,0,0.15);
  background: rgba(255,255,255,0.6);
  cursor: pointer; color: #555; font-family: inherit;
}
.plan-row { display: flex; gap: 3px; margin-bottom: 3px; flex-wrap: nowrap; }

/* ── Room Cell ── */
.room-cell {
  width: 48px; height: 38px;
  border-radius: 4px; border: 1.5px solid #ccc;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex-shrink: 0; cursor: default;
  transition: opacity 0.15s, box-shadow 0.15s;
}
.room-cell--tappable { cursor: pointer; }
.room-cell--selected { box-shadow: 0 0 0 2px var(--primary); border-color: var(--primary); }
.room-cell--dimmed { opacity: 0.15; }
.room-cell--prio { border-left: 3px solid var(--primary); }
.room-cell--offen { background: var(--offen-bg); border-color: var(--offen); }
.room-cell--in_arbeit { background: var(--in-arbeit-bg); border-color: var(--in-arbeit); }
.room-cell--fertig { background: var(--fertig-bg); border-color: var(--fertig); }
.room-cell--geprueft { background: var(--geprueft-bg); border-color: var(--geprueft); }
.room-cell--none { background: #fff; border-color: #ccc; }

.room-nr {
  font-size: 10px; font-weight: 600;
  line-height: 1; text-align: center;
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 100%;
  padding: 0 2px;
}
.room-cell--group .room-nr { font-size: 7px; }
.room-status-dot {
  width: 5px; height: 5px;
  border-radius: 50%; margin-top: 2px;
}
.room-assigned {
  font-size: 6px; color: var(--text-light);
  max-width: 38px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

/* ── Edit Mode Toggle (Rezeption) ── */
.edit-toggle {
  padding: 4px 10px; border-radius: 5px;
  font-size: 10px; cursor: pointer;
  font-family: inherit; flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--card); color: var(--text-light);
}
.edit-toggle--active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary); font-weight: 600;
}
.edit-warning {
  background: #fef3e0; border: 1px solid #f0c040;
  border-radius: 6px; padding: 6px 10px;
  font-size: 10px; color: #8a6d1b;
  margin-bottom: 8px;
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--card); border-radius: 12px;
  padding: 18px; width: 100%; max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-title { font-weight: 600; font-size: 16px; margin-bottom: 2px; }
.modal-subtitle { font-size: 11px; color: var(--text-light); margin-bottom: 14px; }
.modal-section { margin-bottom: 14px; }
.modal-section-label { font-size: 11px; font-weight: 600; margin-bottom: 5px; }

.modal-status-row { display: flex; gap: 4px; }
.modal-status-btn {
  flex: 1; padding: 5px 2px; border-radius: 5px;
  font-size: 9px; cursor: pointer;
  font-weight: 600; font-family: inherit;
}

.modal-user-btn {
  width: 100%; padding: 10px 12px; border-radius: 6px;
  margin-bottom: 4px; cursor: pointer;
  font-size: 13px; text-align: left;
  font-family: inherit; border: 1.5px solid var(--border);
  background: var(--card);
}
.modal-user-btn--selected {
  border-color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}
.modal-user-btn--none {
  font-size: 12px; color: var(--text-light);
}

.modal-textarea {
  width: 100%; height: 54px; border-radius: 6px;
  border: 1px solid var(--border); padding: 8px;
  font-size: 12px; font-family: inherit; resize: none;
}

.modal-actions { display: flex; gap: 6px; }
.modal-btn {
  flex: 1; padding: 9px; border-radius: 6px;
  font-size: 12px; cursor: pointer; font-family: inherit;
}
.modal-btn--cancel {
  border: 1px solid var(--border);
  background: var(--card);
}
.modal-btn--save {
  border: none; background: var(--primary);
  color: #fff; font-weight: 600;
}

/* ── Info text ── */
.info-text { font-size: 10px; color: var(--text-light); margin-bottom: 8px; }
.empty-msg { text-align: center; padding: 40px; color: var(--text-light); font-size: 14px; }

/* ── Scrollable plan ── */
.plan-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Admin ── */
.admin-tabs {
  display: flex; gap: 4px; margin-bottom: 12px;
  border-bottom: 2px solid var(--border); padding-bottom: 4px;
}
.admin-tab {
  padding: 8px 16px; border: none; background: none;
  font-size: 13px; cursor: pointer; font-family: inherit;
  color: var(--text-light); border-radius: 6px 6px 0 0;
}
.admin-tab--active {
  color: var(--primary); font-weight: 600;
  background: var(--primary-light);
  border-bottom: 2px solid var(--primary);
  margin-bottom: -6px;
}
.admin-info {
  background: #dbeafe; border: 1px solid var(--in-arbeit);
  border-radius: 6px; padding: 10px 12px;
  font-size: 11px; color: #1e40af; margin-bottom: 12px;
  line-height: 1.4;
}
.admin-section-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 8px;
}
.admin-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center;
}
.admin-card--compact { padding: 8px 12px; }
.admin-card-main { flex: 1; min-width: 0; }
.admin-card-name { font-size: 13px; font-weight: 500; }
.admin-card-detail { font-size: 10px; color: var(--text-light); margin-top: 2px; }
.admin-form { flex-direction: column; align-items: stretch; }
.admin-edit-btn {
  padding: 4px 10px; border-radius: 5px;
  border: 1px solid var(--border); background: var(--card);
  font-size: 11px; cursor: pointer; font-family: inherit;
  color: var(--text-light); flex-shrink: 0;
}
.admin-label {
  font-size: 11px; font-weight: 600; display: block; margin-bottom: 3px;
}
.admin-input {
  width: 100%; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border); font-size: 13px;
  font-family: inherit;
}
.admin-btn-primary {
  width: 100%; padding: 10px; border-radius: 6px;
  border: none; background: var(--primary); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; margin-top: 8px;
}
.admin-toggle {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; flex-shrink: 0; font-size: 11px;
}
.admin-toggle input { width: 16px; height: 16px; cursor: pointer; }
.admin-toggle-label { color: var(--text-light); }
