:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #15201b;
  --muted: #6a766f;
  --line: #e7ebe8;
  --line-strong: #d7ddd9;
  --brand: #1c7a52;
  --brand-dark: #166544;
  --brand-tint: #e9f4ee;
  --danger: #cf4636;
  --danger-tint: #fbeae7;
  --r: 14px;
  --shadow-sm: 0 1px 2px rgba(16,40,28,.07);
  --shadow: 0 1px 3px rgba(16,40,28,.05), 0 10px 28px rgba(16,40,28,.06);
  --shadow-lg: 0 16px 48px rgba(16,40,28,.22);
  --tabbar-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button { font: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font: inherit; }
svg { display: block; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: 11px 16px; border-radius: 11px; font-weight: 600; letter-spacing: -.01em;
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, transform .05s;
}
.btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line-strong); box-shadow: none; }
.btn.secondary:hover { background: #f1f4f2; border-color: var(--line-strong); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #b93a2c; border-color: #b93a2c; }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 9px; }
.btn.small svg { width: 16px; height: 16px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; pointer-events: none; }

.iconbtn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--muted); border-radius: 10px;
  transition: background .15s, color .15s, border-color .15s;
}
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn:hover { background: #f1f4f2; color: var(--ink); border-color: var(--line-strong); }
.iconbtn.danger:hover { background: var(--danger-tint); color: var(--danger); border-color: #f0c8c2; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(120% 120% at 30% 0%, #2a8c61 0%, #16331f 100%); }
.login-card { background: var(--card); padding: 32px 28px; border-radius: 22px; box-shadow: var(--shadow-lg); width: 100%; max-width: 380px; }
.brandmark { width: 56px; height: 56px; border-radius: 16px; background: var(--brand-tint); display: grid; place-items: center; margin-bottom: 18px; }
.brandmark svg { width: 30px; height: 30px; color: var(--brand); }
.login-card h1 { margin: 0 0 3px; font-size: 26px; font-weight: 780; letter-spacing: -.03em; }
.login-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; padding: 12px; border: 1px solid var(--line-strong); border-radius: 11px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.field input[type=checkbox], .field input[type=radio], .checks input { width: auto; padding: 0; accent-color: var(--brand); }
.err { color: var(--danger); font-size: 13px; margin: 8px 0 0; min-height: 18px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 16px; text-align: center; }

/* ---------- shell ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 56px; background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; letter-spacing: -.02em; color: var(--ink); }
.topbar .logo svg { width: 22px; height: 22px; color: var(--brand); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; max-width: 36vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.container { max-width: 1100px; margin: 0 auto; padding: 16px 14px calc(var(--tabbar-h) + 84px); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabbar-h); background: rgba(255,255,255,.9); backdrop-filter: saturate(180%) blur(12px); border-top: 1px solid var(--line); display: flex; z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; background: none; border: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar button .ic { display: inline-flex; padding: 4px 18px; border-radius: 999px; transition: background .18s, color .18s; }
.tabbar button .ic svg { width: 23px; height: 23px; }
.tabbar button.active { color: var(--brand-dark); }
.tabbar button.active .ic { background: var(--brand-tint); color: var(--brand); }

.fab { position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); z-index: 31;
  background: linear-gradient(180deg, #229863, #1a7049); color: #fff; border: none; border-radius: 30px; padding: 14px 22px; font-weight: 700; letter-spacing: -.01em;
  box-shadow: 0 8px 22px rgba(28,122,82,.42); display: flex; align-items: center; gap: 8px; }
.fab .ic svg { width: 20px; height: 20px; }
.fab:active { transform: translateY(1px); }

/* ---------- day toolbar ---------- */
.day-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.day-toolbar .navbtn { display: grid; place-items: center; background: #fff; border: 1px solid var(--line-strong); border-radius: 12px; width: 40px; height: 40px; color: var(--muted); }
.day-toolbar .navbtn svg { width: 20px; height: 20px; }
.day-toolbar .navbtn:hover { background: #f1f4f2; color: var(--ink); }
.day-toolbar .today-btn { background: #fff; border: 1px solid var(--line-strong); border-radius: 12px; height: 40px; padding: 0 14px; font-weight: 600; }
.day-toolbar .today-btn:hover { background: #f1f4f2; }
.datewrap { position: relative; flex: 1; }
.datewrap .date { width: 100%; height: 40px; background: #fff; border: 1px solid var(--line-strong); border-radius: 12px; font-weight: 700; letter-spacing: -.01em; font-size: 15px; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.datewrap .date .cd { display: inline-flex; color: var(--muted); }
.datewrap .date .cd svg { width: 15px; height: 15px; }
.datewrap input[type=date] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: none; cursor: pointer; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 9px; margin-bottom: 4px; -webkit-overflow-scrolling: touch; }
.chip { flex: 0 0 auto; display: inline-flex; align-items: center; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; font-size: 13px; font-weight: 600; color: var(--ink); user-select: none; white-space: nowrap; transition: all .12s; }
.chip:not(.off) { border-color: var(--brand); background: var(--brand-tint); color: var(--brand-dark); }
.chip.off { color: var(--muted); }
.legend { display: flex; align-items: center; gap: 14px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 4px; -webkit-overflow-scrolling: touch; }
.legend-lbl { font-size: 12px; font-weight: 700; color: var(--muted); flex: 0 0 auto; }
.legend-item { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; white-space: nowrap; color: var(--ink); }
.legend-item .dot { width: 11px; height: 11px; border-radius: 50%; }

/* ---------- day timeline ---------- */
.day-scroll { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; box-shadow: var(--shadow); position: relative; max-height: calc(100vh - 250px); }
.tg { display: flex; min-width: min-content; }
.time-gutter { position: sticky; left: 0; z-index: 6; background: var(--card); border-right: 1px solid var(--line); flex: 0 0 48px; }
.tg-spacer { height: 56px; position: sticky; top: 0; background: var(--card); z-index: 7; border-bottom: 1px solid var(--line); }
.tg-hour { font-size: 11px; color: var(--muted); padding: 3px 6px 0 0; text-align: right; box-sizing: border-box; }
.fg { border-right: 2px solid var(--line-strong); }
.fg:last-child { border-right: none; }
.fg-head { position: sticky; top: 0; z-index: 4; height: 56px; background: #f8faf9; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; }
.fg-title { display: flex; align-items: center; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--brand-dark); padding: 8px 10px 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fg-secs { flex: 1; display: flex; }
.fg-secs .s { flex: 0 0 auto; display: flex; align-items: center; padding: 0 10px; font-size: 12.5px; font-weight: 600; border-left: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fg-secs .s:first-child { border-left: none; }
.fg-secs .s.simple { color: var(--muted); font-weight: 500; }
.fg-body { position: relative; }
.evt { position: absolute; border-radius: 9px; color: #fff; padding: 5px 9px; font-size: 11px; line-height: 1.25; overflow: hidden; box-shadow: 0 2px 5px rgba(16,40,28,.18), inset 0 0 0 1px rgba(255,255,255,.18); }
.evt .t { font-weight: 700; letter-spacing: -.01em; }
.evt .ttl { opacity: .96; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evt .meta { opacity: .82; font-size: 10px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evt .rec { position: absolute; top: 4px; right: 6px; font-size: 10px; opacity: .85; }
.club-muted { font-weight: 500; font-size: 12px; color: var(--muted); }
.ph-titles { min-width: 0; }
.ph-titles h3 { margin: 0; }
.ph-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* ---------- panels / lists ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.panel-head .spacer { flex: 1; }
.subnav { display: flex; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 4px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.subnav button { flex: 1; border: none; background: none; padding: 10px; border-radius: 10px; font-weight: 600; color: var(--muted); transition: background .15s, color .15s; }
.subnav button.active { background: var(--brand); color: #fff; }

.list-row { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow .ttl { font-weight: 600; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.list-row .grow .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.list-row .actions { display: flex; gap: 7px; flex: 0 0 auto; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eef1ef; color: var(--muted); }
.tag.admin { background: #f3e4d6; color: #9a4a1f; }
.tag.role { background: #e2ecf6; color: #2a527e; }
.tag.gadmin { background: #ece2f5; color: #5d3c8c; }
.badge-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.empty { padding: 40px 22px; text-align: center; color: var(--muted); }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(14,24,18,.5); backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal { background: var(--card); border-radius: 22px 22px 0 0; width: 100%; max-width: 480px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slideup .2s cubic-bezier(.2,.8,.3,1); }
@keyframes slideup { from { transform: translateY(28px); opacity: .5; } to { transform: none; opacity: 1; } }
.modal-head { padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.modal-head .x { display: grid; place-items: center; margin-left: auto; background: none; border: none; color: var(--muted); width: 34px; height: 34px; border-radius: 9px; }
.modal-head .x svg { width: 18px; height: 18px; }
.modal-head .x:hover { background: #f1f4f2; color: var(--ink); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 13px 20px calc(13px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.modal-foot .btn { flex: 1; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: flex; background: #f1f4f2; border-radius: 11px; padding: 4px; gap: 4px; }
.seg button { flex: 1; background: none; border: none; padding: 9px; border-radius: 8px; font-weight: 600; color: var(--muted); transition: background .15s, color .15s; }
.seg button.active { background: #fff; color: var(--brand-dark); box-shadow: var(--shadow-sm); }
.optchips { display: flex; flex-wrap: wrap; gap: 8px; }
.optchip { border: 1px solid var(--line-strong); background: #fff; border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 600; color: var(--ink); transition: all .12s; }
.optchip.sel { background: var(--brand); color: #fff; border-color: var(--brand); }
.checks { display: flex; flex-direction: column; gap: 2px; max-height: 190px; overflow-y: auto; border: 1px solid var(--line-strong); border-radius: 11px; padding: 8px 12px; }
.checks label { display: flex; align-items: center; gap: 10px; font-weight: 500; padding: 6px 0; }

/* static (single-choice) value instead of a dropdown */
.static-val { padding: 10px 0 2px; font-weight: 600; }

/* generated credentials */
.cred-val { font-weight: 600; }
.cred-pw { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 22px; font-weight: 700; letter-spacing: 3px; background: var(--brand-tint); color: var(--brand-dark); border-radius: 11px; padding: 13px 14px; text-align: center; user-select: all; }
.cred-actions { display: flex; gap: 10px; margin-top: 8px; }
.cred-actions .btn { flex: 1; }
.cred-actions .btn .ic svg { width: 18px; height: 18px; }

/* contact person on a booking */
.contact-row { display: flex; align-items: center; gap: 10px; }
.contact-row .grow { flex: 1; min-width: 0; }
.contact-actions { display: flex; gap: 8px; flex: 0 0 auto; }
a.iconbtn { text-decoration: none; }
.iconbtn.wa:hover { background: var(--brand-tint); color: var(--brand-dark); border-color: #bfe0cf; }

/* delete section in the booking detail modal */
.del-area { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- impersonation banner ---------- */
.imp-bar { position: sticky; top: 0; z-index: 40; height: 40px; display: flex; align-items: center; gap: 9px; padding: 0 14px; background: linear-gradient(180deg, #a8531f, #8f4015); color: #fff; font-size: 13px; }
.imp-bar .ic { display: inline-flex; }
.imp-bar .ic svg { width: 18px; height: 18px; }
.imp-bar .btn { margin-left: auto; background: #fff; color: #8f4015; border-color: #fff; }
.imp-bar .btn:hover { background: #f3ece6; border-color: #f3ece6; }
.topbar.with-imp { top: 40px; }

.toast { position: fixed; bottom: calc(var(--tabbar-h) + 74px); left: 50%; transform: translateX(-50%); background: #15201b; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 100; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; text-align: center; font-size: 14px; }
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }

/* ---------- desktop ---------- */
@media (min-width: 820px) {
  .container { padding: 24px 20px 44px; }
  .overlay { align-items: center; padding: 24px; }
  .modal { border-radius: 22px; }
  .day-scroll { max-height: calc(100vh - 260px); }
}
