:root {
  --bg: #ffffff;
  --paper: #ffffff;
  --ink: #122642;
  --muted: #53657d;
  --line: #dce5ef;
  --red: #c91620;
  --red-dark: #a91119;
  --blue: #1289c9;
  --blue-dark: #0c5d92;
  --soft: #f5f9fc;
  --success: #147a47;
  --warning: #a95f00;
  --danger: #a91119;
  --shadow: 0 18px 50px rgba(18, 38, 66, 0.08);
  color: var(--ink);
  background: var(--bg);
  font-family: "Avenir Next", "Trebuchet MS", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

a {
  color: var(--blue-dark);
  text-underline-offset: 0.16em;
}

a:hover {
  color: var(--blue);
}

button,
input,
select {
  font: inherit;
}

button,
.button,
.nav-tab,
.pager a {
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease,
    box-shadow 140ms ease;
}

:focus-visible {
  outline: 3px solid rgba(18, 137, 201, 0.34);
  outline-offset: 2px;
}

.topbar {
  background: var(--paper);
  border-bottom: 1px solid rgba(220, 229, 239, 0.82);
  margin: 0 auto;
  max-width: 1500px;
  padding: 8px 24px 14px;
}

.topbar-main {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 118px;
}

.brand-block {
  align-items: center;
  display: flex;
  gap: 22px;
  min-width: 0;
}

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

.brand-logo img {
  display: block;
  height: 92px;
  object-fit: contain;
  width: auto;
}

.brand-copy {
  min-width: 0;
}

.brand {
  color: var(--ink);
  display: inline-block;
  font-size: 30px;
  font-weight: 900;
  line-height: 1.1;
  margin: 0 0 6px;
  text-decoration: none;
}

.brand:hover {
  color: var(--ink);
}

.brand-copy p {
  color: var(--muted);
  font-weight: 800;
  margin: 0;
}

.identity {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  gap: 10px;
  margin-left: 24px;
}

.identity form {
  margin: 0;
}

.link-button {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  min-height: 34px;
  padding: 6px 12px;
}

.link-button:hover {
  border-color: var(--red);
  color: var(--red-dark);
}

.primary-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-tab {
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-weight: 900;
  min-height: 36px;
  padding: 7px 14px;
  text-decoration: none;
}

.nav-tab:hover {
  background: var(--soft);
  border-color: var(--blue);
  color: var(--blue-dark);
}

.nav-tab.active {
  background: var(--red);
  border-color: var(--red);
  box-shadow: 0 12px 24px rgba(201, 22, 32, 0.18);
  color: #ffffff;
}

.nav-tab.active:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
  color: #ffffff;
}

.environment-banner,
.auth-warning {
  margin: 0;
  text-align: center;
}

.environment-banner {
  background: #e9f2ff;
  border-bottom: 1px solid #b8cef0;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 900;
  padding: 8px 16px;
}

.auth-warning {
  border-radius: 0;
  border-width: 0 0 1px;
  padding: 9px 16px;
}

.app-main {
  margin: 0 auto;
  max-width: 1500px;
  min-height: calc(100vh - 190px);
  padding: 24px;
}

.page-heading {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-heading h1,
.login-card h1 {
  color: var(--ink);
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1.12;
  margin: 0;
}

.eyebrow {
  color: var(--red);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.button,
button[type="submit"] {
  align-items: center;
  background: var(--red);
  border: 1px solid var(--red);
  border-radius: 999px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 38px;
  padding: 7px 15px;
  text-decoration: none;
}

.button:hover,
button[type="submit"]:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
  color: #ffffff;
}

.secondary-button {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover {
  background: var(--soft);
  border-color: var(--blue);
  color: var(--blue-dark);
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 14px;
}

.metric-grid article {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 106px;
  padding: 16px;
}

.metric-grid span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 10px;
}

.metric-grid strong {
  color: var(--ink);
  display: block;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.notice {
  align-items: start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  padding: 18px;
}

.notice-marker {
  background: var(--blue);
  border: 4px solid #e9f5fc;
  border-radius: 999px;
  flex: 0 0 auto;
  height: 16px;
  margin-top: 2px;
  width: 16px;
}

.notice h2 {
  font-size: 16px;
  font-weight: 900;
  margin: 0 0 5px;
}

.notice p {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.pipeline-toolbar, .pipeline-board-help {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  margin: 16px 0;
}
.pipeline-toolbar p { margin: 0; }
.pipeline-board-help { font-size: 13px; }
.pipeline-board {
  display: flex;
  align-items: stretch;
  gap: 16px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-color: #8198b3 #edf2f7;
  padding: 4px 2px 20px;
  margin-bottom: 18px;
}
.pipeline-column {
  --stage-color: #1289c9;
  flex: 0 0 300px;
  min-width: 0;
  background: #f3f6fa;
  border: 1px solid var(--line);
  border-top: 4px solid var(--stage-color);
  border-radius: 12px;
  scroll-snap-align: start;
}
.pipeline-column[data-phase="outside_initial_window"] { --stage-color: #8198b3; }
.pipeline-column[data-phase="initial_candidate_review"],
.pipeline-column[data-phase="follow_up_candidate_review"] { --stage-color: #bd840b; }
.pipeline-column[data-phase="initial_candidate_approved"],
.pipeline-column[data-phase="follow_up_candidate_approved"] { --stage-color: #5e66ba; }
.pipeline-column[data-phase="terminal"] { --stage-color: #147a47; }
.pipeline-column-alternative { --stage-color: #a55d59; background: #faf5f4; }
.pipeline-column-header { padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.pipeline-column-header > div { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.pipeline-column-header h2 { font-size: 16px; line-height: 1.4; margin: 0; }
.pipeline-column-header p { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.pipeline-column-header .pipeline-column-step { text-transform: uppercase; letter-spacing: .1em; font-size: 10px; font-weight: 700; margin: 0 0 12px; }
.pipeline-column-count { border-radius: 20px; padding: 4px 10px; background: white; border: 1px solid var(--line); font-weight: 700; }
.pipeline-column-cards { padding: 12px; display: grid; align-content: start; gap: 12px; min-height: 350px; }
.pipeline-card { background: white; border: 1px solid var(--line); border-radius: 9px; padding: 16px; box-shadow: 0 3px 8px rgba(18,38,66,.04); min-width: 0; }
.pipeline-card-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pipeline-card-type { color: var(--muted); font-size: 11px; }
.pipeline-card-date { font-size: 11px; font-weight: 700; border-radius: 4px; padding: 4px 6px; background: var(--soft); }
.pipeline-card h3 { margin: 18px 0 8px; font-size: 17px; }
.pipeline-card h3 a { color: var(--ink); text-decoration: none; }
.pipeline-card h3 a:hover { text-decoration: underline; }
.pipeline-card-plant, .pipeline-card-contact { font-size: 13px; margin: 6px 0; overflow-wrap: anywhere; }
.pipeline-card-contact { color: var(--muted); }
.pipeline-card-review { font-size: 11px; color: var(--muted); margin: 18px 0; display: grid; gap: 5px; }
.pipeline-card-review strong { color: var(--ink); font-size: 12px; }
.pipeline-card-open { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; text-decoration: none; }
.pipeline-card-details { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 16px; font-size: 11px; color: var(--muted); }
.pipeline-card-details summary { cursor: pointer; }
.pipeline-card-details dt { font-weight: 700; margin-top: 10px; }
.pipeline-card-details dd { margin: 4px 0; overflow-wrap: anywhere; }
.pipeline-column-empty { color: var(--muted); font-size: 13px; line-height: 1.6; padding: 20px 8px; text-align: center; }
@media (max-width: 470px) {
  .pipeline-column { flex-basis: min(300px, 82vw); }
}

.operator-action {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  margin: 16px 0;
  max-width: 720px;
  padding: 20px;
}

.operator-action .confirmation {
  align-items: start;
  display: flex;
  gap: 10px;
  line-height: 1.5;
}

.operator-action input[type="checkbox"] {
  flex: 0 0 20px;
  height: 20px;
  min-height: 20px;
  width: 20px;
}

.operator-action button {
  justify-self: start;
}

.filters {
  align-items: end;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
  margin-bottom: 14px;
  padding: 14px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 900;
  gap: 6px;
  min-width: 0;
}

input,
select {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  min-height: 40px;
  min-width: 0;
  padding: 7px 13px;
  width: 100%;
}

input:hover,
select:hover {
  border-color: #b9c8d8;
}

input:focus,
select:focus {
  background: var(--paper);
  border-color: var(--blue);
}

.table-scroll {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 100%;
  overflow: auto;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 820px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid #edf2f6;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

thead th {
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  position: sticky;
  top: 0;
  z-index: 2;
}

tbody th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

td {
  font-size: 13px;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td,
tbody tr:hover th {
  background: #fbfdff;
}

time {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.pager {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  font-weight: 800;
  gap: 12px;
  justify-content: space-between;
  margin: 14px 0;
}

.pager > span:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pager a {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue-dark);
  display: inline-flex;
  font-weight: 900;
  min-height: 32px;
  padding: 5px 12px;
  text-decoration: none;
}

.pager a:hover {
  background: var(--soft);
  border-color: var(--blue);
  color: var(--blue-dark);
}

.week-pager {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-top: 0;
  padding: 10px 12px;
}

.week-pager strong {
  color: var(--ink);
  font-size: 14px;
  text-align: center;
}

.day-block {
  margin: 16px 0;
}

.day-block h2 {
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  margin: 0 0 8px;
}

.week-table {
  table-layout: fixed;
  min-width: 980px;
}

.week-table th:first-child {
  left: 0;
  position: sticky;
  width: 118px;
  z-index: 1;
}

.week-table thead th:first-child {
  z-index: 3;
}

.week-table tbody th {
  background: var(--paper);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.week-table td {
  height: 76px;
  padding: 8px;
}

.appointment {
  background: #fbfdff;
  border-left: 4px solid var(--warning);
  border-radius: 0 8px 8px 0;
  display: grid;
  gap: 7px;
  min-height: 58px;
  padding: 7px 8px;
}

.appointment.confirmed {
  border-left-color: var(--success);
}

.appointment.cancelled {
  border-left-color: var(--danger);
}

.appointment small {
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.status {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  min-height: 26px;
  padding: 3px 9px;
  white-space: nowrap;
  width: fit-content;
}

.status.provisional {
  background: #fff5e8;
  border-color: #f1c896;
  color: #7a4300;
}

.status.confirmed {
  background: #edf8f2;
  border-color: #b8dfc6;
  color: #0f5e35;
}

.status.cancelled {
  background: #fff0f0;
  border-color: #e5b9b9;
  color: #8f1d1d;
}

.free {
  color: #7b8ca1;
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 2px;
}

.empty {
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

p.empty {
  background: var(--soft);
  border: 1px dashed #b9c8d8;
  border-radius: 8px;
  padding: 16px;
  text-align: left;
}

td.empty {
  padding: 30px 16px;
}

.alert {
  background: #fff0f0;
  border: 1px solid #e5b9b9;
  border-radius: 8px;
  color: #8f1d1d;
  line-height: 1.45;
  padding: 11px 13px;
}

.alert.auth-warning {
  border-radius: 0;
  border-width: 0 0 1px;
  margin: 0;
  padding: 9px 16px;
}

.login-page {
  background: var(--soft);
  min-height: 100vh;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.login-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
  width: min(470px, 100%);
}

.login-brand {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
}

.login-brand img {
  display: block;
  height: 70px;
  object-fit: contain;
  width: auto;
}

.login-brand .eyebrow {
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  margin: 0;
}

.login-card > p:not(.alert) {
  color: var(--muted);
  line-height: 1.5;
  margin: 8px 0 20px;
}

.login-card form {
  display: grid;
  gap: 15px;
}

.login-card button[type="submit"] {
  margin-top: 4px;
  width: 100%;
}

@media (max-width: 1040px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filters button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 8px 14px 12px;
  }

  .topbar-main {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 8px 0 12px;
  }

  .brand-block {
    gap: 12px;
  }

  .brand-logo img {
    height: 64px;
  }

  .brand {
    font-size: 24px;
  }

  .brand-copy p {
    font-size: 13px;
  }

  .identity {
    flex-wrap: wrap;
    justify-content: space-between;
    margin-left: 0;
    width: 100%;
  }

  .primary-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-tab {
    flex: 0 0 auto;
  }

  .app-main {
    padding: 18px 14px 28px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .filters button {
    grid-column: auto;
    width: 100%;
  }

  .pager {
    align-items: stretch;
    flex-direction: column;
  }

  .week-pager {
    align-items: center;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .week-pager strong {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .week-pager a:last-child {
    justify-self: end;
  }

  .login-shell {
    padding: 14px;
  }

  .login-card {
    padding: 22px;
  }
}

@media (max-width: 470px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid article {
    min-height: 92px;
  }

  .login-brand {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  button,
  .button,
  .nav-tab,
  .pager a {
    transition: none;
  }
}

.record-traceability { margin: .65rem 0; font-size: .85rem; }
.record-traceability div { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: .4rem; }
.record-traceability dt { font-weight: 600; }
.record-traceability dd { margin: 0; overflow-wrap: anywhere; }

/* Real, administrator-triggered WhatsApp proofs. */
.review-proof { max-width: 960px; margin: 0 auto; }
.proof-card { background: #fff; border: 1px solid #dbe4ef; border-radius: 16px; padding: 24px; margin: 24px 0; overflow-wrap: anywhere; }
.proof-card blockquote { border-left: 4px solid #145779; margin: 20px 0; padding: 12px 20px; background: #f3f7fb; }
.proof-confirm { display: flex; align-items: center; gap: 12px; margin: 20px 0; }
.proof-confirm input[type="checkbox"] { width: 20px; height: 20px; flex: 0 0 20px; margin: 0; }

/* The entire compact maintenance card is an accessible detail link. */
.pipeline-card-link { display: block; margin: -16px; padding: 16px; border-radius: 9px; color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.pipeline-card-link:hover { background: var(--soft); }
.pipeline-card-link:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
.pipeline-card-link p { margin: 0; }

.contact-tag { padding: 3px 8px; border-radius: 12px; background: #e8eef6; color: #243d60; font-size: .75rem; font-weight: 600; }
.contact-tag-whatsapp { background: #dcf3e4; color: #195d32; }
.contact-tag-email, .contact-tag-pec { background: #ede6f7; color: #573478; }
.contact-tag-other, .contact-tag-none { background: #fff0d4; color: #714800; }
.pipeline-card-contacts { list-style: none; padding: 0; margin: 6px 0 0; font-size: .85rem; }
.pipeline-card-contacts li + li { margin-top: 4px; }
.pipeline-card-compact { padding: 10px; }
.pipeline-card-compact .pipeline-card-link { margin: -10px; padding: 10px; }
.pipeline-card-compact h3 { margin: 8px 0 4px; font-size: 15px; }
.pipeline-card-compact .pipeline-card-link > p { font-size: 12px; }
.pipeline-card-contacts li { display: flex; align-items: baseline; gap: 6px; }
.pipeline-card-contacts .contact-tag { flex-shrink: 0; padding: 2px 6px; }
.pipeline-card-contacts li > span:last-child { min-width: 0; overflow-wrap: anywhere; }

.pipeline-card-link .sequence-card-status { margin-top: 6px; color: var(--muted); font-size: 11px; }
.sequence-detail { border: 1px solid var(--line); padding: 16px; margin: 18px 0; border-radius: 9px; overflow-wrap: anywhere; }
.sequence-detail li + li { margin-top: 8px; }

/* Manual pipeline movement and conversations. */
.pipeline-card-compact { position: relative; }
.pipeline-card[draggable="true"] { cursor: grab; }
.pipeline-card.dragging { opacity: .45; }
.pipeline-column.drop-target { outline: 2px solid #d76524; outline-offset: -2px; }
.card-move-button { position: absolute; top: .2rem; right: .2rem; padding: .15rem .4rem; background: transparent; color: #555; border: 0; cursor: grab; font-size: 1.25rem; }
.pipeline-card-date { padding-right: 1.25rem; }
.card-conversation { display: block; font-size: .78rem; padding: .35rem .7rem; border-top: 1px solid #eee; }
.unread-badge { display: inline-block; background: #fff0d7; color: #773c00; border-radius: .35rem; padding: .15rem .4rem; font-weight: 600; font-size: .78rem; }
.unread-badge[hidden] { display: none; }
.sequence-card-reason { font-size: .75rem; color: #773c00; }
dialog { border: 1px solid #ddd; border-radius: .7rem; padding: 1.5rem; max-width: min(28rem, 90vw); }
dialog::backdrop { background: #0005; }
.conversation-preview, .conversation-message { padding: 1rem; border: 1px solid #ddd; border-radius: .6rem; margin-block: .7rem; }
.conversation-message.outbound { background: #f2f5f1; margin-left: 2rem; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; }

.conversation-composer { margin-top: 1.5rem; max-width: 48rem; }
.conversation-composer label { display: block; margin-top: .75rem; }
.conversation-composer textarea, .conversation-composer input:not([type="hidden"]) { width: 100%; box-sizing: border-box; }
.conversation-composer textarea { font: inherit; padding: .75rem; }
.conversation-composer button:disabled { opacity: .55; cursor: not-allowed; }

/* Full-width maintenance board: fit more phases without shrinking text. */
.app-main.app-main-pipeline { max-width: none; padding: 0; }
.app-main.pipeline-top { min-height: 0; padding-bottom: 0; }
.app-main-pipeline .pipeline-board {
  margin-left: 12px;
  margin-right: 12px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(160px, 1fr);
  gap: 8px;
}
.app-main-pipeline .pipeline-column { border-radius: 8px; }
.app-main-pipeline .pipeline-column-header { padding: 10px 8px; }
.app-main-pipeline .pipeline-column-header > div { gap: 4px; align-items: flex-start; }
.app-main-pipeline .pipeline-column-header h2 { font-size: 13px; overflow-wrap: anywhere; }
.app-main-pipeline .pipeline-column-count { flex-shrink: 0; padding: 2px 6px; font-size: 12px; }
.app-main-pipeline .pipeline-column-cards { padding: 6px; gap: 8px; }
.app-main-pipeline .pipeline-card-compact { padding: 8px; }
.app-main-pipeline .pipeline-card-compact .pipeline-card-link { margin: -8px; padding: 8px; }
.app-main-pipeline .pipeline-card-contacts li { flex-wrap: wrap; gap: 2px 4px; }
.app-main-pipeline .pipeline-card-contacts li > span { max-width: 100%; overflow-wrap: anywhere; }
.app-main-pipeline .pipeline-column-empty { padding: 12px 2px; font-size: 12px; }
@media (max-width: 760px) {
  .app-main-pipeline .pipeline-board { grid-auto-columns: minmax(224px, 80vw); }
}

.calendar-scroll{overflow-x:auto}.calendar-grid{display:grid;gap:8px;grid-template-columns:repeat(7,minmax(160px,1fr))}.calendar-day{border:1px solid #dbe3ec;border-radius:8px;padding:10px;min-height:140px}.calendar-day h2{font-size:14px}.calendar-entry{background:#eef4fa;border-radius:6px;padding:9px;margin:8px 0;font-size:13px;overflow-wrap:anywhere}.calendar-entry p{margin:5px 0}.calendar-note{white-space:pre-wrap}.calendar-day.calendar-outside{opacity:.65}.calendar-day .empty{font-size:12px}.calendar-grid.calendar-day{display:block;border:0;padding:0}.calendar-day.calendar-grid>.calendar-day{min-height:0}.calendar-day.calendar-grid .calendar-entry{max-width:900px}

.calendar-grid.calendar-list{display:block}.calendar-list .calendar-day{min-height:0;margin-bottom:12px}

/* Single overview panel: phase counters and general indicators share one grid. */
.home-analytics { margin: 12px 0; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.home-analytics h2 { margin: 0 0 12px; font-size: 16px; }
.home-analytics .home-summary { margin: 0; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; }
.home-summary > a, .home-summary > article { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 12px; border: 0; border-radius: 0; box-shadow: none; background: transparent; text-decoration: none; color: var(--ink); }
.home-summary > a:hover { background: var(--soft); }
.home-summary > a:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.home-summary strong { font-size: 26px; }
.home-summary small { color: var(--muted); font-size: 11px; }
.home-analytics-context { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.pipeline-data-links { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.pipeline-import-summary > strong { display: block; margin-bottom: 4px; }
.home-analytics-context p { margin: 0 0 6px; }
@media (max-width: 480px) {
  .home-analytics { padding: 10px; }
  .home-analytics .home-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-summary > a, .home-summary > article { padding: 10px 6px; overflow-wrap: anywhere; }
}

.card-detail-dialog { width: min(1000px, calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: 90dvh; padding: 0; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--paper); }
.card-detail-dialog::backdrop { background: rgb(18 38 66 / 45%); }
.card-detail-dialog[open] { display: flex; flex-direction: column; }
.card-detail-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.card-detail-header h2 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.card-detail-header button { flex-shrink: 0; }
.card-detail-content { overflow: auto; padding: 20px; min-height: 80px; overflow-wrap: anywhere; }
.card-detail-content table { display: block; overflow-x: auto; max-width: 100%; }
@media (max-width: 480px) { .card-detail-header, .card-detail-content { padding: 12px; } }

.filters.calendar-view-switcher { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: stretch; }
.calendar-view-switcher > .button { width: 100%; min-height: 44px; }
@media (max-width: 480px) {
  .filters.calendar-view-switcher { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.communication-settings textarea { width: 100%; min-height: 140px; padding: 12px; font: inherit; box-sizing: border-box; resize: vertical; }
.communication-settings label { display: block; margin: 12px 0 6px; }

.communication-settings select { width: 100%; max-width: 100%; min-width: 0; }

/* Conversations: stable chat viewport, drafts stay outside refreshes. */
.chat-main { max-width: 1600px; padding: 1rem; }
.chat-workspace { display: grid; grid-template-columns: 310px minmax(0, 1fr); height: max(580px, calc(100dvh - 220px)); border: 1px solid #dbe3df; border-radius: 16px; overflow: hidden; background: #fff; }
.chat-sidebar { display: flex; flex-direction: column; min-height: 0; padding: 1rem 0 0; border-right: 1px solid #dbe3df; background: #f8faf9; }
.chat-sidebar-heading { display:flex; align-items:center; justify-content:space-between; padding:0 1rem; gap:.5rem; }
.chat-sidebar-heading h2 { font-size:1.15rem; margin:0; }
.chat-sidebar-heading a { font-size:.8rem; }
.chat-sidebar #chat-search { margin:1rem; width:calc(100% - 2rem); padding:.65rem; border:1px solid #dbe3df; border-radius:8px; }
.chat-thread-list { overflow-y:auto; min-height:0; }
.chat-thread { display:flex; gap:.65rem; align-items:center; padding:1rem; color:#263c34; text-decoration:none; border-bottom:1px solid #e5ebe8; }
.chat-thread[hidden] { display:none; }
.chat-thread:hover, .chat-thread.selected { background:#e3f1e9; }
.chat-thread.selected { box-shadow:inset 3px 0 #267957; }
.chat-avatar { display:grid; place-items:center; flex:0 0 36px; height:36px; border-radius:50%; background:#dce9e2; color:#245e45; font-weight:700; }
.chat-thread-copy { display:flex; flex-direction:column; min-width:0; flex:1; gap:.2rem; }
.chat-thread-copy strong, .chat-thread-copy span { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.chat-thread-copy span, .chat-thread-copy small { font-size:.75rem; color:#586b62; }
.chat-panel { display:flex; flex-direction:column; min-height:0; min-width:0; position:relative; }
.chat-header { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:.8rem 1.2rem; border-bottom:1px solid #e1e8e3; }
.chat-header h1 { font-size:1.2rem; margin:0; overflow-wrap:anywhere; }
.chat-header p { margin:.25rem 0 0; font-size:.8rem; overflow-wrap:anywhere; }
#chat-connection { color:#52695d; font-size:.75rem; }
.chat-back { display:none; }
.chat-association { margin:0; padding:.45rem 1rem; background:#fff7e5; font-size:.78rem; }
.chat-scroll { flex:1; min-height:120px; overflow-y:auto; overscroll-behavior:contain; padding:1rem 1.5rem; background:#edf3ee; }
.chat-day, .chat-history-note { text-align:center; color:#586b62; font-size:.75rem; }
.chat-day span { display:inline-block; padding:.3rem .7rem; background:#fff; border-radius:12px; }
.chat-scroll .conversation-message { width:fit-content; max-width:82%; margin:.6rem auto .6rem 0; padding:.65rem .85rem; border:1px solid #e0e8e2; border-radius:12px 12px 12px 3px; background:#fff; box-shadow:0 1px 2px #173c2410; overflow-wrap:anywhere; }
.chat-scroll .conversation-message.outbound { margin-left:auto; margin-right:0; border-radius:12px 12px 3px 12px; background:#dcefdc; }
.chat-message-author { font-size:.72rem; font-weight:700; color:#38634e; margin:0 0 .35rem; }
.chat-scroll .message-body { margin:0; white-space:pre-wrap; }
.conversation-message footer { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:.5rem; margin-top:.4rem; color:#586b62; font-size:.68rem; }
.chat-panel .conversation-composer { margin:0; padding:.65rem 1rem; max-width:none; border-top:1px solid #dbe3df; background:#fff; }
.chat-panel .conversation-composer h2 { font-size:.9rem; margin:0; }
.chat-panel .conversation-composer p { font-size:.75rem; margin:.3rem 0; }
.chat-panel .conversation-composer textarea { resize:vertical; min-height:64px; max-height:160px; padding:.65rem; border:1px solid #cbd8cf; border-radius:10px; }
.chat-composer-actions { display:flex; justify-content:flex-end; align-items:center; gap:.5rem; margin-top:.4rem; }
.chat-composer-actions span { margin-right:auto; font-size:.7rem; color:#586b62; }
.chat-composer-actions button { font-size:.8rem; }
.chat-search-label { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
.chat-new-messages { align-self:center; margin:.2rem; font-size:.8rem; }
.chat-read-form { text-align:center; }
.chat-read-form button { font-size:.75rem; }
.chat-empty { padding:1rem; text-align:center; color:#586b62; }
.chat-welcome { padding:2rem; justify-content:center; overflow-y:auto; }
.chat-welcome h1 { font-size:1.5rem; }
.chat-welcome .conversation-composer { border:0; padding:1rem 0; }
@media(max-width:760px) {
  .chat-main { padding:.5rem; }
  .chat-workspace { grid-template-columns:minmax(0,1fr); height:max(620px, calc(100dvh - 185px)); }
  .chat-workspace:not(.chat-directory) .chat-sidebar { display:none; }
  .chat-back { display:inline-block; font-size:.8rem; margin-bottom:.35rem; }
  .chat-header { padding:.7rem; align-items:flex-start; }
  .chat-header h1 { font-size:1rem; }
  .chat-scroll { padding:.75rem; }
  .chat-scroll .conversation-message { max-width:90%; }
  .chat-directory { height:auto; min-height:600px; }
  .chat-directory .chat-sidebar { max-height:60dvh; border-right:0; }
  .chat-welcome { padding:1rem; }
  .chat-composer-actions span { display:none; }
}

.appointment-management label { display: block; margin: 12px 0; }
.appointment-management textarea, .appointment-management select,
.appointment-management input[type="datetime-local"] { width: 100%; max-width: 100%; box-sizing: border-box; padding: 10px; font: inherit; }
.appointment-management textarea { min-height: 80px; }
.appointment-management [data-error] { color: var(--danger, #a32121); }

/* Operator feedback: shared red flag in page and card headers. */
.bug-report-flag { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 38px; height: 38px; padding: 8px; background: #b42318; border: 1px solid #b42318; color: #fff; border-radius: 8px; }
.bug-report-flag:hover { background: #8f1c13; color: #fff; }
.card-detail-header > h2, .card-detail-header > span:first-child { margin-right: auto; }
.bug-report-dialog { box-sizing: border-box; min-width: 0; max-width: calc(100vw - 24px); overflow-wrap: anywhere; width: min(680px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow-y: auto; border: 1px solid #d0d5dd; border-radius: 14px; padding: 20px; }
.bug-report-dialog::backdrop { background: rgb(16 24 40 / 55%); }
.bug-report-dialog fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.bug-report-dialog label { display: block; margin-top: 12px; }
.bug-report-dialog textarea { width: 100%; }
.bug-report-close { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 32px; height: 32px; padding: 0; border: 0; background: transparent; color: inherit; font-size: 22px; line-height: 1; border-radius: 8px; cursor: pointer; }
.bug-report-close:hover { background: rgb(16 24 40 / 8%); }

/* Personal column visibility must override the board display rules. */
.pipeline-board .pipeline-column[hidden], #columns-empty[hidden] { display: none; }
.column-picker { margin: 12px 0; padding: 10px 14px; border: 1px solid #ddd; border-radius: 8px; background: #fff; }
.column-picker summary { cursor: pointer; font-weight: 600; }
.column-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px 16px; margin: 12px 0; }
.column-options label { display: flex; align-items: center; gap: 8px; }
.column-options input { width: auto; margin: 0; }

.request-fields { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:1rem; }
[data-request-form] { margin-block:1rem; padding:1rem; border:1px solid var(--border,#d5dde5); border-radius:8px; }
[data-request-form] input:not([type=checkbox]), [data-request-form] select, [data-request-form] textarea { width:100%; box-sizing:border-box; }
[data-request-form] label { display:block; margin-block:.6rem; }
[data-request-form] fieldset[hidden] { display:none; }

.calendar-technician-filter { margin: 0 0 1rem; }
.calendar-technician-filter fieldset { display: flex; flex-wrap: wrap; gap: 1rem; }
.calendar-technician-filter label { display: inline-flex; align-items: center; gap: .4rem; }
.calendar-technician-filter input[type=checkbox] { width: auto; }
.calendar-entry { position: relative; }
.calendar-card-link { display: block; color: inherit; text-decoration: none; }
.calendar-card-link::after { content: ""; position: absolute; inset: 0; }
.calendar-card-link:focus-visible { outline: 3px solid var(--accent, #2563eb); }
.calendar-entry a[data-appointment-manage] { position: relative; z-index: 1; }

/* Card actions are separated from the link opening the customer detail. */
.app-main-pipeline .pipeline-card-compact { border-radius: 12px; border: 1px solid #dce3ed; background: #fff; box-shadow: 0 2px 5px #18324d08; }
.app-main-pipeline .pipeline-card-compact:hover { border-color: #a5b8d1; box-shadow: 0 4px 12px #18324d10; }
.app-main-pipeline .pipeline-card-compact .pipeline-card-link { padding: 14px; border-radius: 12px; }
.app-main-pipeline .pipeline-card-compact h3 { margin: 8px 25px 10px 0; font-size: 15px; line-height: 1.4; color: #18324d; }
.app-main-pipeline .pipeline-card-date { padding-right: 32px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.app-main-pipeline [data-current-phase="appointment_booked"] .pipeline-card-date time { white-space: normal; }
.app-main-pipeline .pipeline-card-link > p + p { margin-top: 7px; }
.app-main-pipeline .card-cadastre { color: var(--muted); }
.app-main-pipeline .pipeline-card-contacts { border-top: 1px solid #e9edf3; padding-top: 9px; margin-top: 10px; display: grid; gap: 5px; }
.card-actions-menu { position: absolute; right: 5px; top: 5px; z-index: 2; }
.card-actions-menu > summary { display: grid; place-items: center; list-style: none; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 22px; color: #516379; background: #f3f6fa; }
.card-actions-menu > summary::-webkit-details-marker { display: none; }
.card-actions-menu > summary:focus-visible { outline: 3px solid #2764b0; outline-offset: 2px; }
.card-actions-menu[open] { z-index: 5; }
.card-actions-list { position: absolute; right: 0; top: 36px; width: min(230px, 65vw); padding: 5px; background: white; border: 1px solid #dce3ed; border-radius: 10px; box-shadow: 0 8px 25px #18324d25; }
.card-actions-list > button, .card-actions-list > a { position: static; display: block; box-sizing: border-box; width: 100%; text-align: left; padding: 10px; margin: 0; border: 0; border-radius: 6px; background: white; color: #18324d; font-size: 13px; line-height: 1.4; text-decoration: none; cursor: pointer; }
.card-actions-list > :hover, .card-actions-list > :focus-visible { background: #edf3fa; }
.card-actions-list > .card-delete-button { color: #a42e32; border-top: 1px solid #e9edf3; border-radius: 0 0 6px 6px; }
.card-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
#card-visibility-dialog { max-width: min(460px, calc(100vw - 48px)); border: 1px solid #dce3ed; border-radius: 14px; padding: 24px; }
#card-visibility-name { font-weight: 700; }
#card-visibility-explanation { color: var(--muted); line-height: 1.6; }
#card-visibility-error { color: #a42e32; }

/* Shared record detail, in the page and in pipeline/calendar dialogs. */
.record-detail { max-width: 1120px; margin: 0 auto; min-width: 0; overflow-wrap: anywhere; }
.record-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.record-heading > div { min-width: 0; }
.record-heading h2 { margin: 4px 0 10px; font-size: clamp(20px, 3vw, 28px); line-height: 1.25; }
.record-eyebrow { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.record-phase { display: inline-block; border: 1px solid #d6e5f0; border-radius: 20px; padding: 5px 10px; font-size: 12px; font-weight: 700; background: #eef6fc; color: #205777; }
.record-actions { position: relative; flex-shrink: 0; }
.record-actions > summary { display: flex; align-items: center; gap: 12px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); cursor: pointer; list-style: none; font-weight: 700; font-size: 13px; }
.record-actions > summary::-webkit-details-marker { display: none; }
.record-actions[open] > summary { border-color: var(--blue); background: var(--soft); }
.record-actions-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: min(310px, calc(100vw - 72px)); border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: var(--paper); box-shadow: var(--shadow); }
.record-actions-list a { display: block; padding: 10px; border-radius: 6px; font-size: 13px; color: var(--ink); text-decoration: none; }
.record-actions-list a:hover, .record-actions-list a:focus-visible { background: var(--soft); }
.record-section-menu { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; padding: 10px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; }
.record-section-menu a { padding: 8px 10px; border-radius: 7px; color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 700; }
.record-section-menu a:hover, .record-section-menu a:focus-visible { background: #e2edf6; }
.record-section-menu a span { margin-left: 3px; color: var(--muted); }
.record-notice { padding: 12px 14px; background: var(--soft); border: 1px solid var(--line); border-radius: 9px; font-size: 13px; }
.record-notice-attention { background: #fff8eb; border-color: #ecd4a4; color: #765019; }
.record-section { margin: 12px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); scroll-margin-top: 16px; }
.record-section > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 16px 18px; list-style: none; cursor: pointer; font-weight: 700; }
.record-section > summary::-webkit-details-marker { display: none; }
.record-section > summary::after { content: "+"; margin-left: auto; font-size: 19px; line-height: 1; color: var(--muted); }
.record-section[open] > summary { border-bottom: 1px solid var(--line); }
.record-section[open] > summary::after { content: "−"; }
.record-section > summary .record-section-hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.record-section-body { padding: 18px; min-width: 0; }
.record-section-body > :first-child { margin-top: 0; }
.record-section-body > :last-child { margin-bottom: 0; }
.record-section-body h3 { margin: 0 0 12px; font-size: 16px; }
.record-section-body h4 { font-size: 14px; }
.record-section-body p, .record-section-body li { font-size: 13px; line-height: 1.6; }
.record-section-body > section + section, .record-section-body > h3:not(:first-child) { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.record-overview-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; }
.record-overview-grid > section + section { margin: 0; padding: 0; border: 0; }
.record-panel { min-width: 0; }
.record-date { margin: 0 0 14px; padding: 10px 12px; border-radius: 8px; background: var(--soft); font-weight: 700; }
.record-muted { color: var(--muted); font-size: 12px; }
.record-facts { display: grid; gap: 12px; margin: 16px 0 0; }
.record-facts > div { display: grid; grid-template-columns: minmax(110px, .7fr) minmax(0, 1fr); gap: 12px; font-size: 13px; }
.record-facts dt { color: var(--muted); }
.record-facts dd { margin: 0; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.record-contacts { list-style: none; display: grid; gap: 10px; padding: 0; margin: 0 0 14px; }
.record-contacts > li { padding: 12px; border: 1px solid var(--line); border-radius: 9px; min-width: 0; }
.record-contacts strong { display: block; margin: 3px 0 8px; font-size: 14px; }
.record-contact-kind { font-size: 11px; font-weight: 700; color: var(--muted); }
.record-contacts details { font-size: 12px; color: var(--muted); }
.record-contacts summary { cursor: pointer; }
.record-contacts details p { margin: 8px 0 0; font-size: 12px; }
.record-booking { padding: 16px; border: 1px solid #cce2d8; border-radius: 10px; background: #f3faf6; }
.record-booking-date { margin: 0; font-size: 20px !important; font-weight: 700; line-height: 1.4 !important; }
.record-booking-date small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.record-booking > a { display: inline-block; margin-top: 14px; font-size: 13px; }
.record-note { white-space: pre-wrap; }
.record-detail [data-incoming-request], .record-detail section[aria-label="Operazioni collegate all’appuntamento"] > article, .record-detail section[aria-label="Esiti Catasto Import"] > article { padding: 14px; border: 1px solid var(--line); border-radius: 9px; margin: 12px 0; }
.record-detail [data-incoming-request] dl { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, 1fr); gap: 10px 14px; font-size: 13px; }
.record-detail [data-incoming-request] dt { color: var(--muted); }
.record-detail [data-incoming-request] dd { margin: 0; min-width: 0; }
.record-detail [data-incoming-request] summary { cursor: pointer; padding: 8px 0; font-weight: 700; }
.record-detail [data-incoming-request] form { margin-top: 12px; }
.record-detail .panel { border: 0; padding: 0; margin: 0; box-shadow: none; }
.record-history-event { border-left: 3px solid #ccddeb; margin: 14px 0; padding-left: 14px; }
.record-history-event p { margin: 6px 0; }
.record-history ol { padding-left: 20px; }
.record-history li + li { margin-top: 10px; }
@media (max-width: 760px) {
  .record-overview-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .record-overview-grid > section + section { border-top: 1px solid var(--line); padding-top: 20px; }
}
@media (max-width: 480px) {
  .record-heading { gap: 10px; }
  .record-heading h2 { font-size: 20px; }
  .record-section-menu { padding: 6px; gap: 2px; }
  .record-section-menu a { padding: 8px; font-size: 12px; }
  .record-section > summary { padding: 13px 12px; gap: 6px; }
  .record-section > summary .record-section-hint { display: none; }
  .record-section-body { padding: 12px; }
  .record-facts > div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .record-detail [data-incoming-request] dl { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .record-detail [data-incoming-request] dd { margin-bottom: 10px; }
}

.rdi-card-status{padding:.35rem .5rem;border:1px solid currentColor;border-radius:.35rem;font-size:.8rem;line-height:1.35;color:#92400e;background:#fffbeb}.rdi-card-status small{display:block;overflow-wrap:anywhere}.rdi-card-status-verified,.rdi-card-status-operator_confirmed{color:#166534;background:#f0fdf4}.rdi-card-status-pending,.rdi-card-status-running,.rdi-card-status-checking,.rdi-card-status-missing{color:#475569;background:#f8fafc}

/* Personal operator home */
.home-metrics { margin-bottom: 2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.home-metrics article { display: flex; flex-direction: column; gap: .7rem; }
.home-metrics article p { margin: 0; font-size: .9rem; }
.calendar-grid.home-appointments { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; }
.home-appointments .calendar-card-link { height: 100%; }
/* CRM archives: source values remain readable on narrow operator screens. */
.crm-shell { max-width: 1180px; margin: 0 auto; min-width: 0; }
.crm-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 1rem 0; flex-wrap: wrap; }
.crm-heading h1 { margin: .2rem 0 .6rem; overflow-wrap: anywhere; }
.crm-eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: #526274; }
.crm-notice { background: #f0f5fa; border-left: 3px solid #4e789f; padding: .85rem 1rem; border-radius: 6px; line-height: 1.6; }
.crm-search { display: flex; gap: .8rem; align-items: end; flex-wrap: wrap; margin: 1.4rem 0; }
.crm-search label { flex: 1 1 320px; min-width: 0; }
.crm-search input { display: block; width: 100%; margin-top: .4rem; box-sizing: border-box; }
.crm-count { color: #526274; }
.crm-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 1rem; }
.crm-card { padding: 1.2rem; border: 1px solid #dce4eb; border-radius: 12px; background: #fff; min-width: 0; overflow-wrap: anywhere; }
.crm-card h2 { font-size: 1.05rem; margin-top: 0; }
.crm-card small { color: #526274; }
.crm-pagination, .crm-links { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin: 1.3rem 0; }
.crm-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 1rem; padding: .9rem 0; border-bottom: 1px solid #e2e8ee; }
.crm-field h3 { margin: 0 0 .2rem; font-size: .95rem; }
.crm-field code, .crm-field small { display: block; overflow-wrap: anywhere; white-space: normal; font-size: .8rem; }
.crm-field small { margin-top: .35rem; color: #526274; }
.crm-field-value { margin-bottom: .65rem; }
.crm-field-value p { margin: 0 0 .25rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.crm-field-value a { font-size: .8rem; overflow-wrap: anywhere; }
.crm-field-conflict { border-left: 3px solid #bd7a19; padding-left: .75rem; }
.crm-missing { margin: 1rem 0; }
.crm-shell summary { cursor: pointer; font-weight: 600; overflow-wrap: anywhere; }
.crm-shell .panel { margin: 1rem 0; min-width: 0; }
.crm-shell dd { margin: .3rem 0 1rem; overflow-wrap: anywhere; }
.crm-raw { max-width: 100%; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.crm-empty { padding: 2rem; border: 1px dashed #b9c7d4; border-radius: 12px; }
.crm-state { display: inline-block; padding: .3rem .5rem; background: #f4f0e6; border-radius: 6px; }
@media (max-width: 600px) { .crm-field { grid-template-columns: minmax(0, 1fr); } }

/* Technician identity is independent of appointment status and selected filters. */
.technician-color-0{--tech-bg:#e4efff;--tech-edge:#2155a3}
.technician-color-1{--tech-bg:#fff0dc;--tech-edge:#9a4c00}
.technician-color-2{--tech-bg:#e5f5eb;--tech-edge:#21683a}
.technician-color-3{--tech-bg:#f0e8fa;--tech-edge:#70419a}
.technician-color-4{--tech-bg:#fce6ed;--tech-edge:#a13660}
.technician-color-5{--tech-bg:#def3f4;--tech-edge:#156d75}
.technician-color-6{--tech-bg:#f4f0d6;--tech-edge:#736315}
.technician-color-7{--tech-bg:#eee7e1;--tech-edge:#785239}
.technician-color-unassigned{--tech-bg:#edf0f3;--tech-edge:#657180}
.calendar-entry[class*="technician-color-"]{background:var(--tech-bg);border-left:5px solid var(--tech-edge);color:#172b3e}
.technician-legend{display:flex;flex-wrap:wrap;gap:8px 18px;padding:0;list-style:none}
.technician-legend li{display:flex;align-items:center;gap:7px}
.technician-swatch{display:inline-block;width:16px;height:16px;background:var(--tech-bg);border:3px solid var(--tech-edge);border-radius:4px}

.rcee-shell{max-width:1080px;margin:auto}.rcee-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.rcee-fields label{display:flex;flex-direction:column;gap:6px}.rcee-fields input,.rcee-fields select,.rcee-fields textarea{width:100%;min-height:44px;max-width:100%}.rcee-shell dd{white-space:pre-wrap;overflow-wrap:anywhere}@media(max-width:650px){.rcee-fields{grid-template-columns:1fr}}

/* RCEE compilation follows the approved document body without a letterhead. */
.rcee-paper{background:#fff;color:#20252b;border:1px solid #c9cdd2;box-shadow:0 2px 12px #172b3e0b;padding:26px 30px;margin:20px 0;font:13px/1.35 Arial,sans-serif}
.rcee-paper-title{text-align:center;text-transform:uppercase;font-size:19px;line-height:1.25;margin:0 0 5px;color:inherit}
.rcee-paper-subtitle{text-align:center;font-size:12px;margin:0 0 20px;color:#525b65}
.rcee-section{margin-top:16px;min-width:0}
.rcee-section h3{font-size:13px;text-transform:uppercase;margin:0 0 8px;padding:0 0 4px;border-bottom:1px solid #8c949d;color:#20252b}
.rcee-identification{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px 14px;align-items:end}
.rcee-span-2{grid-column:span 2}.rcee-span-3{grid-column:span 3}.rcee-span-4{grid-column:1/-1}
.rcee-paper .rcee-line{display:flex;flex-direction:column;gap:3px;font-size:12px;min-width:0;margin:0;font-weight:400}
.rcee-paper .rcee-line input,.rcee-paper .rcee-line textarea{width:100%;min-width:0;min-height:29px;border:0;border-bottom:1px solid #9da5ad;border-radius:0;background:#f5f8fb;color:#122c43;padding:4px 5px;font:14px/1.3 Arial,sans-serif;box-shadow:none}
.rcee-paper .rcee-line input:focus,.rcee-paper .rcee-line textarea:focus{outline:2px solid #2563a6;outline-offset:1px;background:#fff}
.rcee-paper .rcee-choice{border:0;padding:0;margin:0;min-width:0;font-size:12px}
.rcee-paper .rcee-choice legend{padding:0;margin:0 0 3px;font-weight:400;font-size:12px}
.rcee-options{display:flex;align-items:center;flex-wrap:wrap;gap:2px 12px}
.rcee-options label{display:inline-flex;align-items:center;gap:4px;min-height:28px;cursor:pointer;font-weight:400;font-size:12px;margin:0;color:inherit}
.rcee-options input[type=radio]{appearance:none;display:inline-block;width:13px;height:13px;min-width:13px;padding:0;margin:0;border:1px solid #606b76;border-radius:1px;background:#fff;box-shadow:none;cursor:pointer}
.rcee-options input[type=radio]:checked{background:#1c476e;border-color:#1c476e;box-shadow:inset 0 0 0 2px #fff}
.rcee-options input[type=radio]:focus-visible{outline:2px solid #2563a6;outline-offset:3px}
.rcee-paper .rcee-binary{min-height:31px;padding:2px 0;border-bottom:1px dotted #d7dbdf}
.rcee-paper .rcee-binary legend{float:left;width:calc(100% - 172px);padding:5px 8px 0 0;margin:0}
.rcee-binary .rcee-options{width:172px;justify-content:flex-end;gap:5px}
.rcee-clear-choice{color:#647182!important}
.rcee-check-columns{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:24px}
.rcee-water{display:grid;grid-template-columns:160px minmax(0,1fr);gap:16px}
.rcee-water .rcee-choice + .rcee-choice{margin-top:7px}
.rcee-generator-checks{margin-top:12px}
.rcee-generator-checks .rcee-line,.rcee-generator-checks .rcee-choice:not(.rcee-binary){margin-top:5px}
.rcee-measurements{display:grid;grid-template-columns:1fr 1.15fr .7fr .7fr 1fr 1fr 1.25fr 1.25fr .7fr;margin-top:12px;border-top:1px solid #6e7882;border-left:1px solid #6e7882}
.rcee-paper .rcee-measurements .rcee-line{padding:5px 4px;border-right:1px solid #6e7882;border-bottom:1px solid #6e7882;justify-content:space-between;font-size:11px}
.rcee-paper .rcee-measurements input{margin-top:5px;font-size:13px;padding:4px 2px}
.rcee-field-note{font-size:12px;color:#52606d;line-height:1.5;margin:6px 0 10px}
.rcee-paper .rcee-checklist .rcee-binary legend{width:calc(100% - 172px)}
.rcee-outcome>.rcee-line{margin-top:12px}
.rcee-outcome>.rcee-line>span{font-weight:700;text-transform:uppercase;font-size:12px}
.rcee-paper .rcee-outcome textarea{resize:vertical;min-height:52px;background:repeating-linear-gradient(#fff,#fff 23px,#e4e7eb 23px,#e4e7eb 24px);line-height:24px;padding:0 5px}
.rcee-outcome>.rcee-choice{margin:14px 0 10px}
.rcee-report-reference{font-size:11px;margin:0;overflow-wrap:anywhere;align-self:center}.rcee-report-reference span{display:block;margin-top:3px;color:#52606d}
@media(max-width:800px){
 .rcee-paper{padding:18px 14px}.rcee-paper-title{font-size:17px}
 .rcee-identification{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
 .rcee-span-3,.rcee-span-4{grid-column:1/-1}
 .rcee-check-columns{grid-template-columns:1fr;gap:0}
 .rcee-water{grid-template-columns:1fr}.rcee-measurements{grid-template-columns:repeat(3,minmax(0,1fr))}
 .rcee-paper .rcee-line input{min-height:44px;font-size:16px}.rcee-options label{min-height:44px;padding:4px 2px}
 .rcee-options input[type=radio]{width:18px;height:18px;min-width:18px}
 .rcee-paper .rcee-binary legend,.rcee-paper .rcee-checklist .rcee-binary legend{float:none;width:auto;padding:4px 0 0}
 .rcee-binary .rcee-options{width:auto;justify-content:flex-start;gap:12px}
}
@media(max-width:480px){.rcee-identification{grid-template-columns:1fr}.rcee-span-2,.rcee-span-3,.rcee-span-4{grid-column:1}.rcee-measurements{grid-template-columns:repeat(2,minmax(0,1fr))}.rcee-paper{padding:16px 10px}.rcee-paper-title{font-size:15px}}
.rcee-options input[type=radio]{min-height:13px}
.rcee-attachment-forms{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.rcee-upload{border:1px solid #c7d1da;border-radius:8px;padding:12px;min-width:0}.rcee-upload summary{cursor:pointer;font-weight:700}.rcee-upload form{display:grid;gap:12px;margin-top:14px}.rcee-upload input[type=file]{border-radius:4px;max-width:100%;font-size:13px}.rcee-upload canvas{width:100%;max-height:440px;object-fit:contain;background:#eef1f4}.rcee-upload [hidden]{display:none}.rcee-upload ol{padding-left:20px}.rcee-upload li{margin:6px 0}.rcee-attachment-list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin-top:18px}.rcee-attachment{min-width:0;border:1px solid #c7d1da;border-radius:8px;padding:12px}.rcee-attachment h3{font-size:15px;overflow-wrap:anywhere}.rcee-attachment p{font-size:13px}.rcee-attachment img,.rcee-attachment video{width:100%;max-height:300px;object-fit:contain}.rcee-attachment details{font-size:13px}
@media(max-width:800px){.rcee-attachment-forms,.rcee-attachment-list{grid-template-columns:1fr}.rcee-options input[type=radio]{min-height:18px}}

.rcee-finalize label{display:flex;align-items:center;gap:10px;margin-bottom:12px}.rcee-finalize input[type=checkbox]{width:20px;min-width:20px;height:20px;min-height:20px}
.registry-readiness{margin:14px 0;padding:14px 16px;border:1px solid #bcced9;border-left:4px solid #33745f;border-radius:6px;background:#f4faf7;overflow-wrap:anywhere}.registry-readiness-attention{border-color:#dbc89f;border-left-color:#aa7115;background:#fffbf1}.registry-readiness h2{font-size:16px;margin:0 0 10px}.registry-readiness p{font-size:13px;line-height:1.5;margin:8px 0}.registry-readiness dl{margin:0;font-size:13px}.registry-readiness dl>div{display:grid;grid-template-columns:75px minmax(0,1fr);gap:8px;margin:6px 0}.registry-readiness dd{margin:0}.registry-readiness a{font-size:13px;font-weight:700}

.registry-card-warning{font-size:12px;line-height:1.4;background:#fff4d9;color:#775015;border-left:3px solid #b88628;padding:6px 8px;border-radius:4px}
/* CRM archives: compact rows and search summaries. */
.crm-metrics { display: flex; flex-wrap: wrap; gap: 1.5rem; padding: 1rem 0; border-bottom: 1px solid #dce4eb; }
.crm-metrics dt { color: #526274; font-size: .85rem; }
.crm-shell .crm-metrics dd { font-size: 1.8rem; font-weight: 700; margin: .25rem 0 0; }
.crm-list { list-style: none; padding: 0; margin: 1rem 0; border-top: 1px solid #dce4eb; }
.crm-list-row { display: flex; align-items: center; gap: 1rem; padding: .85rem .5rem; border-bottom: 1px solid #dce4eb; overflow-wrap: anywhere; }
.crm-list-row:hover { background: #f0f5fa; }
.crm-list-main { flex: 1; min-width: 0; }
.crm-list-main > a { font-weight: 600; }
.crm-list-main p { margin: .25rem 0 0; color: #526274; }
.crm-list-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; max-width: 50%; font-size: .85rem; color: #526274; }
.crm-suggestions { padding: 1rem; background: #f0f5fa; border-radius: 6px; }
.crm-suggestions ul { list-style: none; padding: 0; margin: .5rem 0 0; }
.crm-suggestions a { display: block; padding: .4rem 0; overflow-wrap: anywhere; }
.crm-suggestions small { color: #526274; }
#crm-search-status, #crm-search-help { color: #526274; font-size: .85rem; }
#crm-search-status { min-height: 1.4em; }
#crm-results[aria-busy="true"] { opacity: .6; }
@media (max-width: 600px) {
  .crm-list-row { align-items: flex-start; flex-direction: column; gap: .4rem; }
  .crm-list-meta { max-width: 100%; justify-content: flex-start; }
}

.crm-search [hidden] { display: none; }

.home-create-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0 1.5rem; }
.crm-picker { margin: 1rem 0; min-width: 0; }
.crm-picker-results { display: flex; flex-direction: column; gap: .4rem; }
.crm-picker-results button { text-align: left; white-space: normal; overflow-wrap: anywhere; }
.crm-picker [data-picker-selected] { font-weight: 600; overflow-wrap: anywhere; }
.crm-picker [data-picker-clear] { background: transparent; color: #365a7a; border: 1px solid #b9c7d4; }

/* Home search shares the main menu row, with an unclipped suggestion panel. */
.navigation-row { display: flex; align-items: center; gap: 16px; }
.navigation-row .primary-nav { flex: 1; min-width: 0; }
.navigation-row .global-search-compact { flex: 0 0 240px; margin-left: auto; }
@media (max-width: 1100px) {
  .navigation-row { flex-wrap: wrap; }
  .navigation-row .primary-nav { flex-basis: 100%; }
  .navigation-row .global-search-compact #global-search-results { left: auto; right: 0; }
}
@media (max-width: 600px) {
  .navigation-row { gap: 8px; }
  .navigation-row .global-search-compact { flex-basis: 100%; width: 100%; }
}

/* Actions stay visible; consent opens the prefilled customer choice directly. */
.record-heading:has(.record-direct-actions) { flex-wrap: wrap; }
.record-direct-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.record-direct-actions > a { border: 1px solid var(--line); border-radius: 7px; padding: 9px 12px; text-decoration: none; color: var(--ink); background: var(--paper); }
.record-direct-actions > a:hover, .record-direct-actions > a:focus-visible { background: var(--soft); }

/* Card actions live in an icon-only menu, aligned with the flag and close icons. */
.record-heading:has(.record-actions-menu) { flex-wrap: nowrap; }
.record-actions-menu > summary { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; width: 38px; height: 38px; padding: 8px; border-radius: 8px; color: var(--ink); }
.record-actions-menu > summary:focus-visible { outline: 3px solid #2764b0; outline-offset: 2px; }
.record-actions-menu .record-actions-list.record-direct-actions { display: block; width: min(310px, calc(100vw - 48px)); }
.record-actions-menu .record-actions-list.record-direct-actions > a { display: block; border: 0; border-radius: 6px; padding: 10px; background: transparent; }
.record-actions-menu .record-actions-list.record-direct-actions > a:hover, .record-actions-menu .record-actions-list.record-direct-actions > a:focus-visible { background: var(--soft); }

/* Essentials first, everything else in collapsed single-column sections. */
.record-essentials { display: grid; gap: 12px; margin: 0 0 16px; }
.record-essentials > section { margin: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); min-width: 0; }
.record-essentials > .record-booking { border-color: #cce2d8; background: #f3faf6; }
.record-essentials > .record-booking-empty { border-color: var(--line); background: var(--paper); }
.record-essentials h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.record-essentials .record-facts { margin: 8px 0 0; gap: 8px; }
.record-essentials p { margin: 6px 0 0; font-size: 14px; }
.record-agreed { font-size: 14px; }
.record-quick-contacts { list-style: none; display: grid; gap: 8px; margin: 0; padding: 0; }
.record-quick-contacts li { display: grid; gap: 2px; min-width: 0; }
.record-quick-contacts a, .record-quick-contacts strong { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.record-quick-contacts a { display: block; padding: 4px 0; color: var(--blue, #174d83); }
.record-overview-grid { grid-template-columns: minmax(0, 1fr); }

.record-actions-menu .record-actions-list form { margin: 0; }
.record-actions-menu .record-actions-list form > button { display: block; width: 100%; padding: 10px; border: 0; border-radius: 6px; font: inherit; font-size: 13px; text-align: left; color: var(--ink); background: transparent; box-shadow: none; cursor: pointer; }
.record-actions-menu .record-actions-list form > button:hover, .record-actions-menu .record-actions-list form > button:focus-visible { background: var(--soft); }
