* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background: #f5f5f7;
  color: #1d1d1f;
}
header {
  background: #1d1d1f;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header h1 { margin: 0; font-size: 20px; }
header nav { font-size: 14px; }
header nav span { margin-right: 12px; }
button.link {
  background: none;
  color: #4ea1ff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}
main {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 24px;
}
h2 { margin-top: 0; }
.error { color: #c0392b; }
.hint { color: #666; font-size: 13px; }

.login-card {
  max-width: 360px;
  margin: 80px auto;
  background: #fff;
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.login-card label { display: block; margin-bottom: 12px; font-size: 14px; }
.login-card input { width: 100%; padding: 8px; margin-top: 4px; border: 1px solid #ccc; border-radius: 4px; }
.login-card button {
  width: 100%; padding: 10px; background: #007aff; color: #fff;
  border: none; border-radius: 4px; cursor: pointer; font-size: 15px;
}
.login-card button:hover { background: #0062cc; }

.controls {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
}
.controls button {
  padding: 6px 12px; background: #fff; border: 1px solid #ccc;
  border-radius: 4px; cursor: pointer;
}
.range-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.range-form label { font-size: 14px; }
.range-form input { padding: 4px; }
.range-form button {
  padding: 6px 12px; background: #fff; border: 1px solid #ccc;
  border-radius: 4px; cursor: pointer;
}
.range-form button.primary { background: #007aff; color: #fff; border: none; }
#month-label { font-weight: bold; min-width: 160px; text-align: center; }

#calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; max-width: 600px; }
#calendar .dow { font-weight: bold; text-align: center; padding: 8px; background: #e5e5ea; border-radius: 4px; }
#calendar .day {
  background: #fff; padding: 12px 6px; text-align: center;
  border-radius: 4px; cursor: pointer; border: 1px solid transparent;
  user-select: none;
}
#calendar .day:hover { border-color: #007aff; }
#calendar .day.empty { background: transparent; cursor: default; }
#calendar .day.weekend { background: #f0f5ff; }
#calendar .day.holiday { background: #ffe5d0; }
#calendar .day.unavail { background: #ffd0d0 !important; font-weight: bold; }

.card {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

#planning-table table { border-collapse: collapse; width: 100%; }
#planning-table th, #planning-table td { border: 1px solid #ddd; padding: 6px 10px; text-align: center; font-size: 13px; }
#planning-table th { background: #305496; color: #fff; }
#planning-table tr.weekend td { background: #ddebf7; }
#planning-table tr.holiday td { background: #f8cbad; }
#planning-table tr.weekend.holiday td { background: #f4b084; }
#planning-table td.cell-wrap { padding: 2px; }
#planning-table .cell-select {
  width: 100%;
  padding: 4px 2px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}
#planning-table .cell-select:hover { border-color: #007aff; }
#planning-table .cell-select:focus { outline: 2px solid #007aff; border-color: #007aff; }
#planning-table .cell-select.diff-solver {
  background: #FFC7CE; color: #C00000; font-weight: bold;
}
#planning-table .cell-select.diff-manual {
  background: #FFE0B2; color: #C77700; font-weight: bold;
}
#planning-table .indispo-cell { cursor: pointer; }
#planning-table .indispo-cell:hover { outline: 2px solid #c0392b; }
#planning-table .indispo-cell.is-unavail { background: #ffd0d0; font-weight: bold; }

.window-info { display: flex; flex-direction: column; gap: 12px; }
.window-info .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.window-info button { padding: 8px 14px; background: #fff; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; font-size: 13px; }
.window-info button.primary { background: #007aff; color: #fff; border: none; }
.window-info button:hover { opacity: 0.85; }
#status { font-size: 14px; min-height: 18px; }
#status.success { color: #2ecc71; }
#status.error { color: #c0392b; }

.legend-item { display: inline-block; width: 12px; text-align: center; }
.legend-solver { color: #C00000; }
.legend-manual { color: #C77700; }

.admin-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }
.admin-main { min-width: 0; }
.admin-sidebar { height: fit-content; position: sticky; top: 16px; }
.admin-sidebar h3 { margin-top: 0; }
.admin-sidebar h4 { margin: 16px 0 4px 0; font-size: 14px; }
.stats-period { font-size: 11px; color: #888; margin: 0 0 6px 0; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.stats-table th, .stats-table td { padding: 4px 6px; text-align: center; border-bottom: 1px solid #eee; }
.stats-table th { background: #f5f5f7; }
@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; }
}
