/* Appointment calendar (shared by the offline and online Ticket Desk) */
.cal, .cal-overlay { --c-new: #0d9488; --c-new-bg: #ccfbf1; --c-cust: #2563eb; --c-cust-bg: #dbeafe; }
.cal { padding: 16px; }
.cal[hidden] { display: none !important; }
.cal .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-nav, .cal-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-title { margin: 0 0 0 8px; font-size: 20px; }
.cal-btn { font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; }
.cal-btn:hover { background: var(--bg); }
.cal-btn.icon { width: 38px; padding: 8px 0; font-size: 18px; line-height: 1; }
.cal-btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.cal-btn.primary:hover { filter: brightness(.92); }
.cal-btn.danger { color: var(--urgent); border-color: #fecaca; }
.cal-btn:disabled { opacity: .6; cursor: wait; }
.cal-seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.cal-seg button { font: inherit; font-size: 13.5px; font-weight: 600; padding: 8px 12px; border: 0; background: none; cursor: pointer; color: var(--muted); }
.cal-seg button + button { border-left: 1px solid var(--line); }
.cal-seg button.on { background: #0f172a; color: #fff; }

/* events */
.cal-ev { display: block; width: 100%; text-align: left; font: inherit; font-size: 12px; line-height: 1.3; border: 0; border-left: 4px solid; border-radius: 6px; padding: 3px 6px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin-top: 3px; }
.cal-ev.t-new { background: var(--c-new-bg); border-color: var(--c-new); color: #134e4a; }
.cal-ev.t-customer { background: var(--c-cust-bg); border-color: var(--c-cust); color: #1e3a8a; }
.cal-ev:hover { filter: brightness(.96); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.cal-ev i { font-style: normal; font-weight: 700; font-size: 10.5px; text-transform: uppercase; opacity: .8; }
.cal-ev.s-cancelled, .cal-ev.s-noshow { opacity: .5; text-decoration: line-through; }
.cal-ev.s-done { opacity: .7; }
.cal-ev.s-arrived { box-shadow: inset 0 0 0 2px #f59e0b; }

/* month */
.cal-month { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cal-mhead, .cal-mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-mhead div { padding: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); text-align: center; }
.cal-mcell { min-height: 112px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; cursor: pointer; min-width: 0; }
.cal-mcell:nth-child(7n) { border-right: 0; }
.cal-mcell:hover { background: #fafafa; }
.cal-mcell.other { background: #f8f8f8; }
.cal-mcell.other .cal-mday { color: #b0b4bb; }
.cal-mday { font: inherit; font-weight: 700; font-size: 13px; border: 0; background: none; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; }
.cal-mday:hover { background: var(--bg); }
.cal-mcell.today .cal-mday { background: var(--brand); color: #fff; }
.cal-more { font: inherit; font-size: 12px; font-weight: 600; color: var(--brand); border: 0; background: none; cursor: pointer; padding: 3px 4px; }

/* week / day */
.cal-grid { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cal-ghead { display: grid; grid-template-columns: 56px repeat(var(--days), minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.cal-dhead { font: inherit; border: 0; border-left: 1px solid var(--line); background: none; padding: 8px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.cal-dhead span { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.cal-dhead b { font-size: 20px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; }
.cal-dhead.today b { background: var(--brand); color: #fff; }
.cal-dhead em { position: absolute; top: 6px; right: 8px; font-style: normal; font-size: 11px; font-weight: 700; background: #0f172a; color: #fff; border-radius: 10px; padding: 0 6px; }
.cal-gscroll { max-height: calc(100vh - 230px); min-height: 360px; overflow-y: auto; }
.cal-gbody { position: relative; display: grid; grid-template-columns: 56px repeat(var(--days), minmax(0, 1fr)); }
.cal-hours { position: relative; }
.cal-hours div { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--muted); }
.cal-hours div:first-child { transform: none; }
.cal-col { position: relative; border-left: 1px solid var(--line); cursor: copy; }
.cal-col.today { background: #fffbeb; }
.cal-line { position: absolute; left: 0; right: 0; border-top: 1px solid #eef0f3; pointer-events: none; }
.cal-line.half { border-top-style: dashed; border-top-color: #f3f4f6; }
.cal-now { position: absolute; left: 0; right: 0; border-top: 2px solid #ef4444; z-index: 2; pointer-events: none; }
.cal-now::before { content: ""; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; }
.cal-ev.block { position: absolute; margin: 0; white-space: normal; display: flex; flex-direction: column; gap: 1px; z-index: 1; padding: 4px 6px; }
.cal-ev.block b, .cal-ev.block span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev.block .who { opacity: .8; }
.cal-ev.block.short { justify-content: center; padding: 0 6px; }
.cal-ev.block.short span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev.block.short i { float: right; margin-left: 4px; font-size: 9.5px; line-height: 1.8; }
.cal-grid.day .cal-ev.block { font-size: 13px; }

/* editor */
.cal-overlay { position: fixed; inset: 0; z-index: 55; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.cal-overlay[hidden] { display: none; }
.cal-modal { background: #fff; border-radius: 14px; width: 100%; max-width: 620px; max-height: 94vh; display: flex; flex-direction: column; overflow: hidden; }
.cal-mhd { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.cal-mhd h3 { margin: 0; flex: 1; font-size: 17px; }
.cal-x { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.cal-mbd { padding: 16px 18px; overflow-y: auto; }
.cal-type { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.cal-type label { cursor: pointer; }
.cal-type input { position: absolute; opacity: 0; }
.cal-type span { display: block; border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px; font-weight: 700; }
.cal-type small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; margin-top: 2px; }
.cal-type input[value="new"]:checked + span { border-color: var(--c-new); background: var(--c-new-bg); }
.cal-type input[value="customer"]:checked + span { border-color: var(--c-cust); background: var(--c-cust-bg); }
.cal-type input:focus-visible + span { outline: 2px solid #0f172a; outline-offset: 2px; }
.cal-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.cal-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-fields label[hidden] { display: none; }
.cal-fields .full { grid-column: 1 / -1; }
.cal-fields input, .cal-fields select, .cal-fields textarea { font: inherit; font-size: 15px; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; min-width: 0; }
.cal-fields textarea { resize: vertical; }
.cal-fields .bad { border-color: var(--urgent); }
.cal-warn { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 8px; padding: 8px 12px; font-size: 13.5px; margin: 12px 0 0; }
.cal-warn[hidden] { display: none; }
.cal-ticket { margin-top: 14px; }
.cal-hint { color: var(--muted); font-size: 13px; margin: 0; }
.cal-mft { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: #fafafa; }
.cal-mft .grow { flex: 1; }
.cal-mft [hidden] { display: none; }

/* header tabs added to the Ticket Desk */
.view-tabs { display: flex; gap: 4px; background: rgba(255,255,255,.08); padding: 3px; border-radius: 9px; }
.view-tabs button { font: inherit; font-size: 14px; font-weight: 600; border: 0; background: none; color: #cbd5e1; padding: 6px 12px; border-radius: 7px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.view-tabs button.on { background: #fff; color: #0f172a; }
.view-tabs .cal-badge { background: #ef4444; color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 0 6px; min-width: 18px; text-align: center; }
.view-tabs .cal-badge[hidden] { display: none; }
body.cal-mode .board-only { display: none !important; }
main[hidden] { display: none !important; }

@media (max-width: 700px) {
  .cal { padding: 10px; }
  .cal-toolbar { gap: 8px; }
  .cal-title { font-size: 16px; width: 100%; margin: 4px 0 0; order: 5; }
  .cal-tools { width: 100%; }
  .cal-tools .primary { flex: 1; }
  .cal-mcell { min-height: 70px; padding: 2px; }
  .cal-mcell .cal-ev { font-size: 10px; padding: 1px 3px; }
  .cal-mcell .cal-ev b { display: none; }
  .cal-fields, .cal-type { grid-template-columns: 1fr; }
  .cal-gscroll { max-height: calc(100vh - 260px); }
}
