:root {
  --bg: #f6f7fb;
  --card: #fff;
  --text: #1d2330;
  --muted: #7a8194;
  --border: #e3e6ee;
  --accent: #4f46e5;
  --free: #d9f7e3;
  --free-text: #11743a;
  --full: #fde2e2;
  --full-text: #a12a2a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 16px;
}

h1 { margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
}
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.danger { background: #dc2626; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
}

label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }

/* Calendar */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-header h2 { margin: 0; font-size: 20px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-day {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fafbfd;
  color: #b4b9c7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  padding: 0;
}
.cal-day small { font-size: 10px; margin-top: 2px; }
.cal-day.empty { visibility: hidden; }
.cal-day.free { background: var(--free); color: var(--free-text); border-color: #a7e8bd; font-weight: 600; }
.cal-day.full { background: var(--full); color: var(--full-text); border-color: #f5b5b5; }
.cal-day.past { opacity: 0.4; }
.cal-day.selected { outline: 3px solid var(--accent); outline-offset: 1px; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }

.legend { display: flex; gap: 16px; margin-top: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .l-free::before { background: var(--free); border: 1px solid #a7e8bd; }
.legend .l-full::before { background: var(--full); border: 1px solid #f5b5b5; }
.legend .l-none::before { background: #fafbfd; border: 1px solid var(--border); }

/* Slots */
.slots { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.slot {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.slot { display: flex; flex-direction: column; align-items: flex-start; text-align: left; max-width: 100%; }
.slot-note { font-size: 12px; opacity: 0.8; margin-top: 2px; white-space: normal; }
.slot.chosen { background: var(--accent); color: #fff; border-color: var(--accent); }
.slot.booked { text-decoration: line-through; color: var(--muted); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
@media (max-width: 520px) { .form-row { grid-template-columns: 1fr; } }

.msg { padding: 10px 14px; border-radius: 8px; margin-top: 12px; }
.msg.ok { background: var(--free); color: var(--free-text); }
.msg.err { background: var(--full); color: var(--full-text); }
.muted { color: var(--muted); }

/* Admin table */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; }
.pill.free { background: var(--free); color: var(--free-text); }
.pill.booked { background: var(--full); color: var(--full-text); }
select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  background: #fff;
}
.repeat-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 16px 0;
  background: #fafbfd;
}
label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--text);
  margin: 0;
  cursor: pointer;
}
label.check input { width: auto; margin: 0; }
.repeat-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 110px 160px;
  gap: 8px;
  margin: 12px 0 4px;
  align-items: end;
}
@media (max-width: 640px) { .repeat-row { grid-template-columns: 1fr 1fr; } .repeat-row > :first-child { grid-column: 1 / 3; } }
#repeat-preview { font-size: 13px; margin: 6px 0 0; }
td.actions { white-space: nowrap; }
td.actions button { padding: 6px 10px; font-size: 13px; }
.time-rows-head, .time-row {
  display: grid;
  grid-template-columns: 120px 120px 1fr 40px;
  gap: 8px;
  align-items: center;
}
.time-row { margin-bottom: 8px; }
.time-row .remove { padding: 8px 0; }
.row-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
@media (max-width: 520px) {
  .time-rows-head { display: none; }
  .time-row { grid-template-columns: 1fr 1fr 40px; }
  .time-row .note { grid-column: 1 / 3; }
}
.note-edit { padding: 4px 8px; font-size: 13px; min-width: 140px; transition: background 0.3s; }
.note-edit.saved { background: var(--free); }
nav { margin-bottom: 16px; font-size: 14px; }
nav a { color: var(--accent); }
