*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  background: #e8e8e8;
  color: #000;
}

/* ── Passwort-Overlay ── */
#password-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1a3a5c 0%, #2d6a9f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#password-overlay.hidden { display: none; }

.pw-box {
  background: #fff;
  border-radius: 10px;
  padding: 40px 48px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  text-align: center;
  min-width: 320px;
}
.pw-box h2 { font-size: 26px; margin-bottom: 8px; color: #1a3a5c; }
.pw-box p  { color: #666; margin-bottom: 24px; font-size: 17px; }
.pw-box input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #ccc;
  border-radius: 6px;
  font-size: 20px;
  margin-bottom: 16px;
  outline: none;
}
.pw-box input:focus { border-color: #2d6a9f; }
.pw-box button {
  width: 100%;
  padding: 11px;
  background: #2d6a9f;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 20px;
  cursor: pointer;
}
.pw-box button:hover { background: #1a3a5c; }
#pw-error { color: #c0392b; font-size: 17px; margin-top: 10px; display: none; }

/* ── Toolbar ── */
#toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #1a3a5c;
  color: #fff;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
#toolbar h1 { font-size: 21px; flex: 1; }
#toolbar button {
  padding: 8px 18px;
  border: none;
  border-radius: 5px;
  font-size: 17px;
  cursor: pointer;
  font-weight: bold;
}
#btn-pdf  { background: #e67e22; color: #fff; }
#btn-pdf:hover  { background: #d35400; }
#save-status {
  font-size: 14px;
  opacity: .7;
  min-width: 70px;
}

/* ── Stempelfehler / Stempel-Zeile ── */
tr.has-punches:not(.outside-month) {
  cursor: pointer;
}
tr.has-punches:not(.outside-month):hover td {
  background: #eef5fb;
}
tr.stempelfehler:not(.outside-month) td {
  background: #fdecea !important;
}
tr.stempelfehler:not(.outside-month) input {
  background: #fdecea !important;
}
tr.stempelfehler:not(.outside-month) .sum-cell {
  background: #f8d7d4 !important;
}
.stempelfehler-badge {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: bold;
  color: #c0392b;
  line-height: 1.2;
}
tr.has-punches:not(.stempelfehler) .punch-hint {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: #2d6a9f;
  line-height: 1.2;
}

/* ── Stempel-Dialog ── */
.punch-dialog[hidden] { display: none !important; }
.punch-dialog {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.punch-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
}
.punch-dialog-box {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
  padding: 20px 22px 18px;
  color: #1a3a5c;
}
.punch-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.punch-dialog-header h2 { font-size: 20px; }
.punch-dialog-x {
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0 4px;
}
.punch-dialog-sub {
  font-size: 14px;
  color: #666;
  margin-bottom: 14px;
}
.punch-dialog-sub.error { color: #c0392b; font-weight: bold; }
.punch-dialog-section { margin-bottom: 16px; }
.punch-dialog-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #666;
  margin-bottom: 8px;
  font-weight: bold;
}
.punch-dialog-list {
  list-style: none;
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
}
.punch-dialog-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  background: #f4f7fa;
  border-radius: 6px;
  font-size: 15px;
}
.punch-dialog-list .kommen { color: #1e8449; font-weight: bold; }
.punch-dialog-list .gehen { color: #c0392b; font-weight: bold; }
.punch-dialog-list .time { font-variant-numeric: tabular-nums; font-weight: bold; }
.punch-dialog-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.punch-dialog-fields label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: #555;
}
.punch-dialog-fields select {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 15px;
}
.punch-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.punch-dialog-actions button {
  padding: 9px 16px;
  border: none;
  border-radius: 5px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}
#punch-dialog-save { background: #2d6a9f; color: #fff; }
#punch-dialog-save:hover { background: #1a3a5c; }
#restore-dialog-confirm { background: #2d6a9f; color: #fff; }
#restore-dialog-confirm:hover { background: #1a3a5c; }
.punch-dialog-cancel { background: #e8e8e8; color: #333; }
.punch-dialog-cancel:hover { background: #d5d5d5; }
.restore-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #f4f7fa;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.4;
  cursor: pointer;
}
.restore-check input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex-shrink: 0;
}

tr.punch-highlight td { background: #fff9c4 !important; }
tr.punch-highlight input { background: #fff9c4 !important; }

/* Tage außerhalb des Monats */
tr.outside-month td {
  background: #e9e9e9 !important;
  color: #888;
}
tr.outside-month input {
  background: #e9e9e9 !important;
  color: #999;
  cursor: not-allowed;
}
tr.outside-month .sum-cell {
  background: #dedede !important;
  color: #aaa;
}

/* ── Formular-Container ── */
#form-wrapper {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 16px 40px;
}

#arbeitszeitliste {
  background: #fff;
  padding: 18px 20px 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}

/* ── Kopfzeile ── */
.form-title {
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 14px;
  letter-spacing: .3px;
}
.header-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 24px;
  margin-bottom: 12px;
  font-size: 14px;
}
.header-fields .field {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.header-fields .field label { white-space: nowrap; font-weight: bold; }
.header-fields .field input,
.header-fields .field select {
  flex: 1;
  border: none;
  border-bottom: 1px solid #333;
  background: transparent;
  font-size: 14px;
  padding: 3px 5px;
  outline: none;
  min-width: 0;
}
.header-fields .field input:focus,
.header-fields .field select:focus { border-bottom-color: #2d6a9f; }

.form-title select,
.form-title input[type="number"] {
  border: none;
  border-bottom: 1px solid #333;
  background: transparent;
  font-size: 20px;
  font-weight: bold;
}
.form-title input[type="number"] {
  width: 72px;
  text-align: center;
}

/* ── Wochen-Blöcke ── */
.week-block { margin-bottom: 0; }

table.az-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}
table.az-table th,
table.az-table td {
  border: 1px solid #333;
  padding: 3px 4px;
  text-align: center;
  vertical-align: middle;
}
table.az-table th {
  background: #f0f0f0;
  font-weight: bold;
  font-size: 12px;
  line-height: 1.4;
}
table.az-table td.col-datum-cell {
  font-weight: bold;
  background: #fafafa;
  padding: 3px 4px;
}
table.az-table input[type="text"].date-input {
  font-size: 13px;
  font-weight: bold;
  background: #fafafa;
  color: #333;
  width: 100%;
  text-align: center;
}
table.az-table input[type="text"].date-input.outside-date {
  background: #e9e9e9 !important;
  color: #999;
  font-style: italic;
}

table.az-table input[type="text"].time-input,
table.az-table input[type="text"] {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 13px;
  text-align: center;
  padding: 2px;
  outline: none;
}
table.az-table input[type="text"].time-input { min-width: 0; letter-spacing: 0.3px; }

table.az-table input:focus { background: #fffde7; }
table.az-table .sum-cell {
  background: #f5f5f5;
  font-weight: bold;
  font-size: 13px;
}
table.az-table .week-total td {
  font-weight: bold;
  background: #ececec;
  font-size: 13px;
  border-top: 2px solid #333;
}
table.az-table input[type="text"].verf-sum-input {
  text-align: center;
  font-size: 13px;
}

tr[data-day="5"]:not(.outside-month) td,
tr[data-day="6"]:not(.outside-month) td,
tr[data-day="5"]:not(.outside-month) input,
tr[data-day="6"]:not(.outside-month) input,
table.az-table tr[data-day="5"]:not(.outside-month) td.col-datum-cell,
table.az-table tr[data-day="6"]:not(.outside-month) td.col-datum-cell,
table.az-table tr[data-day="5"]:not(.outside-month) input.date-input,
table.az-table tr[data-day="6"]:not(.outside-month) input.date-input {
  background: #eef4fb;
}
tr[data-day="5"]:not(.outside-month) .sum-cell,
tr[data-day="6"]:not(.outside-month) .sum-cell {
  background: #e3ecf8;
}

.col-datum    { width: 9%; }
.col-beginn   { width: 5.5%; }
.col-ende     { width: 5.5%; }
.col-summe    { width: 6.5%; }
.col-bemerkung{ width: 36%; }
.col-gesamt   { width: 7.5%; }

table.az-table col.col-datum { width: 9%; }
table.az-table col.col-beginn,
table.az-table col.col-ende { width: 5.5%; }
table.az-table col.col-summe { width: 6.5%; }
table.az-table col.col-bemerkung { width: 36%; }
table.az-table col.col-gesamt { width: 7.5%; }

table.az-table input.bemerkung-input {
  text-align: left;
  padding-left: 4px;
}

/* ── Fußzeile ── */
.footer-section {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 20px;
  margin-top: 14px;
  align-items: start;
}
.abbr-legend {
  font-size: 12px;
  line-height: 1.8;
  border: 1px solid #333;
  padding: 10px 13px;
}
.abbr-legend strong { font-size: 13px; display: block; margin-bottom: 4px; }
.abbr-legend span { display: inline-block; margin-right: 10px; }

.month-summary table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.month-summary table td {
  border: 1px solid #333;
  padding: 5px 8px;
}
.month-summary table td:first-child { font-weight: bold; }
.month-summary table td:last-child {
  text-align: right;
  width: 70px;
  font-weight: bold;
  background: #f5f5f5;
}
.month-summary table input {
  width: 100%;
  border: none;
  background: transparent;
  text-align: right;
  font-size: 13px;
  font-weight: bold;
  outline: none;
}

.signature-section {
  margin-top: 16px;
  font-size: 13px;
}
.signature-section .certify {
  font-style: italic;
  margin-bottom: 20px;
  font-size: 13px;
}
.sig-lines {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}
.sig-line {
  border-top: 1px solid #333;
  padding-top: 5px;
  font-size: 12px;
  color: #333;
}
.sig-line input,
.sig-spacer {
  border: none;
  border-bottom: 1px solid #aaa;
  background: transparent;
  font-size: 13px;
  width: 100%;
  margin-bottom: 4px;
  outline: none;
}
.sig-spacer { height: 29px; display: block; }

.field-beschaeftigungsgrad input { max-width: 60px; }
#fld-uebertrag[readonly] {
  background: #f0f0f0;
  color: #333;
  cursor: default;
}

/* ── Seiten-Footer (nur Desktop) ── */
#page-footer {
  max-width: 1200px;
  margin: 0 auto 40px;
  padding: 0 16px;
}
.page-footer-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid #d0d5db;
  border-radius: 8px;
  padding: 14px 18px;
}
#page-footer button {
  padding: 8px 16px;
  border: none;
  border-radius: 5px;
  font-size: 15px;
  cursor: pointer;
  font-weight: bold;
}
#btn-clear { background: #7f8c8d; color: #fff; }
#btn-clear:hover { background: #636e72; }
#btn-restore { background: #2d6a9f; color: #fff; }
#btn-restore:hover { background: #1a3a5c; }
#btn-export {
  margin-left: auto;
  background: #1a3a5c;
  color: #fff;
}
#btn-export:hover { background: #0f2438; }
#snapshot-info {
  font-size: 14px;
  color: #666;
}

@media (max-width: 768px) {
  #page-footer { display: none !important; }
}

/* ── Druck / PDF ── */
@media print {
  #toolbar, #password-overlay, #page-footer, #punch-dialog, #restore-dialog { display: none !important; }
  body { background: #fff; }
  #form-wrapper { margin: 0; padding: 0; max-width: none; }
  #arbeitszeitliste { box-shadow: none; padding: 10px; }
  table.az-table input { background: transparent !important; }
}

@page { size: A4 portrait; margin: 8mm; }

/* Kompakt-Layout nur für PDF-Export */
#arbeitszeitliste.pdf-compact {
  padding: 4px 8px 4px 6px;
  box-shadow: none;
  overflow: visible;
}
#arbeitszeitliste.pdf-compact .form-title {
  font-size: 14px;
  margin-bottom: 4px;
}
#arbeitszeitliste.pdf-compact .header-fields {
  margin-bottom: 4px;
  font-size: 10px;
  gap: 2px 10px;
}
#arbeitszeitliste.pdf-compact table.az-table {
  font-size: 8.5px;
  width: 99%;
  max-width: 99%;
  table-layout: fixed;
  box-sizing: border-box;
}
#arbeitszeitliste.pdf-compact .col-datum,
#arbeitszeitliste.pdf-compact col.col-datum { width: 9%; }
#arbeitszeitliste.pdf-compact .col-beginn,
#arbeitszeitliste.pdf-compact .col-ende,
#arbeitszeitliste.pdf-compact col.col-beginn,
#arbeitszeitliste.pdf-compact col.col-ende { width: 5.5%; }
#arbeitszeitliste.pdf-compact .col-summe,
#arbeitszeitliste.pdf-compact col.col-summe { width: 6.5%; }
#arbeitszeitliste.pdf-compact .col-bemerkung,
#arbeitszeitliste.pdf-compact col.col-bemerkung { width: 36%; }
#arbeitszeitliste.pdf-compact .col-gesamt,
#arbeitszeitliste.pdf-compact col.col-gesamt { width: 7.5%; }
#arbeitszeitliste.pdf-compact table.az-table th,
#arbeitszeitliste.pdf-compact table.az-table td {
  border: 0.5px solid #555;
  padding: 1px 2px;
  line-height: 1.3;
  box-sizing: border-box;
}
#arbeitszeitliste.pdf-compact table.az-table th {
  font-size: 8px;
  background: #f5f5f5;
}
#arbeitszeitliste.pdf-compact table.az-table th small {
  font-size: 6.5px;
}
#arbeitszeitliste.pdf-compact table.az-table input,
#arbeitszeitliste.pdf-compact table.az-table .sum-cell {
  font-size: 8.5px;
  background: transparent !important;
}
#arbeitszeitliste.pdf-compact table.az-table input.date-input {
  background: #f5f5f5 !important;
}
#arbeitszeitliste.pdf-compact .week-total td {
  border-top: 1px solid #555;
  padding: 1px 2px;
}
#arbeitszeitliste.pdf-compact .footer-section {
  margin-top: 4px;
  gap: 6px;
}
#arbeitszeitliste.pdf-compact .abbr-legend {
  font-size: 8px;
  line-height: 1.35;
  padding: 4px 5px;
  border: 0.5px solid #555;
}
#arbeitszeitliste.pdf-compact .abbr-legend strong {
  font-size: 8.5px;
  margin-bottom: 2px;
}
#arbeitszeitliste.pdf-compact .month-summary table {
  font-size: 8.5px;
}
#arbeitszeitliste.pdf-compact .month-summary table td {
  border: 0.5px solid #555;
  padding: 1px 4px;
}
#arbeitszeitliste.pdf-compact .signature-section {
  margin-top: 4px;
  font-size: 8.5px;
}
#arbeitszeitliste.pdf-compact .certify {
  margin-bottom: 6px;
  font-size: 8.5px;
}
#arbeitszeitliste.pdf-compact .sig-lines {
  gap: 20px;
}
#arbeitszeitliste.pdf-compact tr[data-day="5"]:not(.outside-month) td,
#arbeitszeitliste.pdf-compact tr[data-day="6"]:not(.outside-month) td,
#arbeitszeitliste.pdf-compact tr[data-day="5"]:not(.outside-month) input,
#arbeitszeitliste.pdf-compact tr[data-day="6"]:not(.outside-month) input,
#arbeitszeitliste.pdf-compact tr[data-day="5"]:not(.outside-month) td.col-datum-cell,
#arbeitszeitliste.pdf-compact tr[data-day="6"]:not(.outside-month) td.col-datum-cell,
#arbeitszeitliste.pdf-compact tr[data-day="5"]:not(.outside-month) input.date-input,
#arbeitszeitliste.pdf-compact tr[data-day="6"]:not(.outside-month) input.date-input {
  background: #eef4fb !important;
}
#arbeitszeitliste.pdf-compact tr[data-day="5"]:not(.outside-month) .sum-cell,
#arbeitszeitliste.pdf-compact tr[data-day="6"]:not(.outside-month) .sum-cell {
  background: #e3ecf8 !important;
}
#arbeitszeitliste.pdf-compact tr.outside-month td,
#arbeitszeitliste.pdf-compact tr.outside-month input {
  background: #eee !important;
}
