/* Calendar: the tape chart (units down, nights across) and the month chart (one disc per night, filled by how much is taken). */

.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 12px; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav .btn { min-height: 38px; }
.cal-title { font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: -.01em; min-width: 9ch; }
.cal-title small { display: block; font-family: var(--font-ui); font-size: var(--fs-xs); font-weight: 500; color: var(--ink-3); letter-spacing: 0; margin-top: 1px; }
.cal-tools { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cal-jump { width: 150px; }
.cal-quick { display: none; }

.cal-legend { display: flex; flex-wrap: nowrap; gap: 6px 16px; align-items: center; overflow-x: auto; scrollbar-width: none; margin-bottom: 10px; font-size: var(--fs-xs); color: var(--ink-2); padding: 2px 1px; }
.cal-legend::-webkit-scrollbar { display: none; }
@media (max-width: 899px) { .cal-legend { -webkit-mask-image: linear-gradient(to right, #000 88%, transparent); mask-image: linear-gradient(to right, #000 88%, transparent); padding-right: 24px; } }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sw { width: 20px; height: 12px; border-radius: 3px; display: inline-block; flex: none; clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%); }
.sw.confirmed { background: var(--st-confirmed); }
.sw.checked_in { background: var(--st-in); }
.sw.checked_out { background: #BCCFC4; }
.sw.tentative { background: repeating-linear-gradient(135deg, #F3C95C 0 4px, #FADD8C 4px 8px); }
.sw.on_hold { background: repeating-linear-gradient(135deg, #EE9F4A 0 4px, #F6C894 4px 8px); }
.sw.block { background: repeating-linear-gradient(45deg, #BCC6D2 0 3px, #DCE2E9 3px 6px); }
.sw-dot { width: 16px; height: 4px; border-radius: 2px; background: linear-gradient(to right, #fff 40%, var(--sold) 40%); box-shadow: 0 0 0 1px var(--line-strong); display: inline-block; }
.sw-line { width: 2px; height: 14px; background: var(--horizon); display: inline-block; }
.sw-disc { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--st-blocked); display: inline-block; }

/* ── Tape chart ── */
.cal-box { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.cal-scroll { position: relative; overflow: auto; max-height: calc(100dvh - 232px); min-height: 280px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.cal-canvas { position: relative; width: max-content; min-width: 100%; --lw: 66px; --cw: 46px; --rh: 48px; --hh: 54px; --n: 14; }
@media (min-width: 900px) { .cal-canvas { --lw: 148px; --rh: 46px; } .cal-scroll { max-height: calc(100dvh - 214px); } }

.cal-hdr { position: sticky; top: 0; z-index: 8; display: flex; height: var(--hh); background: var(--paper); border-bottom: 1px solid var(--line-strong); }
.cal-corner { position: sticky; left: 0; z-index: 9; flex: none; width: var(--lw); background: var(--paper); border-right: 1px solid var(--line-strong); display: flex; align-items: flex-end; padding: 0 10px 8px; color: var(--ink-3); font-size: var(--fs-xs); font-weight: 600; }
.cal-day { flex: none; width: var(--cw); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border-right: 1px solid var(--line); line-height: 1; position: relative; }
.cal-day small { font-size: 10.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .02em; }
.cal-day b { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.cal-day i { position: absolute; top: 4px; left: 0; right: 0; text-align: center; font-style: normal; font-size: 9.5px; font-weight: 700; color: var(--canopy); letter-spacing: .06em; }
.cal-day.we { background: var(--mist); }
.cal-day.we small { color: var(--ink-2); }
.cal-day.today { background: var(--horizon-tint); }
.cal-day.today b { color: var(--horizon); }
.cal-day.today::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--horizon); }
.cal-day.past b, .cal-day.past small { opacity: .6; }

.cal-stripes { position: absolute; left: var(--lw); top: var(--hh); bottom: 0; width: calc(var(--cw) * var(--n)); z-index: 0; pointer-events: none; }
.stripe { position: absolute; top: 0; bottom: 0; width: var(--cw); }
.stripe.we { background: rgba(220, 231, 224, .38); }
.stripe.past { background: rgba(227, 234, 229, .55); }
.today-line { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: calc(var(--cw) / 2 - 1px); background: var(--horizon); opacity: .55; }
.today-line::before { content: ''; position: absolute; top: -1px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--horizon); }

.cal-row { position: relative; display: flex; height: var(--rh); border-bottom: 1px solid var(--line); z-index: 1; }
.cal-label {
  position: sticky; left: 0; z-index: 5; flex: none; width: var(--lw); background: var(--paper); border-right: 1px solid var(--line-strong);
  display: flex; flex-direction: column; justify-content: center; padding: 0 8px 0 10px; min-width: 0; line-height: 1.15;
}
.cal-label b { font-size: 14px; font-weight: 700; }
.cal-label small { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-label .hk { position: absolute; right: 7px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; }
@media (max-width: 899px) { .cal-label small { display: none; } .cal-label { padding-right: 18px; } .cal-label b { font-size: 13.5px; } }
.cal-lane { position: relative; flex: none; width: calc(var(--cw) * var(--n)); background-image: linear-gradient(to right, var(--line) 1px, transparent 1px); background-size: var(--cw) 100%; touch-action: pan-x pan-y; cursor: cell; }
.cal-lane.noclick { cursor: default; }

.cal-group { position: relative; display: flex; height: 40px; background: var(--mist); border-bottom: 1px solid var(--line-strong); border-top: 1px solid var(--line-strong); z-index: 1; margin-top: -1px; }
.cal-group:first-of-type { margin-top: 0; border-top: 0; }
.cal-group .cal-label { background: var(--mist); flex-direction: row; align-items: center; gap: 8px; cursor: pointer; border: 0; border-right: 1px solid var(--line-strong); font-family: var(--font-display); font-size: 14.5px; font-weight: 600; width: var(--lw); text-align: left; }
.cal-group .cal-label svg { width: 15px; height: 15px; color: var(--ink-3); flex: none; transition: transform .15s; margin-left: auto; }
.cal-group.collapsed .cal-label svg { transform: rotate(-90deg); }
.cal-group .cal-label span.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-group .cal-lane { cursor: default; background-image: none; display: flex; }
.gc { flex: none; width: var(--cw); display: grid; place-items: center; font-size: 11.5px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.gc.zero b { background: var(--sold); color: #fff; }
.gc.low b { color: #8A5A00; }
.gc b { min-width: 22px; height: 20px; padding: 0 5px; border-radius: 10px; display: inline-grid; place-items: center; font-weight: 700; }

.bar {
  --sl: 9px; position: absolute; top: 6px; height: calc(var(--rh) - 12px); z-index: 2; border: 0; margin: 0;
  display: flex; flex-direction: column; justify-content: center; gap: 1px; padding: 0 calc(var(--sl) + 3px) 0 calc(var(--sl) + 3px);
  color: #fff; font-size: 12px; font-weight: 600; line-height: 1.12; text-align: left; overflow: hidden; cursor: pointer; user-select: none; -webkit-user-select: none;
  clip-path: polygon(var(--sl) 0, 100% 0, calc(100% - var(--sl)) 100%, 0 100%);
  transition: filter .12s;
}
.bar.cut-l { clip-path: polygon(0 0, 100% 0, calc(100% - var(--sl)) 100%, 0 100%); padding-left: 8px; }
.bar.cut-r { clip-path: polygon(var(--sl) 0, 100% 0, 100% 100%, 0 100%); padding-right: 8px; }
.bar.cut-l.cut-r { clip-path: none; }
.bar:hover { filter: brightness(1.1); }
.bar:focus-visible { outline: none; filter: brightness(1.12); }
.bar:focus-visible::after { content: ''; position: absolute; inset: 2px 6px; border: 2px solid #fff; border-radius: 3px; mix-blend-mode: difference; }
.bar .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .sub { font-size: 10.5px; font-weight: 500; opacity: .92; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Payment progress: the strip along the bottom is white for what has been paid and coral for what is still due */
.bar.unpaid::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: linear-gradient(to right, rgba(255,255,255,.92) var(--paid, 0%), var(--sold) var(--paid, 0%)); }
.bar.tentative.unpaid::before, .bar.on_hold.unpaid::before { background: linear-gradient(to right, rgba(255,255,255,.92) var(--paid, 0%), var(--sold) var(--paid, 0%)); }
.bar.narrow { --sl: 5px; font-size: 11.5px; padding-left: 8px; padding-right: 7px; }
.bar.confirmed { background: var(--st-confirmed); }
.bar.checked_in { background: var(--st-in); }
.bar.checked_out { background: #C3D3CA; color: #2F473D; }
.bar.tentative { background: repeating-linear-gradient(135deg, #F4CB62 0 8px, #F9DB8A 8px 16px); color: #4A3200; }
.bar.on_hold { background: repeating-linear-gradient(135deg, #EE9F4A 0 8px, #F4B672 8px 16px); color: #4A2600; }
.bar.block { background: repeating-linear-gradient(45deg, #C3CCD7 0 5px, #DCE2E9 5px 10px); color: #3B4757; }
.bar.ghost { opacity: .85; pointer-events: none; z-index: 6; box-shadow: none; filter: none; }
.bar.ghost.bad { background: repeating-linear-gradient(45deg, #E4624B 0 6px, #EE8A78 6px 12px); color: #fff; }
.bar .grip { position: absolute; top: 0; bottom: 0; width: 10px; cursor: ew-resize; z-index: 3; }
.bar .grip.l { left: 0; } .bar .grip.r { right: 0; }
@media (pointer: coarse) { .bar .grip { display: none; } }

.sel { position: absolute; top: 4px; bottom: 4px; z-index: 4; border: 2px dashed var(--horizon); background: rgba(8, 101, 204, .13); border-radius: 8px; pointer-events: none; display: flex; align-items: center; justify-content: center; color: var(--horizon); font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; }
.hover-night { position: absolute; top: 4px; bottom: 4px; z-index: 1; border-radius: 8px; background: rgba(27, 90, 71, .08); pointer-events: none; }

.sel-bar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; width: min(94vw, 560px);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 10px 10px 16px; border-radius: 16px; background: var(--ink); color: #fff; box-shadow: var(--shadow-pop);
  animation: rise .2s var(--ease);
}
.sel-bar .what { flex: 1 1 180px; min-width: 0; line-height: 1.25; }
.sel-bar .what b { display: block; font-size: var(--fs-md); }
.sel-bar .what span { font-size: var(--fs-xs); color: #B7D2C5; }
.sel-bar .btn { min-height: 38px; }
.sel-bar .btn-quiet { color: #CFE3D8; }
.sel-bar .btn-quiet:hover { background: rgba(255,255,255,.12); }
@media (max-width: 899px) { .sel-bar { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px); } }

.cal-hint { display: flex; align-items: center; gap: 8px; padding: 8px 4px 0; color: var(--ink-3); font-size: var(--fs-xs); }
.cal-hint svg { width: 15px; height: 15px; }

/* ── Month chart ── */
.mchart { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); align-items: start; }
.mcard { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 14px 12px 12px; }
.mcard-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 6px 10px; }
.mcard-head h3 { font-size: 19px; display: flex; align-items: center; gap: 9px; }
.mcard-head .stat { font-size: var(--fs-xs); color: var(--ink-3); text-align: right; line-height: 1.3; }
.mcard-head .stat b { color: var(--ink); font-weight: 700; }
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px 0; }
.mgrid .dow { text-align: center; font-size: 10.5px; font-weight: 700; color: var(--ink-3); padding: 4px 0 6px; letter-spacing: .03em; }
.mgrid .dow.we { color: var(--ink-2); }
.mday { position: relative; border: 0; background: transparent; padding: 4px 0 5px; display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 10px; min-height: 58px; font-variant-numeric: tabular-nums; }
.mday:hover:not(.blank):not(:disabled) { background: var(--mist-2); }
.mday.blank { visibility: hidden; }
.mday .dn { font-size: 11px; font-weight: 600; color: var(--ink-3); line-height: 1; }
.mday.today .dn { color: #fff; background: var(--horizon); border-radius: 8px; padding: 2px 5px; margin-top: -2px; }
.disc { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #A9BFB2; overflow: hidden; background: linear-gradient(to top, var(--st-blocked) 0 var(--p1, 0%), var(--sold) var(--p1, 0%) var(--p2, 0%), var(--held) var(--p2, 0%) var(--p3, 0%), var(--paper) var(--p3, 0%) 100%); }
.mday.sold .disc { border-color: var(--sold); }
.mday.hold .disc { border-color: var(--held); }
.mday.free .disc { border-color: #8DB8A2; }
.mday .fc { font-size: 10px; font-weight: 600; color: var(--ink-3); line-height: 1; white-space: nowrap; }
.mday.sold .fc { color: var(--danger); }
.mday.past { opacity: .5; }
.mday.we .dn { color: var(--ink-2); }
.mnav { display: flex; align-items: center; gap: 6px; }

/* ── Day sheet & availability results ── */
.day-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.day-sum div { background: var(--mist); border-radius: 12px; padding: 10px 6px; text-align: center; }
.day-sum b { display: block; font-family: var(--font-display); font-size: 22px; font-weight: 600; line-height: 1.1; }
.day-sum span { font-size: var(--fs-xs); color: var(--ink-3); }
.unit-line { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); min-height: 54px; width: 100%; background: transparent; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
button.unit-line:hover { background: var(--mist); }
.unit-line .code { width: 52px; flex: none; font-weight: 700; }
.unit-line .who { flex: 1 1 auto; min-width: 0; }
.unit-line .who small { display: block; color: var(--ink-3); font-size: var(--fs-xs); }
.free-tag { color: var(--ok); font-weight: 600; font-size: var(--fs-sm); }
.avail-cat { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.avail-cat h4 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.unit-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.unit-chip { min-height: 34px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--paper); font-weight: 700; font-size: var(--fs-sm); }
.unit-chip:hover { background: var(--canopy-tint); border-color: var(--canopy); color: var(--canopy); }

@media (max-width: 899px) {
  .cal .page-head { display: none; }
  .cal-toolbar { gap: 8px 10px; margin-bottom: 8px; }
  .cal-title { font-size: 17px; min-width: 0; flex: 1 1 auto; line-height: 1.15; }
  .cal-quick { display: flex; gap: 6px; }
  .cal-tools { margin-left: 0; width: 100%; justify-content: space-between; }
  .cal-tools .seg { padding: 3px; }
  .cal-tools .seg button { min-height: 32px; padding: 0 11px; }
  .cal-jump { display: none; }
  .cal-legend { margin-bottom: 8px; font-size: 11px; gap: 4px 12px; }
  .cal-canvas { --lw: 70px; --hh: 58px; }
  .cal-group .cal-label { flex-direction: row-reverse; justify-content: flex-end; gap: 4px; font-size: 12.5px; padding: 0 6px; line-height: 1.05; white-space: normal; }
  .cal-group .cal-label .pdot { display: none; }
  .cal-group .cal-label svg { width: 12px; height: 12px; margin-left: 0; }
  .cal-group .cal-label span.nm { white-space: normal; }
  .cal-hint { padding-top: 6px; }
  .cal-scroll { max-height: calc(100dvh - 250px); }
}

@media (max-width: 899px) {
  .cal-nav { gap: 5px; }
  .cal-nav .btn { min-height: 36px; padding: 0 12px; }
  .cal-nav .btn-icon { width: 36px; padding: 0; }
  .cal-quick .btn-icon { width: 36px; min-height: 36px; }
}
