/* CBR Booking System.
   Plain local CSS -- no framework, no CDN, no build step. Same five
   dependencies as the other apps on this VPS, so the stylesheet does the
   work a framework otherwise would.

   Layout uses CSS grid; the month calendar in particular relies on
   grid-column spanning, which is what lets a booking bar cross several days
   without any JavaScript. */

:root {
  color-scheme: light dark;

  --ink:        #16191d;
  --ink-soft:   #5b6672;
  --line:       #e2e6ea;
  --line-firm:  #cbd2d9;
  --bg:         #f4f6f8;
  --surface:    #ffffff;
  --accent:     #1a5fb4;
  --accent-ink: #ffffff;
  --good:       #1a7f45;
  --warn:       #96530b;
  --bad:        #a11c1c;

  --high:   #6b3fa0;
  --mid:    #1a5fb4;
  --entry:  #4a5560;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgb(16 24 32 / .06), 0 2px 8px rgb(16 24 32 / .04);
  --gap: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:       #e6eaee;
    --ink-soft:  #9aa6b2;
    --line:      #2a3038;
    --line-firm: #3a424c;
    --bg:        #14171b;
    --surface:   #1c2126;
    --accent:    #6aa6f0;
    --accent-ink:#10151a;
    --good:      #56c98a;
    --warn:      #e0a561;
    --bad:       #ef8080;
    --high:      #b28ce0;
    --mid:       #6aa6f0;
    --entry:     #93a1af;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 2px 10px rgb(0 0 0 / .25);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --- header ------------------------------------------------------------ */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  font-weight: 700; letter-spacing: -.01em; color: var(--ink);
  font-size: 1.05rem;
}
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a {
  padding: .3rem .6rem; border-radius: var(--radius-sm); color: var(--ink-soft);
  font-weight: 500;
}
.topbar nav a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.whoami { margin-left: auto; color: var(--ink-soft); font-size: .875rem; }
.role {
  display: inline-block; padding: .05em .45em; margin: 0 .25em;
  border: 1px solid var(--line-firm); border-radius: 99px;
  font-size: .75em; text-transform: uppercase; letter-spacing: .04em;
}

main { max-width: 1180px; margin: 1.5rem auto 3rem; padding: 0 1.25rem; }
footer {
  max-width: 1180px; margin: 2rem auto; padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .85rem;
}

h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 .3rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .6rem; letter-spacing: -.01em; }
.lede { color: var(--ink-soft); margin-top: 0; max-width: 62ch; }
.hint { color: var(--ink-soft); font-size: .875rem; }

/* --- messages ---------------------------------------------------------- */
.flash, .error {
  padding: .7rem .9rem; border-radius: var(--radius); margin: 0 0 1rem;
  border-left: 3px solid;
}
.flash { background: color-mix(in srgb, var(--good) 10%, var(--surface)); border-color: var(--good); }
.error { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border-color: var(--bad); }
.panel.warn { border-left: 3px solid var(--warn); }

/* --- surfaces ---------------------------------------------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}
.panel ul { margin: .4rem 0; padding-left: 1.1rem; }
.panel li { margin: .2rem 0; }

/* --- tables ------------------------------------------------------------ */
.scroll { overflow-x: auto; border-radius: var(--radius); }
table {
  border-collapse: collapse; width: 100%; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
th, td { padding: .55rem .7rem; border-bottom: 1px solid var(--line);
         text-align: left; vertical-align: top; }
thead th {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-soft); background: var(--bg); font-weight: 600;
  position: sticky; top: 0;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.credit { color: var(--good); }
td.debit  { color: var(--bad); }
td.owing strong { color: var(--warn); }
.cancelled { color: var(--ink-soft); text-decoration: line-through; }

/* --- forms ------------------------------------------------------------- */
form.stack { max-width: 32rem; }
form.stack label { display: block; margin: 1rem 0 .25rem; font-weight: 600;
                   font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
  width: 100%; padding: .5rem .6rem; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-firm);
  border-radius: var(--radius-sm);
}
input:focus, select:focus { border-color: var(--accent); }
.inline { display: inline; }
.inline input, .inline select { width: auto; }

button, .btn {
  display: inline-block; padding: .45rem .85rem; font: inherit; font-weight: 500;
  color: var(--accent); background: var(--surface);
  border: 1px solid var(--line-firm); border-radius: var(--radius-sm);
  cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button[type=submit], .btn.primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
button.secondary { background: var(--surface); color: var(--accent); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line-firm));
                background: var(--surface); }
button.small, .btn.small { padding: .2rem .55rem; font-size: .85rem; }

.filters {
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
  margin: 0 0 1rem; padding: .6rem .75rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.filters .btn.primary { margin-left: auto; }

/* segmented control (Mine / Everyone) */
.seg { display: inline-flex; border: 1px solid var(--line-firm);
       border-radius: var(--radius-sm); overflow: hidden; }
.seg label { padding: .3rem .7rem; cursor: pointer; font-size: .9rem;
             color: var(--ink-soft); }
.seg label.on { background: var(--accent); color: var(--accent-ink); }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }

/* --- tags -------------------------------------------------------------- */
.tag {
  display: inline-block; padding: .05em .5em; border-radius: 99px;
  font-size: .72rem; font-weight: 600; color: #fff; white-space: nowrap;
  vertical-align: middle;
}
.tag.high { background: var(--high); }
.tag.mid  { background: var(--mid); }
.tag.entry{ background: var(--entry); }
.tag.off, .tag.staffonly { background: var(--warn); }
.tag.rental { background: var(--good); }

/* --- month calendar ---------------------------------------------------- */
.cal-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap;
            margin-bottom: .75rem; }
.cal-nav { display: flex; gap: .3rem; margin-left: auto; }
.cal-nav .btn { min-width: 2.2rem; text-align: center; }

.cal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.cal-dow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.cal-dow div {
  padding: .4rem .6rem; font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft);
}

/* One grid per week. Row 1 holds the day cells; the booking chips are placed
   into rows 2.. by inline grid-row, which is how they stack into lanes. */
.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: auto repeat(var(--lanes, 0), 1.55rem);
  border-bottom: 1px solid var(--line);
  position: relative;
  padding-bottom: .3rem;
}
.cal-week:last-child { border-bottom: 0; }

.cal-day {
  grid-row: 1; min-height: 3.2rem; padding: .3rem .4rem;
  border-right: 1px solid var(--line); color: var(--ink);
  display: flex; align-items: flex-start; justify-content: space-between;
}
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:hover { background: color-mix(in srgb, var(--accent) 6%, var(--surface));
                 text-decoration: none; }
.cal-day.weekend { background: color-mix(in srgb, var(--ink) 3%, var(--surface)); }
.cal-day.other-month .dnum { color: var(--ink-soft); opacity: .5; }
.cal-day .dnum { font-size: .82rem; font-variant-numeric: tabular-nums; }
.cal-day.today .dnum {
  background: var(--accent); color: var(--accent-ink);
  border-radius: 99px; min-width: 1.5rem; height: 1.5rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.cal-day .more { font-size: .7rem; color: var(--ink-soft); }

.chip {
  align-self: center; margin: 0 2px; padding: 0 .4rem;
  height: 1.35rem; line-height: 1.35rem;
  border-radius: var(--radius-sm); color: #fff;
  font-size: .75rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; z-index: 2;
}
.chip:hover { text-decoration: none; filter: brightness(1.08); }
.chip strong { font-weight: 700; }
.chip span { opacity: .9; margin-left: .3em; }
.chip .dot { font-weight: 700; opacity: 1; }
.chip.cls-highend  { background: var(--high); }
.chip.cls-midrange { background: var(--mid); }
.chip.cls-entry    { background: var(--entry); }
.chip.mine { box-shadow: inset 0 0 0 2px color-mix(in srgb, #fff 70%, transparent); }
/* Square off the edge a bar runs through, so it reads as continuing. */
.chip.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.chip.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }

.legend { color: var(--ink-soft); font-size: .875rem; margin-top: .9rem; }

/* --- availability strip ------------------------------------------------ */
.strip { display: flex; gap: 2px; flex-wrap: wrap; margin: .4rem 0; }
.strip i {
  width: .95rem; height: 1.3rem; border-radius: 2px; display: inline-block;
  background: color-mix(in srgb, var(--good) 30%, var(--surface));
  font-style: normal;
}
.strip i.busy { background: color-mix(in srgb, var(--bad) 45%, var(--surface)); }

/* --- small screens ----------------------------------------------------- */
@media (max-width: 720px) {
  main { padding: 0 .8rem; }
  .topbar { padding: .6rem .8rem; }
  .whoami { margin-left: 0; width: 100%; }
  .cal-day { min-height: 2.6rem; }
  .chip { font-size: .68rem; }
  .chip span { display: none; }     /* machine code only when space is tight */
  h1 { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: no-preference) {
  a, button, .btn, .chip { transition: background-color .12s ease, border-color .12s ease; }
}
