:root {
  --bg: #f6f5f1;
  --card: #fff;
  --ink: #23302a;
  --muted: #6b766f;
  --line: #e3e1d9;
  --accent: #4f7a5b;
  --booked: #6c8fd1;
  --blocked: #c95f54;
  --closed: #eceae4;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 12px; }

.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: 6px 12px; font: inherit; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.tiny { font-size: .7rem; padding: 2px 6px; margin-top: 4px; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar form { margin: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nav input { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; }
.week-label { font-weight: 600; margin-left: 8px; text-transform: capitalize; }
.legend { display: flex; gap: 14px; font-size: .85rem; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid var(--line); }
.sw.available { background: #fff; }
.sw.booked { background: var(--booked); }
.sw.blocked { background: repeating-linear-gradient(45deg, var(--blocked) 0 3px, #e9a59d 3px 6px); }
.sw.closed { background: var(--closed); }
.hint { color: var(--muted); font-size: .85rem; margin: 12px 0; }

.grid-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.grid { display: grid; user-select: none; touch-action: pan-y; min-width: 600px; }
.corner, .day-head { position: sticky; top: 0; background: var(--card); z-index: 1; border-bottom: 1px solid var(--line); }
.day-head { padding: 8px 4px; text-align: center; display: flex; flex-direction: column; align-items: center; font-size: .85rem; text-transform: capitalize; border-left: 1px solid var(--line); }
.day-head span { color: var(--muted); }
.day-head.is-today strong { color: var(--accent); }
.time { font-size: .7rem; color: var(--muted); text-align: right; padding-right: 6px; height: 22px; line-height: 1; padding-top: 2px; }
.cell { height: 22px; border-left: 1px solid var(--line); border-top: 1px dotted #efede7; font-size: .7rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 4px; line-height: 22px; }
.cell.hour { border-top: 1px solid var(--line); }
.cell.closed { background: var(--closed); }
.cell.available { background: #fff; }
.cell.booked { background: var(--booked); color: #fff; border-top-color: transparent; }
.cell.booked.booking-start { border-top: 2px solid #3f5f9c; font-weight: 600; }
.cell.blocked { background: repeating-linear-gradient(45deg, var(--blocked) 0 4px, #e9a59d 4px 8px); }
.cell.editable { cursor: pointer; }
.cell.editable:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell.pending-block { box-shadow: inset 0 0 0 2px #8a2a20; opacity: .75; }
.cell.pending-unblock { box-shadow: inset 0 0 0 2px var(--accent); background: #e4f0e7; }
.cell.past:not(.booked) { opacity: .5; }

.save-bar {
  position: sticky; bottom: 12px; margin: 12px auto 0; width: fit-content;
  display: flex; gap: 10px; align-items: center; background: var(--ink); color: #fff;
  padding: 8px 8px 8px 16px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 5;
}
.save-bar[hidden] { display: none; }

.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 20px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.booking-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.booking-list li { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.booking-list li strong { text-transform: capitalize; }
.booking-list small, .booking-list .empty, .small { color: var(--muted); font-size: .8rem; }
.range-form { display: flex; flex-direction: column; gap: 10px; }
.range-form label { display: flex; justify-content: space-between; align-items: center; gap: 10px; max-width: 280px; }
.range-form input { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.2); z-index: 10; }
.toast.error { background: var(--blocked); }
.toast[hidden] { display: none; }

.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(340px, 90vw); display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.login-card input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.error { color: var(--blocked); margin: 0; }
