:root {
  --bg: #f4f7ff;
  --surface: #ffffff;
  --surface-2: #f8faff;
  --primary: #2f6df6;
  --primary-dark: #1f56cf;
  --text: #1b2233;
  --muted: #6e7788;
  --danger: #dd3d3d;
  --border: #e6ebf4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 15% 0%, #ffffff 0%, transparent 40%),
    radial-gradient(circle at 90% 10%, #eef4ff 0%, transparent 35%),
    var(--bg);
  color: var(--text);
}

h1, h2, h3, h4, p {
  margin: 0;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  transition: 0.2s ease;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #5d90ff);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.btn-ghost {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: #f7faff;
}

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

.btn-danger:hover {
  filter: brightness(0.95);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(20, 30, 60, 0.06), 0 2px 8px rgba(20, 30, 60, 0.04);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 430px;
  padding: 28px;
  border: 1px solid #dfe7f5;
  box-shadow: 0 16px 34px rgba(22, 39, 73, 0.12);
  background: linear-gradient(170deg, #ffffff, #f8fbff);
}

.muted {
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

input, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: #fff;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(47, 109, 246, 0.1);
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background: rgba(255, 255, 255, 0.95);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
}

.sidebar.collapsed {
  width: 0;
  overflow: hidden;
}

.side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.nav {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav button {
  text-align: left;
  background: transparent;
}

.nav button.active {
  background: #ecf2ff;
  color: var(--primary-dark);
}

.side-foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 12px;
}

.profile-nav-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(30, 50, 90, 0.08);
}

.main {
  flex: 1;
  padding: 18px;
}

.main-inner {
  max-width: 980px;
  margin: 0 auto;
}

.main-inner.main-inner-wide {
  max-width: 1180px;
}

.main-inner.main-inner-calendar {
  max-width: 1180px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  min-height: 52px;
}

.topbar h3,
.topbar-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.menu-float {
  position: fixed;
  top: 16px;
  left: 24px;
  z-index: 40;
  width: 42px;
  height: 42px;
  border: 1px solid #d7e0ef;
  background: #fff;
  font-size: 19px;
  font-weight: 500;
  border-radius: 12px;
  box-shadow: 0 10px 18px rgba(27, 34, 51, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.panel {
  margin-top: 16px;
  padding: 22px;
}

.calendar {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
}

.calendar-wrap {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 4px;
}

.day {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 96px;
  padding: 10px;
}

.day-clickable {
  text-align: left;
  font-weight: 500;
}

.day-clickable:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.12);
}

.day-number {
  display: block;
}

.day-has-note {
  background: #edf3ff;
}

.day-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e03434;
  display: inline-block;
  margin-top: 10px;
}

.day.head {
  background: #eef3fe;
  min-height: auto;
  font-weight: 700;
  text-align: center;
}

.users-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
}

th, td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 10px 8px;
}

.users-table .col-user {
  width: 34%;
}

.users-table .col-class {
  width: 24%;
}

.users-table .col-role {
  width: 18%;
}

.users-table .col-actions {
  width: 24%;
}

.users-create-btn {
  width: 190px;
}

.users-table-wrap {
  overflow-x: auto;
}

.row-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  gap: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 20, 35, 0.35);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 18px;
  box-shadow: 0 20px 40px rgba(12, 20, 35, 0.2);
}

.profile-avatar-section {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9fbff;
}

.profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(140deg, #e7eeff, #f4f7ff);
  color: var(--primary-dark);
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 700;
  margin: 0 auto;
  border: 2px solid #dbe5fb;
  overflow: hidden;
  position: relative;
}

.profile-avatar.has-image {
  background: #fff;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.profile-add-image-btn {
  margin: 12px auto 0;
  display: block;
}

.avatar-adjust-grid {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.avatar-adjust-grid label {
  font-size: 12px;
  color: var(--muted);
  display: grid;
  gap: 4px;
}

.avatar-adjust-grid input[type="range"] {
  width: 100%;
}

.events-list {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.events-list h4 {
  margin-bottom: 10px;
}

.event-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  min-width: 260px;
}

.events-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  flex-direction: column;
}

.modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-actions.modal-actions-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.modal-actions.modal-actions-stack button {
  width: 100%;
}

@media (max-width: 900px) {
  .main {
    padding: 12px;
  }

  .main-inner {
    max-width: 100%;
  }

  .panel {
    padding: 14px;
  }

  .topbar h3 {
    font-size: 20px;
  }

  .calendar {
    grid-template-columns: repeat(7, minmax(38px, 1fr));
    gap: 8px;
    overflow-x: auto;
  }

  .day {
    min-height: 72px;
    font-size: 13px;
  }
}

@media (max-width: 720px) {
  .app-layout {
    position: relative;
  }

  .sidebar {
    position: fixed;
    left: 8px;
    top: 8px;
    transform: none;
    z-index: 20;
    width: min(82vw, 330px);
    height: calc(100vh - 16px);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 16px 32px rgba(10, 20, 40, 0.18);
  }

  .sidebar.collapsed {
    width: 0;
    height: 0;
    border: 0;
    overflow: hidden;
  }

  .users-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar h3 {
    font-size: 18px;
  }

  .users-table,
  .users-table thead,
  .users-table tbody,
  .users-table tr,
  .users-table td {
    display: block;
  }

  .users-table thead {
    display: none;
  }

  .users-table tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
    background: #fff;
  }

  .users-table td {
    border: 0;
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    gap: 10px;
  }

  .users-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
  }

  .users-table td[data-label="Aktionen"] {
    display: block;
    padding-top: 10px;
  }

  .users-table td[data-label="Aktionen"]::before {
    display: none;
  }

  .users-table td[data-label="Aktionen"] .row-actions {
    justify-content: flex-start;
  }

  .modal {
    max-width: 100%;
  }

  .profile-avatar {
    width: 78px;
    height: 78px;
    font-size: 26px;
  }

  .menu-float {
    top: 10px;
    left: 14px;
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .main {
    padding: 10px;
  }

  .panel {
    border-radius: 14px;
    padding: 12px;
  }

  .calendar {
    gap: 8px;
    min-width: 560px;
  }

  .day {
    min-height: 80px;
    padding: 8px;
  }
}
