/* Terminkalender – Gestaltung. Das Raster lehnt sich an das bisherige Programm an. */
:root {
  --grau: #c0c0c0;
  --halb: #8c8c8c;
  --flaeche: #f0f0f0;
  --rand: #a6a6a6;
  --blau: #0b57b5;
  --rot: #d40000;
  --rinne: 32px;
  font-family: Tahoma, "Segoe UI", Verdana, Arial, sans-serif;
  font-size: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: #fff; color: #000; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
#app { height: 100%; display: flex; flex-direction: column; }
.ohne-js, .leer { padding: 24px; font-size: 14px; }

/* ---- Werkzeugleiste ---- */
.oben {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding: 3px 6px;
  background: var(--flaeche); border-bottom: 1px solid var(--rand);
}
.o-gruppe { display: flex; align-items: center; gap: 2px; }
.o-gruppe + .o-gruppe { border-left: 1px solid var(--rand); padding-left: 10px; }
.o-gruppe.rechts { margin-left: auto; border-left: 0; padding-left: 0; }
.o-titel { font-weight: bold; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wk {
  border: 1px solid transparent; background: none; border-radius: 3px; padding: 4px 8px; cursor: pointer; white-space: nowrap;
}
.wk:hover, .wk:focus-visible { background: #dcebfc; border-color: #7da2ce; outline: none; }
.wk.pfeil { font-size: 16px; line-height: 14px; padding: 3px 7px; color: var(--blau); font-weight: bold; }
.wk.menueknopf::after { content: " ▾"; font-size: 10px; color: #444; }
.wk.betont { background: var(--blau); color: #fff; border-color: var(--blau); }
.wk.betont:hover, .wk.betont:focus-visible { background: #084690; }

/* ---- Aufteilung ---- */
.koerper { flex: 1; min-height: 0; display: flex; }
.ansicht { flex: 1; min-width: 0; min-height: 0; }
.seite { width: 214px; flex: none; border-left: 1px solid #000; padding: 4px 6px 10px; overflow-y: auto; background: #fff; }
.seite-zu { display: none; width: 100%; margin-bottom: 8px; padding: 8px; border: 1px solid #8a8a8a; background: #e9e9e9; border-radius: 3px; cursor: pointer; }
.seite-titel { margin: 10px 0 4px; font-size: 12px; border-bottom: 1px solid #000; padding-bottom: 2px; }
.legende { list-style: none; margin: 0; padding: 0; line-height: 1.7; }
.hinweis { color: #555; font-size: 11px; margin: 6px 0; }
.farbfeld { display: inline-block; width: 13px; height: 13px; border: 1px solid #000; vertical-align: -2px; }

/* ---- Zeitraster ---- */
.raster { height: 100%; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; }
.r-titel {
  text-align: center; font-weight: bold; font-size: 13px; letter-spacing: .4px; padding: 6px 4px; margin-top: 2px;
  border-top: 1px solid #000; border-bottom: 1px solid #000; flex: none;
}
.r-scroll { flex: 1; min-height: 0; overflow: auto; }
.r-innen { display: flex; flex-direction: column; }
.r-kopf { display: flex; position: sticky; top: 0; z-index: 6; background: #fff; border-bottom: 1px solid #000; }
.r-kopfzelle {
  flex: 1 1 0; min-width: 0; text-align: center; font-weight: bold; font-size: 13px; letter-spacing: .3px;
  padding: 6px 2px; border-right: 2px solid #000; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.r-kopfzelle small { display: block; font-size: 10px; font-weight: normal; }
.r-kopfzelle.rot { color: var(--rot); }
.r-kopfzelle.heute { background: #dcebfc; }
.r-kopfzelle:last-child, .r-spalte:last-child, .r-bandzelle:last-child { border-right: 0; }
.r-band { display: flex; border-bottom: 1px solid #000; background: #fff; }
.r-bandzelle { flex: 1 1 0; min-width: 0; border-right: 2px solid #000; padding: 1px 1px 0; min-height: 19px; }
.r-chip {
  display: block; width: 100%; text-align: left; border: 1px solid #000; margin-bottom: 1px; padding: 0 3px;
  font-size: 11px; line-height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.r-spalten { display: flex; flex: none; }
.r-spalte { flex: 1 1 0; min-width: 0; position: relative; border-right: 2px solid #000; overflow: hidden; }
.r-std { position: relative; border-bottom: 1px solid #000; background: #fff; }
.r-std.rand { background: var(--grau); }
.r-zeit { position: absolute; left: 3px; top: 50%; transform: translateY(-50%); font-size: 11px; line-height: 1; white-space: nowrap; }
.r-zeit small { font-size: 11px; color: #7b7b7b; margin-left: 3px; }
.r-halb { position: absolute; left: calc(var(--rinne) + 1px); right: 0; top: 50%; border-top: 1px solid var(--halb); }
.r-termin { position: absolute; border: 1px solid #000; overflow: hidden; font-size: 11px; line-height: 1.3; z-index: 2; }
.r-farben { position: absolute; inset: 0; display: flex; }
.r-farben i { flex: 1; }
.r-text { position: relative; padding: 1px 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.r-serie { font-weight: bold; }
.r-griff { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; cursor: ns-resize; }
.raster.aenderbar .r-termin { cursor: move; }
.r-termin.gewaehlt { outline: 2px dashed #000; outline-offset: -4px; }
.r-termin.zieht { z-index: 9; opacity: .88; box-shadow: 0 3px 10px rgba(0, 0, 0, .45); pointer-events: none; }
.r-termin.zieht::after {
  content: attr(data-zeit); position: absolute; right: 1px; bottom: 1px; background: #000; color: #fff; padding: 0 4px; font-size: 10px;
}
/* Die Markierung darf keine Klicks abfangen, sonst kommt der Doppelklick auf die freie Zeit nicht an. */
.r-slot { position: absolute; left: var(--rinne); right: 0; background: var(--grau); outline: 1px dotted #000; outline-offset: -1px; z-index: 1; pointer-events: none; }

/* ---- Monatsansicht ---- */
.monat { height: 100%; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; }
.m-kopf, .m-woche { display: grid; grid-template-columns: 26px repeat(7, minmax(0, 1fr)); }
.m-kopf { border-bottom: 1px solid #000; flex: none; }
.m-kopf > div { text-align: center; font-weight: bold; padding: 5px 0; border-right: 1px solid #000; }
.m-kopf > div:last-child, .m-tag:last-child { border-right: 0; }
.m-wt.rot { color: var(--rot); }
.m-wt .kurz { display: none; }
.m-rumpf { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.m-woche { flex: 1 1 0; min-height: 0; border-bottom: 1px solid #000; }
.m-kw { text-align: center; color: #555; font-size: 10px; padding-top: 4px; border-right: 1px solid #000; background: var(--flaeche); }
.m-kopf .m-kw { font-weight: normal; padding-top: 6px; }
.m-tag { border-right: 1px solid #000; overflow: hidden; padding: 1px 2px; min-width: 0; }
.m-tag.fremd { background: #e6e6e6; }
.m-tag.fremd .m-zahl { color: #777; font-weight: normal; }
.m-tag.frei .m-zahl { color: var(--rot); }
.m-tag.heute { box-shadow: inset 0 0 0 2px var(--blau); }
.m-nr { display: flex; gap: 4px; align-items: baseline; height: 19px; }
.m-zahl { border: 0; background: none; font-weight: bold; font-size: 13px; cursor: pointer; padding: 0 3px; border-radius: 3px; }
.m-zahl:hover, .m-zahl:focus-visible { background: #dcebfc; outline: none; }
.m-ft { color: var(--rot); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-eintrag {
  font-size: 11px; line-height: 14px; height: 16px; margin-bottom: 1px; padding: 0 3px; border: 1px solid #000;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer;
}
.m-mehr { border: 0; background: none; font-size: 11px; color: var(--blau); cursor: pointer; padding: 0 2px; }

/* ---- Kleine Monatskalender ---- */
.mini { margin-bottom: 8px; }
.mini-kopf { display: flex; align-items: center; justify-content: space-between; font-weight: bold; border-bottom: 1px solid #000; padding: 2px 0; }
.mini-pfeil { border: 0; background: none; cursor: pointer; padding: 0 5px; font-size: 12px; }
.mini-pfeil:hover, .mini-pfeil:focus-visible { background: #dcebfc; outline: none; }
.mini-gitter { display: grid; grid-template-columns: 20px repeat(7, 1fr); text-align: center; font-size: 11px; align-items: center; }
.mini-wt { padding: 2px 0; }
.mini-kw { color: #777; font-size: 10px; }
.mini-tag { border: 1px solid transparent; background: none; padding: 2px 0; cursor: pointer; font-size: 11px; }
.mini-tag:hover, .mini-tag:focus-visible { background: #dcebfc; outline: none; }
.mini-tag.belegt { font-weight: bold; }
.mini-tag.rot { color: var(--rot); }
.mini-tag.fremd { color: #8a8a8a; }
.mini-tag.gezeigt { background: #e9e9e9; }
.mini-tag.gewaehlt { background: var(--grau); border-color: #555; }
.mini-tag.heute { border-color: var(--blau); }

/* ---- Menüs ---- */
.menue {
  position: fixed; z-index: 1000; min-width: 170px; max-height: calc(100vh - 8px); overflow-y: auto; padding: 3px;
  background: #fbfbfb; border: 1px solid #8f8f8f; box-shadow: 2px 3px 8px rgba(0, 0, 0, .3);
}
.menue-eintrag { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 5px 14px 5px 24px; cursor: pointer; position: relative; white-space: nowrap; }
.menue-eintrag:hover:not(:disabled), .menue-eintrag:focus-visible { background: #dcebfc; outline: none; }
.menue-eintrag:disabled { color: #9a9a9a; cursor: default; }
.menue-eintrag.an::before { content: "✓"; position: absolute; left: 7px; color: var(--blau); font-weight: bold; }
.menue-kopf { padding: 5px 8px 2px; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: #666; }
.menue hr { border: 0; border-top: 1px solid #c8c8c8; margin: 3px 0; }

/* ---- Fenster ---- */
.dlg { border: 1px solid #555; padding: 0; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); width: 560px; font-size: 13px; }
.dlg.schmal { width: 400px; }
.dlg.breit { width: 780px; }
.dlg.termin { width: 820px; }
.dlg::backdrop { background: rgba(0, 0, 0, .28); }
.dlg-form { display: flex; flex-direction: column; max-height: calc(100vh - 18px); margin: 0; }
.dlg-kopf { display: flex; align-items: center; justify-content: space-between; background: var(--flaeche); border-bottom: 1px solid var(--rand); padding: 6px 6px 6px 12px; }
.dlg-kopf h2 { margin: 0; font-size: 14px; }
.dlg-zu { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 8px; }
.dlg-zu:hover, .dlg-zu:focus-visible { background: #e81123; color: #fff; outline: none; }
.dlg-rumpf { padding: 12px; overflow-y: auto; flex: 1; min-height: 0; }
.dlg-fuss { display: flex; gap: 8px; justify-content: flex-end; padding: 8px 12px; background: var(--flaeche); border-top: 1px solid var(--rand); flex-wrap: wrap; }
.dlg-fuss .knopf.links { order: -1; }
.dlg-fuss .knopf.links + .knopf:not(.links) { margin-left: auto; }
.dlg-text { margin: 0; line-height: 1.5; white-space: pre-line; }
.dlg-fehler { color: #b00000; background: #fde8e8; border: 1px solid #e3a4a4; padding: 6px 8px; margin: 10px 0 0; }
.knopf { border: 1px solid #8a8a8a; background: #e9e9e9; padding: 5px 14px; cursor: pointer; border-radius: 3px; min-width: 76px; }
.knopf:hover, .knopf:focus-visible { background: #dcebfc; border-color: #3d7fc9; outline: none; }
.knopf.haupt { background: var(--blau); border-color: var(--blau); color: #fff; }
.knopf.haupt:hover, .knopf.haupt:focus-visible { background: #084690; }
.knopf.gefahr { color: #a40000; border-color: #c98a8a; }
.knopf.gefahr:hover, .knopf.gefahr:focus-visible { background: #fde8e8; border-color: #a40000; }
.knopf.klein { padding: 2px 8px; min-width: 0; font-size: 12px; }
.knopf:disabled { opacity: .55; cursor: default; }

.feld { display: flex; flex-direction: column; gap: 3px; margin-bottom: 9px; min-width: 0; flex: 1; }
.feld-name { font-size: 12px; color: #333; }
.feld input:not([type=checkbox]):not([type=color]), .feld select, .feld textarea, .gruppe > select {
  border: 1px solid #8a8a8a; padding: 5px 6px; background: #fff; width: 100%; border-radius: 2px;
}
.feld textarea { resize: vertical; min-height: 84px; line-height: 1.35; }
input.kurz { width: 64px !important; }
input[type=color] { width: 44px; height: 28px; padding: 1px; border: 1px solid #8a8a8a; background: #fff; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #3d7fc9; outline-offset: -1px; }
.haken { display: flex; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer; }
.haken input { margin: 0; flex: none; width: 15px; height: 15px; }
.zeile { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.zeile > .haken { margin-bottom: 12px; }
.zeile.eng { gap: 6px; align-items: center; flex-wrap: nowrap; }
.zeile.tage { gap: 10px; margin: 6px 0; }
.zeile.knoepfe { margin-top: 12px; gap: 8px; }
.spalte { display: flex; flex-direction: column; }
.gruppe { border: 1px solid #b4b4b4; padding: 6px 10px 8px; margin: 4px 0 10px; min-width: 0; }
.gruppe legend { padding: 0 4px; font-size: 12px; color: #333; }
.gruppe > .zeile { margin-top: 8px; align-items: center; gap: 6px; }

.termin-form { display: flex; gap: 14px; align-items: flex-start; }
.termin-links { flex: 1 1 400px; min-width: 0; }
.termin-rechts { flex: 0 0 300px; margin: 0; max-height: 62vh; overflow-y: auto; }
.leute-gruppe { margin-bottom: 8px; }
.gruppenknopf { border: 0; background: none; font-weight: bold; cursor: pointer; padding: 2px 0; text-decoration: underline dotted; }
.gruppenknopf:hover, .gruppenknopf:focus-visible { color: var(--blau); outline: none; }
.leute-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 0 10px; }

.ansehen p { margin: 0 0 8px; line-height: 1.45; }
.ansehen-zeit { font-weight: bold; }
.ansehen-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; padding: 8px; background: #f6f6f6; border: 1px solid #d0d0d0; }

.reiter { display: flex; gap: 2px; border-bottom: 1px solid #8a8a8a; margin-bottom: 12px; }
.reiter-kopf { border: 1px solid #8a8a8a; border-bottom: 0; background: #e3e3e3; padding: 5px 14px; cursor: pointer; margin-bottom: -1px; border-radius: 3px 3px 0 0; }
.reiter-kopf.an { background: #fff; border-bottom: 1px solid #fff; font-weight: bold; }
.liste { border-collapse: collapse; width: 100%; }
.liste th, .liste td { border: 1px solid #c4c4c4; padding: 4px 6px; text-align: left; vertical-align: top; }
.liste th { background: var(--flaeche); font-weight: normal; font-size: 12px; }
.liste.typen input[type=text] { width: 100%; border: 1px solid #8a8a8a; padding: 4px 6px; }
.liste td.mitte { text-align: center; vertical-align: middle; }
.nowrap { white-space: nowrap; }
.verwaltung { display: flex; gap: 14px; align-items: flex-start; }
.verwaltung-liste { flex: 0 0 230px; border: 1px solid #8a8a8a; max-height: 58vh; overflow-y: auto; }
.verwaltung-form { flex: 1; min-width: 0; }
.verwaltung-form h3 { margin: 0 0 10px; font-size: 14px; }
.listenknopf { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid #dedede; background: #fff; padding: 5px 8px; cursor: pointer; }
.listenknopf:hover, .listenknopf:focus-visible { background: #eef5fd; outline: none; }
.listenknopf.an { background: #cfe3fa; }
.listenknopf small { color: #555; }

/* ---- Anmeldung ---- */
.anmeldung { height: 100%; display: flex; align-items: center; justify-content: center; background: var(--flaeche); padding: 16px; overflow: auto; }
.anmeldung-karte { width: 340px; max-width: 100%; background: #fff; border: 1px solid #8a8a8a; padding: 22px 24px 24px; font-size: 14px; box-shadow: 0 4px 18px rgba(0, 0, 0, .15); }
.anmeldung-karte h1 { margin: 0 0 16px; font-size: 20px; }
.anmeldung-karte .feld input { padding: 8px; font-size: 15px; }
.anmeldung-karte .knopf { width: 100%; padding: 9px; margin-top: 12px; font-size: 15px; }

.druckliste { display: none; }

/* ---- Schmale Bildschirme (Handy) ---- */
@media (max-width: 700px) {
  :root { font-size: 14px; }
  .oben { gap: 4px; padding: 4px; }
  .o-gruppe + .o-gruppe { border-left: 0; padding-left: 0; }
  .o-titel { order: 10; flex-basis: 100%; padding: 2px 4px 0; }
  .wk { padding: 8px 10px; }
  .wk.pfeil { font-size: 20px; padding: 5px 12px; line-height: 20px; }
  .seite { position: fixed; right: 0; top: 0; bottom: 0; z-index: 20; width: 250px; box-shadow: -4px 0 14px rgba(0, 0, 0, .3); }
  .seite-zu { display: block; }
  .mini-tag { padding: 6px 0; font-size: 13px; }
  .r-termin, .r-chip { font-size: 12px; }
  .m-wt .lang { display: none; }
  .m-wt .kurz { display: inline; }
  .m-eintrag { padding: 0 1px; font-size: 10px; }
  .termin-form, .verwaltung { flex-direction: column; }
  .termin-rechts, .verwaltung-liste { flex: none; width: 100%; max-height: 220px; }
  .termin-links { flex: none; width: 100%; }
  .knopf { padding: 9px 14px; }
}

/* ---- Druck ---- */
@page { size: A4 landscape; margin: 9mm; }
@page liste { size: A4 portrait; margin: 14mm; }
@media print {
  html, body, #app { height: auto; overflow: visible; }
  .oben, .seite, .menue, dialog, .r-slot, .r-griff { display: none !important; }
  .koerper, .ansicht { display: block; }
  .raster, .r-scroll { height: auto; overflow: visible; display: block; }
  .r-innen { min-width: 0 !important; }
  .r-kopf { position: static; }
  .r-termin.gewaehlt { outline: none; }
  .monat { height: 185mm; }
  .m-tag.heute { box-shadow: none; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body.druck-liste #app { display: none; }
  body.druck-liste .druckliste { display: block; page: liste; font-size: 11pt; }
  .druckliste h1 { font-size: 16pt; margin: 0 0 2mm; }
  .druckliste h2 { font-size: 12pt; margin: 6mm 0 2mm; break-after: avoid; }
  .druckliste p { margin: 0 0 4mm; }
  .druckliste table { border-collapse: collapse; width: 100%; table-layout: fixed; }
  .druckliste th:nth-child(1) { width: 15%; }
  .druckliste th:nth-child(2) { width: 22%; }
  .druckliste th:nth-child(3) { width: 13%; }
  .druckliste th, .druckliste td { border: 1px solid #000; padding: 1.5mm 2mm; text-align: left; vertical-align: top; }
  .druckliste th { background: #e0e0e0; font-size: 10pt; }
  .druckliste tr { break-inside: avoid; }
  .druckliste .umbruch { white-space: pre-wrap; overflow-wrap: anywhere; }
}
