:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #10213d;
  background: #f4f7fb;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.app-header {
  height: 68px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid #dbe3ee;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 122px; height: 40px; object-fit: contain; }
.brand span { color: #536987; font-size: 13px; white-space: nowrap; }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(25px, 4vw, 38px); margin-bottom: 8px; letter-spacing: 0; }
h2 { font-size: 20px; letter-spacing: 0; }
.eyebrow { color: #1260ad; font-size: 12px; font-weight: 750; text-transform: uppercase; margin-bottom: 5px; }
.message { min-height: 22px; margin: 0; color: #9b2c2c; font-size: 14px; }

.login-layout {
  min-height: calc(100vh - 116px);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 460px);
  align-items: center;
  gap: 8vw;
}
.password-layout {
  min-height: calc(100vh - 116px);
  display: grid;
  place-items: center;
}
.password-layout .login-form { width: min(100%, 520px); }
.password-layout .login-form > p:not(.eyebrow) { color: #536987; }
.login-intro { max-width: 650px; }
.login-intro > p:not(.eyebrow) { color: #536987; font-size: 17px; line-height: 1.55; max-width: 590px; }
.login-form {
  padding: 28px;
  background: #fff;
  border: 1px solid #d6e0ec;
  border-radius: 8px;
  box-shadow: 0 10px 35px rgba(24, 55, 90, .08);
}
label { display: grid; gap: 7px; color: #344a68; font-size: 14px; font-weight: 650; margin-bottom: 16px; }
input, textarea {
  width: 100%;
  border: 1px solid #bfcddd;
  border-radius: 6px;
  padding: 12px 13px;
  color: #10213d;
  background: #fff;
}
input { min-height: 46px; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus { outline: 3px solid rgba(22, 104, 190, .16); border-color: #1668be; }

.primary-command, .icon-command, .close-command, .range-control button,
.tab, .work-tab, .attendance-tools button {
  border: 0;
  cursor: pointer;
  min-height: 44px;
  border-radius: 6px;
}
.primary-command {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  background: #155eef;
  color: #fff;
  font-weight: 750;
  text-decoration: none;
}
.primary-command:hover { background: #0b4dcc; }
.ms-command { margin: 18px 0; min-height: 48px; }
.login-form .primary-command { width: 100%; }
.icon-command { background: #edf3fa; color: #193a60; padding: 0 14px; }

.portal-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}
.range-control {
  display: grid;
  grid-template-columns: 44px minmax(160px, auto) 44px;
  align-items: center;
  border: 1px solid #cfdae7;
  background: #fff;
  border-radius: 7px;
}
.range-control span { text-align: center; padding: 0 8px; font-size: 14px; font-weight: 700; }
.range-control button { background: transparent; color: #15529a; font-size: 28px; }

.tabs, .work-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid #ccd8e5;
  overflow-x: auto;
}
.tab, .work-tab {
  background: transparent;
  color: #526984;
  padding: 0 15px;
  border-radius: 0;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  font-weight: 700;
}
.tab.active, .work-tab.active { color: #0b56b3; border-color: #155eef; }
.tab-panel { padding-top: 16px; }

.appointment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.appointment {
  background: #fff;
  border: 1px solid #d5dfeb;
  border-left: 4px solid #2772b8;
  border-radius: 7px;
  padding: 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 16px;
}
.appointment.today { border-left-color: #00875a; background: #f6fffb; }
.appointment h3 { font-size: 17px; margin: 0 0 4px; letter-spacing: 0; }
.appointment-meta { color: #526984; line-height: 1.45; }
.appointment-date { font-size: 13px; color: #0b56b3; font-weight: 750; margin-bottom: 5px; }
.appointment-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; grid-column: 1 / -1; }
.appointment-actions button, .appointment-actions a {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid #b9c9da;
  border-radius: 6px;
  background: #fff;
  color: #154d86;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.appointment-actions button.primary { background: #155eef; border-color: #155eef; color: #fff; }

.empty-state { padding: 30px 18px; text-align: center; color: #647891; background: #fff; border: 1px dashed #bdcad9; }
.room-days { display: grid; gap: 14px; }
.room-day { background: #fff; border-top: 3px solid #2772b8; }
.room-day h3 { margin: 0; padding: 11px 14px; font-size: 16px; border: 1px solid #d7e0ea; border-top: 0; }
.room-row { display: grid; grid-template-columns: 90px 120px minmax(0, 1fr); gap: 12px; padding: 11px 14px; border: 1px solid #d7e0ea; border-top: 0; }
.room-row strong { color: #164f88; }

dialog {
  width: min(1040px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #10213d;
  box-shadow: 0 22px 70px rgba(7, 29, 55, .28);
}
dialog::backdrop { background: rgba(13, 31, 53, .55); }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px 12px; border-bottom: 1px solid #d8e1ec; }
.dialog-header h2 { margin: 0; }
.close-command { width: 44px; background: #eef3f8; font-size: 27px; color: #39516d; }
.work-tabs { padding: 0 20px; position: sticky; top: 0; background: #fff; z-index: 2; }
.work-panel { padding: 16px 20px 86px; }
.attendance-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.attendance-tools button { padding: 0 14px; background: #eaf4ff; color: #15529a; font-weight: 750; }
.attendance-list { display: grid; gap: 8px; }
.attendance-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) repeat(3, minmax(94px, auto)) 44px;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid #d8e1eb;
  border-radius: 6px;
}
.attendance-name { font-weight: 750; }
.status-button { min-height: 42px; border: 1px solid #bdcad8; background: #fff; color: #3f5570; border-radius: 5px; font-weight: 700; }
.status-button.active[data-status="ANWESEND"] { background: #dbf7e9; border-color: #1a9c66; color: #087247; }
.status-button.active[data-status="FEHLT"] { background: #ffebeb; border-color: #d45151; color: #a12222; }
.status-button.active[data-status="TEILWEISE"] { background: #fff1cf; border-color: #d49b19; color: #885e00; }
.detail-toggle { min-height: 42px; border: 0; background: #eef3f8; border-radius: 5px; color: #39516d; font-size: 22px; }
.attendance-details { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding-top: 8px; }
.attendance-details label { margin: 0; }
.attendance-details input { min-height: 42px; padding: 8px; }
.check-label { display: flex; align-items: center; gap: 8px; padding-top: 23px; }
.check-label input { width: 20px; min-height: 20px; }
.save-bar {
  position: sticky;
  bottom: 0;
  background: rgba(255, 255, 255, .97);
  border-top: 1px solid #ced9e5;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}
.save-bar .message { flex: 1; color: #087247; text-align: right; }

@media (max-width: 860px) {
  main { padding: 16px 12px; }
  .app-header { padding: 0 12px; }
  .login-layout { display: block; min-height: 0; }
  .login-intro { padding: 22px 0 10px; }
  .login-form { padding: 20px; }
  .portal-heading { align-items: stretch; flex-direction: column; }
  .range-control { align-self: stretch; }
  .appointment-grid { grid-template-columns: 1fr; }
  .room-row { grid-template-columns: 72px 90px minmax(0, 1fr); font-size: 13px; }
  .attendance-row { grid-template-columns: minmax(0, 1fr) repeat(3, 44px) 40px; }
  .status-button { font-size: 0; padding: 0; }
  .status-button::after { font-size: 18px; }
  .status-button[data-status="ANWESEND"]::after { content: "✓"; }
  .status-button[data-status="FEHLT"]::after { content: "×"; }
  .status-button[data-status="TEILWEISE"]::after { content: "½"; }
  .attendance-details { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 430px) {
  .brand span { display: none; }
  .room-row { grid-template-columns: 64px minmax(0, 1fr); }
  .room-row span:last-child { grid-column: 1 / -1; }
  .attendance-row { padding: 8px; gap: 5px; }
  .attendance-details { grid-template-columns: 1fr; }
  .check-label { padding-top: 0; }
}
