/* Job Calendar — month grid with week-spanning status bars.
   Colour is paired with a glyph + border style so status never relies on
   colour alone (colour-blind safe). Uses existing tokens only. */
.cal-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-month { font-size: 18px; font-weight: 600; min-width: 160px; margin: 0 4px; }
.cal-nav-btn { min-width: 44px; min-height: 44px; }
.cal-legend { margin-left: auto; display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-swatch { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid; display: inline-block; }

/* grid line + cell tones — clearly separated in dark, unchanged feel in light */
.cal-board { --cal-grid: #444b59; --cal-cell: #20242d; --cal-weekend: #171a21; --cal-other: #14161c; --cal-today: rgba(80,160,255,.16); }
html[data-theme="light"] .cal-board { --cal-grid: var(--border-strong); --cal-cell: var(--bg-elevated); --cal-weekend: var(--bg-sunken); --cal-other: var(--bg-sunken); --cal-today: var(--accent-soft); }
.cal-board { border: 1px solid var(--cal-grid); border-radius: 12px; background: var(--bg-elevated); overflow: hidden; }
.cal-dow, .cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { background: var(--bg-elevated-2); border-bottom: 1px solid var(--cal-grid); }
.cal-dow span { padding: 8px 10px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
/* each week row: 1 header lane for the date number + up to 5 bar lanes */
.cal-week { grid-template-rows: 26px repeat(5, 24px); position: relative; padding-bottom: 6px; border-bottom: 1px solid var(--cal-grid); }
.cal-week:last-child { border-bottom: 0; }
.cal-day { border-left: 1px solid var(--cal-grid); padding: 4px 8px; background: var(--cal-cell); }
.cal-day:first-child { border-left: 0; }
.cal-day.is-weekend { background: var(--cal-weekend); }
.cal-day.is-other { background: var(--cal-other); }
.cal-day.is-today { background: var(--cal-today); box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.is-other .cal-day-num { color: var(--text-faint); }
.cal-day-num { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.cal-day.is-weekend .cal-day-num { color: var(--text-muted); }
.cal-day.is-today .cal-day-num { background: var(--accent); color: var(--bg); border-radius: 999px; padding: 1px 7px; font-weight: 700; }

.cal-bar { margin: 2px 3px; padding: 0 8px; border-radius: 6px; border: 1.5px solid; text-align: left; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; min-width: 0; overflow: hidden; position: relative; z-index: 1; }
.cal-bar.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.cal-bar.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }
.cal-bar-text { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-bar:focus-visible, .cal-agenda-item:focus-visible, .cal-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* status palette (shared by bars, agenda rows and legend swatches) */
.cal-complete   { background: var(--ok-soft);     border-color: var(--ok);     color: var(--ok); }
.cal-inprogress { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.cal-overdue    { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); border-style: dashed; }
.cal-planned    { background: var(--bg-elevated-2); border-color: var(--text-muted); color: var(--text); border-style: dotted; }
.cal-bar:hover { filter: brightness(1.12); }

.cal-agenda { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 8px; }
.cal-agenda-item { width: 100%; display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1.5px solid; cursor: pointer; font: inherit; text-align: left; }
.cal-agenda-name { font-weight: 600; }
.cal-agenda-meta { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cal-empty { color: var(--text-muted); padding: 10px 2px; }
.cal-unscheduled { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--text-muted); }
.cal-chip { min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--bg-elevated-2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }

@media (max-width: 700px) {
  .cal-legend { margin-left: 0; width: 100%; }
  .cal-dow span { padding: 6px 4px; font-size: 10px; }
  .cal-day { padding: 3px 4px; }
  .cal-bar { padding: 0 4px; font-size: 11px; }
}

/* Reinspections (Inspection module) — visually distinct from installation jobs: solid blue, diamond glyph. */
.cal-reinspect { background: var(--accent-soft); border-color: var(--accent); color: var(--text); border-style: solid; border-left-width: 4px; }
.cal-reinspectoverdue { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); border-style: solid; border-left-width: 4px; }

/* Manual entries — a distinct dashed-left "note" style plus the square glyph, so they read apart from project jobs (colour is never the only cue). */
.cal-manual { background: var(--bg-elevated-2); border-color: var(--text-muted); color: var(--text); border-style: solid; border-left-width: 4px; border-left-color: var(--accent); }

/* Entry editor: docked panel on wide screens, bottom sheet on narrow ones. */
.cal-entry-panel { position: fixed; right: 16px; top: 76px; bottom: 16px; width: min(360px, calc(100vw - 32px)); z-index: 60; overflow-y: auto; padding: 16px; border-radius: 12px; background: var(--bg-elevated); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.35)); }
.cal-entry-panel[hidden] { display: none; }
.cal-entry-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-entry-head h2 { margin: 0; font-size: 16px; }
.cal-field { display: block; margin-bottom: 10px; flex: 1 1 0; min-width: 0; }
.cal-field > span { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.cal-field em { font-weight: 400; font-style: normal; color: var(--text-faint); }
.cal-field input, .cal-field select, .cal-field textarea { width: 100%; box-sizing: border-box; min-height: 40px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--bg-elevated-2); color: var(--text); font: inherit; font-size: 14px; }
.cal-field textarea { resize: vertical; }
.cal-field input:focus-visible, .cal-field select:focus-visible, .cal-field textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-field-row { display: flex; gap: 10px; }
.cal-entry-error { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger); font-size: 13px; font-weight: 600; }
.cal-entry-error[hidden] { display: none; }
.cal-entry-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-entry-spacer { flex: 1 1 auto; }
.cal-entry-delete { color: var(--danger); }
@media (max-width: 700px) {
  .cal-entry-panel { left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 85vh; border-radius: 16px 16px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .cal-field input, .cal-field select, .cal-field textarea { font-size: 16px; } /* no iOS zoom-on-focus */
}
.cal-day[data-date] { cursor: pointer; }
