* { box-sizing: border-box; }
  body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; background: #f3f4f6; color: #111827; overflow: hidden; }

  /* Layout */
  header, footer { background: #fff; border-color: #e5e7eb; border-style: solid; z-index: 100; padding: 10px 16px; }
  header { display: flex; align-items: center; justify-content: space-between; border-width: 0 0 1px 0; position: sticky; top: 0; }
  main { height: calc(100vh - 120px); padding: 10px; overflow-y: auto; }
  footer { position: fixed; bottom: 0; left: 0; right: 0; border-width: 1px 0 0 0; display: flex; justify-content: center; gap: 12px; }
  #period-label { font-weight: 600; font-size: 1.1rem; }

  /* Buttons */
  button { border-radius: 8px; border: 1px solid #d1d5db; padding: 8px 12px; font-size: 0.9rem; cursor: pointer; background: #fff; transition: all 0.2s; }
  button:hover { background: #f9fafb; border-color: #9ca3af; }
  button:active { transform: scale(0.96); }
  .btn-primary, .btn-primary-prime { background: #ffb13c; color: #fff; border-color: #ffb13c; font-weight: 600; }
  .btn-primary:hover { background: #f59e0b; }
  .btn-ghost { border-color: transparent; background: transparent; }
  .btn-ghost:hover { background: #f3f4f6; }

  /* Grid & Table */
  .month-grid { display: grid; grid-template-columns: repeat(7, 1fr); background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }
  .month-header-cell { text-align: center; font-weight: 600; padding: 10px 0; background: #f9fafb; border-bottom: 1px solid #e5e7eb; font-size: 0.8rem; text-transform: uppercase; }
  .month-day-cell { min-height: 100px; min-width: 100px; padding: 4px; border-right: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; position: relative; cursor: pointer; }
  .month-day-cell:nth-child(7n) { border-right: none; }
  .month-day-cell.other-month { background: #f9fafb; color: #9ca3af; }
  .month-day-cell.today { background: #fffbeb; }
  .month-day-number { font-weight: 600; font-size: 0.8rem; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
  .month-day-number.is-holiday { border: 2px solid #ffb13c; color: #b45309; }
  .month-day-text { font-size: 11px; margin-top: 2px; padding: 2px 4px; background: #f3f4f6; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .week-table { width: 100%; border-collapse: collapse; background: #fff; table-layout: fixed; }
  .week-table th, .week-table td { border: 1px solid #e5e7eb; height: 30px; position: relative; }
  .time-col { width: 50px; text-align: center; font-size: 10px; color: #6b7280; background: #f9fafb; }

  /* Appointment Blocks */
  .appointment-title { font-size: 10px; font-weight: bold; opacity: 0.9; }
  .appointment-subject { font-size: 12px; font-weight: 600; }

  /* Persons (Gradients) 
  .person-mama { background: linear-gradient(135deg, #1ff1e0, #14e5f4); }
  .person-papa { background: linear-gradient(135deg, #fb923c, #f97316); }
  .person-eyk { background: linear-gradient(135deg, #53e087, #16a34a); }
  .person-eddy { background: linear-gradient(135deg, #a855f7, #7c3aed); }
  .person-eykeddy { background: linear-gradient(135deg, #86f7af, #b78ffd); }
  .person-family { background: linear-gradient(135deg, #ff64f5, #f423ff); }*/

  .person-holiday { border: 1px solid #ffb13c; color: #b45309; background: #fff7eb; }
  .person-default { background: #f3f4f6; }

  /* Dashboard & Dialog */
  #dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
  .dash-card { background: #fff; border-radius: 16px; padding: 20px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }
  .dash-title { font-size: 0.8rem; color: #6b7280; text-transform: uppercase; margin-bottom: 8px; }
  .dash-big { font-size: 1.8rem; font-weight: 600; margin-bottom: 4px; }
  .dash-item { padding: 10px; border-radius: 8px; margin-bottom: 8px; background: #f9fafb;}
  .dash-term { padding: 10px; border-left: 4px solid #ffb13c; background: #f9fafb;}
  .dash-today { background: #fff7eb; border-left-color: #f59e0b; }

/* Die Zelle selbst zurücksetzen, falls Padding stört */
td.slot {
    padding: 0;
    vertical-align: top; /* Sorgt dafür, dass der Block oben startet */
}

/* Container um die gesamte Tabelle */
.calendar-scroll-wrapper {
    width: 100%;
    overflow-x: auto; /* Horizontales Scrollen auf dem Handy */
    -webkit-overflow-scrolling: touch;
    border: 1px solid #ddd;
}

table {
    min-width: 700px; /* Erzwingt eine Mindestbreite, damit Termine lesbar bleiben */
    width: 100%;
    table-layout: fixed; /* Gleichmäßige Spaltenbreiten */
}

/* Optional: Die erste Spalte (Uhrzeiten) fixieren */
td.time-col, th.time-col {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 10;
    border-right: 2px solid #eee;
}


@media screen and (max-width: 600px) {
    /* Tabelle in Blöcke umwandeln */
    .month-view table, 
    .month-view tbody, 
    .month-view tr, 
    .month-view td {
        display: block;
        width: 100%;
    }

    /* Kopfzeile (Mo, Di, Mi...) ausblenden */
    .month-view thead {
        display: none;
    }

    /* Nur Tage mit Terminen anzeigen oder Tage als Sektionen stylen */
    .month-view td.slot {
        border-bottom: 1px solid #eee;
        padding: 10px;
        min-height: auto;
    }

    /* Kennzeichnung des Datums in der Listenansicht */
    .month-view td.slot::before {
        content: attr(data-date); /* Falls du das Datum im Attribut speicherst */
        display: block;
        font-weight: bold;
        margin-bottom: 5px;
        color: #666;
    }
}


@media screen and (max-width: 600px) {
    .appointment-block {
        padding: 4px 8px;
        font-size: 0.85rem;
    }
    
    .appointment-title {
        font-size: 0.9rem;
    }

    /* Betreff bei Platzmangel evtl. ausblenden oder kürzen */
    .appointment-subject {
        font-size: 0.75rem;
        opacity: 0.8;
    }
}



/* Der Termin-Block füllt die gesamte Zelle aus */
.appointment-block {
    height: 100%;
    min-height: 100%; /* Sicherstellung für manche Browser */
    box-sizing: border-box; /* Padding/Border werden in die 100% eingerechnet */
    
    /* Optionale Optik */
    display: flex;
    align-items: center;
    justify-content: center;
}

  #dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5); /* Etwas dunkler für besseren Fokus */
  backdrop-filter: blur(4px);
  display: none; /* Wird per JS auf 'grid' gesetzt */
  place-items: center; /* Zentriert horizontal UND vertikal */
  padding: 20px; /* Sicherheitsabstand zum Rand auf Handys */
  z-index: 1000;
}
  #dialog {
  background: #fff;
  width: 100%;
  max-width: 450px; /* Etwas breiter für bessere Lesbarkeit */
  padding: 15px;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
  /* Verhindert, dass der Dialog bei kleinen Handys oben/unten rausragt */
  max-height: 90vh; 
  overflow-y: auto; 
}

.appointment-block {
    height: 100%;
    display: flex;
    flex-direction: column; /* Richtet die Kinder (Titel & Betreff) vertikal aus */
    justify-content: center; /* Zentriert den Inhalt vertikal im Block */
    align-items: center;     /* Zentriert den Inhalt horizontal (optional) */
    box-sizing: border-box;
    padding: 5px;            /* Etwas Abstand zum Rand der Zelle */
}

/* Falls du den Text linksbündig haben möchtest: */
.appointment-block {
    align-items: flex-start; 
}

/* Optional: Abstand zwischen Titel und Betreff */
.appointment-title {
    font-weight: bold;
    margin-bottom: 2px;
}

  .form-row { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
  .form-row label { font-size: 0.75rem; font-weight: 600; color: #4b5563; }
  .form-row input, .form-row select { padding: 10px; border-radius: 8px; border: 1px solid #d1d5db; font-size: 1rem; }
  .inline-row { display: flex; gap: 10px; align-items: center; }

  /* Feedback */
  #toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px); color: #fff; padding: 12px 24px; border-radius: 50px; font-weight: 600; z-index: 2000; opacity: 0; transition: all 0.3s; pointer-events: none; }
  #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  #loading-overlay { position: fixed; inset: 0; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 3000; }
  .spinner { width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top-color: #ffb13c; border-radius: 50%; animation: spin 1s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* Mobile */
  @media (max-width: 600px) {
    header { flex-direction: column; gap: 10px; text-align: center; }
    .month-day-cell { min-height: 70px; }
    .month-day-text { font-size: 9px; background: #f3f4f6;}
    .dash-big { font-size: 1.4rem; }
    #dialog { width: 95%; padding: 16px; }
  }
/* ===== MOBILE MONATSANSICHT (LISTE) ===== */
@media (max-width: 600px) {

  .month-grid {
    display: block;
    border: none;
  }

  .month-header-cell {
    display: none;
  }

  .month-day-cell {
    display: block;
    background: #fff;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    min-height: auto;
  }

  .month-day-cell.other-month {
    display: none; /* 👉 blendet andere Monate aus */
  }

  .month-day-number {
    display: none; /* wir nutzen stattdessen data-date */
  }

  /* 👉 Datum als Überschrift */
  .month-day-cell::before {
    content: attr(data-date);
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #374151;
  }

  /* 👉 Termine als echte Liste */
  .month-day-text {
    display: block;
    font-size: 0.85rem;
    padding: 6px 8px;
    margin-bottom: 4px;
    border-radius: 6px;
    background: #f3f4f6;
    white-space: normal;
  }

  /* 👉 Heute hervorheben */
  .month-day-cell.today {
    border: 2px solid #ffb13c;
    background: #fff7eb;
  }

  /* 👉 leere Tage optional ausblenden */
  .month-day-cell:empty {
    display: none;
  }
}