/* BioStudio AI — Instrument Booking.
   Every colour comes from the platform theme variables (--surface, --text,
   --line, --primary…), with light fallbacks, so the app follows light, dark
   and per-window colour themes without its own dark-mode copy.
   Class names deliberately avoid the theme layer's repaint patterns
   (-calendar, -controls, -card, -panel, -modal, -legend, dialog…). */

.instrument-booking-root {
  /* This class is applied to the window body itself. Keep it in the window
     manager's flex layout so it cannot cover the native title bar/controls. */
  position: relative;
  inset: auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg, #f5f6f8);
  color: var(--text, #1b2330);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ib-app {
  --ib-bg: var(--bg, #f5f6f8);
  --ib-surface: var(--surface, #ffffff);
  --ib-surface-2: var(--surface-2, #f7f8fa);
  --ib-ink: var(--text, #1b2330);
  --ib-muted: var(--muted, #667085);
  --ib-faint: var(--faint, #98a2b3);
  --ib-line: var(--line, #e4e7ec);
  --ib-grid: color-mix(in srgb, var(--ib-line) 70%, transparent);
  --ib-grid-soft: color-mix(in srgb, var(--ib-line) 35%, transparent);
  --ib-accent: var(--primary, #3056d3);
  --ib-accent-soft: var(--primary-soft, color-mix(in srgb, var(--ib-accent) 12%, transparent));
  --ib-on-accent: var(--on-primary, #ffffff);
  --ib-warn: var(--warning, #b7791f);
  --ib-warn-soft: var(--warning-soft, rgba(214, 158, 46, 0.14));
  --ib-danger: var(--danger, #c0392b);
  --ib-danger-soft: var(--danger-soft, rgba(192, 57, 43, 0.12));
  --ib-ok: var(--success, #1f8f4e);
  --ib-ok-soft: var(--success-soft, rgba(31, 143, 78, 0.12));
  --ib-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);

  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--ib-bg);
  color: var(--ib-ink);
  font-size: 13px;
  outline: none;
  container-type: inline-size;
  container-name: ib-app;
}
.window-body.has-project-context-bar > .ib-app {
  position: relative;
  inset: auto;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow: hidden;
}
.ib-app button { font: inherit; cursor: pointer; }
.ib-app button:disabled { cursor: not-allowed; }
.ib-headhost { flex: none; }
.ib-mainhost { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* --- Header ------------------------------------------------------------------- */

.ib-header {
  height: 52px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  background: var(--ib-surface);
  border-bottom: 1px solid var(--ib-line);
}
.ib-brand { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.ib-brand strong { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.ib-brand-mark {
  width: 24px; height: 24px; border-radius: 7px; padding: 5px 5px;
  display: grid; align-content: space-between;
  background: var(--ib-accent);
}
.ib-brand-mark span { display: block; height: 2.5px; border-radius: 2px; background: var(--ib-on-accent); opacity: .92; }
.ib-brand-mark span:nth-child(2) { width: 65%; margin-left: 35%; }
.ib-brand-mark span:nth-child(3) { width: 45%; }
.ib-top-nav { display: flex; align-items: stretch; justify-content: center; gap: 2px; height: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.ib-top-nav::-webkit-scrollbar { display: none; }
.ib-nav {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; border: 0; background: transparent;
  color: var(--ib-muted); font-size: 13px; font-weight: 550; white-space: nowrap;
}
.ib-nav:hover { color: var(--ib-ink); }
.ib-nav.active { color: var(--ib-ink); }
.ib-nav.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px;
  border-radius: 2px 2px 0 0; background: var(--ib-accent);
}
.ib-count-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: inline-grid; place-items: center;
  font-size: 10.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--ib-accent-soft); color: var(--ib-accent);
}
.ib-header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

/* --- Buttons and controls ------------------------------------------------------ */

.ib-btn {
  height: 32px; padding: 0 12px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--ib-line); background: var(--ib-surface); color: var(--ib-ink);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.ib-btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--ib-ink) 25%, var(--ib-line)); }
.ib-btn:disabled { opacity: .5; }
.ib-btn.primary { background: var(--ib-accent); border-color: var(--ib-accent); color: var(--ib-on-accent); }
.ib-btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ib-accent) 88%, #000); }
.ib-btn.primary > span { font-size: 16px; line-height: 1; margin-top: -1px; }
.ib-btn.danger { color: var(--ib-danger); border-color: color-mix(in srgb, var(--ib-danger) 35%, var(--ib-line)); }
.ib-btn.danger:hover:not(:disabled) { background: var(--ib-danger-soft); }
.ib-btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.ib-btn:focus-visible, .ib-iconbtn:focus-visible, .ib-seg-btn:focus-visible, .ib-nav:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--ib-accent) 60%, transparent); outline-offset: 2px;
}
.ib-iconbtn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--ib-line);
  background: var(--ib-surface); color: var(--ib-ink); font-size: 18px; line-height: 1;
  display: inline-grid; place-items: center;
}
.ib-iconbtn:hover { background: var(--ib-surface-2); }
.ib-link { border: 0; background: none; padding: 0; color: inherit; font-weight: 650; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.ib-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ib-grow { flex: 1; }

.ib-seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: 9px; background: var(--ib-surface-2); border: 1px solid var(--ib-line); }
.ib-seg-btn {
  height: 26px; padding: 0 11px; border-radius: 7px; border: 1px solid transparent;
  background: transparent; color: var(--ib-muted); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.ib-seg-btn:hover { color: var(--ib-ink); }
.ib-seg-btn.on { background: var(--ib-surface); color: var(--ib-ink); border-color: var(--ib-line); box-shadow: var(--ib-shadow); }
.ib-durations { display: flex; flex-wrap: wrap; gap: 6px; }
.ib-durations .ib-seg-btn { border-color: var(--ib-line); background: var(--ib-surface); }
.ib-durations .ib-seg-btn.on { background: var(--ib-accent-soft); color: var(--ib-accent); border-color: color-mix(in srgb, var(--ib-accent) 45%, transparent); }

.ib-select {
  height: 32px; max-width: 240px; padding: 0 28px 0 10px; border-radius: 8px;
  border: 1px solid var(--ib-line); background: var(--ib-surface); color: var(--ib-ink); font: inherit; font-size: 12.5px;
}
.ib-select.compact { height: 28px; font-size: 12px; }
.ib-search { position: relative; display: flex; align-items: center; flex: 1 1 200px; min-width: 160px; max-width: 320px; }
.ib-search-ico { position: absolute; left: 10px; color: var(--ib-faint); font-size: 14px; pointer-events: none; }
.ib-search-input {
  width: 100%; height: 32px; padding: 0 10px 0 28px; border-radius: 8px;
  border: 1px solid var(--ib-line); background: var(--ib-surface); color: var(--ib-ink); font: inherit; font-size: 12.5px; outline: none;
}
.ib-search-input:focus, .ib-select:focus, .ib-input:focus {
  border-color: var(--ib-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ib-accent) 16%, transparent);
}

/* --- Page layout ---------------------------------------------------------------- */

.ib-main { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 16px 20px 28px; }
.ib-pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 4px 0 16px; }
.ib-pagehead h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.015em; }
.ib-pagehead p { margin: 4px 0 0; color: var(--ib-muted); font-size: 12.5px; }
.ib-topline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ib-nav-group { display: inline-flex; align-items: center; gap: 4px; }
.ib-range { margin: 0 6px 0 4px; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; flex: 1 1 auto; }
.ib-count { color: var(--ib-muted); font-size: 12px; margin-left: auto; }
.ib-quiet { margin: 0; padding: 14px 16px; color: var(--ib-muted); font-size: 12.5px; }
.ib-help { color: var(--ib-muted); font-size: 11.5px; margin: 0; }

.ib-pill {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 650; white-space: nowrap;
  background: var(--ib-surface-2); color: var(--ib-muted);
}
.ib-pill.st-available, .ib-pill.bk-booked { background: var(--ib-ok-soft); color: var(--ib-ok); }
.ib-pill.st-in_use { background: var(--ib-accent-soft); color: var(--ib-accent); }
.ib-pill.st-maintenance, .ib-pill.bk-pending { background: var(--ib-warn-soft); color: var(--ib-warn); }
.ib-pill.st-out_of_service, .ib-pill.bk-declined { background: var(--ib-danger-soft); color: var(--ib-danger); }
.ib-swatch { width: 4px; min-height: 26px; align-self: stretch; border-radius: 4px; background: var(--c, var(--ib-accent)); }

.ib-blank {
  margin: 8px 0; padding: 34px 20px; border: 1px dashed var(--ib-line); border-radius: 12px;
  display: grid; justify-items: center; gap: 8px; text-align: center; color: var(--ib-muted); font-size: 12.5px;
}
.ib-blank strong { color: var(--ib-ink); font-size: 15px; font-weight: 650; }
.ib-blank > span { max-width: 460px; line-height: 1.5; }
.ib-blank.big { padding: 64px 24px; background: var(--ib-surface); }
.ib-blank .ib-actions { justify-content: center; margin-top: 6px; }

.ib-loading { flex: 1; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--ib-muted); }
.ib-spinner { width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--ib-line); border-top-color: var(--ib-accent); animation: ib-spin .8s linear infinite; }
@keyframes ib-spin { to { transform: rotate(360deg); } }

/* --- Schedule ------------------------------------------------------------------- */

.ib-sched {
  --res-w: 220px;
  background: var(--ib-surface); border: 1px solid var(--ib-line); border-radius: 12px;
  box-shadow: var(--ib-shadow); overflow: hidden;
}
.ib-row { display: grid; grid-template-columns: var(--res-w) minmax(0, 1fr); border-bottom: 1px solid var(--ib-line); }
.ib-row:last-child { border-bottom: 0; }
.ib-row.head { position: sticky; top: -16px; z-index: 4; background: var(--ib-surface); }
.ib-res-head { display: flex; align-items: center; padding: 0 14px; color: var(--ib-muted); font-size: 11px; font-weight: 600; border-right: 1px solid var(--ib-line); }

.ib-res {
  display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 8px 12px; border: 0; border-right: 1px solid var(--ib-line); background: transparent; color: inherit; text-align: left; min-width: 0;
}
.ib-res:hover { background: var(--ib-surface-2); }
.ib-res .ib-swatch { min-height: 30px; }
.ib-res-text { display: grid; gap: 2px; min-width: 0; }
.ib-res-text strong { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-res-text small { font-size: 11px; color: var(--ib-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ib-axis { position: relative; color: var(--ib-muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.ib-axis.x { height: 34px; margin: 0 14px; }
.ib-axis.x .ib-tick { position: absolute; top: 50%; transform: translate(-50%, -50%); white-space: nowrap; }
.ib-axis.x .ib-tick:first-child { transform: translate(0, -50%); }
.ib-axis.x .ib-tick:last-child { transform: translate(-100%, -50%); }

/* Day timeline: hour lines drawn as a background, sized by --hours. */
.ib-track {
  position: relative; min-height: 50px; margin: 0 14px; cursor: crosshair; touch-action: none;
  background-image:
    linear-gradient(to right, var(--ib-grid) 1px, transparent 1px),
    linear-gradient(to right, var(--ib-grid-soft) 1px, transparent 1px);
  background-size: calc(100% / var(--hours)) 100%, calc(100% / var(--hours) / 2) 100%;
  border-right: 1px solid var(--ib-grid);
}
.ib-day .ib-row:not(.head):hover .ib-track:not(.blocked) { background-color: color-mix(in srgb, var(--ib-accent) 3%, transparent); }
.ib-track.blocked, .ib-col.blocked, .ib-cell.blocked {
  cursor: not-allowed;
  background-image: repeating-linear-gradient(135deg, transparent 0 6px, var(--ib-grid-soft) 6px 8px);
  background-size: auto;
}
.ib-blocked-label { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ib-muted); font-size: 11px; font-weight: 600; pointer-events: none; }

.ib-bar {
  position: absolute; z-index: 2; overflow: hidden; min-width: 0;
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  padding: 3px 7px; text-align: left; border: 0;
  border-left: 3px solid var(--c);
  border-radius: 5px;
  background: color-mix(in srgb, var(--c) 14%, var(--ib-surface));
  color: var(--ib-ink);
}
.ib-track .ib-bar { top: 6px; bottom: 6px; }
.ib-bar strong, .ib-bar span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; }
.ib-bar strong { font-size: 11.5px; font-weight: 600; }
.ib-bar span { font-size: 10.5px; color: var(--ib-muted); }
.ib-bar:hover { z-index: 3; box-shadow: 0 2px 8px rgba(16, 24, 40, .14); }
.ib-bar.mine { background: var(--c); color: #fff; border-left-color: color-mix(in srgb, var(--c) 70%, #000); }
.ib-bar.mine span { color: rgba(255, 255, 255, .85); }
.ib-bar.pending {
  border: 1.5px dashed var(--c); border-left-width: 3px; border-left-style: solid;
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 10%, var(--ib-surface)) 0 6px, var(--ib-surface) 6px 12px);
  color: var(--ib-ink);
}
.ib-bar.pending span { color: var(--ib-muted); }

.ib-ghost {
  position: absolute; z-index: 5; pointer-events: none;
  border: 1.5px dashed var(--ib-accent); border-radius: 5px; background: var(--ib-accent-soft);
  display: grid; place-items: center; color: var(--ib-accent); font-size: 10.5px; font-weight: 700; white-space: nowrap; overflow: hidden;
}
.ib-track .ib-ghost { top: 4px; bottom: 4px; }
.ib-col .ib-ghost { left: 3px; right: 3px; }

.ib-now { position: absolute; z-index: 4; pointer-events: none; background: var(--ib-danger); }
.ib-now.x { top: 0; bottom: 0; width: 2px; margin-left: -1px; }
.ib-now.y { left: 0; right: 0; height: 2px; margin-top: -1px; }
.ib-now::before { content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--ib-danger); }
.ib-now.x::before { top: -3px; left: -2.5px; }
.ib-now.y::before { left: -3px; top: -2.5px; }

.ib-dayhead {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 4px; border: 0; border-left: 1px solid var(--ib-line);
  background: transparent; color: var(--ib-muted);
}
.ib-dayhead span { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.ib-dayhead strong { min-width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: var(--ib-ink); font-size: 14px; font-weight: 600; }
.ib-dayhead:hover strong { background: var(--ib-surface-2); }
.ib-dayhead.today strong { background: var(--ib-accent); color: var(--ib-on-accent); }
.ib-dayhead.weekend, .ib-col.weekend, .ib-cell.weekend { background-color: color-mix(in srgb, var(--ib-surface-2) 70%, transparent); }

/* Week, one instrument */
.ib-week1 { --hour-h: 44px; }
.ib-w1-head, .ib-w1-body { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); }
.ib-w1-head { position: sticky; top: -16px; z-index: 4; background: var(--ib-surface); border-bottom: 1px solid var(--ib-line); }
.ib-w1-body { height: calc(var(--hours) * var(--hour-h)); }
.ib-axis.y .ib-tick { position: absolute; right: 8px; transform: translateY(-50%); }
.ib-axis.y .ib-tick:first-child { transform: translateY(2px); }
.ib-axis.y .ib-tick:last-child { display: none; }
.ib-col {
  position: relative; border-left: 1px solid var(--ib-line); cursor: crosshair; touch-action: none;
  background-image:
    linear-gradient(to bottom, var(--ib-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--ib-grid-soft) 1px, transparent 1px);
  background-size: 100% calc(100% / var(--hours)), 100% calc(100% / var(--hours) / 2);
}
.ib-col .ib-bar { left: 3px; right: 3px; justify-content: flex-start; padding-top: 4px; }

/* Week, all instruments */
.ib-weekall { overflow-x: auto; }
.ib-weekall .ib-row { grid-template-columns: var(--res-w) repeat(7, minmax(92px, 1fr)); min-width: calc(var(--res-w) + 7 * 92px); }
.ib-cell {
  min-height: 56px; padding: 5px; border-left: 1px solid var(--ib-line);
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.ib-cell.open { cursor: pointer; }
.ib-cell.open:hover { background-color: color-mix(in srgb, var(--ib-accent) 5%, transparent); }
.ib-chipbtn {
  display: block; width: 100%; padding: 2px 6px; border: 0; border-left: 3px solid var(--c); border-radius: 4px;
  background: color-mix(in srgb, var(--c) 14%, var(--ib-surface)); color: var(--ib-ink);
  font-size: 10.5px; font-weight: 550; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ib-chipbtn.mine { background: var(--c); color: #fff; }
.ib-chipbtn.pending { background: var(--ib-surface); outline: 1.5px dashed var(--c); outline-offset: -1.5px; }
.ib-more { border: 0; background: none; padding: 0 2px; color: var(--ib-accent); font-size: 10.5px; font-weight: 650; text-align: left; }

.ib-key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 10px; color: var(--ib-muted); font-size: 11.5px; }
.ib-key > span { display: inline-flex; align-items: center; gap: 6px; }
.ib-key i { width: 12px; height: 10px; border-radius: 3px; display: inline-block; }
.ib-key i.mine { background: var(--ib-accent); }
.ib-key i.other { background: color-mix(in srgb, var(--ib-accent) 16%, var(--ib-surface)); border-left: 3px solid var(--ib-accent); }
.ib-key i.pending { border: 1.5px dashed var(--ib-warn); }
.ib-key i.blocked { background: repeating-linear-gradient(135deg, transparent 0 3px, var(--ib-line) 3px 5px); border: 1px solid var(--ib-line); }
.ib-key-hint { margin-left: auto; color: var(--ib-faint); }

/* --- Instruments directory ------------------------------------------------------- */

.ib-inst-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.ib-inst {
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--ib-surface); border: 1px solid var(--ib-line); border-radius: 12px; box-shadow: var(--ib-shadow);
}
.ib-inst-top { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.ib-badge {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 14%, var(--ib-surface)); color: var(--c); font-size: 12px; font-weight: 750; letter-spacing: .02em;
}
.ib-inst-name { min-width: 0; display: grid; gap: 2px; }
.ib-inst-name h3 { margin: 0; font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-inst-name small { color: var(--ib-muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-inst-desc { margin: 0; color: var(--ib-muted); font-size: 12px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ib-inst-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.ib-inst-facts li { padding: 2px 7px; border-radius: 6px; background: var(--ib-surface-2); color: var(--ib-muted); font-size: 11px; }
.ib-inst-facts li.warn { background: var(--ib-warn-soft); color: var(--ib-warn); font-weight: 600; }
.ib-load { height: 5px; border-radius: 999px; background: var(--ib-surface-2); overflow: hidden; }
.ib-load span { display: block; height: 100%; border-radius: inherit; background: var(--c); }
.ib-inst-next { font-size: 12px; font-weight: 550; }
.ib-inst-actions { display: flex; gap: 6px; margin-top: auto; }
.ib-inst-actions .ib-btn.primary { margin-left: auto; min-width: 72px; }

/* --- My bookings ----------------------------------------------------------------- */

.ib-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 8px; }
.ib-kpis > div { display: grid; gap: 4px; padding: 12px 16px; background: var(--ib-surface); border: 1px solid var(--ib-line); border-radius: 12px; }
.ib-kpis span { color: var(--ib-muted); font-size: 11.5px; }
.ib-kpis strong { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ib-group-title { margin: 18px 0 8px; color: var(--ib-muted); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.ib-brow {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  margin-bottom: 6px; padding: 10px 12px; background: var(--ib-surface); border: 1px solid var(--ib-line); border-radius: 10px;
}
.ib-brow.past { opacity: .82; }
.ib-date {
  width: 44px; height: 48px; border-radius: 9px; display: grid; place-items: center; align-content: center;
  background: color-mix(in srgb, var(--c) 12%, var(--ib-surface)); color: var(--c);
}
.ib-date span { font-size: 9.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.ib-date strong { font-size: 17px; font-weight: 700; line-height: 1.1; }
.ib-brow-main { display: grid; gap: 3px; min-width: 0; }
.ib-brow-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ib-brow-title strong { font-size: 13.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-brow-main > span { font-size: 12px; color: var(--ib-ink); opacity: .82; }
.ib-brow-main > small { font-size: 12px; color: var(--ib-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-history { margin-top: 18px; }
.ib-history summary { cursor: pointer; padding: 6px 0 10px; color: var(--ib-muted); font-size: 12.5px; font-weight: 650; }

/* --- Manage ---------------------------------------------------------------------- */

.ib-block { margin-bottom: 14px; background: var(--ib-surface); border: 1px solid var(--ib-line); border-radius: 12px; overflow: hidden; }
.ib-block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--ib-line); }
.ib-block-head h2 { margin: 0; font-size: 14px; font-weight: 650; }
.ib-block-head span { color: var(--ib-muted); font-size: 12px; }
.ib-block > .ib-blank { margin: 14px; }
.ib-approval { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--ib-line); }
.ib-approval:last-child { border-bottom: 0; }
.ib-approval > div:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
.ib-approval strong { font-size: 13px; }
.ib-approval span, .ib-approval small { color: var(--ib-muted); font-size: 12px; }
.ib-tablewrap { overflow-x: auto; }
.ib-grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ib-grid th { padding: 8px 12px; text-align: left; color: var(--ib-muted); font-size: 11px; font-weight: 650; white-space: nowrap; background: var(--ib-surface-2); }
.ib-grid td { padding: 9px 12px; border-top: 1px solid var(--ib-line); vertical-align: middle; }
.ib-grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.ib-grid .right { text-align: right; }
.ib-cellname { display: grid; grid-template-columns: 4px minmax(0, 1fr); gap: 10px; align-items: center; }
.ib-cellname > div { display: grid; gap: 2px; min-width: 0; }
.ib-cellname small { color: var(--ib-muted); font-size: 11px; }

/* --- Overlays (inside the window, never on <body>) ------------------------------- */

.ib-overlay {
  position: absolute; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px;
  background: rgba(15, 20, 30, .36); animation: ib-fade .12s ease;
}
@keyframes ib-fade { from { opacity: 0; } }
.ib-sheet {
  width: min(560px, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column;
  background: var(--ib-surface); color: var(--ib-ink); border: 1px solid var(--ib-line); border-radius: 14px;
  box-shadow: 0 24px 64px rgba(16, 24, 40, .28);
}
.ib-sheet.wide { width: min(680px, 100%); }
.ib-sheet > form, .ib-sheet > div { display: flex; flex-direction: column; min-height: 0; }
.ib-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; }
.ib-sheet-head h2 { margin: 2px 0 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.ib-eyebrow { color: var(--ib-muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.ib-x { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--ib-surface-2); color: var(--ib-muted); font-size: 18px; line-height: 1; flex: none; }
.ib-x:hover { color: var(--ib-ink); }
.ib-sheet-body { display: grid; gap: 12px; padding: 4px 18px 14px; }
.ib-sheet-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--ib-line); }
.ib-sheet-foot .ib-btn.danger { margin-right: auto; }
.ib-field { display: grid; gap: 5px; min-width: 0; }
.ib-field > span { color: var(--ib-muted); font-size: 11.5px; font-weight: 600; }
.ib-input {
  width: 100%; height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--ib-line);
  background: var(--ib-surface); color: var(--ib-ink); font: inherit; font-size: 13px; outline: none; box-sizing: border-box;
}
textarea.ib-input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
select.ib-input { padding-right: 26px; }
.ib-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ib-grid3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; }
.ib-subhead { margin-top: 4px; color: var(--ib-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.ib-check { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; line-height: 1.4; }
.ib-check input { margin-top: 2px; accent-color: var(--ib-accent); }
.ib-check[hidden] { display: none; }
.ib-error { color: var(--ib-danger); font-size: 12.5px; }
.ib-error:empty { display: none; }

.ib-inst-info {
  display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center;
  padding: 10px 12px; border-radius: 10px; background: var(--ib-surface-2);
}
.ib-inst-info > div { display: grid; gap: 2px; min-width: 0; }
.ib-inst-info strong { font-size: 13px; }
.ib-inst-info small { color: var(--ib-muted); font-size: 11.5px; }
.ib-rules { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.ib-rules span { padding: 2px 7px; border-radius: 6px; background: var(--ib-surface); border: 1px solid var(--ib-line); font-size: 10.5px; color: var(--ib-muted); white-space: nowrap; }
.ib-instructions { grid-column: 2 / -1; margin: 4px 0 0; font-size: 12px; line-height: 1.45; }

.ib-strip { display: grid; gap: 3px; }
.ib-strip-track {
  position: relative; height: 26px; border-radius: 7px; cursor: pointer; overflow: hidden;
  background-color: var(--ib-surface-2);
  background-image: linear-gradient(to right, var(--ib-grid) 1px, transparent 1px);
  background-size: calc(100% / var(--hours, 14)) 100%;
  border: 1px solid var(--ib-line);
}
.ib-strip-busy { position: absolute; top: 4px; bottom: 4px; border-radius: 3px; background: color-mix(in srgb, var(--ib-muted) 45%, transparent); }
.ib-strip-busy.pending { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--ib-warn) 45%, transparent) 0 4px, transparent 4px 8px); }
.ib-strip-slot { position: absolute; top: 0; bottom: 0; border: 2px solid var(--ib-ok); border-radius: 5px; background: var(--ib-ok-soft); }
.ib-strip-slot.bad { border-color: var(--ib-danger); background: var(--ib-danger-soft); }
.ib-strip-axis { position: relative; height: 13px; color: var(--ib-faint); font-size: 10px; }
.ib-strip-tick { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.ib-strip-tick:first-child { transform: none; }
.ib-strip-tick:last-child { transform: translateX(-100%); }
.ib-verdict { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; font-size: 12.5px; }
.ib-verdict.ok { background: var(--ib-ok-soft); color: var(--ib-ok); }
.ib-verdict.bad { background: var(--ib-danger-soft); color: var(--ib-danger); }

.ib-facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--ib-line); border-radius: 10px; overflow: hidden; }
.ib-facts > div { padding: 9px 12px; border-bottom: 1px solid var(--ib-line); }
.ib-facts > div:nth-child(odd):not(.full) { border-right: 1px solid var(--ib-line); }
.ib-facts > div.full { grid-column: 1 / -1; }
.ib-facts dt { color: var(--ib-muted); font-size: 11px; }
.ib-facts dd { margin: 3px 0 0; font-size: 13px; }
.ib-decide { display: grid; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--ib-warn-soft); }
.ib-decide strong { color: var(--ib-warn); font-size: 12.5px; }

/* --- Narrow windows --------------------------------------------------------------- */

@container ib-app (max-width: 1080px) {
  .ib-axis.x .ib-tick.odd { display: none; }
}
@container ib-app (max-width: 980px) {
  .ib-key .ib-key-hint { display: none; }
  .ib-sched { --res-w: 170px; }
  .ib-header { gap: 10px; padding: 0 12px; }
  .ib-brand strong { display: none; }
}
@container ib-app (max-width: 760px) {
  .ib-header { padding: 0 10px; }
  .ib-nav { padding: 0 7px; font-size: 12.5px; }
  .ib-main { padding: 12px 12px 24px; }
  .ib-sched { --res-w: 132px; }
  .ib-res .ib-pill { display: none; }
  .ib-range { flex-basis: 100%; order: -1; margin: 0; }
  .ib-kpis { grid-template-columns: 1fr; }
  .ib-grid3 { grid-template-columns: 1fr 1fr; }
  .ib-grid3 > :first-child { grid-column: 1 / -1; }
  .ib-grid2 { grid-template-columns: 1fr; }
  .ib-brow { grid-template-columns: 44px minmax(0, 1fr); }
  .ib-brow > .ib-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .ib-approval { grid-template-columns: 4px minmax(0, 1fr); }
  .ib-approval > .ib-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .ib-pagehead { flex-direction: column; align-items: flex-start; }
}

/* ---- Function search (header-actions, 22px pill, opaque 2-col pop) ---- */
.ib-header { overflow: visible; z-index: 20; position: relative; min-width: 0; }
.ib-brand, .ib-top-nav { min-width: 0; }
.ib-header-actions { overflow: visible; position: relative; z-index: 12; flex: none; }
.ib-fnsearch {
  position: relative; z-index: 12; flex: none; flex-shrink: 0;
  align-self: center; display: flex; align-items: center;
}
.ib-fnsearch-field {
  display: flex; align-items: center; gap: 6px;
  height: 22px; min-height: 22px; max-height: 22px;
  width: 178px; padding: 0 10px 0 8px;
  border-radius: 999px;
  background: color-mix(in srgb, #1f2733 8%, #fff);
  border: 1px solid color-mix(in srgb, #1f2733 16%, #fff);
  color: #1f2733;
  box-sizing: border-box;
  overflow: hidden;
  cursor: text;
  transition: background .14s ease, border-color .14s ease, box-shadow .14s ease, width .18s ease, color .14s ease;
}
.ib-fnsearch-field:hover {
  background: color-mix(in srgb, #1f2733 12%, #fff);
  border-color: color-mix(in srgb, #2f6bd4 35%, #c5ccd8);
}
.ib-fnsearch.open .ib-fnsearch-field,
.ib-fnsearch-field.on,
.ib-fnsearch-field:focus-within {
  background: #fff;
  border-color: #2f6bd4;
  color: #1f2733;
  box-shadow:
    0 0 0 2px color-mix(in srgb, #2f6bd4 35%, transparent),
    0 8px 22px rgba(10, 24, 56, .16);
}
.ib-fnsearch-field:focus-visible {
  outline: 2px solid color-mix(in srgb, #2f6bd4 65%, #fff);
  outline-offset: 2px;
}
.ib-fnsearch-ic { display: inline-flex; align-items: center; justify-content: center; color: inherit; opacity: .92; flex: none; }
.ib-fnsearch-ic svg { width: 14px; height: 14px; display: block; overflow: visible; stroke-width: 2; }
.ib-fnsearch.open .ib-fnsearch-ic,
.ib-fnsearch-field.on .ib-fnsearch-ic,
.ib-fnsearch-field:focus-within .ib-fnsearch-ic { color: #2f6bd4; opacity: 1; }
.ib-fnsearch-input {
  flex: 1; min-width: 0; min-height: 0; height: 20px; line-height: 20px;
  border: 0; background: transparent; color: inherit;
  font: inherit; font-size: 12px; font-weight: 500; outline: none;
  padding: 0; appearance: none; -webkit-appearance: none;
}
.ib-fnsearch-input::-webkit-search-decoration,
.ib-fnsearch-input::-webkit-search-cancel-button { display: none; }
.ib-fnsearch-input::placeholder { color: #6c7686; font-weight: 500; }
.ib-fnsearch.open .ib-fnsearch-input::placeholder,
.ib-fnsearch-field.on .ib-fnsearch-input::placeholder,
.ib-fnsearch-field:focus-within .ib-fnsearch-input::placeholder { color: #6c7686; }
.ib-fnsearch-pop {
  --fn-pop-bg: #ffffff;
  --fn-pop-ink: #1f2733;
  --fn-pop-muted: #5c6573;
  --fn-pop-line: #d7dce6;
  --fn-pop-accent: #2f6bd4;
  --fn-pop-shadow: 0 22px 56px rgba(16, 32, 72, .28), 0 2px 8px rgba(16, 32, 72, .08);
  display: flex;
  position: absolute; top: calc(100% + 7px); right: 0;
  width: min(540px, calc(100cqi - 24px));
  max-width: min(540px, calc(100cqi - 16px));
  max-height: min(420px, 72vh);
  isolation: isolate;
  color-scheme: light;
  background-color: #ffffff;
  background-image: linear-gradient(180deg, color-mix(in srgb, var(--fn-pop-accent) 9%, #ffffff), #ffffff 2.4rem);
  color: #1f2733;
  border: 1px solid var(--fn-pop-line);
  border-radius: 14px;
  box-shadow: var(--fn-pop-shadow);
  z-index: 80;
  overflow: hidden;
  flex-direction: column;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(-6px) scale(.985);
  transform-origin: top right;
  transition: opacity .14s ease, transform .16s ease, visibility 0s linear .16s;
}
.ib-fnsearch-pop.on {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: translateY(0) scale(1);
  transition: opacity .14s ease, transform .16s ease, visibility 0s;
}
.ib-fnsearch-head {
  display: flex; align-items: baseline; gap: 8px; flex: none;
  padding: 10px 14px 8px;
  background: #ffffff;
  border-bottom: 1px solid color-mix(in srgb, var(--fn-pop-line) 85%, #ffffff);
}
.ib-fnsearch-title {
  font-size: 10.5px; font-weight: 800; letter-spacing: .72px;
  text-transform: uppercase; color: var(--fn-pop-muted);
}
.ib-fnsearch-count {
  margin-left: auto; font-size: 11px; color: var(--fn-pop-muted);
  font-variant-numeric: tabular-nums; font-weight: 600;
}
.ib-fnsearch-pop.is-suggest .ib-fnsearch-count { display: none; }
.ib-fnsearch-list {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px 6px;
  padding: 8px; overflow: auto; min-height: 0; flex: 1 1 auto;
  background: #ffffff;
  scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--fn-pop-muted) 45%, transparent) transparent;
}
.ib-fnsearch-list::-webkit-scrollbar { width: 8px; height: 8px; }
.ib-fnsearch-list::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--fn-pop-muted) 40%, transparent);
  border-radius: 99px; border: 2px solid transparent; background-clip: padding-box;
}
.ib-fnsearch-list.cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.ib-fnsearch-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; min-width: 0; text-align: left;
  border: 1px solid transparent; background: transparent;
  color: var(--fn-pop-ink); border-radius: 10px;
  padding: 6px 8px; cursor: pointer; min-height: 40px;
  box-sizing: border-box; overflow: hidden;
  font: inherit; appearance: none; -webkit-appearance: none;
  transition: background .08s ease, border-color .08s ease, color .08s ease, box-shadow .08s ease;
}
.ib-fnsearch-item:hover {
  background: color-mix(in srgb, var(--fn-pop-accent) 8%, #ffffff);
  border-color: color-mix(in srgb, var(--fn-pop-accent) 18%, #ffffff);
}
.ib-fnsearch-item.is-active,
.ib-fnsearch-item:hover.is-active {
  background: var(--fn-pop-accent);
  border-color: var(--fn-pop-accent);
  color: #fff;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--fn-pop-accent) 38%, transparent);
}
.ib-fnsearch-item:focus { outline: none; }
.ib-fnsearch-item:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--fn-pop-accent) 65%, #fff);
  outline-offset: -2px;
}
.ib-fnsearch-item.is-active:focus-visible { outline-color: rgba(255,255,255,.72); }
.ib-fnsearch-item-ic {
  flex: none; width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--fn-pop-accent) 12%, #ffffff);
  color: var(--fn-pop-accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fn-pop-accent) 14%, transparent);
}
.ib-fnsearch-item:hover:not(.is-active) .ib-fnsearch-item-ic {
  background: color-mix(in srgb, var(--fn-pop-accent) 18%, #ffffff);
}
.ib-fnsearch-item.is-active .ib-fnsearch-item-ic {
  background: rgba(255,255,255,.18); color: #fff; box-shadow: none;
}
.ib-fnsearch-item-ic svg { width: 15px; height: 15px; display: block; overflow: visible; }
.ib-fnsearch-item-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.ib-fnsearch-item-name {
  font-size: 12.5px; font-weight: 600; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ib-fnsearch-item-hint {
  font-size: 10.5px; color: var(--fn-pop-muted); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ib-fnsearch-item.is-active .ib-fnsearch-item-hint { color: rgba(255,255,255,.82); }
.ib-fnsearch-pop.is-empty {
  background-image: none;
  background-color: #ffffff;
  color: var(--fn-pop-ink);
}
.ib-fnsearch-pop.is-empty .ib-fnsearch-list {
  grid-template-columns: minmax(0, 1fr);
  min-height: 168px;
  background-color: #ffffff;
}
.ib-fnsearch-empty {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 8px; padding: 32px 28px 28px; color: var(--fn-pop-muted);
  min-height: 168px; background: #ffffff;
}
.ib-fnsearch-empty-ic {
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fn-pop-accent);
  background: color-mix(in srgb, var(--fn-pop-accent) 12%, #ffffff);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fn-pop-accent) 16%, transparent);
}
.ib-fnsearch-empty-ic svg { width: 18px; height: 18px; overflow: visible; }
.ib-fnsearch-empty strong {
  color: var(--fn-pop-ink); font-size: 13px; font-weight: 700;
  max-width: min(420px, 100%); overflow-wrap: anywhere;
}
.ib-fnsearch-empty p { margin: 0; font-size: 12px; line-height: 1.45; max-width: 320px; }
.ib-fnsearch-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: none;
  padding: 7px 12px 8px;
  border-top: 1px solid var(--fn-pop-line);
  background: color-mix(in srgb, var(--fn-pop-ink) 2.5%, #ffffff);
  font-size: 10.5px; color: var(--fn-pop-muted);
}
.ib-fnsearch-k { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.ib-fnsearch-k kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 16px; padding: 0 5px;
  border-radius: 4px; font: 600 10px/1 ui-sans-serif, system-ui, sans-serif;
  color: var(--fn-pop-ink);
  background: #fff;
  box-shadow: 0 1px 0 rgba(16, 32, 72, .14), inset 0 0 0 1px var(--fn-pop-line);
}
.ib-fnsearch-pop:not(.cols-2) .ib-fnsearch-k-cols,
.ib-fnsearch-pop.is-empty .ib-fnsearch-k-move,
.ib-fnsearch-pop.is-empty .ib-fnsearch-k-cols,
.ib-fnsearch-pop.is-empty .ib-fnsearch-k-open { display: none; }

.dark .ib-fnsearch-field {
  background: #252a34;
  border-color: #3a4252;
  color: #e8ecf3;
}
.dark .ib-fnsearch-field:hover { background: #2c3340; border-color: #5b8def; }
.dark .ib-fnsearch-ic { color: #9aa5b5; }
.dark .ib-fnsearch-input::placeholder { color: #9aa5b5; }
.dark .ib-fnsearch.open .ib-fnsearch-field,
.dark .ib-fnsearch-field.on,
.dark .ib-fnsearch-field:focus-within {
  color: #e8ecf3;
  background: #1c212b;
  border-color: #5b8def;
  box-shadow:
    0 0 0 2px rgba(91, 141, 239, .45),
    0 10px 24px rgba(0, 0, 0, .45);
}
.dark .ib-fnsearch.open .ib-fnsearch-ic,
.dark .ib-fnsearch-field.on .ib-fnsearch-ic,
.dark .ib-fnsearch-field:focus-within .ib-fnsearch-ic { color: #9cbcff; }
.dark .ib-fnsearch-pop {
  --fn-pop-bg: #1c212b;
  --fn-pop-ink: #e8ecf3;
  --fn-pop-muted: #9aa5b5;
  --fn-pop-line: #3a4252;
  --fn-pop-accent: #5b8def;
  --fn-pop-shadow: 0 28px 64px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.06);
  color-scheme: dark;
  background-color: #1c212b;
  background-image: linear-gradient(180deg, #22283a, #1c212b 2.4rem);
  color: #e8ecf3;
  border-color: #3a4252;
}
.dark .ib-fnsearch-head,
.dark .ib-fnsearch-list,
.dark .ib-fnsearch-empty,
.dark .ib-fnsearch-pop.is-empty,
.dark .ib-fnsearch-pop.is-empty .ib-fnsearch-list,
.dark .ib-fnsearch-pop.is-empty .ib-fnsearch-empty {
  background: #1c212b;
  background-color: #1c212b;
  color: #e8ecf3;
}
.dark .ib-fnsearch-foot {
  background: #191e27;
  border-top-color: #3a4252;
}
.dark .ib-fnsearch-item:hover:not(.is-active) {
  background: rgba(91, 141, 239, .14);
  border-color: rgba(91, 141, 239, .28);
}
.dark .ib-fnsearch-item-ic {
  background: rgba(91, 141, 239, .16);
  color: #9cbcff;
  box-shadow: inset 0 0 0 1px rgba(91, 141, 239, .22);
}
.dark .ib-fnsearch-empty strong { color: #e8ecf3; }
.dark .ib-fnsearch-k kbd {
  color: #e8ecf3;
  background: #2a3140;
  box-shadow: 0 1px 0 rgba(0,0,0,.4), inset 0 0 0 1px #3a4252;
}

@media (prefers-reduced-motion: reduce) {
  .ib-fnsearch-field,
  .ib-fnsearch-pop,
  .ib-fnsearch-pop.on,
  .ib-fnsearch-item { transition: none; transform: none; }
}

/* Windowed chrome: header/search must compact on *app* width, not the viewport. */
@container ib-app (max-width: 1080px) {
  .ib-fnsearch-field { width: 156px; }
}
@container ib-app (max-width: 920px) {
  .ib-fnsearch-field { width: 138px; padding: 0 8px 0 7px; }
  .ib-fnsearch-input { font-size: 11.5px; }
}
@container ib-app (max-width: 760px) {
  .ib-fnsearch-field {
    width: 32px; max-width: 32px; padding: 0; gap: 0; justify-content: center; cursor: pointer;
  }
  .ib-fnsearch-input {
    width: 0; min-width: 0; padding: 0; opacity: 0; pointer-events: none;
  }
  .ib-fnsearch.open .ib-fnsearch-field,
  .ib-fnsearch-field.on,
  .ib-fnsearch-field:focus-within {
    width: 158px; max-width: 158px; gap: 6px; padding: 0 10px 0 8px; justify-content: flex-start; cursor: text;
  }
  .ib-fnsearch.open .ib-fnsearch-input,
  .ib-fnsearch-field.on .ib-fnsearch-input,
  .ib-fnsearch-field:focus-within .ib-fnsearch-input {
    width: auto; opacity: 1; pointer-events: auto; flex: 1;
  }
}
@container ib-app (max-width: 620px) {
  .ib-header-actions { gap: 6px; }
  .ib-header-actions .ib-btn { width: 36px; min-width: 36px; padding: 0; font-size: 0; }
  .ib-header-actions .ib-btn span { font-size: 20px; }
  /* Stay in-flow so the 36px New booking control is not painted through the 22px pill. */
  .ib-fnsearch.open .ib-fnsearch-field,
  .ib-fnsearch-field.on,
  .ib-fnsearch-field:focus-within {
    width: 148px;
    max-width: 148px;
  }
}
@container ib-app (max-width: 480px) {
  .ib-fnsearch-list.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .ib-fnsearch-pop.cols-2 .ib-fnsearch-k-cols { display: none; }
  .ib-fnsearch.open .ib-fnsearch-field,
  .ib-fnsearch-field.on,
  .ib-fnsearch-field:focus-within { width: 136px; max-width: 136px; }
}

/* Beat OS per-window color-theme input/surface !important. */
#os .window[data-app-color-theme] .window-body .ib-app input.ib-fnsearch-input:not([type="color"]):not([type="range"]):not([type="file"]):not([type="checkbox"]):not([type="radio"]),
body .window[data-app-color-theme] .window-body .ib-app input.ib-fnsearch-input:not([type="color"]):not([type="range"]):not([type="file"]):not([type="checkbox"]):not([type="radio"]) {
  background: transparent !important;
  color: inherit !important;
  border: 0 !important;
  border-color: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  min-height: 0 !important;
  height: 20px !important;
  line-height: 20px !important;
  outline: none !important;
}
#os .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-input::placeholder,
body .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-input::placeholder {
  color: var(--fn-pop-muted, #6c7686) !important;
  opacity: 1;
}
#os .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-pop,
#os .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-pop.is-empty,
body .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-pop,
body .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-pop.is-empty {
  background-color: var(--fn-pop-bg, #fff) !important;
  color: var(--fn-pop-ink, #1f2733) !important;
  border-color: var(--fn-pop-line, #d7dce6) !important;
}
#os .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-head,
#os .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-list,
#os .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-empty,
body .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-head,
body .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-list,
body .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-empty {
  background-color: transparent !important;
  color: inherit;
  border-color: transparent !important;
}
#os .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-empty strong,
body .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-empty strong {
  color: var(--fn-pop-ink, #1f2733) !important;
}
#os .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-item,
body .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-item {
  background: transparent !important;
  color: var(--fn-pop-ink) !important;
  border-color: transparent !important;
}
#os .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-item:hover,
body .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-item:hover {
  background: color-mix(in srgb, var(--fn-pop-accent) 8%, transparent) !important;
  border-color: color-mix(in srgb, var(--fn-pop-accent) 18%, transparent) !important;
  color: var(--fn-pop-ink) !important;
}
#os .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-item.is-active,
#os .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-item:hover.is-active,
body .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-item.is-active,
body .window[data-app-color-theme] .window-body .ib-app .ib-fnsearch-item:hover.is-active {
  background: var(--fn-pop-accent, #2f6bd4) !important;
  border-color: var(--fn-pop-accent, #2f6bd4) !important;
  color: #fff !important;
}
