/* Meeting chips, location badges, markers. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-size: var(--fs-xs);
  line-height: 1.45;
  /* background + colour set inline per meeting (order hue, membership fade) */
}
.chip--compact { white-space: nowrap; }
.chip--full { white-space: normal; }
/* Ruled out = superseded by a meeting that requires you → ghosted. */
.chip--ghost { opacity: 0.3; }
/* Whole pill ghosts (rail included); cancel inner chip ghost to avoid compounding. */
.daygroup--ghost { opacity: 0.3; }
.daygroup--ghost .chip--ghost { opacity: 1; }
.chip__venue { font-weight: 400; opacity: 0.8; }
.chip__abbr { display: none; }
.ev-ico { width: 1em; height: 1em; fill: currentColor; flex: none; }
.ord-emblem { display: inline-block; width: 1.05em; height: 1.05em; margin-right: 3px; vertical-align: -0.16em; }
.ord-emblem svg { width: 100%; height: 100%; display: block; }
.chip--clickable { cursor: pointer; }
@media (max-width: 640px) {
  .chip--full .chip__full { display: none; }
  .chip--full .chip__abbr { display: inline; }
}
.chip--install { box-shadow: 0 0 0 2px #e0b23c inset; }
.chip__install { color: #ffe08a; font-size: 0.7em; }
.chip__conflict {
  color: #fff;
  background: #c0392b;
  border-radius: 50%;
  width: 12px; height: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 700;
  margin-left: 1px;
}

/* Location badge */
/* Plain week-summary letter in the gutter (location colour is on day edges). */
.locbadge { font-size: var(--fs-xs); font-weight: 700; color: var(--text-dim); text-align: center; }

/* Location container pills — a box per location with a coloured left rail and
   meeting chips nested inside. Used by month day cells and the week-expand. */
.daygroup {
  display: flex; flex-direction: column; align-items: stretch; gap: 3px;
  border: 1px solid var(--border); border-left-width: 5px; border-radius: 6px;
  padding: 3px; margin-top: 3px;
}
.daygroup.loc-london { border-left-color: var(--loc-london); }
.daygroup.loc-manchester { border-left-color: var(--loc-manchester); }
.daygroup.loc-other { border-left-color: var(--loc-other); }

/* Light-red clash background on a clash day (month cell + week-expand). */
.cal__cell.is-clash { background: color-mix(in srgb, #c0392b 12%, var(--surface)); }
.clash-tag { display: inline-block; font-size: var(--fs-xs); font-weight: 500; color: #fff; background: #c0392b; border-radius: 3px; padding: 0 6px; margin: 2px 0 3px; }
.agenda__total { font-size: var(--fs-sm); color: var(--text-dim); }

/* Collapsed "weeks" (trip planner) mode — Mon–Sun day columns per week */
.agenda-weeks { display: flex; flex-direction: column; gap: 3px; max-width: 880px; }
.wk-head, .wk-row { display: grid; grid-template-columns: 8px 5ch repeat(7, minmax(0, 1fr)); gap: 6px; }
.wk-head { padding: 2px 8px; font-size: var(--fs-xs); color: var(--text-dim); }
.wk-head span { text-align: center; }
.wk-row { align-items: stretch; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.wk-row:hover { background: var(--surface-2); }
.wk--free .wk-row { background: var(--free-week); }
.wk-band { border-radius: 3px; }
.loc-band-london { background: var(--loc-london); }
.loc-band-manchester { background: var(--loc-manchester); }
.loc-band-other { background: var(--loc-other); }
.loc-band-both { background: linear-gradient(180deg, var(--loc-london) 50%, var(--loc-manchester) 50%); }
.loc-band-free { background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.wk-date { align-self: center; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-dim); }
.wk-day { display: flex; flex-flow: row wrap; justify-content: center; align-content: center; align-items: center; gap: 2px 3px; min-width: 0; padding: 2px; border-radius: 4px; }
/* only days with meetings get a box + a location rail (like the month view) */
.wk-day[class*="loc-edge-"] { position: relative; background: var(--surface); border: 1px solid var(--border); padding-left: 7px; }
.wk-day[class*="loc-edge-"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 4px 0 0 4px; }
.wk-day.loc-edge-london::before { background: var(--loc-london); }
.wk-day.loc-edge-manchester::before { background: var(--loc-manchester); }
.wk-day.loc-edge-other::before { background: var(--loc-other); }
.wk-day.loc-edge-both::before { background: linear-gradient(180deg, var(--loc-london) 50%, var(--loc-manchester) 50%); }
.wk-day.is-clash { background: color-mix(in srgb, #c0392b 12%, var(--surface)); }
.wk-day--ghost { opacity: 0.3; }
.wk-day--ghost .chip--ghost { opacity: 1; }   /* avoid double-fade */
.wk-detail { padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 6px; }
.wk-detail-day { border-radius: 6px; padding: 3px 5px; }
.wk-detail-day.is-clash { background: color-mix(in srgb, #c0392b 12%, var(--surface)); }
.wk-detail-date { display: block; font-size: var(--fs-xs); color: var(--text-dim); margin-bottom: 2px; }
/* Don't stretch expand pills across the wide table — size to content. */
.wk-detail .daygroup { align-items: flex-start; width: fit-content; max-width: 100%; }
/* Expand always shows the full label, even on narrow screens (beats the media query). */
.wk-detail .chip--full .chip__full { display: inline; }
.wk-detail .chip--full .chip__abbr { display: none; }

/* Unit registry */
.reg-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.reg-toolbar input[type="search"] { flex: 1 1 220px; min-width: 160px; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.reg-toolbar select, .reg-toolbar button { padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: var(--fs-sm); cursor: pointer; }
.reg-spacer { flex: 1; }
.reg-danger { color: #c0392b; }
.reg-status { font-size: var(--fs-xs); color: var(--text-dim); margin: 0 0 10px; }
.reg-status.is-dirty { color: var(--loc-both); }
.reg-empty { color: var(--text-dim); font-size: var(--fs-sm); padding: 8px 2px; }

.reg-group { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin: 14px 0 5px; display: flex; gap: 6px; align-items: baseline; }
.reg-group span { opacity: 0.7; }
.unit-row { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; background: var(--surface); }
.unit-row.is-inactive { opacity: 0.55; }
.unit-head { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.unit-chip { flex: none; }
.unit-name { flex: 0 0 auto; min-width: 15ch; }
.unit-name small { color: var(--text-dim); }
.unit-sched { flex: 1; color: var(--text-dim); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-head select.mini { font-size: var(--fs-xs); padding: 2px 4px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); }
.mini-chk { font-size: var(--fs-xs); color: var(--text-dim); display: inline-flex; gap: 3px; align-items: center; }
.unit-head button { font-size: var(--fs-xs); padding: 3px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); cursor: pointer; }

/* Registry on small screens: let the row wrap — name + chip on the first line,
   the location/level/active/edit controls flow onto the next; drop the schedule
   text (it's shown in the expanded editor). */
@media (max-width: 640px) {
  .reg-toolbar select { flex: 1 1 auto; }
  .unit-head { flex-wrap: wrap; gap: 6px 8px; }
  .unit-name { flex: 1 1 auto; min-width: 8ch; }
  .unit-sched { display: none; }
  .unit-head > button { margin-left: auto; }
  .ed-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}

.unit-editor { border-top: 1px dashed var(--border); padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.ed-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.ed-grid label, .ed-notes { display: flex; flex-direction: column; font-size: var(--fs-xs); color: var(--text-dim); gap: 2px; }
.ed-grid input, .ed-grid select, .ed-notes textarea { padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); font-size: var(--fs-sm); }
.ed-colours { display: flex; gap: 6px; }
.ed-colours input[type="color"] { flex: 1; min-width: 0; height: 28px; padding: 2px; cursor: pointer; }

/* View-only (offline) mode: neutralise editing controls but keep viewing —
   expanding a unit (Edit toggle) and Export still work; field edits, adds,
   deletes, orders editor and cloud reload are disabled. */
.is-readonly input[data-field],
.is-readonly select[data-field],
.is-readonly textarea[data-field],
.is-readonly [data-pfield],
.is-readonly input[data-pmonth],
.is-readonly [data-action="add"],
.is-readonly [data-action="orders"],
.is-readonly [data-action="reset"],
.is-readonly [data-action="add-pattern"],
.is-readonly [data-action="del-pattern"],
.is-readonly [data-action="add-event"],
.is-readonly [data-action="edit-event"],
.is-readonly [data-action="del-event"],
.is-readonly [data-action="del-unit"] {
  pointer-events: none;
  opacity: 0.5;
}
.ed-patterns-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ed-patterns-head button, .ed-foot button { font-size: var(--fs-xs); padding: 3px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); cursor: pointer; }
.pattern { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 5px 0; border-top: 1px solid var(--border); }
.pattern select { font-size: var(--fs-xs); padding: 2px 4px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); }
.pattern .months { display: inline-flex; flex-wrap: wrap; gap: 2px 8px; }
.pattern .mchk { font-size: var(--fs-xs); color: var(--text-dim); display: inline-flex; gap: 2px; align-items: center; }
.pattern button { border: none; background: none; color: #c0392b; cursor: pointer; font-size: 0.9rem; }

.ed-events { margin-top: 4px; }
.event { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-top: 1px solid var(--border); }
.event-sum { flex: 1; font-size: var(--fs-sm); }
.event button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 4px; padding: 2px 8px; font-size: var(--fs-xs); cursor: pointer; }
.event button[data-action="del-event"] { border: none; background: none; color: #c0392b; font-size: 0.9rem; }

/* Appointment dialog */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; z-index: 50; }
.modal-card { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; width: min(460px, 96vw); max-height: 88vh; overflow: auto; display: flex; flex-direction: column; gap: 9px; }
.modal-card h3 { margin: 0 0 2px; font-size: 1rem; }
.modal-context { margin: 0; font-size: var(--fs-xs); color: var(--text-dim); }
.modal-card label { display: flex; flex-direction: column; gap: 3px; font-size: var(--fs-xs); color: var(--text-dim); }
.modal-card input, .modal-card select { font-size: var(--fs-sm); padding: 5px 7px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.modal-row { display: flex; gap: 10px; }
.modal-row > label { flex: 1; }
.modal-chk { flex-direction: row !important; align-items: center; gap: 6px; align-self: flex-end; padding-bottom: 6px; }
.modal-chk input { width: auto; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.modal-spacer { flex: 1; }
.modal-actions button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; padding: 6px 14px; cursor: pointer; font-size: var(--fs-sm); }
.modal-primary { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }

/* Orders editor rows */
.ord-list { display: flex; flex-direction: column; gap: 6px; }
.ord-edit { display: flex; align-items: center; gap: 8px; }
.ord-sw { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border); flex: none; }
.ord-edit input[data-of="name"] { flex: 1; }
.ord-edit input[type="color"] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); cursor: pointer; }
.ord-rb { font-size: var(--fs-xs); color: var(--text-dim); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.ord-edit button[data-x="del-ord"] { border: none; background: none; color: #c0392b; cursor: pointer; font-size: 0.9rem; }
.modal-danger { color: #c0392b !important; border-color: var(--border) !important; }

.legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin-top: 14px; font-size: var(--fs-xs); color: var(--text-dim);
}
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
