/* ============================================================
   Event & Hall Booking  |  GEV
   Powered by DhenujaAutomations
   ============================================================ */

:root {
  --accent:        #2F6B4F;
  --accent-dark:   #24523D;
  --accent-soft:   #E8F1EC;
  --ochre:         #C08A2E;
  --ochre-soft:    #FBF1DE;
  --ink:           #23291F;
  --ink-soft:      #5C6659;
  --line:          #DFE4DB;
  --bg:            #F6F7F3;
  --surface:       #FFFFFF;
  --danger:        #A6362C;
  --danger-soft:   #FBEAE8;
  --radius:        10px;
  --shadow:        0 1px 2px rgba(35,41,31,.05), 0 4px 14px rgba(35,41,31,.06);
  --shadow-lift:   0 2px 6px rgba(35,41,31,.08), 0 10px 26px rgba(35,41,31,.10);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--ochre);
  outline-offset: 2px;
}

/* ---------- Top bar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  margin-right: auto;
}
.brand__logo { height: 34px; width: auto; display: block; }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__title { font-weight: 700; font-size: 16px; color: var(--accent-dark); }
.brand__sub { font-size: 12px; color: var(--ink-soft); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  color: var(--ink);
  cursor: pointer;
}

.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav__spacer { flex: 1 1 auto; }
.nav__link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.nav__link:hover { background: var(--accent-soft); color: var(--accent-dark); }
.nav__link.is-active { background: var(--accent); color: #fff; }
.nav__link--quiet { font-weight: 500; }
.nav__user { display: inline-flex; align-items: center; gap: 8px; padding: 0 6px; }
.nav__username { font-size: 14px; color: var(--ink-soft); }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.badge--admin { background: var(--accent-soft); color: var(--accent-dark); }
.badge--view  { background: var(--ochre-soft);  color: #7A5512; }

/* ---------- Page ---------- */
.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 18px 48px;
}
h1, h2, h3 { color: var(--ink); line-height: 1.25; }
.page-title { margin: 0 0 4px; font-size: 22px; }
.page-sub { margin: 0 0 22px; color: var(--ink-soft); }
.muted { color: var(--ink-soft); }
.tight { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card--pad { padding: 20px; }
.card__title { margin: 0 0 10px; font-size: 17px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.tile--ochre { border-left-color: var(--ochre); }
.tile__value { font-size: 26px; font-weight: 700; color: var(--accent-dark); }
.tile__label { font-size: 13px; color: var(--ink-soft); }

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--radius);
  padding: 12px 15px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  font-size: 14px;
}
.alert--ok   { background: var(--accent-soft); border-color: #C6DDD0; color: var(--accent-dark); }
.alert--warn { background: var(--ochre-soft);  border-color: #EBD6A6; color: #7A5512; }
.alert--err  { background: var(--danger-soft); border-color: #EEC5C0; color: var(--danger); }
.alert code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, box-shadow .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { background: var(--accent-soft); border-color: #C6DDD0; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--block { width: 100%; }
.btn--sm { padding: 6px 11px; font-size: 13px; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 15px; }
.field__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field__input,
.field__select,
.field__textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}
.field__input:focus,
.field__select:focus,
.field__textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field__hint { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.form-section {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent-dark);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin: 22px 0 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 16px;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.table tbody tr:hover { background: #FAFBF8; }

/* ---------- Status pills ---------- */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.pill--confirmed { background: var(--accent-soft); color: var(--accent-dark); }
.pill--tentative { background: var(--ochre-soft);  color: #7A5512; }
.pill--cancelled { background: #ECEEE9;            color: var(--ink-soft); text-decoration: line-through; }

/* ---------- Auth pages ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #EEF3EC 0%, #F6F7F3 55%, #FAF4E7 100%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lift);
  padding: 30px 28px 22px;
}
.auth-card__logo { display: block; max-height: 56px; margin: 0 auto 14px; }
.auth-card__title { margin: 0 0 2px; font-size: 20px; text-align: center; color: var(--accent-dark); }
.auth-card__sub { margin: 0 0 20px; text-align: center; color: var(--ink-soft); font-size: 14px; }
.auth-card__foot {
  margin: 20px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------- Footer ---------- */
.sitefoot {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-soft);
}
.sitefoot__by { font-weight: 600; color: var(--accent-dark); }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding-top: 8px;
  }
  .nav.is-open { display: flex; }
  .nav__link { width: 100%; }
  .nav__spacer { display: none; }
  .nav__user { padding: 8px 12px; }
  .page { padding: 16px 14px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   Phase 2 — Planning map
   ============================================================ */

.crumb { margin: 0 0 10px; font-size: 14px; }
.crumb a { text-decoration: none; font-weight: 600; }

.map-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}
.map-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.map-month { font-weight: 700; color: var(--accent-dark); font-size: 15px; }

.map-filter {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.field--inline { margin-bottom: 0; min-width: 220px; }
.map-summary { font-size: 13px; color: var(--ink-soft); padding-bottom: 8px; }

.section-head {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent-dark);
  margin: 24px 0 12px;
}

/* ---- Month grid ---- */
.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.mapgrid { border-collapse: separate; border-spacing: 0; width: 100%; }

.mapgrid__corner,
.mapgrid__rowhead {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  border-right: 2px solid var(--line);
  text-align: left;
  min-width: 132px;
  padding: 8px 12px;
}
.mapgrid__corner {
  z-index: 3;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--line);
}
.mapgrid__rowhead { border-bottom: 1px solid var(--line); vertical-align: middle; }
.mapgrid__locname { display: block; font-size: 13px; font-weight: 700; }
.mapgrid__loctype { display: block; font-size: 11px; color: var(--ink-soft); font-weight: 500; }

.mapgrid__day {
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
  border-left: 1px solid #EDF1EA;
  padding: 5px 0;
  min-width: 34px;
  font-weight: 600;
}
.mapgrid__day.is-weekend { background: #EFF2EC; }
.mapgrid__day.is-today   { background: var(--ochre); color: #fff; }
.mapgrid__dnum { display: block; font-size: 12px; line-height: 1.1; }
.mapgrid__dow  { display: block; font-size: 10px; opacity: .7; font-weight: 500; }

.mapgrid__cell {
  border-bottom: 1px solid var(--line);
  border-left: 1px solid #EDF1EA;
  padding: 0;
  min-width: 34px;
  height: 44px;
  vertical-align: top;
  position: relative;
}
.mapgrid__cell.is-today { box-shadow: inset 0 0 0 2px var(--ochre); }

.mapgrid__link {
  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: stretch;
  justify-content: center;
  height: 100%;
  min-height: 44px;
  padding: 3px 2px;
  text-decoration: none;
  color: inherit;
}
.mapgrid__link:hover { background: #F2F6F0; }
.mapgrid__cell.is-booked  { background: var(--accent-soft); }
.mapgrid__cell.is-fullday { background: #D9E8DF; }
.mapgrid__cell.is-stacked { background: var(--ochre-soft); }

.chip {
  display: block;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.3;
  padding: 1px 3px;
  border-radius: 3px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chip--confirmed { background: var(--accent);    color: #fff; }
.chip--tentative { background: var(--ochre);     color: #fff; }
.chip--more      { background: #C9D2C4;          color: var(--ink); }
.chip--plain {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 4px;
}

.overlap-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 1.5px #fff;
}
.overlap-dot--static { position: static; display: inline-block; box-shadow: none; }

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-soft);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 13px; height: 13px; border-radius: 3px; display: inline-block; }
.swatch--confirmed { background: var(--accent); }
.swatch--tentative { background: var(--ochre); }
.swatch--fullday   { background: #D9E8DF; border: 1px solid #B9CFC3; }

.session-list { list-style: none; margin: 8px 0 0; padding: 0; }
.session-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.session-list li:last-child { border-bottom: 0; }

/* ---- Day view ---- */
.sessgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.sesscard {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  background: #FCFDFB;
}
.sesscard.is-free    { border-left-color: var(--accent); }
.sesscard.is-taken   { border-left-color: var(--ochre);  background: var(--ochre-soft); }
.sesscard.is-blocked { border-left-color: #C2C8BD;       background: #F1F3EF; }
.sesscard__label { font-weight: 700; font-size: 14px; }
.sesscard__time  { font-size: 12px; color: var(--ink-soft); margin-bottom: 8px; }
.sesscard__state { margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 5px; }

.pill--free { background: var(--accent-soft); color: var(--accent-dark); }

.booking-panel { border-left: 4px solid var(--accent); }
.booking-panel--tentative { border-left-color: var(--ochre); }
.booking-panel--cancelled { border-left-color: #C2C8BD; opacity: .72; }
.booking-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.booking-panel__title { margin: 0; font-size: 17px; }
.booking-panel__ref { margin: 2px 0 0; font-size: 13px; }
.booking-panel__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.deflist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 20px;
  margin: 0;
}
.deflist dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  font-weight: 700;
  margin-bottom: 2px;
}
.deflist dd { margin: 0; font-size: 14px; }
.amount-due { color: var(--danger); }

.setup-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

@media (max-width: 820px) {
  .mapgrid__corner, .mapgrid__rowhead { min-width: 108px; }
  .map-head { flex-direction: column; }
  .legend { gap: 12px; }
}

/* ============================================================
   Phase 3 — Booking form and list
   ============================================================ */

.checkrow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-bottom: 6px;
}
.checkcard {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px;
  background: #FCFDFB;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.checkcard:hover { border-color: var(--accent); background: var(--accent-soft); }
.checkcard input { margin-top: 3px; flex: none; accent-color: var(--accent); }
.checkcard span { display: block; font-size: 14px; line-height: 1.35; }
.checkcard span .muted { display: block; font-size: 12px; }
.checkcard--warn {
  border-color: #EBD6A6;
  background: var(--ochre-soft);
  margin-top: 16px;
}
.checkcard--warn:hover { border-color: var(--ochre); background: #F8E9CB; }

.calcbox {
  padding: 9px 11px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #F7F9F5;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-soft);
}
.calcbox--due   { color: var(--danger);      border-color: #EEC5C0; background: var(--danger-soft); }
.calcbox--clear { color: var(--accent-dark); border-color: #C6DDD0; background: var(--accent-soft); }
.calcbox--over  { color: #7A5512;            border-color: #EBD6A6; background: var(--ochre-soft); }

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.filterbar .form-actions { margin-top: 6px; padding-top: 14px; }

.table a { text-decoration: none; }
.table a:hover { text-decoration: underline; }

/* ============================================================
   Phase 5 — Audit trail and reports
   ============================================================ */

.changelist { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.changelist li { padding: 1px 0; }
.changelist .was { color: var(--ink-soft); text-decoration: line-through; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 6px 0 20px;
  font-size: 13px;
}

/* ============================================================
   Phase 6 — Mobile polish and final pass
   ============================================================ */

/* Comfortable tap targets on touch devices. */
@media (pointer: coarse) {
  .btn      { min-height: 44px; padding: 11px 18px; }
  .btn--sm  { min-height: 38px; }
  .nav__link { min-height: 44px; }
  .field__input, .field__select, .field__textarea { min-height: 44px; font-size: 16px; }
  .checkcard { padding: 14px; }
  .checkcard input { width: 20px; height: 20px; }
}

/* ---- Wide tables become stacked cards on small screens ---- */
@media (max-width: 720px) {
  .table thead { display: none; }

  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }

  .table tr {
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    margin: 0 12px 12px;
    width: auto;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  .table tbody tr:hover { background: var(--surface); }

  .table td {
    border: 0;
    border-bottom: 1px solid #EEF1EB;
    padding: 9px 14px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    text-align: right;
  }
  .table td:last-child { border-bottom: 0; }

  .table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
    text-align: left;
    flex: none;
  }
  /* Cells with no label (action buttons) span the full width. */
  .table td[data-label=""] { justify-content: flex-end; }
  .table td[data-label=""]::before { content: none; }

  /* The first cell reads as the card heading. */
  .table td:first-child {
    background: #FAFBF8;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 2px;
  }
  .table td:first-child::before { margin-bottom: 1px; }

  .table td .muted { text-align: inherit; }
  .changelist { text-align: left; }

  /* An empty-state row should not look like a card. */
  .table td[colspan] { display: block; text-align: left; }
  .table td[colspan]::before { content: none; }

  .table-wrap { overflow-x: visible; padding: 12px 0 2px; }
}

/* ---- Planning map on a phone ---- */
@media (max-width: 560px) {
  .mapgrid__corner, .mapgrid__rowhead { min-width: 92px; padding: 6px 8px; }
  .mapgrid__locname { font-size: 12px; }
  .mapgrid__cell, .mapgrid__day { min-width: 30px; }
  .mapgrid__link { min-height: 40px; }
  .chip { font-size: 8px; }

  .map-nav { width: 100%; }
  .map-nav .btn { flex: 1 1 auto; }
  .map-month { width: 100%; text-align: center; order: -1; margin-bottom: 4px; }

  .form-grid { grid-template-columns: 1fr; }
  .checkrow  { grid-template-columns: 1fr; }
  .deflist   { grid-template-columns: 1fr 1fr; }
  .form-actions .btn { flex: 1 1 auto; }

  .page-title { font-size: 19px; }
  .filterbar .form-actions { flex-direction: column; }
  .filterbar .form-actions .btn { width: 100%; }
}

/* Hint that the month grid scrolls sideways. */
.grid-scroll { position: relative; }
@media (max-width: 820px) {
  .grid-scroll::after {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 22px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,.92));
  }
}

/* ---- Print: any page, not just the report ---- */
@media print {
  .topbar, .sitefoot, .form-actions, .filterbar, .map-nav, .nav-toggle, .pager { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .page { max-width: none; padding: 0; }
  .card { box-shadow: none; border-color: #999; break-inside: avoid; }
  a { text-decoration: none; color: inherit; }
  .table thead { display: table-header-group; }
}

/* ---- Empty states ---- */
.empty {
  text-align: center;
  padding: 34px 20px;
  color: var(--ink-soft);
}
.empty__title { font-weight: 700; color: var(--ink); margin-bottom: 4px; }
