/* ==========================================================================
   Theme: red + skin (warm beige) + black.
   Light: skin pages, white-ish cards, black sidebar, red accents.
   Dark : black pages, charcoal cards, red accents.
   ========================================================================== */
:root {
  --sidebar-w: 250px;
  --app-red: #c8102e;
  --app-red-dark: #9d0c24;
  --app-black: #141414;
  --app-skin: #f3e6d8;
  --app-skin-light: #fbf5ee;
  --app-skin-dark: #e6d2bd;
}

[data-bs-theme='light'] {
  --bs-body-bg: #fffaf5;
  --bs-body-bg-rgb: 255, 250, 245;
  --bs-body-color: #1c1917;
  --bs-secondary-bg: #ecdcc9;
  --bs-tertiary-bg: var(--app-skin);
  --bs-border-color: #e3d0bb;
  --bs-link-color: var(--app-red);
  --bs-link-color-rgb: 200, 16, 46;
  --bs-link-hover-color: var(--app-red-dark);
  --bs-link-hover-color-rgb: 157, 12, 36;
  --bs-focus-ring-color: rgba(var(--bs-primary-rgb), 0.25);
  --page-bg: var(--app-skin);
  --side-bg: var(--app-black);
}
[data-bs-theme='dark'] {
  --bs-body-bg: #181818;
  --bs-body-bg-rgb: 24, 24, 24;
  --bs-body-color: #f1ebe4;
  --bs-secondary-bg: #262626;
  --bs-tertiary-bg: #1f1f1f;
  --bs-border-color: #333;
  --bs-link-color: #ff6b7f;
  --bs-link-color-rgb: 255, 107, 127;
  --bs-link-hover-color: #ff93a1;
  --bs-link-hover-color-rgb: 255, 147, 161;
  --bs-focus-ring-color: rgba(255, 107, 127, 0.3);
  --page-bg: #0e0e0e;
  --side-bg: #000;
}

html,
body {
  font-family: 'Tajawal', system-ui, sans-serif;
}
body {
  background: var(--page-bg);
}

/* ---- Red primary everywhere Bootstrap hard-codes blue ---- */
.btn-primary {
  --bs-btn-bg: var(--app-red);
  --bs-btn-border-color: var(--app-red);
  --bs-btn-hover-bg: var(--app-red-dark);
  --bs-btn-hover-border-color: var(--app-red-dark);
  --bs-btn-active-bg: var(--app-red-dark);
  --bs-btn-active-border-color: var(--app-red-dark);
  --bs-btn-disabled-bg: var(--app-red);
  --bs-btn-disabled-border-color: var(--app-red);
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-color: #fff;
}
.btn-outline-primary {
  --bs-btn-color: var(--app-red);
  --bs-btn-border-color: var(--app-red);
  --bs-btn-hover-bg: var(--app-red);
  --bs-btn-hover-border-color: var(--app-red);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--app-red-dark);
  --bs-btn-active-border-color: var(--app-red-dark);
  --bs-btn-active-color: #fff;
  --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
[data-bs-theme='dark'] .btn-outline-primary {
  --bs-btn-color: #ff6b7f;
  --bs-btn-border-color: #ff6b7f;
}
.btn-outline-secondary {
  --bs-btn-color: #3a332c;
  --bs-btn-border-color: #a8957f;
  --bs-btn-hover-bg: var(--app-black);
  --bs-btn-hover-border-color: var(--app-black);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--app-black);
  --bs-btn-active-border-color: var(--app-black);
  --bs-btn-active-color: #fff;
}
[data-bs-theme='dark'] .btn-outline-secondary {
  --bs-btn-color: #d9cfc4;
  --bs-btn-border-color: #555;
  --bs-btn-hover-bg: #e9e2d9;
  --bs-btn-hover-color: #000;
}
.text-bg-primary,
.bg-primary {
  background-color: var(--app-red) !important;
  color: #fff !important;
}
.text-primary {
  color: var(--app-red) !important;
}
[data-bs-theme='dark'] .text-primary {
  color: #ff6b7f !important;
}
.border-primary {
  border-color: var(--app-red) !important;
}
.form-check-input:checked {
  background-color: var(--app-red);
  border-color: var(--app-red);
}
.form-control:focus,
.form-select:focus {
  border-color: var(--app-red);
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.18);
}
.btn-check:checked + .btn-outline-primary,
.btn-check:checked + .btn-outline-secondary {
  color: #fff;
}
.btn-check:checked + .btn-outline-secondary {
  background: var(--app-black);
  border-color: var(--app-black);
}
.page-item.active .page-link {
  background: var(--app-red);
  border-color: var(--app-red);
  color: #fff;
}
.page-link {
  color: var(--app-red);
}
.table-hover > tbody > tr:hover > * {
  --bs-table-hover-bg: rgba(var(--bs-primary-rgb), 0.05);
}

/* ---- Layout ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--side-bg);
  color: #e9e2d9;
  padding: 1rem;
  border-inline-end: 3px solid var(--app-red);
}
.app-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  text-decoration: none;
  margin-bottom: 1.5rem;
}
.app-sidebar .brand .bi {
  color: var(--app-red);
  font-size: 1.5rem;
}
/* An uploaded logo may be dark: it sits on a light plate so it shows on the black sidebar */
.app-sidebar .brand .brand-logo {
  max-height: 40px;
  max-width: 96px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 3px 5px;
}
.auth-logo {
  max-height: 64px;
  max-width: 220px;
  object-fit: contain;
}
.brand-preview {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(#e9e2d9 0 25%, #fff 0 50%) 50% / 16px 16px;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 0.5rem;
}
.brand-preview img {
  max-height: 64px;
  max-width: 100%;
  object-fit: contain;
}
.brand-preview .favicon-preview {
  width: 32px;
  height: 32px;
}
.app-sidebar .nav-link {
  color: #d8cfc5;
  border-radius: 0.5rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.app-sidebar .nav-link.active,
.app-sidebar .nav-link:hover {
  background: var(--app-red);
  color: #fff;
}
.app-sidebar .nav-section {
  font-size: 0.75rem;
  color: #9a8f84;
  margin: 1rem 0.5rem 0.25rem;
}
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.app-topbar {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
}
.app-content {
  padding: 1.25rem;
}
.card {
  border-color: var(--bs-border-color);
  box-shadow: 0 1px 2px rgba(20, 20, 20, 0.04);
}
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg);
  padding: 1rem;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  border-top: 4px solid var(--app-red);
}
.lang-switch .btn {
  font-size: 0.8rem;
  padding-block: 0.15rem;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 1040;
    transition: transform 0.2s;
  }
  html[dir='rtl'] .app-sidebar {
    transform: translateX(100%);
  }
  html[dir='ltr'] .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: none !important;
  }
}

.pre-wrap {
  white-space: pre-wrap;
}
.company-results {
  z-index: 1050;
  max-height: 280px;
  overflow-y: auto;
}
.side-card {
  top: 1rem;
}
.badge[class*='type-'] {
  color: #fff;
}
.status-planned {
  background: var(--bs-secondary-bg);
  color: var(--bs-body-color);
}
.status-confirmed {
  background: #1f1f1f;
  color: #fff;
}
.status-completed {
  background: #198754;
  color: #fff;
}
.status-cancelled {
  background: var(--app-red);
  color: #fff;
}

/* ---- Calendar: big, readable event cards that show everything, each clearly separate from the next ---- */
.fc {
  --fc-border-color: #cdb79f;
  --fc-page-bg-color: var(--bs-body-bg);
  --fc-neutral-bg-color: var(--bs-tertiary-bg);
  --fc-today-bg-color: rgba(var(--bs-primary-rgb), 0.1);
  --fc-button-bg-color: var(--app-black);
  --fc-button-border-color: var(--app-black);
  --fc-button-hover-bg-color: var(--app-red);
  --fc-button-hover-border-color: var(--app-red);
  --fc-button-active-bg-color: var(--app-red-dark);
  --fc-button-active-border-color: var(--app-red-dark);
}
[data-bs-theme='dark'] .fc {
  --fc-border-color: #4a4a4a;
  --fc-today-bg-color: rgba(255, 107, 127, 0.14);
  --fc-button-bg-color: #2b2b2b;
  --fc-button-border-color: #5a5a5a;
}
[data-bs-theme='dark'] .fc .weekend-day {
  background: repeating-linear-gradient(135deg, #1b1b1b, #1b1b1b 8px, #272727 8px, #272727 16px);
}
.fc .fc-toolbar-title {
  font-size: 1.35rem;
  font-weight: 700;
}
/* Day-name row: a solid black band with a red underline */
.fc .fc-col-header-cell {
  background: var(--app-black);
  border-color: #3a3a3a;
}
.fc .fc-col-header {
  border-bottom: 3px solid var(--app-red);
}
.fc .fc-col-header-cell-cushion {
  color: #fff !important;
  padding: 0.5rem 0.25rem;
  font-weight: 700;
}
.fc .weekend-day {
  background: var(--bs-tertiary-bg);
}
[data-bs-theme='light'] .fc .weekend-day {
  background: repeating-linear-gradient(
    135deg,
    var(--app-skin),
    var(--app-skin) 8px,
    #efdfcd 8px,
    #efdfcd 16px
  );
}
.fc .fc-daygrid-day-frame {
  min-height: 140px;
}
.fc .fc-daygrid-day-top {
  border-bottom: 1px solid var(--fc-border-color);
  margin-bottom: 4px;
  background: rgba(0, 0, 0, 0.035);
}
.fc .fc-daygrid-day-number {
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.2rem 0.5rem;
}
.fc .fc-day-today .fc-daygrid-day-number {
  background: var(--app-red);
  color: #fff !important;
  border-radius: 0 0 0.5rem 0;
  padding-inline: 0.6rem;
}
.fc .fc-daygrid-day-events {
  padding-bottom: 6px;
}
/* Each audit is its own card: a white ring + shadow cuts it off from the neighbours */
.fc .fc-daygrid-event {
  white-space: normal;
  border-radius: 8px;
  margin: 0 4px 6px;
  padding: 0;
  box-shadow:
    0 0 0 2px var(--fc-page-bg-color),
    0 2px 5px rgba(0, 0, 0, 0.4);
}
.fc .fc-event {
  cursor: pointer;
  border-width: 0;
  border-inline-start: 6px solid rgba(0, 0, 0, 0.4);
}
.fc .fc-event:hover {
  box-shadow:
    0 0 0 2px var(--fc-page-bg-color),
    0 0 0 4px var(--app-red),
    0 3px 8px rgba(0, 0, 0, 0.45);
}
.fc .fc-event-main {
  padding: 0;
  color: #fff;
}
.fc .holiday-event {
  background: #fbe3e4;
  color: #842029;
  border-color: #f1aeb5;
}
.fc .holiday-event .fc-event-main {
  color: #842029;
  padding: 3px 8px;
}
[data-bs-theme='dark'] .fc .holiday-event {
  background: #3a1d20;
  border-color: #842029;
}
[data-bs-theme='dark'] .fc .holiday-event .fc-event-main {
  color: #ea868f;
}
.fc .audit-cancelled {
  opacity: 0.55;
  text-decoration: line-through;
}
.fc-ev {
  line-height: 1.35;
  font-size: 0.85rem;
}
.fc-ev-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: normal;
}
/* Audit cards: the audit type is a white pill with an icon, in the type colour */
.fc-ev-audit .fc-ev-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.fc-ev-type {
  background: #fff;
  border-radius: 999px;
  padding: 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.fc-ev-dates {
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}
/* Audit cards: company name on a darker band, details underneath */
.fc-ev-audit .fc-ev-title {
  background: rgba(0, 0, 0, 0.28);
  padding: 4px 8px;
  border-start-start-radius: 2px;
  border-start-end-radius: 6px;
}
.fc-ev-body {
  padding: 4px 8px 6px;
}
/* every field is its own row: a small label, then the value (the label sits beside it in a wide card) */
.fc-ev-row {
  white-space: normal;
  padding: 4px 0;
}
.fc-ev-row + .fc-ev-row {
  border-top: 1px dashed rgba(255, 255, 255, 0.28);
}
.fc-ev-label {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
  opacity: 0.88;
}
.fc-ev-label .bi {
  opacity: 0.9;
}
.fc-ev-val {
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
}
.fc-daygrid-event .fc-ev {
  container-type: inline-size;
  width: 100%;
}
@container (min-width: 330px) {
  .fc-ev-row {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
  }
  .fc-ev-label {
    flex: 0 0 6.5rem;
  }
  .fc-ev-val {
    flex: 1 1 auto;
  }
}
.fc-ev-tag {
  display: inline-block;
  background: rgba(255, 255, 255, 0.24);
  border-radius: 4px;
  padding: 0 0.35rem;
  margin-inline-end: 0.2rem;
  font-size: 0.75rem;
}
.fc-ev-foot {
  opacity: 0.95;
  font-size: 0.75rem;
  margin-top: 3px;
  padding-top: 3px;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
}
/* List view: events have no coloured background there, so the card parts use neutral tints */
.fc-list-event .fc-ev-audit .fc-ev-title {
  background: none;
  padding-inline: 0;
}
.fc-list-event .fc-ev-body {
  padding-inline: 0;
}
.fc-list-event .fc-ev-row + .fc-ev-row {
  border-top-color: var(--bs-border-color);
}
.fc-list-event .fc-ev-tag {
  background: var(--bs-secondary-bg);
}
.fc-list-event .fc-ev-foot {
  border-top-color: var(--bs-border-color);
}
/* Phones: the month / week grid keeps a readable width and scrolls sideways (the list view fits as is) */
@media (max-width: 767.98px) {
  #calendar-page .card-body {
    overflow-x: auto;
  }
  #calendar.cal-wide {
    min-width: 760px;
  }
}
/* Legend: a clear key for the colours */
#legend > span {
  display: inline-flex;
  align-items: center;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  padding: 0.15rem 0.7rem 0.15rem 0.5rem;
  font-weight: 500;
}
.legend-dot {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border-radius: 4px;
  margin-inline-end: 0.4rem;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.legend-dot.holiday-event {
  background: #f1aeb5;
}
.swal2-html-container {
  white-space: pre-line;
}
.swal2-confirm {
  background-color: var(--app-red) !important;
}

/* ---- Print: logo + name on top, company footer (phone, email, address...) at the bottom of every page ---- */
/* on screen the print header / footer never show; the print rules below turn them on */
@media screen {
  .print-only {
    display: none !important;
  }
  /* the print-sheet table only exists for printing: on screen it behaves like plain blocks */
  .print-sheet,
  .print-sheet > tbody,
  .print-sheet > tbody > tr,
  .print-sheet > tbody > tr > td {
    display: block;
    padding: 0;
    border: 0;
  }
}
.print-footer {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  border-top: 2px solid var(--app-red);
  padding-top: 0.4rem;
  font-size: 0.8rem;
  line-height: 1.55;
}
.print-footer-col {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-width: 0;
}
.print-footer-contact {
  align-items: center;
  text-align: center;
}
.print-footer-extra {
  align-items: flex-end;
}
.print-footer .bi {
  color: var(--app-red);
}
.print-footer-preview {
  background: #fff;
  color: #1c1917;
  border: 1px dashed var(--bs-border-color);
  border-top: 2px solid var(--app-red);
  padding: 0.6rem 0.8rem;
  border-radius: 0.25rem;
}
/* Landscape suits the calendar, the audit lists and the auditor board. The page margin is 0 on purpose:
   Chrome clips whatever is pushed into a page margin, so the margins are made by two spacer boxes that
   behave like a table header / footer and therefore repeat on EVERY printed page; the footer itself
   is `position: fixed` (also repeated) and sits inside the bottom spacer. */
@page {
  size: A4 landscape;
  margin: 0;
}
@media print {
  .app-sidebar,
  .app-topbar,
  .no-print,
  .btn,
  .pagination,
  form[method='get'],
  .modal {
    display: none !important; /* buttons, filters and paging are for the screen only */
  }
  /* a scroll box would cut a long table at the page end (rows would be lost): let it flow */
  .table-responsive {
    overflow: visible !important;
  }
  html,
  body {
    margin: 0;
    background: #fff;
    color: #000;
  }
  .app-shell {
    display: block;
  }
  .app-main {
    display: block;
    padding-inline: 10mm;
  }
  .app-content {
    padding: 0;
  }
  .print-sheet {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
  }
  .print-sheet > tbody > tr > td,
  .print-sheet > thead > tr > td,
  .print-sheet > tfoot > tr > td {
    padding: 0;
    border: 0;
    vertical-align: top;
  }
  .print-space-top > tr > td > div {
    height: 10mm;
  }
  .print-space-bottom > tr > td > div {
    height: 27mm;
  }
  .print-footer.print-only {
    display: flex;
    position: fixed;
    inset-inline: 10mm;
    bottom: 8mm;
    background: #fff;
    color: #000;
  }
  .print-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    border-bottom: 3px solid var(--app-red);
    padding-bottom: 0.5rem;
    margin-bottom: 0.8rem;
  }
  .print-logo {
    max-height: 48px;
    max-width: 170px;
    object-fit: contain;
  }
  .print-title {
    font-size: 1.3rem;
    font-weight: 700;
  }
  .card {
    box-shadow: none;
  }
  #calendar-page .card {
    border: 0;
  }
  #calendar-page .card-body {
    padding: 0 !important;
    overflow: visible;
  }
  #calendar.cal-wide {
    min-width: 0;
  }
  .fc .fc-daygrid-event-harness,
  .fc .fc-daygrid-event,
  .fc-daygrid-body tr,
  .table tr {
    break-inside: avoid;
  }
  .fc .fc-daygrid-day-frame {
    min-height: 0;
  }
  /* the grid must shrink to the paper width, whatever width it had on screen */
  .fc,
  .fc .fc-view-harness,
  .fc .fc-scrollgrid,
  .fc .fc-col-header,
  .fc .fc-daygrid-body,
  .fc .fc-scrollgrid-sync-table {
    width: 100% !important;
    max-width: 100%;
  }
  .fc .fc-toolbar .fc-button,
  .fc .fc-toolbar .fc-button-group {
    display: none;
  }
  .fc-event,
  .fc-ev-title,
  .fc .fc-col-header-cell,
  .fc .weekend-day,
  .fc .fc-daygrid-day-top,
  #legend .legend-dot,
  .print-footer .bi,
  .print-header {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ---- Dashboard ---- */
.chart-box {
  position: relative;
  height: 260px;
}
.chart-box.tall {
  height: 340px;
}
.kpi .fs-2 {
  color: var(--app-red);
}
[data-bs-theme='dark'] .kpi .fs-2 {
  color: #ff6b7f;
}

/* ---- Notification bell ---- */
.bell-menu {
  width: 340px;
  max-width: 92vw;
}
#bell-list {
  max-height: 340px;
  overflow-y: auto;
}
.bell-item.unread {
  background: var(--bs-tertiary-bg);
  font-weight: 600;
}

/* ---- Import ---- */
.import-rows td,
.import-rows th {
  font-size: 0.85rem;
}
.import-ok {
  background: rgba(25, 135, 84, 0.08);
}
.import-dup {
  background: rgba(255, 193, 7, 0.14);
}
.import-err {
  background: rgba(var(--bs-primary-rgb), 0.1);
}

/* FullCalendar renders day names / numbers as links: keep them plain and readable */
.fc a,
.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number {
  color: var(--bs-body-color);
  text-decoration: none;
}
.fc .fc-day-other .fc-daygrid-day-number {
  opacity: 0.45;
}
.fc a.fc-event {
  color: #fff;
}

/* Black audit types (Surv1) must stay visible on the black dark theme */
[data-bs-theme='dark'] .fc .fc-event,
[data-bs-theme='dark'] .legend-dot {
  outline: 1px solid rgba(255, 255, 255, 0.28);
}

/* Auditors already booked on the chosen dates */
.btn.auditor-busy {
  border-style: dashed;
  border-color: var(--app-red);
  color: var(--app-red);
  text-decoration: line-through;
}
.btn-check:disabled + .btn.auditor-busy {
  opacity: 0.6;
}

/* Notes inside calendar cards (first lines; the full text is in the tooltip and the details window) */
.fc-ev-notes {
  font-size: 0.85rem;
  opacity: 0.98;
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* The "you have an audit soon" pop-up */
.audit-alert-popup {
  border-top: 6px solid var(--app-red);
}
.audit-alert-item {
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
  border-inline-start: 5px solid var(--app-red);
  border-radius: 0.5rem;
  padding: 0.5rem 0.8rem;
  margin-top: 0.5rem;
  color: var(--bs-body-color);
  text-align: start;
}
.audit-alert-item:hover {
  background: var(--bs-secondary-bg);
}

/* Dashboard */
#widget-menu {
  min-width: 270px;
  max-height: 70vh;
  overflow-y: auto;
}
.kpi .fs-2 {
  line-height: 1.1;
}

/* Admin hub tiles */
.admin-tile {
  color: var(--bs-body-color);
  border-top: 3px solid transparent;
  transition:
    border-color 0.15s,
    transform 0.15s;
}
.admin-tile:hover {
  border-top-color: var(--app-red);
  transform: translateY(-2px);
}

/* ---- Side menu: collapse to icons, drag to resize, dock on either side (public/js/sidebar.js) ---- */
:root {
  --sidebar-collapsed-w: 68px;
}
.app-sidebar {
  transition: width 0.18s ease;
}
.sidebar-options {
  min-width: 270px;
}
.ring-list {
  max-height: 180px;
  overflow-y: auto;
}
.ring-body {
  white-space: pre-line;
  text-align: start;
}
@media (min-width: 992px) {
  .app-sidebar {
    position: relative;
  }
  .sidebar-resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-end: -6px;
    width: 12px;
    cursor: col-resize;
    z-index: 5;
  }
  .sidebar-resizer:hover,
  .sidebar-dragging .sidebar-resizer {
    background: linear-gradient(
      to right,
      transparent 4px,
      rgba(var(--bs-primary-rgb), 0.55) 4px,
      rgba(var(--bs-primary-rgb), 0.55) 8px,
      transparent 8px
    );
  }
  .sidebar-dragging,
  .sidebar-dragging * {
    cursor: col-resize !important;
    user-select: none;
  }
  .sidebar-dragging .app-sidebar {
    transition: none;
  }
  html[data-sidebar='collapsed'] .app-sidebar {
    width: var(--sidebar-collapsed-w);
    padding-inline: 0.5rem;
  }
  html[data-sidebar='collapsed'] .app-sidebar .brand {
    justify-content: center;
  }
  html[data-sidebar='collapsed'] .app-sidebar .brand span,
  html[data-sidebar='collapsed'] .app-sidebar .nav-section {
    display: none;
  }
  html[data-sidebar='collapsed'] .app-sidebar .brand-logo {
    max-width: 44px;
  }
  html[data-sidebar='collapsed'] .app-sidebar .nav-link {
    font-size: 0;
    justify-content: center;
    gap: 0;
    padding-inline: 0;
  }
  html[data-sidebar='collapsed'] .app-sidebar .nav-link .bi {
    font-size: 1.25rem;
  }
  /* docked on the other side from the language's default */
  html[dir='rtl'][data-dock='left'] .app-shell,
  html[dir='ltr'][data-dock='right'] .app-shell {
    flex-direction: row-reverse;
  }
  html[dir='rtl'][data-dock='left'] .app-sidebar,
  html[dir='ltr'][data-dock='right'] .app-sidebar {
    border-inline-end: 0;
    border-inline-start: 3px solid var(--app-red);
  }
  html[dir='rtl'][data-dock='left'] .sidebar-resizer,
  html[dir='ltr'][data-dock='right'] .sidebar-resizer {
    inset-inline-end: auto;
    inset-inline-start: -6px;
  }
  /* forced sides the same as the default: nothing to change */
}
@media print {
  .sidebar-resizer {
    display: none !important;
  }
}

/* Sign-in page: with the picture on one side (Settings -> login layout "split") the card moves to the other */
@media (min-width: 992px) {
  .auth-split {
    justify-content: flex-end;
    padding-inline-end: 8vw;
  }
}
.auth-card {
  position: relative;
  z-index: 1;
}

/* Global search box in the top bar */
.gs-form {
  max-width: 380px;
}
.gs-results {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 4px);
  z-index: 1055;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  max-height: 70vh;
  overflow-y: auto;
}
.gs-item {
  color: var(--bs-body-color);
}
.gs-item:hover,
.gs-all:hover {
  background: var(--bs-tertiary-bg);
}

/* Calendar quick filters: a chip is a type or an auditor; off = faded and struck through */
.legend-chip {
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
}
.legend-chip:not(.on) {
  opacity: 0.45;
  text-decoration: line-through;
}
.legend-chip.on {
  font-weight: 600;
  border-color: var(--bs-secondary-color);
}
.fc-ev-type[data-solo],
.fc-ev-person[data-solo] {
  cursor: pointer;
}
.fc-ev-person[data-solo]:hover,
.fc-ev-type[data-solo]:hover {
  text-decoration: underline;
}

/* calendar: quick-add window and the card lines */
.qa-results {
  z-index: 1090;
  max-height: 220px;
  overflow-y: auto;
}
.fc-ev-member {
  line-height: 1.5;
}
.fc-ev-custom {
  font-size: 0.9rem;
}
.push-banner {
  border-width: 0 0 1px;
}

/* calendar: the "+" of a day, and the pointer over a day that can take a new audit */
.fc-daygrid-day-frame .cal-add {
  position: absolute;
  top: 3px;
  inset-inline-start: 4px;
  z-index: 3;
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bs-border-color);
  border-radius: 50%;
  background: var(--bs-body-bg);
  color: var(--app-red);
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0.45;
  cursor: pointer;
}
.fc-daygrid-day:hover .cal-add,
.cal-add:focus-visible {
  opacity: 1;
  background: var(--app-red);
  color: #fff;
  border-color: var(--app-red);
}
@media (hover: none) {
  .fc-daygrid-day-frame .cal-add {
    opacity: 1;
  }
}
@media print {
  .cal-add {
    display: none !important;
  }
}

/* ---- Auditors schedule: a board with a sticky name column, coloured bars for audits, hatched days off ---- */
.sch-stat {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.6rem;
  padding: 0.6rem 0.9rem;
}
.sch-stat-n {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
}
.sch-scroll {
  overflow-x: auto;
  max-height: 75vh;
}
.sch-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-size: 0.85rem;
}
.sch-table th,
.sch-table td {
  border-bottom: 1px solid var(--bs-border-color-translucent);
  border-inline-start: 1px solid var(--bs-border-color-translucent);
  padding: 0;
  text-align: center;
}
.sch-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bs-tertiary-bg);
  padding: 0.3rem 0;
  font-weight: 500;
}
.sch-table .sch-name {
  position: sticky;
  inset-inline-start: 0;
  z-index: 4;
  min-width: 190px;
  max-width: 230px;
  padding: 0.45rem 0.7rem;
  text-align: start;
  background: var(--bs-body-bg);
  border-inline-end: 2px solid var(--bs-border-color);
}
.sch-table thead .sch-name,
.sch-table tfoot .sch-name {
  background: var(--bs-tertiary-bg);
}
.sch-table th.sch-day,
.sch-table td.sch-free,
.sch-table td.sch-clash {
  min-width: 38px;
  width: 38px;
}
.sch-abbr {
  display: block;
  font-size: 0.65rem;
  opacity: 0.75;
}
.sch-num {
  display: inline-block;
  min-width: 1.6rem;
  border-radius: 1rem;
  font-weight: 700;
}
th.sch-today .sch-num {
  background: var(--app-red);
  color: #fff;
}
.sch-table tbody tr:hover td.sch-free,
.sch-table tbody tr:hover .sch-name {
  background-color: var(--bs-tertiary-bg);
}
.sch-table .sch-weekend {
  background-image: repeating-linear-gradient(
    135deg,
    transparent 0 5px,
    rgba(0, 0, 0, 0.05) 5px 10px
  );
  background-color: var(--bs-tertiary-bg);
}
.sch-table .sch-holiday {
  background-color: #fbe3e4;
}
[data-bs-theme='dark'] .sch-table .sch-holiday {
  background-color: #3a1d20;
}
.sch-table td.sch-today-col {
  box-shadow:
    inset 2px 0 0 var(--app-red),
    inset -2px 0 0 var(--app-red);
}
.sch-avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  background: #6c757d;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.sch-who {
  min-width: 0;
}
.sch-who-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sch-load {
  height: 4px;
  border-radius: 2px;
  background: var(--bs-border-color);
  margin-top: 3px;
  overflow: hidden;
}
.sch-load-bar {
  display: block;
  height: 100%;
  background: var(--bs-success);
}
td.sch-book {
  padding: 3px 2px;
  max-width: 0;
}
.sch-bar {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  height: 30px;
  padding: 0 0.5rem;
  border-radius: 0.45rem;
  color: #fff;
  text-decoration: none;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.8rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.sch-bar:hover {
  filter: brightness(1.1);
  color: #fff;
}
.sch-bar .bi-star-fill {
  color: #ffd54a;
  flex: 0 0 auto;
}
/* a short bar has no room for the star: the leader's bar gets a gold edge instead */
.sch-bar-lead {
  box-shadow:
    inset 0 0 0 2px #ffd54a,
    0 1px 2px rgba(0, 0, 0, 0.25);
}
.sch-short {
  padding: 0 0.3rem;
  font-size: 0.7rem;
}
.sch-short .bi-star-fill,
.sch-short .sch-bar-role {
  display: none;
}
.sch-bar-text {
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.sch-bar-role {
  opacity: 0.85;
  flex: 0 0 auto;
}
.sch-done {
  opacity: 0.6;
}
td.sch-clash {
  background: repeating-linear-gradient(45deg, #c8102e, #c8102e 6px, #7a0a1d 6px, #7a0a1d 12px);
  color: #fff;
}
.sch-sum th,
.sch-sum td {
  background: var(--bs-tertiary-bg);
  padding: 0.3rem 0;
  font-size: 0.78rem;
}
.sch-sum-booked td {
  color: var(--bs-primary);
  font-weight: 700;
}
.sch-sum-free td {
  color: var(--bs-success);
  font-weight: 700;
}
.sch-table tfoot th,
.sch-table tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 3;
}
.sch-table tfoot tr:first-child th,
.sch-table tfoot tr:first-child td {
  bottom: 1.9rem;
}
.sch-table tfoot .sch-name {
  z-index: 5;
}
.sch-weekend-dot {
  background: var(--app-skin-dark);
}
.sch-holiday-dot {
  background: #f1aeb5;
}
@media print {
  .sch-scroll {
    max-height: none;
    overflow: visible;
  }
  .sch-table {
    font-size: 0.65rem;
  }
  .sch-table .sch-name {
    position: static;
    min-width: 120px;
  }
  .sch-table th.sch-day,
  .sch-table td.sch-free {
    min-width: 0;
    width: auto;
  }
  .sch-table thead th,
  .sch-table tfoot th,
  .sch-table tfoot td {
    position: static;
  }
  .sch-bar {
    height: 20px;
    font-size: 0.6rem;
  }
}

/* auditor leave: a grey hatched bar on the schedule, a grey event on the calendar */
.sch-leave {
  background: repeating-linear-gradient(135deg, #6c757d 0 8px, #868e96 8px 16px);
  cursor: default;
}
.sch-leave-dot {
  background: #6c757d;
}
.fc .leave-event {
  background: repeating-linear-gradient(135deg, #6c757d 0 8px, #868e96 8px 16px);
  border-color: #6c757d;
  color: #fff;
}
.fc .leave-event .fc-event-main {
  color: #fff;
  padding: 2px 6px;
}

/* people's photos: a round picture, or the first letter on a coloured disc */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bs-tertiary-bg);
}
.avatar-sm {
  width: 30px;
  height: 30px;
  font-size: 0.85rem;
}
.avatar-lg {
  width: 84px;
  height: 84px;
  font-size: 2rem;
  box-shadow:
    0 0 0 3px var(--bs-body-bg),
    0 0 0 5px rgba(var(--bs-primary-rgb), 0.35);
}
.avatar-letter {
  background: var(--app-red);
  color: #fff;
  font-weight: 700;
}
.topbar-me:hover .avatar {
  box-shadow: 0 0 0 2px var(--app-red);
}
/* Phones: the top bar keeps every button on one line by showing icons only */
@media (max-width: 575.98px) {
  .app-topbar {
    padding: 0.5rem 0.6rem;
  }
  .app-topbar > .me-auto {
    gap: 0.3rem !important;
  }
  .app-topbar .topbar-label,
  .app-topbar .lang-text {
    display: none;
  }
}
.min-w-0 {
  min-width: 0;
}
/* Admin > sign-in page: ready-made designs */
.preset-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #2a0a0f;
}
/* Admin > sign-in page: small preview of each picture */
.login-pic-thumb {
  flex: 0 0 auto;
  width: 132px;
  height: 88px;
  object-fit: cover;
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color);
}
@media (max-width: 575.98px) {
  .login-pic > .d-flex {
    flex-direction: column;
  }
  .login-pic-thumb {
    width: 100%;
    height: 140px;
  }
}

/* status as a small menu (audits list) and the calendar's right-click menu */
.status-menu-btn {
  cursor: pointer;
}
.status-menu-btn::after {
  margin-inline-start: 0.35em;
  vertical-align: 0.1em;
}
.status-dot {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
}
.cal-ctx {
  position: fixed;
  z-index: 1080;
  min-width: 230px;
  max-width: 320px;
}
.cal-ctx .dropdown-header {
  max-width: 300px;
}
.status-ico-planned {
  color: #6c757d;
}
.status-ico-confirmed {
  color: var(--bs-body-color);
}
.status-ico-completed {
  color: #198754;
}
.status-ico-cancelled {
  color: #dc3545;
}

/* calendar cards never spill out of their box: long names wrap, every line stays inside */
.fc .fc-daygrid-event,
.fc .fc-event-main,
.fc-ev {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.fc-ev {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.fc-ev-title {
  min-width: 0;
}
.fc-ev-name {
  min-width: 0;
  overflow-wrap: anywhere;
}
.fc-ev-tag {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.fc-ev-type {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fc-ev-member,
.fc-ev-custom,
.fc-ev-foot {
  overflow-wrap: anywhere;
}
.fc .fc-daygrid-day-frame {
  min-width: 0;
}

/* the search box: a magnifier inside it */
.gs-form .gs-icon {
  position: absolute;
  inset-inline-start: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  pointer-events: none;
  font-size: 0.85rem;
}
.gs-form #global-search {
  padding-inline-start: 2rem;
}

/* companies: a ring showing how much of the year since the last audit has passed (red = overdue, amber = soon) */
.cycle-ring {
  --p: 0;
  --ring: #198754;
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), var(--bs-border-color) 0);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cycle-ring > span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bs-body-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}
.cycle-ring-soon {
  --ring: #f0ad00;
}
.cycle-ring-overdue {
  --ring: var(--app-red);
}
.companies-table tr.cycle-soon > td:first-child {
  box-shadow: inset 4px 0 0 #f0ad00;
}
.companies-table tr.cycle-overdue > td:first-child {
  box-shadow: inset 4px 0 0 var(--app-red);
}
html[dir='rtl'] .companies-table tr.cycle-soon > td:first-child {
  box-shadow: inset -4px 0 0 #f0ad00;
}
html[dir='rtl'] .companies-table tr.cycle-overdue > td:first-child {
  box-shadow: inset -4px 0 0 var(--app-red);
}

/* Approvals page */
.approval-subject {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.approval-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 260px;
  max-width: 100%;
  margin: 0;
}
@media (max-width: 575.98px) {
  .approval-actions {
    width: 100%;
  }
}
.nav-link .badge {
  font-size: 0.7rem;
}

/* Approval settings: the lists of people to pick from */
.route-pick {
  max-height: 260px;
  overflow: auto;
}

/* Company Timeline (company page): a vertical line, a round icon per event, one card per event */
.ct-filters .btn.active {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  color: #fff;
}
.ct-list.list-unstyled {
  position: relative;
  padding-inline-start: 2.5rem;
}
.ct-list::before {
  content: '';
  position: absolute;
  inset-block: 0.4rem;
  inset-inline-start: 0.95rem;
  width: 2px;
  background: var(--bs-border-color);
}
.ct-item {
  position: relative;
  margin-bottom: 0.75rem;
  --ct-tone: var(--bs-secondary);
}
.ct-tone-success {
  --ct-tone: var(--bs-success);
}
.ct-tone-primary {
  --ct-tone: var(--bs-primary);
}
.ct-tone-warning {
  --ct-tone: var(--bs-warning);
}
.ct-tone-danger {
  --ct-tone: var(--bs-danger);
}
.ct-tone-info {
  --ct-tone: var(--bs-info);
}
.ct-dot {
  position: absolute;
  inset-inline-start: -2.5rem;
  top: 0.2rem;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bs-body-bg);
  border: 2px solid var(--ct-tone);
  color: var(--ct-tone);
  font-size: 0.85rem;
}
.ct-card {
  min-width: 0;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-inline-start: 3px solid var(--ct-tone);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
}
.ct-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.15rem 0.75rem;
}
.ct-title {
  font-weight: 700;
}
.ct-detail,
.ct-note-text {
  margin-top: 0.15rem;
  overflow-wrap: anywhere;
}
.ct-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  margin-top: 0.35rem;
}
.ct-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-inline-start: auto;
}
.ct-more-li,
.ct-empty {
  list-style: none;
  margin-block: 0.5rem;
}

/* ---- Round 9: the top bar follows the page; a calm calendar (light cards, clear status), soft motion ---- */

/* The top bar stays at the top while the page scrolls. --topbar-h (set by js/app.js) is its height, so the calendar's
   day names can stay right under it. */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: color-mix(in srgb, var(--bs-body-bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  backdrop-filter: saturate(1.4) blur(8px);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}
.fc .fc-scrollgrid-section-sticky > * {
  top: var(--topbar-h, 56px) !important;
}

/* ---- Calendar frame: softer lines, a light day-name row, today as a filled circle ---- */
.fc {
  --fc-border-color: var(--bs-border-color);
  box-shadow: none;
}
.fc .fc-col-header-cell {
  background: var(--bs-tertiary-bg);
  border-color: var(--bs-border-color);
}
.fc .fc-col-header {
  border-bottom: 2px solid var(--app-red);
}
.fc .fc-col-header-cell-cushion {
  color: var(--bs-body-color) !important;
  font-weight: 700;
}
.fc .weekend-day,
[data-bs-theme='light'] .fc .weekend-day,
[data-bs-theme='dark'] .fc .weekend-day {
  background: color-mix(in srgb, var(--bs-body-color) 4%, var(--bs-body-bg));
}
.fc .fc-daygrid-day-top {
  background: transparent;
  border-bottom: 0;
  margin-bottom: 2px;
}
.fc .fc-daygrid-day-number {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bs-secondary-color);
}
.fc .fc-day-today {
  background: color-mix(in srgb, var(--app-red) 5%, var(--bs-body-bg)) !important;
}
.fc .fc-day-today .fc-daygrid-day-number {
  background: var(--app-red);
  color: #fff !important;
  border-radius: 999px;
  min-width: 1.9rem;
  height: 1.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 4px;
  animation: cal-today 2.2s ease-out 3;
}
.fc .fc-daygrid-day:hover {
  background: color-mix(in srgb, var(--bs-primary) 4%, transparent);
}

/* ---- The audit card: a light surface, a colour stripe, a tinted company band, a clear status pill ---- */
.fc .fc-daygrid-event.fc-card {
  --ev: #0b5ea8;
  background: var(--bs-body-bg) !important;
  color: var(--bs-body-color);
  border: 1px solid var(--bs-border-color) !important;
  border-inline-start: 5px solid var(--ev) !important;
  border-radius: 10px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 4px 12px rgba(15, 23, 42, 0.07);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
  animation: cal-ev-in 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}
.fc .fc-daygrid-event.fc-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--ev) 45%, transparent),
    0 10px 22px rgba(15, 23, 42, 0.18);
}
.fc .fc-daygrid-event.fc-card .fc-event-main,
.fc a.fc-daygrid-event.fc-card {
  color: var(--bs-body-color);
}
.fc-card .fc-ev-audit .fc-ev-title {
  background: color-mix(in srgb, var(--ev, #0b5ea8) 14%, var(--bs-body-bg));
  color: var(--bs-emphasis-color);
  border-bottom: 1px solid color-mix(in srgb, var(--ev, #0b5ea8) 28%, transparent);
  border-radius: 0;
}
.fc-card .fc-ev-audit .fc-ev-name {
  color: var(--bs-emphasis-color);
  text-shadow: none;
}
.fc-card .fc-ev-audit .fc-ev-name .bi {
  color: var(--ev, #0b5ea8);
}
.fc-card .fc-ev-row + .fc-ev-row {
  border-top: 1px dashed var(--bs-border-color);
}
.fc-card .fc-ev-label {
  color: var(--bs-secondary-color);
  opacity: 1;
}
.fc-card .fc-ev-val {
  color: var(--bs-body-color);
}
.fc-card .fc-ev-tag {
  background: var(--bs-secondary-bg);
  color: var(--bs-body-color);
}
.fc-card .fc-ev-type {
  background: color-mix(in srgb, var(--ev, #0b5ea8) 10%, var(--bs-body-bg));
  color: var(--bs-body-color);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ev, #0b5ea8) 38%, transparent);
}

.fc-ev-audit .fc-ev-name {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.3;
}
.fc-ev-audit .fc-ev-name .bi {
  font-size: 0.95em;
  opacity: 0.9;
}
.fc-list-event .fc-ev-audit .fc-ev-name {
  text-shadow: none;
}

/* the status pill (it sits in the company band of every card) */
.fc-ev-status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0 0.6rem;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.75;
  white-space: nowrap;
  border: 1px solid transparent;
  box-shadow: none;
}
.fc-ev-status.fc-st-planned {
  background: #fff3cd;
  color: #7a5400;
  border-color: #ffe08a;
}
.fc-ev-status.fc-st-confirmed {
  background: #d1e7dd;
  color: #0f5132;
  border-color: #a3cfbb;
}
.fc-ev-status.fc-st-completed {
  background: #e9ecef;
  color: #495057;
  border-color: #ced4da;
}
.fc-ev-status.fc-st-cancelled {
  background: #f8d7da;
  color: #842029;
  border-color: #f1aeb5;
}
[data-bs-theme='dark'] .fc-ev-status.fc-st-planned {
  background: rgba(255, 193, 7, 0.16);
  color: #ffda6a;
  border-color: rgba(255, 193, 7, 0.4);
}
[data-bs-theme='dark'] .fc-ev-status.fc-st-confirmed {
  background: rgba(25, 135, 84, 0.22);
  color: #75b798;
  border-color: rgba(25, 135, 84, 0.5);
}
[data-bs-theme='dark'] .fc-ev-status.fc-st-completed {
  background: rgba(173, 181, 189, 0.14);
  color: #ced4da;
  border-color: rgba(173, 181, 189, 0.35);
}
[data-bs-theme='dark'] .fc-ev-status.fc-st-cancelled {
  background: rgba(220, 53, 69, 0.2);
  color: #ea868f;
  border-color: rgba(220, 53, 69, 0.45);
}
[data-bs-theme='dark'] .fc-card .fc-ev-type .bi {
  filter: brightness(1.9);
}

/* what the status does to the card: planned = not fixed yet (dashed), confirmed = fixed (solid, green ring),
   completed = done (calm, grey band), cancelled = crossed out */
.fc .fc-daygrid-event.fc-card-planned {
  border-style: dashed !important;
  border-inline-start-style: solid !important;
}
.fc .fc-daygrid-event.fc-card-confirmed {
  box-shadow:
    0 0 0 1px rgba(25, 135, 84, 0.45),
    0 4px 12px rgba(25, 135, 84, 0.14);
}
.fc .fc-daygrid-event.fc-card-completed {
  opacity: 0.88;
  filter: saturate(0.6);
}
.fc .fc-daygrid-event.fc-card-completed .fc-ev-title {
  background: var(--bs-tertiary-bg);
}
.fc .fc-daygrid-event.fc-card-cancelled {
  opacity: 0.55;
}

/* the status buttons inside the audit window */
.em-st {
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  font-weight: 700;
}
.em-st-confirmed {
  color: #146c43;
  border-color: #a3cfbb;
}
.em-st-planned {
  color: #7a5400;
  border-color: #ffe08a;
}
.em-st-completed {
  color: #495057;
}
.em-st-cancelled {
  color: #b02a37;
  border-color: #f1aeb5;
}
.em-st:hover {
  background: var(--bs-secondary-bg);
}

/* ---- Window of proposed next audits (calendar) and the same blocks in the audits list ---- */
.due-note {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: color-mix(in srgb, #ffc107 14%, var(--bs-body-bg));
  border: 1px solid color-mix(in srgb, #ffc107 45%, transparent);
  border-radius: 0.6rem;
  padding: 0.6rem 0.85rem;
  font-size: 0.86rem;
  margin-bottom: 0.9rem;
}
.due-note .bi {
  color: #b8860b;
  font-size: 1.1rem;
  margin-top: 0.1rem;
}
.due-item {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--bs-border-color);
  border-inline-start: 5px solid #ffc107;
  border-radius: 0.7rem;
  background: var(--bs-body-bg);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  animation: cal-ev-in 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 30ms);
}
.due-item-late {
  border-inline-start-color: #dc3545;
}
.due-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.8rem;
}
.due-name {
  font-weight: 800;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}
.due-country {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--bs-secondary-color);
  white-space: nowrap;
  margin-inline-start: 0.5rem;
}
.due-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
}
.due-block {
  flex: 1 1 13rem;
  min-width: 0;
  border-radius: 0.6rem;
  padding: 0.45rem 0.65rem;
}
.due-block-done {
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
}
.due-block-next {
  background: color-mix(in srgb, #ffc107 8%, var(--bs-body-bg));
  border: 2px dashed color-mix(in srgb, #e0a800 70%, transparent);
}
.due-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 0 0.55rem;
  line-height: 1.7;
  margin-bottom: 0.3rem;
}
.due-tag-done {
  background: #e2e6ea;
  color: #3d4852;
}
.due-tag-next {
  background: #fff3cd;
  color: #7a5400;
}
[data-bs-theme='dark'] .due-tag-done {
  background: rgba(173, 181, 189, 0.18);
  color: #ced4da;
}
[data-bs-theme='dark'] .due-tag-next {
  background: rgba(255, 193, 7, 0.18);
  color: #ffda6a;
}
.due-arrow {
  align-self: center;
  color: var(--bs-secondary-color);
  font-size: 1.1rem;
}
.due-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
}
.due-type {
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  box-shadow: 0 0 0 1px var(--bs-border-color);
}
.due-date {
  font-size: 0.9rem;
}
.due-last {
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
}
.due-stds {
  margin-top: 0.25rem;
}
.due-std {
  background: var(--bs-secondary-bg);
  color: var(--bs-body-color);
}
.due-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}
.due-badge {
  border-radius: 999px;
  padding: 0 0.65rem;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.75;
  white-space: nowrap;
  display: inline-block;
}
.due-late {
  background: #dc3545;
  color: #fff;
}
.due-near {
  background: #ffc107;
  color: #3b2f00;
}
.due-later {
  background: var(--bs-secondary-bg);
  color: var(--bs-body-color);
}
/* the audits list: the same two blocks inside table cells */
.due-table .due-block {
  display: inline-block;
  min-width: 11rem;
}
.due-row-late {
  --bs-table-bg-state: color-mix(in srgb, #dc3545 5%, transparent);
}
.aud-quick-due {
  font-weight: 700;
}
#btn-due #due-count:not(.d-none) {
  animation: cal-pulse 1.8s ease-out 4;
}

/* ---- Motion: gentle, short, and off for people who asked their system for less motion ---- */
@keyframes cal-ev-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes cal-today {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--app-red) 55%, transparent);
  }
  100% {
    box-shadow: 0 0 0 12px transparent;
  }
}
@keyframes cal-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.55);
  }
  100% {
    box-shadow: 0 0 0 9px rgba(220, 53, 69, 0);
  }
}
.cal-quiet .fc-card,
.cal-quiet .fc-card:hover {
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .fc .fc-daygrid-event.fc-card,
  .due-item,
  .fc .fc-day-today .fc-daygrid-day-number,
  #btn-due #due-count {
    animation: none !important;
    transition: none !important;
  }
  .fc .fc-daygrid-event.fc-card:hover {
    transform: none;
  }
}
@media print {
  .fc .fc-daygrid-event.fc-card {
    animation: none !important;
    transition: none;
    transform: none !important;
    box-shadow: none;
  }
}

/* ---- A company's DONE audits: the last one as a clear card, the earlier ones in a short list ---- */
.ch-box {
  margin-top: 0.6rem;
}
.ch-hero {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid var(--bs-border-color);
  border-inline-start: 6px solid #3d4852;
  background: color-mix(in srgb, #3d4852 6%, var(--bs-body-bg));
  border-radius: 0.7rem;
  padding: 0.7rem 0.9rem;
  animation: cal-ev-in 0.3s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.ch-hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem 0.6rem;
}
.ch-tag {
  background: #e2e6ea;
  color: #3d4852;
  border-radius: 999px;
  padding: 0 0.65rem;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.8;
}
[data-bs-theme='dark'] .ch-tag {
  background: rgba(173, 181, 189, 0.18);
  color: #ced4da;
}
.ch-ago {
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
}
.ch-hero-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.8rem;
}
.ch-dates {
  font-size: 1.02rem;
}
.ch-type {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  padding: 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.7;
  white-space: nowrap;
}
.ch-field {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.25rem 0.7rem;
}
.ch-label {
  flex: 0 0 5.2rem;
  padding-top: 0.12rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bs-secondary-color);
}
.ch-chips,
.ch-people {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.4rem;
  flex: 1 1 11rem;
  min-width: 0;
}
.ch-std {
  background: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.35rem;
  padding: 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.7;
  white-space: nowrap;
}
.ch-person {
  background: color-mix(in srgb, var(--bs-primary) 8%, transparent);
  border-radius: 999px;
  padding: 0 0.6rem;
  font-size: 0.82rem;
  line-height: 1.7;
}
.ch-lead {
  font-weight: 800;
}
.ch-none {
  color: var(--bs-secondary-color);
}
.ch-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.35rem 0.7rem;
  background: transparent;
  color: var(--bs-body-color);
  border: 1px dashed var(--bs-border-color);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: start;
}
.ch-toggle:hover {
  background: var(--bs-secondary-bg);
}
.ch-caret {
  margin-inline-start: auto;
  transition: transform 0.2s ease;
}
.ch-toggle.open .ch-caret {
  transform: rotate(180deg);
}
.ch-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.4rem;
  max-height: 17rem;
  overflow: auto;
}
.ch-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.7rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  background: var(--bs-body-bg);
}
.ch-item .ch-people {
  flex-basis: 100%;
}
.ch-empty,
.ch-loading,
.ch-more {
  padding: 0.4rem 0.2rem;
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
}
.ch-more {
  text-align: center;
}

/* ---- Companies list / company page: the last audit done, standards laid out in tidy chips ---- */
.last-done {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 14rem;
}
.last-done .ld-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
}
.last-done .ch-chips,
.last-done .ch-people {
  flex: none;
}
.last-done .ld-count {
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
}
.hist-table th,
.hist-table td {
  vertical-align: top;
}
.hist-last td {
  background: color-mix(in srgb, #3d4852 6%, var(--bs-body-bg));
}

/* ---- Ring buttons: pick the day and how it reaches people ---- */
.ring-channels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.ring-ch {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.6rem 0.4rem;
  line-height: 1.25;
  text-align: center;
}
.ring-ch .bi {
  font-size: 1.25rem;
}
.ring-ch small {
  font-size: 0.72rem;
  font-weight: 400;
  opacity: 0.85;
}
.btn-check:checked + .ring-ch {
  background: var(--app-red);
  border-color: var(--app-red);
  color: #fff;
}
.ring-whens {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.ring-whens .btn-check:checked + .btn {
  background: var(--app-black);
  border-color: var(--app-black);
  color: #fff;
}
.ring-preview {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 14rem;
  overflow: auto;
}
.ring-person {
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  background: var(--bs-body-bg);
}
@media (prefers-reduced-motion: reduce) {
  .ch-hero {
    animation: none !important;
  }
}

/* ---- Calendar, round 10: a lighter top, three card sizes, the list of the year, the colour guide ---- */
.cal-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.6rem;
}
.cal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.cal-panel {
  padding: 0.6rem 0.75rem;
}
.cal-search {
  min-width: 14rem;
}
.cal-more-caret {
  transition: transform 0.2s ease;
}
#cal-more-toggle[aria-expanded='true'] .cal-more-caret {
  transform: rotate(180deg);
}
.cal-legend-box {
  border-top: 1px dashed var(--bs-border-color);
  padding-top: 0.6rem;
}
.fc .fc-button {
  border-radius: 0.6rem;
  font-weight: 600;
  transition:
    background-color 0.15s ease,
    transform 0.15s ease;
}
.fc .fc-button:active {
  transform: scale(0.97);
}
/* a thin moving bar while the audits are being fetched */
#calendar {
  position: relative;
}
#calendar.cal-loading::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 3px;
  z-index: 6;
  background: linear-gradient(90deg, transparent, var(--app-red), transparent) no-repeat;
  background-size: 40% 100%;
  animation: cal-load 1s linear infinite;
}
@keyframes cal-load {
  from {
    background-position: -40% 0;
  }
  to {
    background-position: 140% 0;
  }
}

/* "normal" card: the facts that matter, one short line each (an icon instead of a label) */
.fc-ev-normal .fc-ev-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem 0.65rem;
}
.fc-ev-line {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  min-width: 0;
}
.fc-ev-line > .bi {
  flex: none;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
}
.fc-ev-linebody {
  flex: 1;
  min-width: 0;
}
.fc-ev-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.3rem;
}
.fc-card .fc-ev-person {
  background: color-mix(in srgb, var(--ev, #0b5ea8) 10%, var(--bs-body-bg));
  border: 1px solid color-mix(in srgb, var(--ev, #0b5ea8) 28%, transparent);
  border-radius: 999px;
  padding: 0 0.55rem;
  font-size: 0.78rem;
  line-height: 1.7;
}
.fc-ev-lead {
  font-weight: 800;
}
/* "compact" card: just the name and the status */
.fc-ev-compact .fc-ev-title {
  flex-wrap: nowrap;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
}
.fc-ev-compact .fc-ev-name {
  font-size: 0.92rem;
}
.fc-ev-sub {
  padding: 0.2rem 0.55rem 0.4rem;
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
}
.fc-ev-status-icon {
  padding: 0 0.4rem;
}
.cal-d-compact .fc .fc-daygrid-day-frame {
  min-height: 96px;
}
.cal-d-normal .fc .fc-daygrid-event {
  margin-bottom: 8px;
}
/* the list views (month list, list of the year): one tidy row per audit */
.fc-ev-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  padding: 0.2rem 0;
}
.fc-ev-list .fc-ev-name {
  font-size: 1rem;
}
.fc-list-event .fc-ev-person {
  background: var(--bs-secondary-bg);
  border-radius: 999px;
  padding: 0 0.55rem;
  font-size: 0.8rem;
  line-height: 1.7;
}

/* the colour guide window */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
}
@media (max-width: 767.98px) {
  .guide-grid {
    grid-template-columns: 1fr;
  }
}
.guide-card {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.7rem;
  padding: 0.8rem 0.9rem;
  background: var(--bs-body-bg);
}
.guide-statuses {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.guide-st {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.guide-type {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  padding: 0.1rem 0.65rem;
  font-size: 0.8rem;
}
.guide-list {
  padding-inline-start: 1.1rem;
}
@media (prefers-reduced-motion: reduce) {
  #calendar.cal-loading::after {
    animation: none;
  }
}

/* FullCalendar hides the (screen-reader) header of its list views far to the left; on a right-to-left page that
   makes the whole page scroll sideways. Hide it in place instead. */
.fc .fc-list-table thead {
  left: auto;
  inset-inline-start: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* ---- Automatic sending: what the system prepared at 08:00 waits here for approval ---- */
.as-note {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid color-mix(in srgb, #198754 40%, transparent);
  border-radius: 0.7rem;
  background: color-mix(in srgb, #198754 9%, var(--bs-body-bg));
}
.as-note .bi {
  font-size: 1.4rem;
  color: #198754;
}
.as-mode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0;
  border-top: 1px dashed var(--bs-border-color);
}
.as-mode-row:first-of-type {
  border-top: 0;
}
.as-mode-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
  text-align: start;
}
.as-mode-btn small {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.85;
}
.btn-check:checked + .as-mode-ask {
  background: #198754;
  border-color: #198754;
  color: #fff;
}
.btn-check:checked + .as-mode-auto {
  background: #b26a00;
  border-color: #b26a00;
  color: #fff;
}
.btn-check:checked + .as-mode-off {
  background: #6c757d;
  border-color: #6c757d;
  color: #fff;
}
.as-check {
  width: 2.2rem;
}
.as-kind-due {
  background: #fff3cd;
  color: #7a5400;
}
.as-kind-reminder {
  background: #d1e7dd;
  color: #0f5132;
}
[data-bs-theme='dark'] .as-kind-due {
  background: rgba(255, 193, 7, 0.18);
  color: #ffda6a;
}
[data-bs-theme='dark'] .as-kind-reminder {
  background: rgba(25, 135, 84, 0.22);
  color: #75b798;
}
.as-bar {
  position: sticky;
  top: var(--topbar-h, 56px);
  z-index: 5;
  padding: 0.5rem 0;
  background: color-mix(in srgb, var(--bs-body-bg) 94%, transparent);
}

/* ---- Reports, bulk planning, team shortcuts (round 12) ---- */
.as-kind-digest {
  background: #cfe2ff;
  color: #084298;
}
.as-kind-weekly {
  background: #e2d9f3;
  color: #432874;
}
[data-bs-theme='dark'] .as-kind-digest {
  background: rgba(13, 110, 253, 0.2);
  color: #6ea8fe;
}
[data-bs-theme='dark'] .as-kind-weekly {
  background: rgba(111, 66, 193, 0.28);
  color: #c29ffa;
}

/* dashboard: companies that need a date */
.dash-late-red {
  border-color: color-mix(in srgb, #dc3545 55%, transparent);
}
.dl-stats {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.dl-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 0.5rem;
  border-radius: 0.6rem;
  background: var(--bs-tertiary-bg);
}
.dl-stat b {
  font-size: 1.7rem;
  line-height: 1.1;
}
.dl-stat span {
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
}
.dl-stat-late b {
  color: #dc3545;
}
.dl-stat-soon b {
  color: #b26a00;
}

/* weekly report */
.wk-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin-bottom: 0.75rem;
}
.wk-range {
  font-size: 1.1rem;
  font-weight: 700;
}
.wk-text {
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  background: var(--bs-tertiary-bg);
}
.wk-table td {
  vertical-align: top;
}

/* team shortcuts beside the team boxes */
.team-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  vertical-align: middle;
}
.team-suggest {
  margin-bottom: 0.5rem;
}
.team-chip {
  padding: 0.05rem 0.5rem;
  font-size: 0.8rem;
  transition:
    transform 0.15s ease,
    background-color 0.15s ease;
}
.team-chip:hover {
  transform: translateY(-1px);
}

/* planning several companies at once */
.bp-c1 {
  width: 2rem;
}
.bp-bar {
  position: sticky;
  top: var(--topbar-h, 56px);
  z-index: 5;
  padding: 0.4rem 0;
  background: color-mix(in srgb, var(--bs-body-bg) 94%, transparent);
}
.bp-table td {
  vertical-align: top;
}
.bp-table .bp-start {
  min-width: 9.5rem;
}
.bp-table .bp-days {
  min-width: 4.5rem;
  max-width: 6rem;
}
.bp-days-group {
  max-width: 11rem;
}
.bp-table tr.bp-ok {
  background: color-mix(in srgb, #198754 7%, transparent);
}
.bp-table tr.bp-bad {
  background: color-mix(in srgb, #dc3545 6%, transparent);
}
.bp-table tr.bp-saved {
  opacity: 0.75;
}
.due-bulkbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.35rem 0;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bs-body-bg);
}
.due-head .due-check {
  flex: none;
  margin-inline-end: 0.5rem;
}
@media (prefers-reduced-motion: reduce) {
  .team-chip {
    transition: none;
  }
}

/* the planning window on a phone: every row becomes a card with its headings */
@media (max-width: 767.98px) {
  .bp-table thead {
    display: none;
  }
  .bp-table,
  .bp-table tbody,
  .bp-table tr,
  .bp-table td {
    display: block;
    width: 100%;
  }
  .bp-table tr {
    position: relative;
    padding: 0.6rem 0.4rem;
    border-bottom: 1px solid var(--bs-border-color);
  }
  .bp-table td {
    border: 0;
    padding: 0.15rem 0;
  }
  .bp-table td[data-label]:not([data-label='']):before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    color: var(--bs-secondary-color);
  }
  .bp-table td.bp-include {
    position: absolute;
    inset-block-start: 0.6rem;
    inset-inline-end: 0.4rem;
    width: auto;
  }
  .bp-table td.bp-company {
    padding-inline-end: 2rem;
  }
  .bp-table .bp-start,
  .bp-table .bp-days {
    max-width: none;
  }
}

/* ---- Finance section (reports and query screens, view only). It wears the look of the accounting program: cream paper
   with a faint grid, a classic menu bar, sand table headers and an orange accent. The rest of the site keeps its colours. ---- */
.fin {
  --fin-paper: #f6f2df;
  --fin-paper-2: #ebe5c7;
  --fin-card: #fffdf3;
  --fin-line: #cfc79f;
  --fin-ink: #2d2a1f;
  --fin-muted: #6f6a52;
  --fin-head: #e4d9a8;
  --fin-accent: #d98a1d;
  --fin-blue: #2f5f9e;
  --fin-sel: #2f5f9e;
  padding: 0.75rem;
  border: 1px solid var(--fin-line);
  border-radius: 0.3rem;
  color: var(--fin-ink);
  background-color: var(--fin-paper);
  background-image:
    linear-gradient(rgba(120, 105, 40, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 105, 40, 0.07) 1px, transparent 1px);
  background-size: 26px 26px;
}
[data-bs-theme='dark'] .fin {
  --fin-paper: #25231a;
  --fin-paper-2: #322f20;
  --fin-card: #2c2a1e;
  --fin-line: #5c563b;
  --fin-ink: #eee8cd;
  --fin-muted: #b9b293;
  --fin-head: #4c4627;
  --fin-accent: #e8a43a;
  --fin-blue: #8fb4e6;
  --fin-sel: #3d6db3;
  background-image:
    linear-gradient(rgba(255, 240, 160, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 240, 160, 0.04) 1px, transparent 1px);
}
.fin a {
  color: var(--fin-blue);
}
.nav-link.nav-fin.active,
.nav-link.nav-fin:hover {
  background-color: #d98a1d;
  color: #2d2a1f;
}

/* the title strip and the menu bar */
.fin-titlebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--fin-line);
  border-bottom: 2px solid var(--fin-accent);
  background: var(--fin-paper-2);
  font-weight: 700;
}
.fin-titlebar .bi {
  color: var(--fin-accent);
}
.fin-titlebar small {
  margin-inline-start: auto;
  font-weight: 400;
  color: var(--fin-muted);
}
.fin-menu {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
  border: 1px solid var(--fin-line);
  border-top: 0;
  background: linear-gradient(var(--fin-card), var(--fin-paper-2));
  font-size: 0.92rem;
}
.fin-menu .dropdown {
  position: relative;
}
.fin-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.9rem;
  border: 0;
  background: transparent;
  color: var(--fin-ink);
}
.fin-menu-btn:hover,
.fin-menu-btn.show,
.fin-menu-btn.active {
  background: var(--fin-sel);
  color: #fff;
}
.fin-menu .dropdown-menu {
  min-width: 14rem;
  padding: 0.15rem 0;
  border: 1px solid #8a8466;
  border-radius: 0;
  background: var(--fin-card);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.18);
}
.fin-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.9rem;
  color: var(--fin-ink);
  background: transparent;
  border: 0;
  width: 100%;
  text-align: start;
}
.fin-menu .dropdown-item:hover,
.fin-menu .dropdown-item:focus,
.fin-menu .dropdown-item.active {
  background: var(--fin-sel);
  color: #fff;
}
.fin-menu .dropdown-item .bi {
  width: 1.1rem;
  color: var(--fin-accent);
}
.fin-menu .dropdown-item:hover .bi,
.fin-menu .dropdown-item.active .bi {
  color: #ffd98f;
}
.fin-menu form {
  margin: 0;
}

.fin-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.fin-title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--fin-ink);
}
.fin-title .bi {
  color: var(--fin-accent);
}
.fin-note {
  margin-bottom: 0.9rem;
  color: var(--fin-muted);
  font-size: 0.85rem;
}
.btn-fin {
  background: #e3a13a;
  border-color: #b97f1f;
  color: #2d2a1f;
  font-weight: 600;
}
.btn-fin:hover {
  background: #d18d22;
  color: #2d2a1f;
}
.fin .btn-outline-secondary,
.fin .btn-outline-success {
  background: var(--fin-card);
}
.fin-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.8rem;
  border: 1px solid var(--fin-line);
  background: var(--fin-paper-2);
}
.fin-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 9.5rem;
}
.fin-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fin-blue);
}
.fin-field .form-control,
.fin-field .form-select {
  border-radius: 0;
  border-color: #a59d78;
  background-color: var(--fin-card);
  color: var(--fin-ink);
}
.fin-field-wide {
  flex: 1 1 16rem;
}
.fin-checks {
  justify-content: flex-end;
}
.fin-pick {
  position: relative;
}
.fin-results {
  position: absolute;
  inset-inline: 0;
  top: 100%;
  z-index: 20;
  max-height: 18rem;
  overflow-y: auto;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.18);
}
.fin-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.fin-card {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--fin-line);
  background: var(--fin-card);
}
.fin-card-main {
  border-top: 3px solid var(--fin-accent);
}
.fin-card-label {
  font-size: 0.78rem;
  color: var(--fin-blue);
  font-weight: 600;
}
.fin-card-value {
  font-size: 1.35rem;
  font-weight: 700;
  text-align: end;
}
.fin-card-sub {
  font-size: 0.75rem;
  color: var(--fin-muted);
}
.fin-subject {
  margin-bottom: 0.7rem;
  font-size: 1.05rem;
}
.fin-subject-name {
  font-weight: 700;
}
.fin-subject-no {
  color: var(--fin-muted);
  font-size: 0.85rem;
}
.fin-table-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
  border: 1px solid var(--fin-line);
  background: var(--fin-card);
}
.fin-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--fin-ink);
  --bs-table-border-color: var(--fin-line);
  margin: 0;
  font-size: 0.86rem;
}
.fin-table thead th {
  background: var(--fin-head);
  color: var(--fin-ink);
  white-space: nowrap;
  font-weight: 700;
  border-bottom: 2px solid #b4aa7a;
}
.fin-table tbody tr:nth-child(even) {
  background: rgba(150, 130, 40, 0.07);
}
.fin-table tbody tr.fin-click {
  cursor: pointer;
}
.fin-table tbody tr.fin-click:hover {
  background: rgba(47, 95, 158, 0.12);
}
.fin-table td.fin-num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.fin-neg {
  color: #b3261e;
}
/* what a line was written as, under its dinar value (another currency) */
.fin-fx {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--fin-muted);
  white-space: nowrap;
}
.fin-fx.fin-neg {
  color: #b3261e;
}
[data-bs-theme='dark'] .fin-neg {
  color: #ff9d94;
}
.fin-desc {
  min-width: 14rem;
  max-width: 28rem;
}
.fin-acc-name {
  min-width: 14rem;
}
.fin-row-open td {
  background: var(--fin-paper-2);
  font-style: italic;
}
.fin-row-total td {
  background: var(--fin-head);
  font-weight: 700;
  border-top: 2px solid #b4aa7a;
}
.fin-lvl-1 td {
  font-weight: 700;
}
.fin-lvl-2 .fin-acc-name {
  padding-inline-start: 1rem;
}
.fin-lvl-3 .fin-acc-name {
  padding-inline-start: 2rem;
}
.fin-lvl-4 .fin-acc-name {
  padding-inline-start: 3rem;
}
.fin-lvl-5 .fin-acc-name {
  padding-inline-start: 4rem;
}
.fin-table-compact {
  font-size: 0.78rem;
}
.fin-table-narrow {
  max-width: 46rem;
}
.fin-share progress {
  width: 5rem;
  height: 0.6rem;
  vertical-align: middle;
  accent-color: var(--fin-accent);
}
.fin-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.5rem 0 1rem;
}
.fin-pager-info {
  padding: 0 0.6rem;
  font-size: 0.85rem;
  color: var(--fin-muted);
}
.fin-chart {
  position: relative;
  height: 18rem;
  margin-bottom: 1rem;
  padding: 0.6rem;
  border: 1px solid var(--fin-line);
  background: var(--fin-card);
}
.fin-two {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
}
@media (min-width: 992px) {
  .fin-two {
    grid-template-columns: 1fr 1fr;
  }
}
.fin-h2 {
  margin: 0.2rem 0 0.5rem;
  color: var(--fin-blue);
}
.fin-balance {
  display: inline-block;
  margin-bottom: 0.8rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid;
  font-weight: 600;
}
.fin-balance.ok,
.fin-health.ok {
  background: color-mix(in srgb, #198754 14%, var(--fin-card));
  border-color: #198754;
  color: #146c43;
}
.fin-balance.bad,
.fin-health.bad {
  background: color-mix(in srgb, #dc3545 14%, var(--fin-card));
  border-color: #dc3545;
  color: #b02a37;
}
[data-bs-theme='dark'] .fin-balance.ok,
[data-bs-theme='dark'] .fin-health.ok {
  color: #75b798;
}
[data-bs-theme='dark'] .fin-balance.bad,
[data-bs-theme='dark'] .fin-health.bad {
  color: #ea868f;
}
.fin-health {
  padding: 0.9rem 1.1rem;
  border: 1px solid;
}
.fin-kind {
  display: flex;
  gap: 0;
  margin-bottom: 0.8rem;
}
.fin-kind .btn {
  border-radius: 0;
}
.fin-kind .btn.active {
  background: var(--fin-sel);
  border-color: var(--fin-sel);
  color: #fff;
}
.fin-badge {
  display: inline-block;
  padding: 0 0.4rem;
  border: 1px solid var(--fin-line);
  background: var(--fin-paper-2);
  font-size: 0.72rem;
  color: var(--fin-muted);
}
.fin-tree-toggle {
  display: inline-block;
  width: 1.4rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fin-blue);
  font-weight: 700;
}
.fin-crumbs {
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
}
.fin-modal .modal-content {
  border-radius: 0;
  border: 1px solid #8a8466;
  background: var(--bs-body-bg);
}
.fin-modal .modal-header {
  background: var(--fin-head);
  color: #2d2a1f;
  border-bottom: 2px solid var(--fin-accent);
}
.fin-modal dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0 0 1rem;
}
.fin-modal dt {
  color: #2f5f9e;
  font-weight: 600;
}
.fin-modal dd {
  margin: 0;
}
@media (max-width: 767.98px) {
  .fin {
    padding: 0.4rem;
  }
  .fin-filters {
    padding: 0.6rem;
  }
  .fin-field {
    min-width: 8rem;
    flex: 1 1 8rem;
  }
  .fin-title {
    font-size: 1.05rem;
  }
  .fin-menu-btn {
    padding: 0.3rem 0.6rem;
  }
}
@media print {
  .fin {
    background: #fff;
    border: 0;
  }
  .fin-table thead th {
    background: #fff;
    border-bottom: 2px solid #000;
  }
  .fin-chart {
    display: none;
  }
}

/* ---- the audits table you can type into (partials/audit-sheet.ejs): it looks like the ordinary list; a cell becomes a control when used ---- */
.sheet-wrap {
  overflow-x: auto;
  min-height: 16rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.6rem;
  background: var(--bs-body-bg);
}
table.sheet {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}
table.sheet th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bs-tertiary-bg);
  border-bottom: 2px solid var(--bs-border-color);
  padding: 0.55rem 0.4rem;
  font-weight: 600;
  white-space: normal;
  vertical-align: middle;
}
table.sheet th .sh-h {
  display: block;
  padding-inline-end: 0.5rem;
}
/* the edge of a heading that is dragged to change the width */
.sh-rs {
  position: absolute;
  inset-block: 0;
  inset-inline-end: -3px;
  width: 7px;
  cursor: col-resize;
  z-index: 4;
}
.sh-rs::after {
  content: '';
  position: absolute;
  inset-block: 25%;
  inset-inline-start: 3px;
  width: 1px;
  background: var(--bs-border-color);
}
.sh-rs:hover::after {
  width: 3px;
  inset-inline-start: 2px;
  background: var(--bs-primary);
}
table.sheet td {
  padding: 0.4rem 0.4rem;
  border-bottom: 1px solid var(--bs-border-color);
  vertical-align: middle;
  overflow-wrap: anywhere;
}
table.sheet tbody tr:hover td {
  background: var(--bs-tertiary-bg);
}
table.sheet td.sh-n {
  text-align: center;
  color: var(--bs-secondary-color);
  padding-inline: 0.1rem;
}
table.sheet td.sh-td {
  cursor: text;
  min-height: 2.2rem;
  height: 2.6rem;
}
table.sheet td.sh-ro {
  color: var(--bs-secondary-color);
  text-align: center;
  cursor: default;
}
table.sheet td.sh-td:focus {
  outline: 2px solid var(--bs-primary);
  outline-offset: -2px;
}
table.sheet td.sh-editing {
  padding: 0;
  background: var(--bs-body-bg);
  outline: 2px solid var(--bs-primary);
  outline-offset: -2px;
}
table.sheet td.sh-bad {
  box-shadow: inset 0 -3px 0 #dc3545;
  background: rgba(220, 53, 69, 0.08);
}
.sh-company {
  font-weight: 600;
}
.sh-person.sh-lead {
  font-weight: 700;
}
.sh-person.sh-role {
  font-style: italic;
  color: var(--bs-secondary-color);
}
.sh-badge {
  font-weight: 500;
  white-space: normal;
}
/* the control of the cell being edited */
.sh-ed {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: 0.4rem;
  font: inherit;
  line-height: 1.3;
  resize: none;
  overflow: hidden;
  outline: none;
  box-shadow: none;
}
select.sh-ed {
  padding: 0.4rem 0.2rem;
  height: auto;
  background-color: var(--bs-body-bg);
}
table.sheet td.sh-mark {
  text-align: center;
  font-weight: 700;
  padding-inline: 0;
}
th.sh-mark-h {
  text-align: center;
}
table.sheet tr.sh-dirty td {
  background: rgba(255, 193, 7, 0.1);
}
table.sheet tr.sh-dirty td.sh-n {
  box-shadow: inset 3px 0 0 #ffc107;
}
table.sheet tr.sh-err td.sh-mark {
  color: #b3261e;
}
table.sheet tr.sh-warn td.sh-mark {
  color: #946200;
}
table.sheet tr.sh-ok td.sh-mark {
  color: #1a7f4b;
}
[data-bs-theme='dark'] table.sheet tr.sh-err td.sh-mark {
  color: #ff9d94;
}
[data-bs-theme='dark'] table.sheet tr.sh-warn td.sh-mark {
  color: #f3c969;
}
[data-bs-theme='dark'] table.sheet tr.sh-ok td.sh-mark {
  color: #6fd29c;
}
col.sh-col-n {
  width: 34px;
}
col.sh-col-mark {
  width: 34px;
}
/* the standards: a list of check boxes under the cell, and the company suggestions */
.sh-pop,
.sheet-sug {
  position: absolute;
  z-index: 1080;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
  max-height: 16rem;
  overflow: auto;
}
.sh-pop {
  min-width: 11rem;
  padding: 0.4rem;
}
.sh-pop-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  white-space: nowrap;
}
.sh-pop-item:hover {
  background: var(--bs-primary-bg-subtle);
}
.sh-pop-bar {
  padding: 0.35rem 0.2rem 0.1rem;
  text-align: end;
}
.sh-sug-item {
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  white-space: nowrap;
}
.sh-sug-item.on,
.sh-sug-item:hover {
  background: var(--bs-primary-bg-subtle);
}
@media print {
  .sheet-bar {
    display: none !important;
  }
  .sheet-wrap {
    max-height: none;
    overflow: visible;
  }
}

/* a month heading in the audits table you can type into: click it to fold the month */
tr.sh-month td {
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-body-color);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  border-bottom: 1px solid var(--bs-border-color);
}
tr.sh-month:hover td {
  background: var(--bs-primary-bg-subtle);
  filter: brightness(0.96);
}
.sh-month-n {
  display: inline-block;
  min-width: 1.5rem;
  margin-inline-start: 0.4rem;
  padding: 0 0.4rem;
  border-radius: 1rem;
  background: var(--bs-body-bg);
  color: var(--bs-secondary-color);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}
/* the heading of the month it is now: marked, so the eye finds it when the table opens on it */
.sh-month-now {
  display: inline-block;
  margin-inline-start: 0.5rem;
  padding: 0.05rem 0.55rem;
  border-radius: 1rem;
  background: var(--bs-primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
}
.fin-row-head td {
  background: var(--fin-paper-2);
  font-weight: 700;
  border-top: 1px solid #b4aa7a;
}
