:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --primary: #0ea5e9;
  --job: #2563eb;
  --visit: #16a34a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  background: linear-gradient(135deg, #0f172a, #0369a1);
  color: white;
  padding: 20px;
}

header h1 {
  margin: 0;
  font-size: 26px;
}

header p {
  margin: 6px 0 0;
  color: #dbeafe;
}

.wrap {
  padding: 20px;
  max-width: 1400px;
  margin: auto;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.people-grid {
  grid-template-columns: 2fr 1fr 1fr;
}

.section-gap {
  margin-top: 12px;
}

.bottom-align {
  display: flex;
  align-items: end;
}

label {
  font-size: 13px;
  font-weight: bold;
  color: #374151;
  display: block;
  margin-bottom: 4px;
}

input,
select,
textarea,
button {
  width: 100%;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 46px;
}

button {
  cursor: pointer;
  background: var(--primary);
  color: white;
  border: none;
  font-weight: bold;
}

button:hover {
  opacity: 0.9;
}

.btn-grey {
  background: #64748b;
}

.btn-red {
  background: #dc2626;
}

.btn-green {
  background: #16a34a;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.month-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.month-bar h2 {
  margin: 0;
}

.month-controls {
  display: flex;
  gap: 8px;
  width: auto;
}

.month-controls button {
  min-width: 95px;
}

.people-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.person-chip {
  color: white;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: bold;
}

.people-checks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 4px;
}

.people-checks label {
  font-weight: normal;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.people-checks input {
  width: auto;
}

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.job-dot {
  background: var(--job);
}

.visit-dot {
  background: var(--visit);
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: white;
}

.day-name {
  background: #e5e7eb;
  font-weight: bold;
  text-align: center;
  padding: 10px;
  border-right: 1px solid var(--border);
}

.day {
  min-height: 145px;
  padding: 8px;
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: #fff;
}

.day:nth-child(7n) {
  border-right: none;
}

.day.other-month {
  background: #f9fafb;
  color: #9ca3af;
}

.day-number {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 6px;
}

.booking {
  border-radius: 8px;
  padding: 6px;
  margin-bottom: 6px;
  color: white;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.3;
}

.booking strong {
  display: block;
  font-size: 13px;
}

.booking small {
  display: block;
  opacity: 0.95;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
}

.modal-box {
  background: white;
  border-radius: 14px;
  padding: 18px;
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .people-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .calendar {
    font-size: 12px;
  }

  .day {
    min-height: 120px;
    padding: 5px;
  }

  .people-checks {
    grid-template-columns: repeat(2, 1fr);
  }

  .month-bar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .grid,
  .people-grid,
  .people-checks {
    grid-template-columns: 1fr;
  }

  .actions,
  .month-controls {
    flex-direction: column;
  }

  .day {
    min-height: 105px;
  }
}

@media print {
  .form-panel,
  .month-controls,
  .modal {
    display: none !important;
  }

  body {
    background: white;
  }

  .wrap {
    padding: 0;
  }
}
