:root {
  --bg: #0f172a;
  --card: #111827;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --btn: #2563eb;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #020617, #0b1222 40%, #111827);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 880px;
  margin: 20px auto 60px;
  padding: 0 14px;
}
.top-user-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.user-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid #374151;
  background: rgba(11, 18, 34, 0.9);
  max-width: min(100%, 420px);
}
.user-bubble .muted {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-door {
  min-height: 34px;
  min-width: 34px;
  width: 34px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-color: rgba(239, 68, 68, 0.45);
}
.logout-icon {
  width: 18px;
  height: 18px;
  display: block;
}
.logout-admin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
h1 { margin-bottom: 8px; }
.app-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-title-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
}
.sub { color: var(--muted); margin-top: 0; font-size: 15px; }

.card {
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-top: 14px;
}
.card h2 { margin-top: 0; font-size: 18px; }

.row { display: grid; gap: 6px; margin-bottom: 10px; }
input, select, button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #0b1222;
  color: var(--text);
  padding: 9px 10px;
  min-height: 42px;
}
button {
  cursor: pointer;
  background: var(--btn);
  border-color: #1d4ed8;
}
button.secondary {
  background: #1f2937;
  border-color: #374151;
}
button:disabled { opacity: 0.6; cursor: not-allowed; }

.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #1f2937;
  color: var(--text);
  text-decoration: none;
  min-height: 42px;
}
.muted { color: var(--muted); }
.users-list {
  display: grid;
  gap: 8px;
}
.user-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #374151;
  border-radius: 12px;
  background: #0b1222;
}
.user-list-main {
  min-width: 0;
}
.user-list-title {
  margin: 0;
  font-weight: 700;
}
.user-list-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-edit-btn {
  width: auto;
  height: 40px;
  min-height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  padding: 16px;
  background: rgba(2, 6, 23, 0.68);
  display: grid;
  place-items: center;
  z-index: 50;
}
.modal-backdrop[hidden] {
  display: none !important;
}
.modal-card {
  width: min(100%, 460px);
  max-height: min(100vh - 32px, 760px);
  overflow: auto;
  background: rgba(17, 24, 39, 0.98);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.modal-head h3 {
  margin: 0;
}

.notif-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.notif-toggle-row span {
  font-weight: 700;
}
.switch {
  min-height: 34px;
  height: 34px;
  width: 58px;
  padding: 2px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.25);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
}
.switch .switch-thumb {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transform: translateX(0);
  transition: transform 180ms ease;
}
.switch.is-on {
  background: linear-gradient(135deg, #34d399, #10b981);
  border-color: rgba(16, 185, 129, 0.55);
}
.switch.is-on .switch-thumb {
  transform: translateX(24px);
}
.switch:disabled { opacity: 0.5; cursor: not-allowed; }

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  margin-bottom: 12px;
}
.my-slots-count {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(52, 211, 153, 0.4);
  background: rgba(16, 185, 129, 0.12);
  color: #a7f3d0;
  font-weight: 700;
}
.my-slots-count.has-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.my-slots-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
.my-slots-count.is-empty {
  border-color: #374151;
  background: rgba(31, 41, 55, 0.55);
  color: #cbd5e1;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.month-nav strong {
  text-transform: capitalize;
}

.month-nav button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  justify-self: center;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 560px) {
  .month-nav {
    flex-wrap: nowrap;
    justify-content: space-between;
  }

  .month-nav button {
    flex: 0 0 44px;
  }
}

.slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.slot {
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 10px;
  background: #0b1222;
}
.slot.slot-past {
  opacity: 0.58;
  filter: grayscale(0.35);
}
.slot-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.slot .date {
  font-weight: 600;
  margin-bottom: 6px;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 6px 8px;
  display: inline-block;
  white-space: nowrap;
}

.slot .date.date-tri {
  border-color: #facc15;
  background: rgba(250, 204, 21, 0.12);
}

.slot .date.date-dechet {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
}

.collection-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 9px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.collection-chip.tri {
  color: #a16207;
  background: rgba(250, 204, 21, 0.16);
  border-color: rgba(250, 204, 21, 0.45);
}

.collection-chip.dechet {
  color: #075985;
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.45);
}

.shift-alert {
  margin: 0 0 8px;
  color: #fde047;
  font-size: 13px;
}
.badge {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 8px;
}
.slot-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.slot-person {
  color: #cbd5e1;
  font-size: 14px;
  text-align: left;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slot-meta-row button {
  min-height: 38px;
  min-width: 98px;
  width: 98px;
  padding: 8px 12px;
  margin-left: auto;
}
.slot-action-spacer {
  min-width: 98px;
  width: 98px;
  height: 38px;
  flex: 0 0 auto;
}
.free { color: #86efac; }
.mine { color: #fcd34d; }
.taken { color: #fca5a5; }

footer {
  margin-top: 16px;
  color: var(--muted);
}

.auth-page .container {
  max-width: 460px;
  margin: 24px auto;
}

.auth-page h1,
.auth-page .sub {
  text-align: center;
}

.auth-page .buttons {
  display: grid;
  gap: 8px;
}

.auth-page button,
.auth-page .secondary-link {
  width: auto;
}

@media (max-width: 640px) {
  .container {
    margin: 12px auto 24px;
    padding: 0 12px;
  }

  h1 {
    font-size: 18px;
  }

  .top-user-bar {
    justify-content: center;
  }

  .user-bubble {
    width: 100%;
    border-radius: 14px;
    display: grid;
    grid-template-columns: 34px 1fr 34px;
    align-items: center;
    gap: 8px;
  }

  .user-bubble::before {
    content: "";
    width: 34px;
    height: 34px;
  }

  .user-bubble .muted {
    text-align: center;
  }

  .logout-door {
    justify-self: end;
  }

  .card {
    padding: 12px;
    border-radius: 16px;
  }

  .buttons {
    display: grid;
    gap: 8px;
  }

  .buttons button,
  .buttons .secondary-link {
    width: 100%;
  }

  .slots {
    grid-template-columns: 1fr;
  }

  .legend {
    gap: 10px;
    justify-content: center;
    font-size: 11px;
  }

  #slotsTitle {
    text-align: center;
    text-decoration: underline;
    margin: 0 0 19px;
  }

  .my-slots-count {
    font-size: 13px;
    margin: 0 0 14px;
  }

  .month-nav {
    margin-bottom: 25px;
  }

  .legend {
    margin-bottom: 24px;
    row-gap: 8px;
    column-gap: 12px;
  }

  .user-list-item {
    align-items: flex-start;
  }

  .user-edit-btn {
    width: auto;
    min-width: 40px;
  }
}
