:root {
  --green: #16442f;        /* deep forest — brand / header / primary buttons */
  --green-dark: #0f3323;
  --green-soft: #e8f0ea;   /* soft sage for chips / fills */
  --wa: #2f7a57;           /* muted WhatsApp green (not neon) */
  --wa-dark: #276848;
  --amber: #a6701a;
  --red: #c0392b;
  --red-soft: #fdECEA;
  --ink: #18261e;
  --muted: #697a6f;
  --line: #e8e5db;
  --bg: #f4f2ea;           /* warm cream page background */
  --card: #ffffff;
  --free: #f1f6f1;
  --radius: 16px;
  --shadow: 0 4px 16px rgba(22,68,47,.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: calc(96px + var(--safe-bottom)); }

/* App bar */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: linear-gradient(135deg, #1b5137 0%, var(--green) 55%, var(--green-dark) 100%);
  color: #fff;
}
.appbar__brand { display: flex; align-items: center; gap: 10px; }
.appbar__logo {
  width: 36px; height: 36px; border-radius: 10px; object-fit: cover;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.appbar__title { font-size: 21px; font-weight: 800; letter-spacing: .2px; }
.appbar__actions { display: flex; align-items: center; gap: 8px; }
.iconbtn {
  width: 36px; height: 36px; flex: 0 0 auto;
  border: none; border-radius: 50%; background: rgba(255,255,255,.18);
  color: #fff; cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.userchip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.18);
  border: none; color: #fff;
  padding: 6px 12px 6px 6px; border-radius: 999px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.userchip__avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; color: var(--green);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
}
.userchip__name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Banner */
.banner {
  padding: 8px 16px; font-size: 13px; font-weight: 600;
  text-align: center;
}
.banner--offline { background: #fff6e5; color: var(--amber); }
.banner--live { background: var(--green-soft); color: var(--green-dark); }
.banner--hidden { display: none; }

/* Date bar */
.datebar {
  position: sticky; top: calc(56px + var(--safe-top)); z-index: 15;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.datebar__nav {
  width: 40px; height: 40px; flex: 0 0 auto;
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  font-size: 22px; line-height: 1; color: var(--ink); cursor: pointer;
}
.datebar__today {
  flex: 0 0 auto; height: 40px; padding: 0 16px;
  border: none; background: var(--green);
  color: #fff; border-radius: 10px; font-weight: 700; cursor: pointer;
}
.datebar__today:active { background: var(--green-dark); }
.datebar__picker { position: relative; flex: 1 1 auto; display: block; }
.datebar__picker input[type="date"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: none; cursor: pointer;
}
.datebar__label {
  display: flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 10px;
  font-weight: 700; font-size: 15px; background: #fff; pointer-events: none;
  text-align: center;
}

/* Day view */
.dayview { padding: 12px 12px 8px; }
.loading, .empty { text-align: center; color: var(--muted); padding: 40px 16px; }

.slot {
  display: flex; gap: 12px; align-items: stretch;
  margin-bottom: 10px;
}
.slot__time {
  flex: 0 0 62px; text-align: right; padding-top: 2px;
  font-size: 13px; font-weight: 700; color: var(--muted);
  display: flex; flex-direction: column; gap: 2px;
}
.slot__time small { font-weight: 600; color: var(--muted); font-size: 11px; }

.booking {
  flex: 1 1 auto; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px;
  border-left: 5px solid var(--green);
  cursor: pointer;
}
.booking--cricket { border-left-color: #1769aa; }
.booking__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.booking__name { font-size: 17px; font-weight: 700; }
.booking__sport {
  font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: var(--green-soft); color: var(--green-dark); white-space: nowrap;
}
.booking--cricket .booking__sport { background: #e7f0f8; color: #1769aa; }
.booking__meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.booking__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px;
  background: #f0f2f1; color: var(--ink);
}
.tag--advance { background: var(--green-soft); color: var(--green-dark); }
.tag--note { background: #eef1ef; color: #4a5a4f; }

.wabtn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 10px; padding: 10px; border-radius: 10px;
  background: var(--wa); color: #fff; font-weight: 600; font-size: 14px;
  text-decoration: none;
}
.wabtn:active { background: var(--wa-dark); }

.free {
  flex: 1 1 auto; border: 1.5px dashed #cfe3d7; background: var(--free);
  border-radius: var(--radius); padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--green-dark); font-weight: 600; cursor: pointer;
}
.free__add { font-size: 13px; color: var(--green); font-weight: 700; }

/* FAB */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + var(--safe-bottom)); z-index: 18;
  border: none; background: var(--green); color: #fff;
  font-size: 17px; font-weight: 700;
  padding: 15px 30px; border-radius: 999px;
  cursor: pointer;
}
.fab:active { background: var(--green-dark); }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet--hidden { display: none; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 92vh; overflow-y: auto;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 8px 18px calc(24px + var(--safe-bottom));
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet__handle { width: 42px; height: 5px; border-radius: 3px; background: #d8ddda; margin: 6px auto 10px; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet__head h2 { margin: 0; font-size: 20px; }
.sheet__x { border: none; background: #f0f2f1; width: 34px; height: 34px; border-radius: 50%; font-size: 15px; cursor: pointer; color: var(--muted); }
.sheet__hint { color: var(--muted); font-size: 14px; margin: 4px 0 14px; }

/* Fields */
.field { display: block; margin-bottom: 14px; }
.field__label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 13px 14px; font-size: 16px; background: #fff; color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--green); }
.field .datebtn, .field .selectfield {
  width: 100%; height: 50px; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 0 14px; font-size: 16px; background: #fff; color: var(--ink);
  font-family: inherit; cursor: pointer;
}
.field .datebtn { text-align: left; font-weight: 600; }
.field .datebtn:focus, .field .selectfield:focus { outline: none; border-color: var(--green); }
.field-row { display: flex; gap: 12px; }
.field--grow { flex: 1 1 auto; }
.field--time { flex: 0 0 44%; }

/* Duration stepper */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper__btn {
  width: 72px; height: 50px; flex: 0 0 auto;
  border: 1.5px solid var(--green); background: var(--green-soft);
  color: var(--green-dark); border-radius: 12px;
  font-size: 16px; font-weight: 700; cursor: pointer;
}
.stepper__btn:disabled { opacity: .4; cursor: not-allowed; }
.stepper__btn:active:not(:disabled) { background: #d6ecdf; }
.stepper__val {
  flex: 1 1 auto; text-align: center; font-size: 17px; font-weight: 700;
  padding: 13px 8px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
}

/* Quick-extend chips (edit mode) */
.quickext { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.quickext--hidden { display: none; }

/* Repeat / regulars */
.repeatopts--hidden { display: none; }
.dowpick { display: flex; gap: 6px; }
.dowpick button {
  flex: 1 1 0; height: 42px; border: 1.5px solid var(--line); background: #fff;
  border-radius: 10px; font-size: 14px; font-weight: 700; color: var(--ink); cursor: pointer;
}
.dowpick button.dow--on { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); }
.quickext__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.chip {
  border: 1.5px solid var(--green); background: #fff; color: var(--green-dark);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.chip:active { background: var(--green-soft); }

.segmented { display: flex; gap: 8px; }
.seg {
  flex: 1 1 0; padding: 12px 8px; border: 1.5px solid var(--line);
  background: #fff; border-radius: 12px; font-size: 15px; font-weight: 600;
  color: var(--ink); cursor: pointer;
}
.seg--on { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); }

/* Price estimate box */
.pricebox {
  background: var(--green-soft); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 14px;
}
.pricebox__row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; color: var(--green-dark); font-weight: 600;
}
.pricebox__row strong { font-size: 18px; }
.pricebox__row--sub { margin-top: 6px; padding-top: 6px; border-top: 1px dashed #bfe0cd; font-size: 14px; }
.pricebox__row--hidden { display: none; }

.linkbtn {
  border: none; background: none; color: var(--green-dark);
  font-size: 13px; font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline;
}
.linkbtn--hidden { display: none; }

.tag--price { background: #edf1ee; color: #2c4b3a; }
.tag--pending { background: var(--red-soft); color: var(--red); }
.tag--discount { background: #fff0f6; color: #a61e6b; }
.tag--night { background: #e7e9f2; color: #3b3f66; }

.formerror {
  background: var(--red-soft); color: var(--red); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; font-weight: 600; margin-bottom: 14px;
}
.formerror--hidden { display: none; }

/* Live clash warning (shows as you pick date/time) */
.clashwarn {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--red-soft); color: var(--red);
  border: 1.5px solid #f0b8b0; border-radius: 12px;
  padding: 11px 13px; font-size: 14px; font-weight: 600; margin-bottom: 14px;
}
.clashwarn--hidden { display: none; }

.sheet__actions { display: flex; gap: 10px; margin-top: 4px; }
.btn {
  flex: 1 1 auto; border: none; border-radius: 12px; padding: 15px;
  font-size: 16px; font-weight: 700; cursor: pointer;
}
.btn--primary { background: var(--green); color: #fff; }
.btn--primary:active { background: var(--green-dark); }
.btn--danger { background: var(--red-soft); color: var(--red); flex: 0 0 auto; padding: 15px 18px; }
.btn--danger-armed { background: var(--red); color: #fff; }
.btn--hidden { display: none; }

/* Calendar / month view */
.datebar__cal { font-size: 18px; }
.calnav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 12px; }
.calnav__month { flex: 1 1 auto; text-align: center; font-size: 17px; font-weight: 700; }
.cal__dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal__dow span { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal__day {
  position: relative; aspect-ratio: 1 / 1;
  border: 1.5px solid var(--line); background: #fff; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer; padding: 0;
}
.cal__day:disabled { visibility: hidden; }
.cal__day--today { border-color: var(--green); }
.cal__day--selected { background: var(--green); color: #fff; border-color: var(--green); }
.cal__count { font-size: 10px; font-weight: 700; color: var(--muted); }
.cal__day--selected .cal__count { color: #d6e4db; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot--free { background: #cfd8d2; }
.dot--some { background: #3f9b6a; }
.dot--full { background: #b65b4e; }
.cal__legend {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
  margin-top: 16px; font-size: 12px; color: var(--muted);
}
.cal__legend span { display: flex; align-items: center; gap: 6px; }

/* Reports */
.report__presets { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.report__presets .chip.chip--on { background: var(--green); color: #fff; border-color: var(--green); }
.report__range { text-align: center; color: var(--muted); font-size: 13px; font-weight: 600; margin: 4px 0 14px; }
.report__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 14px;
}
.stat--wide { grid-column: 1 / -1; background: var(--green); border-color: var(--green); color: #fff; }
.stat__label { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat--wide .stat__label { color: #cfe0d6; }
.stat__value { font-size: 24px; font-weight: 800; margin-top: 4px; }
.stat__sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Live change banner */
.notify {
  position: fixed; z-index: 30;
  top: calc(60px + var(--safe-top)); left: 12px; right: 12px;
  background: var(--green); color: #fff;
  padding: 12px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 18px rgba(22,68,47,.3);
  cursor: pointer;
  animation: notifyIn .25s ease;
}
@keyframes notifyIn { from { transform: translateY(-14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.notify--hidden { display: none; }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(90px + var(--safe-bottom)); z-index: 60;
  background: var(--ink); color: #fff; padding: 12px 18px;
  border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); max-width: 90vw; text-align: center;
}
.toast--hidden { display: none; }
.toast--error { background: var(--red); }
