/* ============================================================
   CALENDAR_V1 (2026-11-10, roadmap 321) — the Calendar tab, all classes prefixed cal-.
   ADMIN_PREVIEW_CALENDAR: the tab button carries style="display:none" in index.html (the CSS default,
   because Rocket Loader runs scripts after first paint); js/calendar.js reveals it for admins only.
   Colours are the Room Board's (js/roomboard.js) and the dashboard tokens (css/base.css).

   CAL_LOOK_V2 (2026-11-11, operator: "it looks shrink ... look how beds24 calendar look its visible and breath").
   Measured on the live Beds24 calendar: 12px text, 40px rows with 37px bars, ~100px per day and a sideways scroll,
   solid fills. So here: the grid takes the whole page width, every day is at least 90px wide (the grid scrolls
   sideways and down INSIDE its card, with the date header and the room labels pinned), bars are solid and fill
   the row, text is centred, and the booking panel is a drawer that slides over the grid only when opened.
============================================================ */
#cal-root { color: var(--navy-800); font-size: 14px; }

/* The dashboard caps every tab at 1280px (base.css .main-content). The calendar uses the whole width, and only
   while its pane is shown (#tab-calendar is .hidden on every other tab). */
.main-content:has(> #tab-calendar:not(.hidden)) { max-width: none; }

/* ---------- toolbar ---------- */
.cal-toolbar { background: #fff; border-radius: 12px; box-shadow: var(--shadow-sm); padding: 12px 16px;
  display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; margin-bottom: 12px; }
.cal-break { flex-basis: 100%; height: 0; }
.cal-toolbar select, .cal-toolbar input[type="search"] { height: 36px; padding: 0 10px; border: 1px solid var(--gray-200);
  border-radius: 8px; background: var(--gray-50); color: var(--navy-800); font: inherit; font-size: 14px; }
.cal-toolbar select { font-weight: 600; max-width: 320px; }
.cal-findwrap { position: relative; flex: 0 1 300px; min-width: 170px; display: flex; }
.cal-toolbar .cal-findwrap input[type="search"] { flex: 1 1 auto; width: 100%; min-width: 0; }
/* CAL_SEARCH_V1: the results list under the box, as Beds24's (booking number / date on the left, name / email, hotel · room /
   channel on the right); every hotel, any date */
.cal-results { position: absolute; top: calc(100% + 4px); left: 0; z-index: 350; width: min(720px, calc(100vw - 32px));
  max-height: min(62vh, 560px); overflow-y: auto; overscroll-behavior: contain; background: #fff; border-radius: 10px;
  box-shadow: 0 16px 40px rgba(15, 31, 61, .22), 0 0 0 1px rgba(15, 31, 61, .1); }
.cal-results[hidden] { display: none; }
.cal-fr-head { position: sticky; top: 0; z-index: 1; padding: 8px 14px; font-size: 12px; color: #556070; background: #f7f9fc; border-bottom: 1px solid #e3e7ee; }
.cal-fr-head.cal-fr-busy { color: #a07a22; font-weight: 700; }
.cal-fr { display: grid; grid-template-columns: 172px minmax(0, 1fr) minmax(0, 250px); grid-template-areas: "id name where" "date tag where"; column-gap: 14px; row-gap: 2px;
  padding: 8px 14px; border-bottom: 1px solid #edf0f4; cursor: pointer; font-size: 13px; line-height: 1.35; }
.cal-fr:last-child { border-bottom: 0; }
.cal-fr.cal-fr-on { background: #fdf6e3; }
.cal-fr > span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-fr-id { grid-area: id; font-weight: 700; color: #0f1f3d; font-variant-numeric: tabular-nums; }
.cal-fr-name { grid-area: name; font-weight: 600; color: #0f1f3d; }
.cal-fr > .cal-fr-where { grid-area: where; align-self: center; display: flex; justify-content: flex-end; gap: 6px; color: #374151; }
.cal-fr-where .cal-fr-h { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-fr-where b { flex: none; color: #0f1f3d; font-weight: 700; }   /* the room number is never cut */
.cal-fr-date { grid-area: date; color: #556070; font-size: 12px; }   /* grey, not blue (operator: "too much") */
.cal-fr-tag { grid-area: tag; color: #556070; font-size: 12px; }
.cal-fr.cal-fr-x .cal-fr-id, .cal-fr.cal-fr-x .cal-fr-name, .cal-fr.cal-fr-x .cal-fr-date { color: #8a94a6; }
.cal-fr.cal-fr-x .cal-fr-tag { color: #b91c1c; font-weight: 700; }
@media (max-width: 560px) {
  .cal-fr { grid-template-columns: max-content minmax(0, 1fr); grid-template-areas: "id name" "date tag" "where where"; }
  .cal-fr > .cal-fr-where { justify-content: flex-start; }
}
.cal-btn { height: 36px; padding: 0 12px; border: 1px solid var(--gray-200); border-radius: 8px; background: var(--gray-50);
  color: var(--navy-800); font: inherit; font-size: 13px; cursor: pointer; }
.cal-btn:hover { border-color: var(--gold-600); }
.cal-btn.cal-today { border-color: #8a6a1c; color: #6b5313; background: #fff; font-weight: 700; }
.cal-date { font-weight: 700; min-width: 150px; text-align: center; }
.cal-seg { display: inline-flex; border: 1px solid var(--gray-200); border-radius: 8px; overflow: hidden; }
.cal-seg button { height: 34px; padding: 0 11px; border: 0; background: var(--gray-50); color: var(--navy-800); font: inherit; font-size: 13px; cursor: pointer; }
.cal-seg button[aria-pressed="true"] { background: var(--navy-800); color: #fff; font-weight: 700; }
.cal-seg-label { font-size: 12px; color: #556070; }
.cal-sum { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cal-stat { height: 30px; padding: 0 11px; border-radius: 15px; border: 1px solid var(--gray-200); background: #fff;
  color: #374151; font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.cal-stat b { color: #0f1f3d; font-size: 14px; font-weight: 800; margin-left: 2px; }
.cal-stat:hover { border-color: var(--gold-600); }
.cal-stat.cal-stat-warn { border-color: #fca5a5; background: #fef2f2; color: #991b1b; }
.cal-stat.cal-stat-warn b { color: #b91c1c; }
.cal-asof { font-size: 12px; color: #556070; margin-left: auto; }
/* (the "Admin preview" label was removed 2026-11-11, operator: "i want to see how it will look"; the admin-only gates stay) */

/* ---------- legend ---------- */
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 10px 16px; border-top: 1px solid #e3e7ee; font-size: 12px; color: #374151; }   /* under the grid (CAL_LEGEND_BELOW_V1) */
.cal-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.cal-sw { width: 18px; height: 12px; border-radius: 3px; border: 1px solid; display: inline-block; }

/* ---------- grid: scrolls inside the card; header rows pinned on top, room labels pinned on the left ---------- */
.cal-card { background: #fff; border-radius: 12px; box-shadow: var(--shadow-sm); overflow: hidden; }
.cal-scroll { overflow: auto; max-height: calc(100vh - 230px); min-height: 380px; }   /* js fit() sizes it to the window */
/* CAL_SCROLLBAR_V1 (2026-11-11, operator: "make it bigger", after comparing Beds24's thick window scroll bar): a 16px
   sideways bar and a 14px up-down bar with a dark thumb, so the sideways scroll is easy to see and grab. Mouse/trackpad
   screens only (phones keep their own thin bars); Firefox gets the same colours through scrollbar-color. */
@media (hover: hover) and (pointer: fine) {
  .cal-scroll::-webkit-scrollbar { height: 16px; width: 14px; }
  .cal-scroll::-webkit-scrollbar-track { background: #e3e7ee; }
  .cal-scroll::-webkit-scrollbar-thumb { background: #64748b; border: 3px solid #e3e7ee; border-radius: 8px; min-width: 60px; }
  .cal-scroll::-webkit-scrollbar-thumb:hover { background: #334155; }
  .cal-scroll::-webkit-scrollbar-thumb:active { background: #0f1f3d; }
  .cal-scroll::-webkit-scrollbar-corner { background: #e3e7ee; }
  @supports not selector(::-webkit-scrollbar) { .cal-scroll { scrollbar-color: #64748b #e3e7ee; scrollbar-width: auto; } }
}
/* CAL_FIT_NAMES_V1: js render() sets the grid's min-width = 128px labels + the fitted day widths (each day at least 90px,
   120px in the 7-day view, wider where a name needs it, as Beds24's month table) and the day lines as --cal-vl */
.cal-grid { min-width: 1404px; }

.cal-row { display: flex; position: relative; border-bottom: 1px solid #e3e7ee; }
/* CAL_LABEL_SIZES_V1 (2026-11-11, operator: "room number and date take too much space and too big"). Beds24, measured live:
   dates one line "Thu 12" 12px regular, room number ~10px, room type 12px, guest names ~12px — all about one size, so the
   bookings stand out. Ours had an 18px extra-bold date over a 52px header and a 16px extra-bold room number: now dates are one
   line (12–13px, header 34px), the room label one line ("304  Max 3 guests", 13px bold + 10.5px grey), labels 128px wide. */
.cal-label { position: sticky; left: 0; z-index: 6; flex: 0 0 128px; width: 128px; box-sizing: border-box; padding: 5px 8px 0 12px;
  background: #fff; border-right: 1px solid #d9dee7; overflow: hidden; white-space: nowrap; }
.cal-track { position: relative; flex: 1 1 auto; min-width: 0; }
.cal-lines::before { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; background-image: var(--cal-vl); }
/* one line at the start of each day (days are not all the same width). CAL_DAY_LINES_V1 (2026-11-11, operator: "the date has
   a | which separate date but not the % booked and the unit left … all these three should share same |"): drawn on the Booked
   row and the room-type (free rooms) rows too, in the dates' own colour, and ABOVE the weekend/today shading (it hid the line
   at the start of those days); bars (z-index 2) still sit on top. A see-through colour so it shows on white and grey rows. */

.cal-head { position: sticky; top: 0; z-index: 9; height: 34px; background: #f7f9fc; border-bottom: 1px solid #d9dee7; }
.cal-head .cal-label { background: #f7f9fc; font-size: 11.5px; font-weight: 700; color: #556070; display: flex; align-items: center; padding: 0 8px 0 12px; white-space: normal; line-height: 1.25; }
.cal-day { position: absolute; top: 0; bottom: 0; box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap;
  border-left: 1px solid rgba(15, 31, 61, .17); border-bottom: 3px solid transparent; }
.cal-day small { font-size: 12px; font-weight: 600; }
.cal-day b { font-size: 13px; font-weight: 700; line-height: 1; }
.cal-day.cal-we { color: #b91c1c; background: #fdf2f2; }
.cal-day.cal-now { color: #6b5313; background: #fdf6e3; border-bottom-color: #a07a22; }

.cal-occ { position: sticky; top: 34px; z-index: 8; height: 26px; background: #fff; border-bottom: 1px solid #d9dee7; }
.cal-occ .cal-label { font-size: 11.5px; color: #556070; display: flex; align-items: center; padding-top: 0; }
.cal-cell { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }

.cal-type { height: 38px; background: #f2f5fa; border-bottom: 1px solid #d9dee7; }
.cal-type .cal-label { background: #f2f5fa; display: flex; align-items: center; padding: 0 8px 0 12px; white-space: normal;
  font-size: 11.5px; font-weight: 700; line-height: 1.2; color: #0f1f3d; line-break: strict; }   /* strict: never start a line with ー */
.cal-type .cal-label span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cal-type.cal-off .cal-label { color: #556070; }
.cal-free { position: absolute; top: 8px; height: 22px; border-radius: 11px; font-size: 11.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; white-space: nowrap;
  background: #dcfce7; color: #166534; }
.cal-free.cal-full { background: transparent; color: #94a3b8; font-weight: 600; }
.cal-free.cal-offfree { background: #e9edf3; color: #556070; }

.cal-room .cal-num { font-size: 13px; font-weight: 700; color: #0f1f3d; line-height: 1; }
.cal-room .cal-sub { font-size: 10.5px; color: #64748b; line-height: 1; }
.cal-room.cal-off .cal-num { color: #6b7280; }
.cal-shade { position: absolute; top: 0; bottom: 0; }
.cal-shade.cal-we { background: #fdf4f4; }
.cal-shade.cal-now { background: #fffbeb; }
.cal-room .cal-label { display: flex; align-items: center; gap: 6px; padding: 0 8px 0 12px; }   /* one line: number + Max n guests */
.cal-norow .cal-label { display: block; padding-top: 5px; }   /* "No room yet / n to place" keeps two lines */
.cal-norow .cal-sub { margin-top: 3px; }
.cal-norow, .cal-norow .cal-label { background: #fff7f7; }
.cal-norow .cal-label { border-right-color: #f3d0d0; }
.cal-norow .cal-num { color: #b91c1c; font-size: 13px; }

/* ---------- bars: solid, fill the row, centred text (name / channel · nights) ---------- */
/* CAL_TEXT_NOT_CLIPPED_V1 (2026-11-11, operator: "names in vertical seem cut … when zoom everything seem fine"). Measured: the
   two lines are 1.25 line-height but Noto Sans JP's letters reach ~1px past that, and each line clipped its own box (overflow
   hidden, for the "…") while the bar clipped again, so the bottom of g/p/y was cut on 252 of 259 bars at every zoom 80–125%.
   Now each line's clip box reaches 4px above/below it without moving anything (padding + negative margin), the bar no longer
   clips (each line already cuts its own width), and bars sit 2px from the row edges (35px tall, Beds24's are 37px). */
.cal-bar { position: absolute; top: 2px; bottom: 2px; box-sizing: border-box; padding: 0 2px; border-radius: 6px; border: 1px solid;
  font: inherit; text-align: center; cursor: pointer; overflow: visible; z-index: 2; color: inherit;
  display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 1px;
  box-shadow: 0 1px 2px rgba(15, 31, 61, .12); }
.cal-bar:hover { filter: brightness(1.06); box-shadow: 0 2px 6px rgba(15, 31, 61, .22); }
.cal-bar:focus-visible { outline: 2px solid #a07a22; outline-offset: 1px; }
.cal-bar.cal-sel { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #a07a22; z-index: 4; }
.cal-bar.cal-fade { opacity: .2; }
.cal-bar.cal-request { border-style: dashed; border-width: 2px; }
.cal-bar.cal-conflict { border-width: 2px; }
.cal-bar .cal-n { display: block; padding: 4px 0; margin: -4px 0; font-size: 12px; font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-bar .cal-m { display: block; padding: 4px 0; margin: -4px 0; font-size: 11.5px; font-weight: 400; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .92; }
/* Unpaid / note markers: small badges at the start of the channel line, so the name keeps the whole width */
.cal-ic { display: inline-block; vertical-align: -2px; height: 14px; min-width: 14px; padding: 0 3px; margin-right: 4px; border-radius: 3px; box-sizing: border-box;
  font-size: 10px; font-weight: 800; line-height: 14px; text-align: center; font-style: normal; }
.cal-ic svg { display: block; margin: 2.5px auto 0; }
.cal-gi { display: inline-block; vertical-align: -1px; margin-right: 4px; flex: none; }   /* CAL_GROUP_MARK_V1: group mark, bar text colour */
.cal-ic-yen { background: #b91c1c; color: #fff; box-shadow: 0 0 0 1px #fff; }
.cal-ic-note { background: #0f1f3d; color: #fff; box-shadow: 0 0 0 1px #fff; }

/* ---------- booking / overview drawer ---------- */
.cal-drawer { position: fixed; top: 64px; right: 16px; bottom: 16px; width: 420px; max-width: calc(100vw - 32px); z-index: 300;
  box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 72px;
  background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(15, 31, 61, .28), 0 0 0 1px rgba(15, 31, 61, .08); }
.cal-drawer[hidden] { display: none; }
.cal-panel { background: #fff; }
.cal-drawer .cal-panel + .cal-panel { border-top: 1px solid #edf0f4; }
.cal-panel h3 { margin: 0; font-size: 13px; font-weight: 800; }
.cal-pad { padding: 12px 16px; }
.cal-list-item { padding: 7px 0; border-bottom: 1px solid #f0f2f5; font-size: 13px; }
.cal-list-item:last-child { border-bottom: 0; }
.cal-muted { color: #556070; font-size: 12px; }
.cal-chip { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; border: 1.5px solid; }
.cal-tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid #e3e7ee; }
.cal-tabs button { height: 34px; padding: 0 10px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: #556070; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.cal-tabs button[aria-selected="true"] { color: #0f1f3d; border-bottom-color: #a07a22; }
.cal-dl { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 6px 10px; margin: 0; font-size: 13px; }
.cal-dl dt { color: #556070; }
.cal-dl dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.cal-money { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px solid #f0f2f5; font-size: 13px; }
.cal-money span:first-child { flex: 1; }
.cal-bal { display: flex; padding: 9px 12px; margin-top: 10px; border-radius: 8px; font-weight: 800; }
.cal-notebox { margin-top: 8px; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.cal-notebox small { display: block; font-size: 11px; font-weight: 600; color: #556070; }
.cal-close { width: 32px; height: 32px; border: 1px solid #e3e7ee; border-radius: 8px; background: #fff; color: #556070; font: inherit; font-size: 16px; cursor: pointer; }
.cal-msg { padding: 30px 16px; text-align: center; color: #556070; }
/* CAL_INSTANT_SWITCH_V1: while a view not loaded yet is on its way, the old grid stays, dimmed (never a blank page) */
#cal-root.cal-is-loading .cal-scroll { opacity: .45; transition: opacity .12s; pointer-events: none; }
#cal-root.cal-is-loading .cal-asof { color: #a07a22; font-weight: 700; }

/* ---------- phones ---------- */
@media (max-width: 768px) {
  .cal-scroll { max-height: none; min-height: 0; }
  .cal-asof { margin-left: 0; }
  .cal-drawer { top: 12px; right: 12px; left: 12px; bottom: 12px; width: auto; max-width: none; }
}
