/* ==========================================================
   Helpdesk — design tokens
   Subject: internal MSP/IT ticket triage tool, used by
   technicians who need to scan queues fast and act on
   priority. Not a marketing surface — dense, legible, calm.
   ========================================================== */

:root {
  /* Color */
  --bg: #14181c;
  --surface: #1c2126;
  --surface-raised: #242a31;
  --border: #2e353d;
  --text: #e7eaed;
  --text-muted: #8b96a1;
  --accent-signal: #e8a33d; /* urgent / attention only — kept separate from brand color on purpose */
  --accent-ok: #4fb286;
  --accent-danger: #e57f70;
  --accent-info: #6c9bd1;
  --brand-green: #4bb648;
  --brand-green-light: #8dc63f;
  --brand-green-dark: #379140;
  /* WCAG 2.1 AA: buttons' text on the green (7.4:1), focus rings (3:1+ on the
     page), and form-field edges (3:1). */
  --btn-text: #0b0f12;
  --btn-bg-hover: #8dc63f;
  --focus: #8dc63f;
  --input-border: #6b7682;

  /* Type */
  --font-sans: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', monospace;

  /* Layout */
  --radius: 4px;

  color-scheme: dark;
}

/* Light theme — same roles, darker accents so badges and links keep
   their contrast on a white surface. Toggled via data-theme on <html>
   (see includes/theme_head.php and public/js/theme.js). */
:root[data-theme="light"] {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-raised: #eceff2;
  --border: #d3d9df;
  --text: #1b2127;
  --text-muted: #5a6570;
  --accent-signal: #935606;
  --accent-ok: #236b49;
  --accent-danger: #b03a2a;
  --accent-info: #2f6aa8;
  /* Darker greens on white, so green text, links and white button text
     reach 4.5:1 (WCAG 2.1 AA). */
  --brand-green: #2a7a27;
  --brand-green-light: #24741f;
  --brand-green-dark: #1f661d;
  --btn-text: #ffffff;
  --btn-bg-hover: #1f661d;
  --focus: #1f661d;
  --input-border: #77828d;

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--brand-green-light); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-sans); font-weight: 600; margin: 0 0 0.6em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; color: var(--text-muted); font-weight: 500; }

.mono { font-family: var(--font-mono); }

/* ---------- App shell ---------- */

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.topbar-right { gap: 10px; }

.brand { display: flex; align-items: center; }

.brand-logo {
  display: block;
  height: 30px;
  width: auto;
}
/* Two logos: logo-dark.png on the dark theme (the default), logo.png on light. */
.brand-logo.logo-for-light { display: none; }
:root[data-theme="light"] .brand-logo.logo-for-dark { display: none; }
:root[data-theme="light"] .brand-logo.logo-for-light { display: block; }

.top-nav { display: flex; gap: 4px; }

.top-nav a {
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius);
  border-bottom: 2px solid transparent;
}

.top-nav a:hover { color: var(--text); text-decoration: none; background: var(--surface-raised); }

.top-nav a.active {
  color: var(--text);
  border-bottom-color: var(--brand-green);
}

.topbar-context {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.topbar-context .tenant-name { color: var(--text); font-weight: 600; }
.topbar .role-tag { text-transform: lowercase; }

main { padding: 28px; max-width: 1100px; margin: 0 auto; }
main.main-wide { max-width: 1238px; } /* ticket list, maintenance tasks: 1/8 wider, so their columns fit without scrolling */
main.main-wider { max-width: 1375px; } /* scheduled report emails: 1/4 wider */
main.main-wider-list { max-width: 1315px; } /* ticket list: 1/8 + 1/16 wider (1238 px × 1.0625) */

.back-link {
  display: inline-block;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.back-link:hover { color: var(--text); }

/* ---------- Cards & tables ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.stat-grid {
  /* Computers: each tile is as wide as its label needs (and shares any
     spare room), so labels stay a readable size on one line. */
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text);
  transition: background 0.1s ease, border-color 0.1s ease;
  flex: 1 1 auto;
}

.stat:hover {
  background: var(--surface-raised);
  border-left-color: var(--brand-green);
  text-decoration: none;
}

.stat-active {
  border-left-color: var(--brand-green);
  background: var(--surface-raised);
}

.stat-active .stat-value { color: var(--brand-green-light); }

.stat .stat-value { font-family: var(--font-mono); font-size: 1.15rem; line-height: 1; flex: 0 0 auto; }
.stat .stat-label { color: var(--text-muted); font-size: 0.8rem; white-space: nowrap; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:hover td { background: var(--surface-raised); }

.ticket-number { font-family: var(--font-mono); color: var(--text-muted); }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius);
  font-size: 0.78rem;
  border: 1px solid transparent;
}

.badge-urgent { color: var(--accent-danger); border-color: var(--accent-danger); }
.badge-high { color: var(--accent-signal); border-color: var(--accent-signal); }
.badge-low { color: var(--text-muted); border-color: var(--border); }
.badge-maintenance { color: var(--accent-info); border-color: var(--accent-info); }

.badge-status-new { color: var(--accent-info); border-color: var(--accent-info); }
.badge-status-active { color: var(--accent-signal); border-color: var(--accent-signal); }
.badge-status-done { color: var(--accent-ok); border-color: var(--accent-ok); }
.badge-billed { color: var(--accent-info); border-color: var(--accent-info); } /* the Billed status */
.badge-status-canceled { color: var(--text-muted); border-color: var(--border); text-decoration: line-through; }

/* ---------- Forms ---------- */

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="datetime-local"],
input[type="month"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

textarea { min-height: 100px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

button, .btn {
  display: inline-block;
  background: var(--brand-green);
  color: var(--btn-text);
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

button:hover, .btn:hover { background: var(--btn-bg-hover); text-decoration: none; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

/* Light/dark toggle — shows the icon for the mode you'd switch to. A round
   button with a soft shadow, like dotinc.tools (matches the EN | FR pill). */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.theme-toggle:hover { background: var(--surface-raised); color: var(--text); transform: scale(1.07); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* On sign-in pages there's no top bar, so pin it to the corner. */
.theme-toggle-fixed { position: fixed; top: 16px; right: 16px; z-index: 10; }
/* The EN / FR switch beside the light/dark toggle (includes/theme_toggle.php). */
.prefs-toggles { display: inline-flex; align-items: center; gap: 10px; }
/* EN | FR as a pill (like dotinc.tools): the current language filled green. */
.lang-toggle { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); }
.lang-option { display: inline-flex; align-items: center; justify-content: center; padding: 5px 10px; border-radius: 16px;
  font-size: 0.75rem; font-weight: 700; line-height: 1; color: var(--text-muted); text-decoration: none;
  transition: background 0.15s, color 0.15s; }
a.lang-option:hover { color: var(--text); background: var(--surface-raised); text-decoration: none; }
.lang-option.is-active { background: var(--brand-green); color: var(--btn-text); }

/* ---------- Log work form ---------- */

.work-times { display: flex; flex-wrap: wrap; gap: 12px; }
.work-time { flex: 1 1 260px; min-width: 0; }
.time-row { display: flex; gap: 6px; }
.time-row input { min-width: 0; }
.time-row button { flex: 0 0 auto; }


.checkbox-label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 16px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand-green);
}
.checkbox-hint { color: var(--text-muted); font-size: 0.8rem; }

.btn-danger-outline {
  background: transparent;
  color: var(--accent-danger);
  border: 1px solid var(--accent-danger);
}
.btn-danger-outline:hover { background: rgba(217, 107, 91, 0.12); }

/* Ticket header: badges on the left, action buttons on the right;
   on narrow screens the actions wrap onto their own full-width row. */
.ticket-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ticket-actions { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 720px) {
  .ticket-actions { width: 100%; justify-content: stretch; }
  .ticket-actions > * { flex: 1 1 auto; }
  .ticket-actions button, .ticket-actions .btn { width: 100%; }
}

.form-narrow { max-width: 400px; }

/* ---------- Auth pages ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column; /* the card, then the copyright line under it */
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.auth-card h1 { font-size: 1.2rem; margin-bottom: 4px; }
.auth-card p.subtitle { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 20px; }
.auth-card-wide { max-width: 480px; } /* room for side-by-side fields */

/* Secondary action under the auth form, e.g. "Request a new tenant". */
.auth-alt {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.auth-alt .btn { text-align: center; }

/* Honeypot field — visually hidden, still in the form for bots to fill. */
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.error-message {
  background: rgba(217, 107, 91, 0.12);
  border: 1px solid var(--accent-danger);
  color: var(--accent-danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

/* ---------- Admin pages ---------- */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.page-head h1 { margin: 0; }

/* Side-by-side form fields that stack on narrow screens. */
.field-row { display: flex; flex-wrap: wrap; gap: 0 12px; }
.field-row > div { flex: 1 1 180px; min-width: 0; }

.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Secondary line inside a table cell (e.g. location title, city line). */
.cell-sub { color: var(--text-muted); font-size: 0.8rem; }

/* Small select inside a table row (member Edit mode). */

select.inline-select { margin: 0; min-width: 130px; padding: 5px 8px; font-size: 0.85rem; }

/* A heads-up that isn't an error (e.g. report emails going outside the organization). */
.warning-message {
  background: rgba(232, 163, 61, 0.12);
  border: 1px solid var(--accent-signal);
  color: var(--accent-signal);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.success-message {
  background: rgba(79, 178, 134, 0.12);
  border: 1px solid var(--accent-ok);
  color: var(--accent-ok);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

/* Copyable invite link shown when the email couldn't be sent. */
input.invite-link {
  margin: 10px 0 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

.stats-and-filter {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.stats-and-filter .stat-grid {
  flex: 1 1 auto;
  margin-bottom: 0;
}

.priority-filter { flex: 0 0 auto; }
.priority-filter select { margin-bottom: 0; min-width: 160px; }

.ticket-entry {
  border-left: 2px solid var(--border);
  padding: 4px 0 4px 14px;
  margin-bottom: 14px;
}

.ticket-entry .meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }

/* Timer icon on a history entry with no end time — clicking it sets
   the entry's end time to now. Plain icon, no button chrome. */
.end-entry-form { display: inline-block; margin: 0 0 0 6px; vertical-align: middle; }
.entry-timer {
  display: inline-flex;
  padding: 0;
  background: none;
  border: none;
  color: var(--brand-green-light);
  vertical-align: middle;
}
.entry-timer:hover { background: none; color: var(--brand-green); }
.entry-timer:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 50%; }
main button.entry-timer[type="submit"] { width: auto; } /* beats the full-width phone rule */

/* ---------- Tables that might overflow on narrow screens ---------- */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Phone layout ---------- */

@media (max-width: 720px) {
  /* Top bar becomes two rows:
       [logo]  Tenant name · role              [theme]
       [ + New ticket ] [ Switch ] [ Sign out ]
     The left/right wrappers dissolve (display: contents) so every item
     is a direct flex child that can be reordered; ::after is a
     zero-height, full-width break between the two rows. */
  .topbar {
    padding: 10px 14px;
    column-gap: 8px;
    row-gap: 4px; /* doubled around the zero-height break → 8px between rows */
  }

  .topbar-left,
  .topbar-right { display: contents; }

  .topbar .brand { order: 1; }

  .topbar-context {
    order: 2;
    flex: 1 1 0;
    min-width: 0;
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .theme-toggle, .topbar .prefs-toggles { order: 3; }

  .topbar::after {
    content: '';
    order: 4;
    flex-basis: 100%;
    height: 0;
  }

  .topbar-right > .btn {
    order: 5;
    flex: 1 1 auto;
    text-align: center;
    padding: 7px 10px;
    font-size: 0.85rem;
  }

  .brand-logo { height: 24px; }

  main { padding: 16px; }

  h1 { font-size: 1.25rem; }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* On the ticket list, tiles and the priority dropdown share one
     2-column grid: 5 tiles + dropdown = 3 even rows, same gaps, and
     the dropdown stretches to the height of the tile beside it. */
  .stats-and-filter {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch; /* tiles in a row share the tallest one's height */
  }

  .stats-and-filter .stat-grid { display: contents; }

  /* Tighter tiles so "Completed / Canceled" fits a half-width column;
     on very narrow phones the label ellipsizes rather than widening it. */
  /* Phones: tiles are equal halves, so their text scales with the tile's
     width (cqi units — each tile is a size container) and every label,
     up to "In Progress / Pending Info", fits on one line. */
  .stat { padding: 8px 10px; gap: 6px; min-width: 0; align-items: center; container-type: inline-size; }
  .stat .stat-value { font-size: 1rem; font-size: clamp(0.85rem, 9.5cqi, 1.15rem); }
  .stat .stat-label {
    font-size: 0.7rem;                          /* fallback for older browsers */
    font-size: clamp(0.6rem, 6.8cqi, 0.8rem);
    overflow: hidden;
    text-overflow: ellipsis;                    /* last resort on tiny screens */
    min-width: 0;
  }

  .priority-filter { display: flex; min-width: 0; }

  .priority-filter select {
    width: 100%;
    min-width: 0;
    height: 100%;
    padding: 8px 10px;
    background: var(--surface);
    font-size: 16px; /* 16px+ stops iOS zooming in when the dropdown is tapped */
  }

  table { min-width: 560px; }

  .card { padding: 14px; }

  main button[type="submit"],
  .auth-card button[type="submit"] { width: 100%; }

  .claim-form {
    flex-direction: column;
    align-items: stretch !important;
    width: 100%;
  }

  .claim-form input[type="number"] { width: 100% !important; }
}

/* "← Back to tickets" link at the foot of admin/invite pages. */
.page-foot { margin: 8px 0 0; }

/* Section heading inside a long form (e.g. "Main location"). */
.form-section {
  margin: 24px 0 4px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--text);
}

/* Compact button for actions inside table rows. */
button.btn-small, .btn.btn-small { padding: 5px 10px; font-size: 0.8rem; }
main button.btn-small[type="submit"] { width: auto; } /* beats the full-width phone rule */

/* ---------- Row actions: hide (ghost) / delete (trash) ---------- */

.actions-col { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: inline-flex; align-items: center; gap: 10px; }
.row-actions form { margin: 0; }

/* Plain icon button — no chrome, just the icon. */
.icon-btn {
  display: inline-flex;
  padding: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  vertical-align: middle;
}
.icon-btn:hover { background: none; color: var(--text); }
.icon-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius); }
.icon-btn.is-on { color: var(--accent-info); }            /* ghost on a hidden row = click to unhide */
.icon-btn-danger:hover { color: var(--accent-danger); }
main button.icon-btn[type="submit"] { width: auto; }       /* beats the full-width phone rule */

/* Hidden tenants / locations / members: greyed out, still manageable. */
tr.row-hidden td { color: var(--text-muted); }
tr.row-hidden td > a, tr.row-hidden td > select { opacity: 0.7; }
.hidden-tag { margin-left: 6px; text-decoration: none; }

/* "Forgot password?" under the sign-in button. */
.forgot-link { margin: 12px 0 0; text-align: center; font-size: 0.85rem; }

/* Pending Info — open but waiting on the affected person: dashed amber. */
.badge-status-pending { color: var(--accent-signal); border-color: var(--accent-signal); border-style: dashed; }


/* Satisfaction slider on the "How did we do?" feedback form. */
.satisfaction-slider { margin-bottom: 16px; }
.satisfaction-slider input[type="range"] { width: 100%; margin: 4px 0 0; accent-color: var(--brand-green); }
.satisfaction-scale { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); }
.satisfaction-slider output { display: block; margin-top: 6px; font-weight: 600; color: var(--brand-green-light); }

/* "📍 At Toronto — travel time filled in" next to the entry's travel field. */
.travel-status { margin: 30px 0 0; min-height: 1.2em; }
@media (max-width: 720px) { .travel-status { margin-top: -8px; margin-bottom: 12px; } }

/* View-only value shown in a form (e.g. an entry's travel time). */
input.readonly-field { background: transparent; border-style: dashed; color: var(--text-muted); cursor: default; }
input.readonly-field:focus { outline-style: dashed; } /* still visible (WCAG 2.4.7) */

/* Phone inputs in a member row's Edit mode (Admin → tenant → Members). */
.phone-edit { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.phone-edit input { margin: 0; width: 130px; padding: 5px 8px; font-size: 0.85rem; }
.phone-edit input.phone-ext { width: 64px; }

/* "Set estimate" on a claimed ticket that has none (ticket details table). */
.inline-estimate { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline-estimate input { width: 90px; margin: 0; padding: 5px 8px; font-size: 0.9rem; }
main .inline-estimate button[type="submit"] { width: auto; } /* beats the full-width phone rule */

/* Invite a user: wider card, two sections (Person / Access). */
.invite-card { max-width: 680px; }
.form-section.form-section-first { margin-top: 0; padding-top: 0; border-top: none; }
.field-row > .field-narrow { flex: 0 0 90px; }
.field-hint { color: var(--text-muted); font-size: 0.8rem; margin: -6px 0 8px; }
.invite-actions { margin-top: 8px; gap: 14px; }
main .invite-actions button[type="submit"] { width: auto; }
@media (max-width: 720px) {
  .invite-actions { flex-direction: column; align-items: stretch; }
  main .invite-actions button[type="submit"] { width: 100%; }
}

/* Table cells that should stay on one line (names, short values). */
.nowrap { white-space: nowrap; }

/* Anything marked hidden stays hidden, even if a class gives it a display. */
[hidden] { display: none !important; }

/* Maintenance task schedule: weekday chips (Sun … Sat). */
.weekday-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 16px; }
.weekday-picker .field-label { font-size: 0.85rem; color: var(--text-muted); margin-right: 4px; }
label.weekday-chip { display: inline-flex; margin: 0; cursor: pointer; }
.weekday-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.weekday-chip span {
  display: inline-block;
  min-width: 44px;
  padding: 6px 8px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.weekday-chip input:checked + span { color: var(--text); border-color: var(--brand-green); background: var(--surface-raised); }
.weekday-chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
input[type="time"] { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 8px 10px; font-family: var(--font-sans); font-size: 0.95rem; margin-bottom: 16px; }

/* Member Edit row: the extra "Reset password" action under Save / Cancel. */
.edit-row-extra { margin: 6px 0 0; }
.reset-btn { display: inline-flex; align-items: center; gap: 5px; }
.reset-btn svg { width: 14px; height: 14px; }

/* Sortable column titles on the ticket list. */
th a.sort-link { color: inherit; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
th a.sort-link:hover { color: var(--text); text-decoration: none; }
th a.sort-link.is-sorted { color: var(--text); }
.sort-icon { flex: 0 0 auto; }
.sort-icon-none { opacity: 0.35; }
th a.sort-link:hover .sort-icon-none { opacity: 0.8; }

/* Clock in / clock out bar (above the ticket tiles). */
.clock-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 12px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.clock-bar.is-on { border-left: 3px solid var(--brand-green); }
.clock-bar .clock-text { flex: 1 1 auto; font-size: 0.9rem; min-width: 0; }
main .clock-bar button[type="submit"] { width: auto; }

/* Tickets worked during a site visit (Admin → Site visits → Edit). */
.visit-tickets { list-style: none; margin: 0 0 8px; padding: 0; }
.visit-tickets li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

/* ---------- Reports ---------- */
.report-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 20px; }
.report-controls > div { min-width: 180px; }
.report-controls select, .report-controls input { margin-bottom: 0; }
.report-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
main .report-buttons button[type="submit"] { width: auto; }
.report-table .num { text-align: right; }
.report-table tfoot th { color: var(--text); font-weight: 600; border-top: 2px solid var(--border); border-bottom: none; }
.report-table tr:hover td { background: transparent; }

/* Printing a report: just the report, on white. */
@media print {
  .topbar, .no-print, .clock-bar, .theme-toggle, .prefs-toggles { display: none !important; }
  :root { --bg: #fff; --surface: #fff; --surface-raised: #fff; --border: #ccc; --text: #000; --text-muted: #444; }
  main, main.main-wide, main.main-wider, main.main-wider-list { padding: 0; max-width: none; }
  .card { break-inside: avoid; border-color: #ccc; }
  .table-scroll { overflow: visible; }
  table { min-width: 0 !important; }
}

/* Report tabs: Site visits · Hours on tickets · 12-month overview. */
.report-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
.report-tabs a { padding: 8px 14px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.report-tabs a:hover { color: var(--text); text-decoration: none; }
.report-tabs a.is-active { color: var(--text); border-bottom-color: var(--brand-green); }

/* Hours on tickets: time over the ticket's estimate. */
.over-estimate { color: var(--accent-signal); font-weight: 600; }

/* 12-month overview grid. */
.overview-table td.cell-empty { color: var(--text-muted); opacity: 0.6; }
.overview-table th .cell-sub { font-weight: 400; }

/* Maintenance tasks: selection column. */
.check-col { width: 1%; }
.check-col input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand-green); }
.tenant-picks { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; }
.tenant-picks .weekday-chip span { min-width: 0; padding: 6px 12px; }

/* Admin → Members: base-location checkbox + tag. */
.base-check { margin: 6px 0 0; font-size: 0.85rem; }
.field-hint.base-help { margin: 6px 0 0; }
.card > .field-hint.base-help { padding: 10px 14px 12px; margin: 0; }
.base-tag { margin-left: 6px; font-size: 0.75rem; color: var(--brand-green); white-space: nowrap; }

/* Checklists: required marker, admin order buttons, and the ticket's fill-in form. */
.required-mark { color: var(--accent-danger); font-weight: 600; }
td.num, th.num { text-align: right; }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.checklist-form { margin-top: 14px; }
.checklist-item { margin-bottom: 4px; }
.checklist-label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }
.checklist-item .tenant-picks { margin-top: 0; }
.checklist-date { max-width: 220px; }
.checklist-phone { max-width: 260px; }

/* Checklist item form: the item's own list of choices. */
.choice-rows { list-style: decimal; margin: 0 0 8px; padding-left: 24px; }
.choice-row { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.choice-row input { flex: 1; margin: 0; }
/* A chart heading's column type: only for Expanding Chart items. */
.choice-row .choice-type { display: none; flex: 0 0 auto; width: auto; min-width: 0; }
#options-field.is-chart .choice-type { display: block; }
.choice-row .choice-total { display: none; margin: 0 4px; font-size: 0.8rem; color: var(--text); white-space: nowrap; }
#options-field.is-chart .choice-total:not([hidden]) { display: inline-flex; align-items: center; gap: 4px; }
.choice-row .choice-total input { width: auto; flex: 0 0 auto; }
.checklist-multi { min-width: 240px; max-width: 100%; }
.checklist-multi-hint { margin: -8px 0 12px; }

/* Ticket list: "Filter by" — the column, then its value box. */
.filter-by { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-by select, .filter-by input { margin-bottom: 0; }
.filter-by input[type="search"], .filter-by input[type="date"] { width: auto; min-width: 160px; }
.filter-clear { color: var(--text-muted); text-decoration: none; padding: 4px 6px; }
.filter-clear:hover { color: var(--text); }
@media (max-width: 640px) {
  .stats-and-filter .filter-by { grid-column: 1 / -1; }
  .filter-by select, .filter-by input[type="search"], .filter-by input[type="date"] { flex: 1 1 140px; min-width: 0; }
}

/* Clock in: pick the site by hand when the device's position doesn't match one. */
.clock-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; flex: 1 1 100%; }
.clock-picker[hidden] { display: none; }
.clock-picker .cell-sub { flex: 1 1 100%; }
.clock-picker select { margin: 0; }

/* Top bar: the tenant · role label doubles as the switcher (more than one membership). */
.topbar-switch {
  text-decoration: none;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}
.topbar-switch:hover, .topbar-switch:focus-visible {
  border-color: var(--border);
  background: var(--surface);
}
.topbar-switch .switch-caret { margin-left: 4px; font-size: 0.75rem; }

/* Ticket checklist: a Done tick per item, and the "n of m done" count. */
.checklist-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 10px 0; border-top: 1px solid var(--border); margin-bottom: 0; }
.checklist-item:first-of-type { border-top: 0; }
.checklist-done { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 2px 0 0;
  font-size: 0.7rem; color: var(--text-muted); cursor: pointer; min-width: 36px; }
.checklist-done input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand-green); cursor: pointer; }
.checklist-item.is-done .checklist-done { color: var(--brand-green); }
.checklist-body > :last-child { margin-bottom: 0; }
.checklist-progress { margin-left: 10px; font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
.checklist-progress.is-complete { color: var(--brand-green); }
.checklist-tick { width: 28px; text-align: center; }
.tick-yes { color: var(--brand-green); font-weight: 600; }
.tick-no { color: var(--text-muted); }
.checklist-warn { margin: 6px 0 0; font-size: 0.8rem; color: var(--accent-danger); }
/* An item that wasn't saved: marked, with why under it. */
.checklist-item.has-error { border-left: 3px solid var(--accent-danger); padding-left: 8px; }
.yesno-clear span { color: var(--text-muted); }

/* Checklist password answers: field + Show/Hide. */
.password-field { display: flex; gap: 6px; align-items: center; }
.password-field input { flex: 1; margin: 0; font-family: 'IBM Plex Mono', monospace; }
.pw-reveal { margin-left: 8px; }

/* Reports → Checklists: one column per item. */
.checklist-report th { min-width: 110px; vertical-align: bottom; }
.checklist-report td { vertical-align: top; }

/* Checklist password answers: a text box drawn as dots (see ticket_view.php). */
.masked-input.is-masked { -webkit-text-security: disc; text-security: disc; }
.manual-site { color: var(--accent-signal); }
.checklist-checkbox { margin: 2px 0 0; font-weight: 500; }

/* Checklist Text Only items: a note, no Done tick. */
.checklist-note-text { color: var(--text-muted); font-size: 0.9rem; font-style: italic; }
.checklist-note-done { font-style: normal; color: var(--text); padding-top: 2px; }

/* Reports → Users: each location's details above its people. */
.users-tenant-heading { margin: 28px 0 12px; }
/* "All tenants" reports: each tenant's section starts with its name. */
/* Hours on tickets: a heading over each site visit's tickets. */
.report-visit-heading { margin: 0; padding: 14px 20px 6px; font-size: 0.9rem; font-weight: 600; border-top: 1px solid var(--border); }
.report-billed-heading { margin: 14px 20px 0; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 1rem; }
.report-tech h2 + .report-visit-heading { border-top: none; }
.report-visit-heading.is-none { color: var(--text-muted); }
.report-tenant-heading { margin: 32px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--brand-green); }
.users-location-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding: 20px 20px 12px; }
.users-location-info { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.users-location-info strong { color: var(--text); font-weight: 500; }
.users-location-info .phone-label { display: inline-block; min-width: 72px; }

/* Reports → Users: every location's table uses the same column widths, so
   the columns line up across locations and tenants, and each person fits on
   one line — anything longer is cut with "…" (full text on hover). Narrow
   screens scroll sideways instead of squeezing. */
.users-table { table-layout: fixed; width: 100%; min-width: 1060px; font-size: 0.85rem; }
.users-table th, .users-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 8px 10px; }
.users-table .col-name { width: 190px; }
.users-table .col-roles { width: 150px; }
.users-table .col-email { width: 250px; }
.users-table .col-main { width: 160px; }
.users-table .col-ext { width: 60px; }
.users-table .col-cell { width: 160px; }
.users-table .col-account { width: 90px; }
.users-table .mono { font-size: 0.8rem; }

/* Phone numbers: + [cc] ( [area] ) [exchange] - [line] (includes/phone.php). */
.phone-parts { display: inline-flex; align-items: center; gap: 3px; flex-wrap: nowrap; max-width: 100%; }
.phone-parts input { width: auto; margin: 0; padding-left: 6px; padding-right: 6px; text-align: center;
  font-family: 'IBM Plex Mono', monospace; }
.phone-parts .ph-cc { width: 3.4em; }
.phone-parts .ph-area, .phone-parts .ph-exchange { width: 3.9em; }
.phone-parts .ph-line { width: 4.8em; }
.phone-parts .ph-sym { color: var(--text-muted); font-family: 'IBM Plex Mono', monospace; }
.phone-old { display: block; margin-top: 4px; }
label + .phone-parts, label + .phone-parts + .phone-old { margin-bottom: 16px; }
.phone-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.phone-edit-label { font-size: 0.75rem; color: var(--text-muted); }

/* Click-to-sort report tables (includes/sortable_tables.php). */
th.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable-th:hover, th.sortable-th.is-sorted { color: var(--text); }
th.sortable-th .sort-icon-slot { display: inline-flex; margin-left: 4px; vertical-align: middle; }
th.sortable-th:hover .sort-icon-none { opacity: 0.8; }
@media print { th.sortable-th .sort-icon-slot { display: none; } }

/* SLA: Admin → SLA targets, Reports → SLA, and the ticket page. */
.sla-table input[type="number"] { width: 90px; margin: 0; display: inline-block; }
.sla-example-row td { border-top: 0; padding-top: 0; }
.sla-example-row .sla-use-example { margin-left: 8px; }
.sla-example-label { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; font-weight: 400; }
.sla-example-label input { flex: 1; margin: 0; }
.sla-ok, .sla-met { color: var(--brand-green); font-weight: 600; }
.sla-miss, .sla-missed { color: var(--accent-danger); font-weight: 600; }
.sla-due { color: var(--text); }

/* Admin → SLA: business hours. */
.sla-hours-table td { padding: 6px 12px 6px 0; border: 0; }
.sla-hours-table input[type="time"] { width: auto; margin: 0; display: inline-block; }
.sla-hours-table input[type="time"]:disabled { opacity: 0.4; }
.sla-business-cell .checkbox-label { white-space: nowrap; }

/* Admin → SLA: holidays. */
.sla-holidays-table td { padding: 6px 12px 6px 0; }
.holiday-forms { display: flex; flex-wrap: wrap; gap: 12px 32px; margin-top: 16px; }
.holiday-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.holiday-add input, .holiday-add select { margin-bottom: 0; width: auto; }

/* Password rules checklist (includes/password_policy.php). */
.password-rules { list-style: none; margin: -6px 0 16px; padding: 0; font-size: 0.82rem; color: var(--text-muted); }
.password-rules li { margin: 2px 0; }
.password-rules .rule-mark { display: inline-block; width: 1.1em; }
.password-rules li.is-met { color: var(--brand-green); }
.must-change { margin: 8px 0 0; font-size: 0.85rem; }
.must-change-tag { color: var(--accent-signal); }
.topbar-icon { display: inline-flex; align-items: center; }

/* ---------- Attachments (files and phone photos on tickets) ---------- */

/* The picker: "Take photo" / "Add files" buttons, then what's been picked. */
.attach-picker { margin: 4px 0 16px; }
.attach-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.attach-btn { position: relative; overflow: hidden; }
/* The real file input sits invisibly over its button, so a tap opens the picker / camera. */
.attach-btn .attach-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; font-size: 0; }
.attach-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.attach-item { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.85rem; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px 8px; overflow-wrap: anywhere; }
.attach-chip img { width: 32px; height: 32px; object-fit: cover; border-radius: 2px; }

/* Shown on the ticket: picture thumbnails and file links. */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attachment { position: relative; display: inline-flex; align-items: flex-start; gap: 2px; }
.attachment-thumb img { display: block; height: 96px; max-width: 160px; object-fit: cover; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); }
.attachment-file { display: inline-flex; align-items: center; gap: 6px; max-width: 280px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); font-size: 0.85rem; }
.attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-delete { margin: 0; }

/* ---------- Copyright line at the bottom of every page ---------- */
.site-footer { padding: 24px 16px; text-align: center; color: var(--text-muted); font-size: 0.78rem; }
.auth-page .site-footer { padding-bottom: 0; }
@media print { .site-footer { padding: 12px 0 0; } }

/* Line under a page title, e.g. "Reports – Site visits" / tenant · month. */
.page-subtitle { margin: 2px 0 0; color: var(--text-muted); font-size: 0.9rem; }

/* ---------- ⚙ menu in the top bar (My profile, Change password, Sign out) ---------- */
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; }
.user-menu > summary::-webkit-details-marker { display: none; }
/* The button: ⚙ ▾, like a pulldown. */
.user-menu-button { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 10px;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.user-menu-button:hover, .user-menu[open] > .user-menu-button { background: var(--surface-raised); }
.user-menu-button .switch-caret { font-size: 0.75rem; color: var(--text-muted); transition: transform 0.15s; }
.user-menu[open] > .user-menu-button .switch-caret { transform: rotate(180deg); }
@media (max-width: 720px) {
  .topbar .user-menu { order: 3; } /* beside the EN | FR and theme toggles on phones */
}
.user-menu-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; z-index: 50;
  display: flex; flex-direction: column; padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); }
.user-menu-head { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.user-menu-panel a { padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 0.9rem; }
.user-menu-panel a:hover { background: var(--surface-raised); text-decoration: none; }
/* ⚙ menu → Email testing (MSP Admins): a row with an on/off switch. */
.user-menu-form { margin: 0; }
.user-menu-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit;
  font-size: 0.9rem; text-align: left; cursor: pointer; }
.user-menu-toggle:hover { background: var(--surface-raised); }
.user-menu-toggle-text { display: flex; flex-direction: column; gap: 2px; }
.mini-switch { position: relative; flex: none; width: 34px; height: 20px; border-radius: 999px;
  background: var(--border); transition: background 0.15s; }
.mini-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; transition: transform 0.15s; }
.mini-switch.is-on { background: var(--accent-signal); }
.mini-switch.is-on::after { transform: translateX(14px); }
.email-test-banner { margin-bottom: 16px; }
.phone-with-ext { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.phone-with-ext .phone-ext { width: 80px; }

/* Clock bar: the site pulldown and the Parking box. */
.clock-site-picker { max-width: 360px; }
.clock-bar .clock-label { display: inline; margin: 0; font-size: 0.9rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.clock-parking { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 0.85rem; white-space: nowrap; }
.clock-parking input { width: 90px; margin: 0; }

/* Clock bar → New site… (MSP Admins). */
.clock-new-site { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; }
.clock-new-site p { flex-basis: 100%; }
.clock-new-site label { margin: 0; font-size: 0.85rem; }
.clock-new-site input[type="text"] { width: auto; min-width: 180px; margin: 0; }

/* New ticket → "+ New tenant / location / person" fields. */
.new-entity-fields { margin: -6px 0 14px; padding: 10px 12px; border-left: 3px solid var(--brand-green); background: var(--surface-raised); border-radius: var(--radius); }
.new-entity-fields label:first-child { margin-top: 0; }

/* Ticket page → Edit ticket (MSP Admins). */
.edit-ticket-form { margin-top: 8px; max-width: 560px; }
.edit-ticket-form textarea, .edit-ticket-form select { width: 100%; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Ticket page → Edit dates (MSP Admins). */
.edit-dates summary { cursor: pointer; color: var(--text-muted); font-size: 0.85rem; }
.edit-dates-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; }
.edit-dates-form label { margin: 0; }
.edit-dates-form .field-hint { flex-basis: 100%; margin: 0; }

/* Reports → ✉ Email: the address box under the report controls. */
.report-email-panel { max-width: 560px; margin: -4px 0 16px; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; }
.report-email-panel input[type="text"] { width: 100%; }

/* "✉ Scheduled emails" at the end of the report tabs. */
.report-tabs .report-tabs-extra { margin-left: auto; }

/* "What each role can do" chart (admin_tenant.php, includes/role_chart.php). */
.role-chart td:first-child { min-width: 220px; }
.role-chart .role-col { text-align: center; white-space: normal; min-width: 90px; font-size: 0.82rem; }
.role-chart .role-yes { color: var(--accent-ok); font-weight: 700; font-size: 1rem; }
.role-chart .role-no { color: var(--text-muted); }
.role-chart .role-some { color: var(--text); }
.role-chart .role-section th { text-align: left; background: var(--surface-raised); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

/* ---------- Accessibility (WCAG 2.1 AA) ---------- */

/* A visible focus ring on everything you can tab to (2.4.7). */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn-secondary:hover { background: var(--surface-raised); color: var(--text); }
.btn-danger-outline:hover { color: var(--accent-danger); }

/* "Skip to main content" — the first thing Tab reaches; shown when focused (2.4.1). */
.skip-link { position: absolute; left: 8px; top: -100px; z-index: 100; padding: 8px 14px;
  background: var(--surface); color: var(--text); border: 2px solid var(--focus); border-radius: var(--radius); }
.skip-link:focus { top: 8px; text-decoration: none; }
main:focus { outline: none; } /* focused only by the skip link */

/* Links inside sentences are underlined, not told apart by colour alone (1.4.1). */
main p a:not(.btn), .field-hint a, .cell-sub a, .error-message a, .warning-message a, .success-message a, .auth-alt a, li > a:not(.btn) { text-decoration: underline; }

/* Label cells of the ticket's detail tables (row headers for screen readers). */
fieldset.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
th.kv-label { text-align: left; font-weight: 400; color: var(--text-muted); vertical-align: top; }

/* Sortable report columns: the heading text is a real button (keyboard + screen readers). */
button.sort-btn { display: inline-flex; align-items: center; gap: 4px; padding: 0; margin: 0; background: none; border: 0;
  color: inherit; font: inherit; text-align: inherit; cursor: pointer; }
button.sort-btn:hover { background: none; text-decoration: underline; }

/* Less motion for people who ask their system for it (2.3.3 good practice). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

/* Number checklist items: a narrower box; $ in front for dollar amounts. */
.number-field { display: flex; align-items: center; max-width: 220px; margin-bottom: 16px; }
.number-field input { margin: 0; text-align: right; }
.number-field .number-prefix { padding: 0 8px 0 0; color: var(--text-muted); font-weight: 600; }

/* Expanding Chart checklist items: how many rows, then the table to fill in. */
.chart-field { margin: 4px 0 16px; }
.chart-field .chart-count-label { display: inline; margin-right: 8px; }
.chart-field input.chart-count { width: 90px; margin: 0 0 10px; }

/* The chart as a spreadsheet: grid lines, a shaded heading row and row
   numbers, boxes that fill their cells, the cell being typed in outlined. */
.chart-table { border-collapse: collapse; font-size: 0.85rem; background: var(--bg); }
.chart-table th, .chart-table td { border: 1px solid var(--input-border); padding: 0; height: 32px; }
.chart-table thead th { background: var(--surface-raised); color: var(--text); font-weight: 600; text-align: left;
  padding: 4px 10px; white-space: nowrap; }
.chart-table .chart-rownum { width: 1%; min-width: 40px; padding: 4px 8px; text-align: center; white-space: nowrap;
  background: var(--surface-raised); color: var(--text-muted); font-weight: 400; }
.chart-table td input, .chart-table td select { display: block; width: 100%; min-width: 120px; height: 100%; margin: 0;
  padding: 5px 8px; border: 0; border-radius: 0; background: transparent; color: var(--text); font-size: 0.85rem; }
.chart-table td input:focus, .chart-table td select:focus { outline: none; } /* the cell's outline shows instead */
.chart-table td:focus-within { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--surface); }
.chart-table td input.chart-number { min-width: 100px; text-align: right; font-variant-numeric: tabular-nums; }
.chart-table td.num, .chart-table td.chart-total { text-align: right; font-variant-numeric: tabular-nums; }
.chart-table .chart-total-row th, .chart-table .chart-total-row td { background: var(--surface-raised); font-weight: 700;
  border-top: 2px solid var(--text-muted); padding: 4px 8px; }
.chart-table-view td { padding: 4px 10px; white-space: normal; }
/* Notes and web-address checklist items. */
textarea.checklist-notes { min-height: 90px; }
a.checklist-url { word-break: break-all; }
.checklist-ticket-label { color: var(--text-muted); margin-right: 4px; }
/* The checklist's PDF download, beside its title on the ticket. */
h2 .checklist-pdf { vertical-align: middle; margin-left: 8px; font-size: 0.8rem; font-weight: 600; }
h2 .checklist-pdf.is-disabled, h2 .checklist-pdf.is-disabled:hover { opacity: 0.45; cursor: not-allowed; background: transparent; }

/* ---------- Checklist print layout (admin_checklist_layout.php) ---------- */
/* The toolbar stays in view while scrolling down the pages. */
.layout-toolbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px; }
.layout-inspector { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.layout-inspector label { display: inline; margin: 0 0 0 6px; font-size: 0.8rem; }
.layout-inspector select { max-width: 220px; }
.layout-inspector input.layout-num { width: 72px; margin: 0; padding: 4px 6px; }
.layout-stage { display: flex; flex-direction: column; gap: 22px; padding: 18px; background: var(--surface-raised); border-radius: var(--radius); }
/* The sheet is paper: white with dark text in both themes. */
.layout-page { position: relative; width: 100%; max-width: 765px; margin: 0 auto; aspect-ratio: 612 / 792; background: #ffffff; color: #111111;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.3); touch-action: none; user-select: none; overflow: hidden; }
.layout-band { position: absolute; left: 0; right: 0; display: flex; align-items: center; padding: 0 5%; font-size: 0.7rem; color: #555555;
  background: repeating-linear-gradient(45deg, #f1f3f5, #f1f3f5 6px, #e7eaed 6px, #e7eaed 12px); }
.layout-margins { position: absolute; border: 1px dashed #b6bec6; pointer-events: none; }
.layout-box { position: absolute; padding: 2px 5px; overflow: hidden; border: 1px solid #77828d; background: rgba(42, 122, 39, 0.07);
  cursor: move; font-size: 0.72rem; line-height: 1.25; color: #111111; }
.layout-box strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layout-box .layout-type { display: block; color: #4a545e; font-size: 0.66rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layout-box.is-selected { z-index: 2; border: 2px solid #1f661d; background: rgba(42, 122, 39, 0.16); }
.layout-box.is-primary { box-shadow: 0 0 0 2px rgba(31, 102, 29, 0.35); } /* the one the number boxes show */
/* The rectangle drawn to select several boxes. */
.layout-marquee { position: absolute; z-index: 3; border: 1px dashed #1f661d; background: rgba(42, 122, 39, 0.12); pointer-events: none; }
.layout-box:focus-visible { outline: 3px solid #1f661d; outline-offset: 1px; }
.layout-handle { position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, #1f661d 50%); }
.layout-clear { margin-top: 12px; }
/* The blank sheet at the end: drop a box on it to start a new page. */
.layout-page.is-spare { opacity: 0.6; outline: 2px dashed #77828d; outline-offset: -2px; }
.layout-spare-note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;
  color: #4a545e; font-size: 0.9rem; }

/* ---------- Projects (projects.php, project.php) ---------- */
.badge-project { color: var(--accent-info); border-color: var(--accent-info); margin-right: 6px; white-space: nowrap; }
/* Checklists: the bulk Export / Duplicate at the list's top right. */
.bulk-head { padding: 14px 20px 4px; }
.bulk-actions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.bulk-import input[type="file"] { width: auto; max-width: 230px; margin: 0; font-size: 0.8rem; }
.badge-schedule { margin-left: 6px; color: var(--text-muted); border-color: var(--input-border); font-size: 0.7rem; }
a.task-edit-link { font-weight: 600; }
#task-start-field.is-derived input { opacity: 0.6; }
.project-facts { margin-bottom: 4px; }
.project-facts .kv-label { width: 140px; }
/* The Gantt chart: a label column, then a day scale (bars placed in %). */
.gantt { min-width: 720px; font-size: 0.8rem; }
.gantt-row { display: grid; grid-template-columns: 210px minmax(0, 1fr); align-items: stretch; border-bottom: 1px solid var(--border); }
.gantt-label { padding: 6px 10px 6px 0; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.gantt-task { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-track { position: relative; min-height: 34px;
  background: repeating-linear-gradient(to right, transparent 0, transparent calc(700% / var(--gantt-days) - 1px), var(--border) calc(700% / var(--gantt-days) - 1px), var(--border) calc(700% / var(--gantt-days))); }
.gantt-scale .gantt-track { min-height: 24px; background: none; }
.gantt-tick { position: absolute; top: 4px; padding-left: 3px; border-left: 1px solid var(--input-border); color: var(--text-muted); font-size: 0.7rem; white-space: nowrap; }
.gantt-bar { position: absolute; height: 12px; border-radius: 3px; }
.gantt-planned { top: 5px; border: 2px solid var(--accent-info); background: color-mix(in srgb, var(--accent-info) 15%, transparent); }
.gantt-actual { top: 19px; height: 9px; }
.gantt-actual.is-active { background: var(--accent-signal); }
.gantt-actual.is-done { background: var(--accent-ok); }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent-danger); }
.gantt-project-line { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--text-muted); }
.gantt-legend { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.gantt-key { display: inline-block; width: 18px; height: 10px; border-radius: 2px; vertical-align: middle; position: static; }
.gantt-key.gantt-planned { border: 2px solid var(--accent-info); }
.gantt-today-key { width: 3px; height: 14px; background: var(--accent-danger); }

/* Confirmation pop-ups (High / Critical priority — includes/priority_confirm.php). */
.confirm-dialog { max-width: 460px; width: calc(100% - 32px); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 20px; }
.confirm-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.confirm-dialog h2 { margin: 0 0 10px; font-size: 1.1rem; }
.confirm-dialog p { margin: 0 0 10px; }
.confirm-dialog .form-actions { margin-top: 14px; }

/* Admin → Email templates: English and French side by side, the placeholders, Preview. */
.template-langs { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.template-lang { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0; min-width: 0; }
.template-lang legend { padding: 0 6px; font-weight: 600; }
.template-lang textarea.mono-text { font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.45; }
.template-preview { margin-top: 10px; padding: 10px 12px; background: var(--surface-raised); border-radius: var(--radius); }
.template-preview pre { white-space: pre-wrap; margin: 6px 0 0; font-family: var(--font-sans); font-size: 0.9rem; }
.placeholder-list th { width: 180px; }
tr.row-current td { background: var(--surface-raised); }
tr.group-row th { background: var(--surface-raised); text-align: left; font-weight: 600; }
/* 🎙 Voice note (includes/voice_notes.php) */
.voice-note { margin: -8px 0 12px; }
.voice-buttons, .voice-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.voice-panel { margin-top: 8px; padding: 10px 12px; border-left: 3px solid var(--brand-green); background: var(--surface-raised); border-radius: var(--radius); }
.voice-status { margin: 0 0 6px; }
.voice-status.voice-error { color: var(--accent-danger); }
.voice-text { min-height: 2.5em; max-height: 12em; overflow-y: auto; margin-bottom: 8px; padding: 6px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); white-space: pre-wrap; }
.voice-text:empty::before { content: "…"; color: var(--text-muted); }
.voice-camera { margin-bottom: 8px; }
.voice-video { width: 100%; max-height: 260px; background: #000; border-radius: var(--radius); }
