:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #111111;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #e8573a;
  --accent-dark: #d4451e;
  --blue: #3a87c8;
  --green: #22c55e;
  --purple: #7c3aed;
  --amber: #f59e0b;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #e8863a;
  box-shadow: 0 0 0 3px rgba(232, 134, 58, 0.12);
}

label {
  display: grid;
  gap: 6px;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.app-main {
  min-width: 0;
  padding: 22px 28px 48px;
}

.mobile-brand {
  display: none;
  margin-bottom: 16px;
}

.brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  padding: 3px;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand strong,
.login-brand strong {
  display: block;
  font-size: 15px;
}

.brand small,
.login-brand small,
.sidebar-user small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: capitalize;
}

.side-nav {
  display: grid;
  gap: 7px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 10px;
  border-radius: 9px;
  color: #374151;
  font-weight: 700;
}

.side-nav a.active,
.side-nav a:hover {
  background: #fef2f2;
  color: var(--accent);
}

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: currentColor;
}

.sidebar-user {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
}

.avatar-large {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #fef3c7;
  color: #92400e;
  font-size: 14px;
}

.avatar-small {
  width: 24px;
  height: 24px;
  font-size: 10px;
}

.page-header,
.ticket-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.page-header h1,
.ticket-hero h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.page-header h2,
.panel h2,
.side-panel h2,
.hero-panel h2 {
  margin: 0;
  font-size: 16px;
}

.eyebrow {
  margin: 0 0 7px;
  color: #9ca3af;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.header-actions,
.button-row,
.composer-foot,
.channel-row,
.message-send-row,
.ticket-title-line,
.meta-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.header-actions-empty {
  min-width: 1px;
}

.btn {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.btn-secondary {
  background: #fff;
  color: #374151;
  border-color: var(--line);
}

.btn-secondary:hover,
.btn-ghost:hover,
.btn-outline:hover {
  background: var(--surface-soft);
}

.btn-outline {
  background: #fff;
  color: var(--accent);
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.inbox-button {
  position: relative;
}

.btn-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.btn-small {
  min-height: 30px;
  padding: 5px 11px;
  font-size: 12px;
}

.full {
  width: 100%;
}

.flash {
  margin-bottom: 16px;
  padding: 11px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
}

.flash-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.flash-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.flash-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.notice-details {
  margin: 8px 0 0 18px;
  padding: 0;
}

.panel,
.hero-panel,
.side-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.panel,
.side-panel {
  padding: 16px;
}

.soft-panel {
  background: #fcfcfd;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-head.tight {
  margin-bottom: 10px;
}

.panel-head a {
  color: var(--accent);
  font-weight: 800;
  font-size: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.dashboard-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.dashboard-title-group h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.08;
}

.dashboard-title-group > span {
  display: block;
  margin-top: 7px;
  color: #4b5563;
  font-weight: 700;
}

.dashboard-tools {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-search {
  width: min(360px, 38vw);
  display: grid;
  gap: 6px;
  color: #9ca3af;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.dashboard-search input {
  min-height: 34px;
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.dashboard-tools form {
  margin: 0;
}

.dashboard-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(142px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.dashboard-summary-card {
  position: relative;
  overflow: hidden;
  min-height: 118px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: none;
}

.dashboard-summary-card::after {
  display: none;
}

.dashboard-summary-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-summary-card strong {
  display: block;
  margin-top: 12px;
  color: var(--text);
  font-size: 29px;
  line-height: 1;
}

.dashboard-summary-card p {
  position: relative;
  z-index: 1;
  margin: 14px 0 0;
  color: #4b5563;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.summary-open::after {
  background: var(--amber);
}

.summary-progress::after {
  background: var(--blue);
}

.summary-pending::after {
  background: var(--purple);
}

.summary-closed::after {
  background: var(--green);
}

.summary-overdue::after {
  background: var(--danger);
}

.dashboard-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(318px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.dashboard-side-stack {
  display: grid;
  gap: 16px;
}

.dashboard-ticket-table {
  min-width: 0;
  min-width: 920px;
  table-layout: auto;
  font-size: 12px;
}

.dashboard-ticket-table th,
.dashboard-ticket-table td {
  padding-left: 10px;
  padding-right: 10px;
  overflow-wrap: normal;
}

.dashboard-ticket-table th:nth-child(1),
.dashboard-ticket-table td:nth-child(1) {
  width: 10%;
}

.dashboard-ticket-table th:nth-child(2),
.dashboard-ticket-table td:nth-child(2) {
  width: 22%;
}

.dashboard-ticket-table th:nth-child(3),
.dashboard-ticket-table td:nth-child(3) {
  width: 10%;
}

.dashboard-ticket-table th:nth-child(4),
.dashboard-ticket-table td:nth-child(4) {
  width: 12%;
}

.dashboard-ticket-table th:nth-child(5),
.dashboard-ticket-table td:nth-child(5) {
  width: 9%;
}

.dashboard-ticket-table th:nth-child(6),
.dashboard-ticket-table td:nth-child(6) {
  width: 10%;
}

.dashboard-ticket-table th:nth-child(7),
.dashboard-ticket-table td:nth-child(7) {
  width: 9%;
}

.dashboard-ticket-table th:nth-child(8),
.dashboard-ticket-table td:nth-child(8) {
  width: 18%;
}

.dashboard-ticket-table td:first-child strong,
.dashboard-ticket-table td:nth-child(5),
.dashboard-ticket-table td:nth-child(7) {
  white-space: nowrap;
}

.dashboard-ticket-row:focus {
  outline: 2px solid rgba(232, 87, 58, 0.35);
  outline-offset: -2px;
}

.communication-list {
  display: grid;
  gap: 9px;
}

.communication-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.communication-item strong,
.communication-item small {
  display: block;
}

.communication-item small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.comm-ready {
  background: #dcfce7;
  color: #166534;
}

.comm-testing {
  background: #fffbeb;
  color: #92400e;
}

.comm-warning {
  background: #fee2e2;
  color: #991b1b;
}

.comm-muted {
  background: #f3f4f6;
  color: #4b5563;
}

.dashboard-new-ticket-modal {
  width: min(760px, calc(100vw - 28px));
}

.new-ticket-form input.is-invalid,
.new-ticket-form select.is-invalid,
.new-ticket-form textarea.is-invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.11);
}

.summary-card {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.summary-card strong {
  display: block;
  margin-top: 12px;
  font-size: 34px;
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-accent {
  position: absolute;
  right: -18px;
  bottom: -18px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  opacity: 0.18;
}

.summary-accent.open {
  background: var(--amber);
}

.summary-accent.progress {
  background: var(--blue);
}

.summary-accent.pending {
  background: var(--purple);
}

.summary-accent.closed {
  background: var(--green);
}

.summary-accent.overdue {
  background: var(--danger);
}

.dashboard-grid,
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 16px;
}

.tickets-grid {
  align-items: start;
}

.ticket-board-shell {
  display: grid;
  gap: 14px;
}

.ticket-board-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.ticket-board-summary div {
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.ticket-board-summary small {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.ticket-board-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  line-height: 1;
}

.ticket-list-panel .panel-head {
  align-items: center;
  flex-wrap: wrap;
}

.ticket-filter-bar {
  flex: 1 1 520px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: min(100%, 520px);
}

.ticket-filter-bar input {
  flex: 1 1 340px;
  min-width: 220px;
  max-width: 560px;
}

.ticket-filter-bar select {
  flex: 0 0 152px;
  width: 152px;
  min-width: 152px;
}

.ticket-filter-bar button,
.ticket-filter-bar a {
  flex: 0 0 auto;
  white-space: nowrap;
}

.ticket-board-row {
  outline: none;
}

.ticket-board-row:focus-visible {
  background: #fff7ed;
  box-shadow: inset 3px 0 0 var(--accent);
}

.ticket-number-link,
.ticket-project-link {
  color: var(--text);
  font-weight: 900;
}

.ticket-number-link:hover,
.ticket-project-link:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.category-badge {
  display: inline-flex;
  width: fit-content;
  margin-top: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.category-installation {
  background: #e55c2b;
}

.category-engineering {
  background: #2e7d32;
}

.category-inspection {
  background: #6a1b9a;
}

.category-administrative {
  background: #6b7280;
}

.category-service {
  background: #1565c0;
}

.unmatched-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.unmatched-detail-grid {
  align-items: start;
}

.message-preview {
  max-width: 360px;
  white-space: pre-line;
}

.unmatched-table tbody tr {
  cursor: default;
}

.review-status-new {
  background: #fef2f2;
  color: #991b1b;
}

.review-status-reviewed {
  background: #f0fdf4;
  color: #166534;
}

.review-status-ignored {
  background: #f3f4f6;
  color: #4b5563;
}

.unmatched-detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.unmatched-detail-list div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.unmatched-detail-list dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.unmatched-detail-list dd {
  margin: 4px 0 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.unmatched-message-body {
  margin: 0 0 14px;
}

.unmatched-message-body pre {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  white-space: pre-wrap;
  font-family: inherit;
  line-height: 1.45;
}

.media-indicator {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.attachment-gallery-panel {
  margin-bottom: 18px;
}

.attachment-gallery-table th:first-child,
.attachment-gallery-table td:first-child {
  width: 150px;
}

.attachment-gallery-table tbody tr {
  cursor: default;
}

.attachment-gallery-thumb,
.attachment-gallery-video {
  width: 132px;
  max-height: 96px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fafb;
  object-fit: cover;
}

.attachment-gallery-video {
  object-fit: contain;
}

.attachment-gallery-path {
  min-width: 220px;
  max-width: 360px;
  overflow-wrap: anywhere;
}

.attachment-gallery-empty {
  color: var(--muted);
  font-size: 12px;
}

.attachment-gallery-attach {
  display: grid;
  grid-template-columns: minmax(118px, 1fr) minmax(136px, 1fr) auto;
  gap: 6px;
  align-items: end;
  min-width: 340px;
}

.attachment-gallery-attach label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.attachment-gallery-attach input {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 8px;
  font: inherit;
  font-size: 12px;
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-bar input {
  min-width: 250px;
}

.ticket-filter-bar input {
  min-width: 220px;
}

.ticket-list.compact {
  display: grid;
  gap: 8px;
}

.ticket-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.ticket-row:hover,
.task-card:hover,
.file-row:hover {
  border-color: var(--line-strong);
  background: #fffdfb;
}

.ticket-row strong,
.ticket-row span,
.ticket-row small,
.task-card strong,
.task-card span,
.task-card small {
  display: block;
}

.ticket-row small,
.task-card small,
.file-row small {
  color: var(--muted);
  font-size: 12px;
}

.ticket-row-side {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.ticket-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  padding: 9px 14px;
  text-align: left;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: #fef9f5;
}

.data-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.badge,
.meta-pill,
.count-pill,
.dept-pill,
.ticket-number-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.dept-pill,
.ticket-number-pill {
  border-radius: 6px;
}

.dept-pill {
  background: var(--blue);
  color: #fff;
}

.ticket-number-pill {
  background: #dbeafe;
  color: #1d4ed8;
}

.meta-pill,
.count-pill {
  background: var(--surface-soft);
  color: #374151;
}

.count-pill.danger {
  background: #fef2f2;
  color: #991b1b;
}

.status-open {
  background: #fef3c7;
  color: #92400e;
}

.status-progress {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-pending {
  background: #ede9fe;
  color: #5b21b6;
}

.status-closed {
  background: #dcfce7;
  color: #166534;
}

.status-blocked,
.priority-urgent {
  background: #fee2e2;
  color: #991b1b;
}

.priority-low {
  background: #f3f4f6;
  color: #4b5563;
}

.priority-medium {
  background: #eff6ff;
  color: #1d4ed8;
}

.priority-high {
  background: #fffbeb;
  color: #92400e;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.form-grid {
  display: grid;
  gap: 10px;
}

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

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

.form-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-notice {
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.form-notice.warning {
  border: 1px solid #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.form-button-align {
  display: flex;
  align-items: end;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #f3f4f6;
}

.login-shell {
  width: min(440px, calc(100vw - 32px));
}

.login-panel {
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.14);
}

.login-panel h1 {
  margin: 24px 0 8px;
  font-size: 30px;
}

.login-foot {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.crumbs a {
  color: var(--accent);
  font-weight: 800;
}

.ticket-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.ticket-hero .hero-panel {
  padding: 14px 16px;
}

.ticket-info-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.ticket-info-title .eyebrow {
  margin-bottom: 0;
}

.ticket-info-title a {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.ticket-status-panel {
  min-height: 0;
}

.ticket-status-panel p,
.homeowner-card p {
  color: var(--muted);
}

.ticket-status-panel > p:not(.eyebrow) {
  margin: 0;
  line-height: 1.45;
}

.homeowner-card p {
  margin: 2px 0 0;
  line-height: 1.35;
}

.ticket-status-panel h1 {
  margin: 8px 0 4px;
  font-size: 20px;
}

.person-line {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-bottom: 8px;
}

.homeowner-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.homeowner-edit-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.homeowner-feedback {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  background: #fef2f2;
  color: #991b1b;
  font-size: 12px;
  line-height: 1.4;
}

.homeowner-feedback ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.homeowner-identity {
  min-width: 0;
  flex: 1;
}

.homeowner-edit-fields,
.homeowner-edit-field {
  display: none;
}

.homeowner-edit-fields {
  gap: 8px;
}

.homeowner-card.is-editing .homeowner-readonly {
  display: none;
}

.homeowner-card.is-editing .homeowner-edit-fields {
  display: grid;
}

.homeowner-card.is-editing .homeowner-edit-field {
  display: block;
  margin-top: 6px;
}

.person-line h2 {
  font-size: 17px;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.contact-grid div {
  min-height: 48px;
  padding: 7px 8px;
  border: 1px solid #f0f2f5;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.contact-grid small,
.detail-list dt {
  display: block;
  color: var(--faint);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.contact-grid strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.stage-bar {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  margin: 10px 0 8px;
}

.stage-bar span {
  padding: 5px 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stage-bar span:first-child {
  border-radius: 7px 0 0 7px;
}

.stage-bar span:last-child {
  border-radius: 0 7px 7px 0;
}

.stage-bar span + span {
  border-left: 0;
}

.stage-bar .done {
  background: #f0fdf4;
  color: #166534;
}

.stage-bar .active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.ticket-stage-bar span {
  min-width: 86px;
  text-align: center;
}

.progress-block {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
}

.progress-block > div:first-child {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.progress-track span {
  display: block;
  height: 100%;
  background: var(--green);
}

.progress-preview {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 900;
}

.meta-strip {
  color: var(--muted);
}

.meta-strip span {
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 12px;
}

.meta-strip.small span {
  padding: 0;
  background: transparent;
}

.ticket-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 16px;
  align-items: start;
}

.workspace-main {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.tab span,
.subtabs span {
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-pane {
  display: none;
  padding: 18px;
  background: #f7f7f8;
}

.tab-pane.active {
  display: block;
}

.subtabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 2px solid var(--line);
  margin-bottom: 16px;
}

.subtabs button {
  flex: 1 0 180px;
  padding: 11px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.subtabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.subtabs button.is-closed-thread {
  color: #64748b;
}

.thread-closed-chip {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.discussion-pane {
  display: none;
}

.discussion-pane.active {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  max-height: max(420px, calc(100vh - 360px));
  overflow: hidden;
}

.ticket-discussion-pane.active {
  max-height: none;
  overflow: visible;
}

.discussion-stub-grid {
  display: grid;
  gap: 12px;
}

.discussion-thread-card {
  display: none;
}

.discussion-thread-card.active {
  display: block;
}

.discussion-subtabs {
  margin-bottom: 14px;
}

.ticket-comms-stub-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.ticket-comms-stub-actions .composer-feedback {
  flex: 1 1 260px;
}

.composer,
.customer-composer,
.installer-composer,
.thread-header,
.comment-card,
.issue-section,
.task-card,
.file-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.composer,
.customer-composer,
.installer-composer {
  display: grid;
  gap: 10px;
  padding: 13px;
  margin-bottom: 14px;
}

.discussion-pane .composer,
.discussion-pane .customer-composer,
.discussion-pane .installer-composer {
  flex: 0 0 auto;
  margin: 12px 0 0;
}

.composer-head,
.message-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.composer-head small,
.message-head small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.composer-foot {
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.team-mention-field {
  position: relative;
}

.mention-dropdown {
  position: absolute;
  left: 0;
  bottom: calc(100% + 5px);
  z-index: 20;
  width: min(280px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.14);
}

.mention-option {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.mention-option:last-child {
  border-bottom: 0;
}

.mention-option.active,
.mention-option:hover {
  background: #fff7ed;
}

.mention-option span:last-child {
  display: grid;
  gap: 1px;
}

.mention-option strong {
  font-size: 13px;
}

.mention-option small {
  color: var(--muted);
  font-size: 11px;
  text-transform: capitalize;
}

.mention-token {
  display: inline;
  border-radius: 5px;
  background: #fff7ed;
  color: var(--accent-dark);
  font-weight: 800;
  padding: 1px 3px;
}

.feed {
  display: grid;
  gap: 9px;
}

.discussion-pane .feed,
.discussion-pane .bubble-feed {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  align-content: start;
}

.comment-card {
  padding: 13px;
}

.comment-card.internal {
  border-left: 3px solid var(--amber);
  background: #fffdf5;
}

.comment-card p {
  margin: 8px 0 0 39px;
  color: #1f2937;
  line-height: 1.6;
  white-space: pre-line;
}

.thread-header {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  margin-bottom: 12px;
}

.thread-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 42px;
}

.thread-sync-button {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--accent);
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.thread-sync-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: #fff7ed;
}

.thread-sync-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.thread-sync-button.is-loading span {
  animation: sync-spin 0.9s linear infinite;
}

.thread-sync-feedback {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.thread-close-form {
  margin: 0;
}

.thread-close-button {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #fecaca;
  border-radius: 999px;
  background: #fff;
  color: #b91c1c;
  cursor: pointer;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}

.thread-close-button:hover {
  background: #fef2f2;
}

.thread-sync-feedback.is-success {
  color: var(--green);
}

.thread-sync-feedback.is-error {
  color: var(--danger);
}

.thread-sync-feedback.is-pending {
  color: var(--accent);
}

@keyframes sync-spin {
  to {
    transform: rotate(360deg);
  }
}

.thread-header small {
  display: block;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.thread-state-pill,
.thread-closed-inline {
  display: inline-flex;
  width: fit-content;
  margin-top: 5px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.thread-closed-inline {
  margin-top: 0;
}

.installer-thread-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.bubble-feed {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.discussion-pane .bubble-feed {
  margin-bottom: 0;
}

.bubble-row {
  display: flex;
  flex-direction: column;
}

.bubble-row.outgoing {
  align-items: flex-end;
}

.bubble-row.incoming {
  align-items: flex-start;
}

.bubble-label,
.bubble-meta {
  color: var(--muted);
  font-size: 11px;
  display: flex;
  gap: 7px;
}

.bubble {
  max-width: min(620px, 78%);
  padding: 10px 13px;
  border-radius: 16px;
  line-height: 1.5;
  white-space: pre-line;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  max-width: min(680px, 100%);
}

.bubble-row.outgoing .message-attachments {
  justify-content: flex-end;
}

.message-attachment-thumb {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.message-attachment-thumb img {
  display: block;
  width: 132px;
  height: 96px;
  object-fit: cover;
}

.message-attachment-file {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.message-attachment-file span {
  flex: 0 0 auto;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 900;
}

.message-attachment-file strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.bubble.out {
  border-bottom-right-radius: 4px;
  background: var(--accent);
  color: #fff;
}

.bubble.out.channel-whatsapp {
  background: #16a34a;
}

.bubble.out.channel-email {
  background: var(--blue);
  border-radius: 10px;
}

.bubble.in {
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  background: #fff;
}

.channel-row {
  align-items: center;
}

.channel-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.channel-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 5px 11px;
  cursor: pointer;
  font-weight: 900;
}

.channel-btn.active,
.channel-btn:hover {
  background: #fef2f2;
  color: var(--accent);
  border-color: #fecaca;
}

.channel-btn.is-disabled,
.channel-btn:disabled {
  background: #f8fafc;
  color: #94a3b8;
  border-color: #e5e7eb;
  cursor: not-allowed;
}

.composer-feedback {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.composer-feedback-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.composer-feedback-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.composer-feedback-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.message-send-row {
  align-items: flex-end;
  flex-wrap: nowrap;
}

.message-send-row textarea {
  min-height: 46px;
}

.send-dot {
  width: 44px;
  min-width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.send-dot:disabled {
  cursor: wait;
  opacity: 0.7;
}

.issue-section {
  overflow: hidden;
  margin-bottom: 12px;
}

.issue-section-head {
  display: flex;
  justify-content: space-between;
  padding: 11px 14px;
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
}

.issue-section-head span {
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.issue-table-wrap {
  overflow-x: auto;
}

.issue-table {
  min-width: 940px;
}

.issue-table td:nth-child(2) {
  min-width: 220px;
}

.ticket-detail-link {
  color: var(--accent);
  font-weight: 900;
}

.ticket-detail-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.linked-ref {
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
}

.blocking-flag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f0fdf4;
  color: #166534;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.blocking-flag.is-blocking {
  background: #fef2f2;
  color: #991b1b;
}

.issue-action-cell {
  align-items: center;
  flex-wrap: nowrap;
}

.ticket-dispatch-feedback {
  display: grid;
  gap: 5px;
  margin-top: 7px;
}

.owner-cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.inline-form {
  display: grid;
  gap: 6px;
}

.inline-form select {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
}

.inline-form .btn {
  width: 100%;
}

.task-columns,
.files-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 0.45fr);
  gap: 14px;
  align-items: start;
}

.task-list {
  display: grid;
  gap: 9px;
}

.task-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 14px;
}

.task-card.mini {
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  color: var(--text);
}

.task-card.is-overdue {
  border-color: #fecaca;
  background: #fff7f7;
}

.task-card.is-done {
  opacity: 0.7;
}

.task-card.is-done strong {
  text-decoration: line-through;
}

.task-check,
.task-toggle {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
}

.task-toggle {
  cursor: pointer;
  color: #166534;
  font-weight: 900;
}

.task-title-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.task-body p {
  margin: 6px 0 8px;
  color: var(--muted);
  line-height: 1.5;
}

.text-danger {
  color: var(--danger) !important;
  font-weight: 900;
}

.file-list {
  display: grid;
  gap: 8px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
}

.file-row > a {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.file-icon {
  width: 42px;
  height: 42px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 900;
}

.activity-feed {
  display: grid;
}

.activity-item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #f0f2f5;
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--blue);
}

.activity-item p {
  margin: 3px 0;
  color: #374151;
}

.activity-item small {
  color: var(--muted);
}

.ticket-sidebar {
  display: grid;
  gap: 12px;
}

/* Tickets reference design port. Scoped to the Tickets board/detail roots. */
.tickets-reference-board,
.ticket-reference-detail {
  --ticket-ref-bg: #f3f4f6;
  --ticket-ref-surface: #ffffff;
  --ticket-ref-soft: #f9fafb;
  --ticket-ref-line: #e5e7eb;
  --ticket-ref-text: #111111;
  --ticket-ref-mid: #374151;
  --ticket-ref-muted: #6b7280;
  --ticket-ref-faint: #9ca3af;
  --ticket-ref-primary: #e8573a;
  --ticket-ref-primary-dark: #c8462c;
  --ticket-ref-install: #e8863a;
  --ticket-ref-service: #3a87c8;
  --ticket-ref-eng: #3dad6f;
  --ticket-ref-inspect: #8b5cf6;
  --ticket-ref-admin: #4b5563;
  --ticket-ref-radius: 10px;
  color: var(--ticket-ref-text);
  font-size: 13.5px;
}

.tickets-reference-board {
  display: grid;
  gap: 14px;
}

.ticket-ref-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.ticket-ref-summary-card {
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--ticket-ref-line);
  border-radius: var(--ticket-ref-radius);
  background: var(--ticket-ref-surface);
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.05);
}

.ticket-ref-summary-card small,
.ticket-ref-note,
.ticket-ref-muted {
  color: var(--ticket-ref-muted);
}

.ticket-ref-summary-card small {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.ticket-ref-summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 25px;
  line-height: 1;
}

.ticket-ref-board-panel,
.ticket-ref-info-bar,
.ticket-ref-chat-main,
.ticket-ref-side-block {
  border: 1px solid var(--ticket-ref-line);
  border-radius: var(--ticket-ref-radius);
  background: var(--ticket-ref-surface);
}

.ticket-ref-board-panel {
  overflow: hidden;
}

.ticket-ref-board-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--ticket-ref-line);
}

.ticket-ref-board-title {
  min-width: 220px;
}

.ticket-ref-board-title h2 {
  margin: 2px 0 0;
  font-size: 18px;
}

.ticket-ref-board-title p,
.ticket-ref-form-note {
  margin: 0;
  color: var(--ticket-ref-muted);
  font-size: 12px;
  line-height: 1.4;
}

.ticket-ref-filter-bar {
  flex: 1 1 680px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.ticket-ref-filter-bar input {
  flex: 1 1 320px;
  min-width: 220px;
}

.ticket-ref-filter-bar select {
  flex: 0 0 150px;
  width: 150px;
}

.ticket-ref-filter-bar input,
.ticket-ref-filter-bar select,
.ticket-ref-control {
  min-height: 34px;
  border: 1px solid var(--ticket-ref-line);
  border-radius: 7px;
  background: #fff;
  color: var(--ticket-ref-mid);
  font-size: 12.5px;
}

.ticket-ref-table-wrap {
  overflow-x: auto;
}

.ticket-ref-board-table,
.ticket-ref-issues-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.ticket-ref-board-table th,
.ticket-ref-board-table td,
.ticket-ref-issues-table th,
.ticket-ref-issues-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ticket-ref-line);
  text-align: left;
  vertical-align: middle;
}

.ticket-ref-board-table th,
.ticket-ref-issues-table th {
  background: #fafafa;
  color: var(--ticket-ref-faint);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.35px;
  text-transform: uppercase;
}

.ticket-ref-board-row {
  cursor: pointer;
  transition: background 0.14s ease, box-shadow 0.14s ease;
}

.ticket-ref-board-row:hover,
.ticket-ref-board-row:focus-visible,
.ticket-ref-issues-table tbody tr:hover {
  background: #fef9f5;
  outline: none;
}

/* Compact board density — match the Deals list (board density + pagination pass). Scoped to the
   board table so the detail Issues table (.ticket-ref-issues-table) keeps its own padding. */
.ticket-ref-board-table {
  min-width: 1040px;
  font-size: 12px;
}

.ticket-ref-board-table th {
  padding: 7px 10px;
  font-size: 9px;
  letter-spacing: 0.4px;
}

.ticket-ref-board-table td {
  padding: 6px 10px;
}

.ticket-ref-board-table .ticket-ref-avatar {
  width: 22px;
  height: 22px;
  font-size: 9px;
}

.ticket-ref-board-table .ticket-ref-cell-stack small {
  font-size: 10.5px;
}

/* Breathing room between the ticket number and its category pill in the first column. */
.ticket-ref-board-table td .ticket-ref-dept-pill {
  margin-left: 10px;
  vertical-align: middle;
}

/* Pagination bar — mirrors the Deals list footer (Showing X–Y of Z · rows per page · prev/next). */
.ticket-ref-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-top: 1px solid var(--ticket-ref-line);
  background: #fff;
}

.ticket-ref-pagination-info {
  color: var(--ticket-ref-mid);
  font-size: 11.5px;
  font-weight: 700;
}

.ticket-ref-pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ticket-ref-page-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ticket-ref-faint);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ticket-ref-page-size select {
  min-height: 28px;
  border: 1px solid var(--ticket-ref-line);
  border-radius: 6px;
  background: #fff;
  color: var(--ticket-ref-text);
  font-size: 12px;
  padding: 4px 8px;
}

.ticket-ref-page-label {
  min-width: 96px;
  color: var(--ticket-ref-mid);
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
}

.ticket-ref-pagination .ticket-ref-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ticket-ref-primary-link {
  color: var(--ticket-ref-text);
  font-weight: 800;
}

.ticket-ref-primary-link:hover {
  color: var(--ticket-ref-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ticket-ref-cell-stack {
  display: grid;
  gap: 3px;
}

.ticket-ref-cell-stack small {
  color: var(--ticket-ref-faint);
  font-size: 11.5px;
  line-height: 1.25;
}

.ticket-ref-mini-pills,
.ticket-ref-meta-chips,
.ticket-ref-row-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ticket-ref-pill,
.ticket-ref-status-pill,
.ticket-ref-dept-pill,
.ticket-ref-id-pill,
.ticket-ref-task-chip,
.ticket-ref-po-chip,
.ticket-ref-po-status,
.ticket-ref-count-badge,
.ticket-ref-demo-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 5px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.ticket-ref-pill,
.ticket-ref-status-pill {
  padding: 4px 9px;
  background: #f3f4f6;
  color: var(--ticket-ref-mid);
}

.ticket-ref-id-pill {
  padding: 5px 10px;
  border: 1px solid var(--ticket-ref-line);
  background: #fff;
  color: var(--ticket-ref-mid);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.ticket-ref-dept-pill {
  padding: 5px 10px;
  color: #fff;
}

.ticket-ref-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.ticket-ref-status-blocking {
  background: #fee2e2;
  color: #991b1b;
}

.ticket-ref-status-attention,
.ticket-ref-status-active {
  background: #fffbeb;
  color: #92400e;
}

.ticket-ref-status-ready {
  background: #dcfce7;
  color: #166534;
}

.ticket-ref-status-empty {
  background: #f3f4f6;
  color: #4b5563;
}

.ticket-ref-cat-installation,
.ticket-ref-dept-installation {
  background: var(--ticket-ref-install);
}

.ticket-ref-cat-service,
.ticket-ref-dept-service {
  background: var(--ticket-ref-service);
}

.ticket-ref-cat-engineering,
.ticket-ref-dept-engineering {
  background: var(--ticket-ref-eng);
}

.ticket-ref-cat-inspection,
.ticket-ref-dept-inspection {
  background: var(--ticket-ref-inspect);
}

.ticket-ref-cat-administrative,
.ticket-ref-dept-administrative {
  background: var(--ticket-ref-admin);
}

.ticket-reference-detail {
  display: grid;
  gap: 12px;
  background: var(--ticket-ref-bg);
}

.ticket-ref-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 10px 14px;
  border: 1px solid var(--ticket-ref-line);
  border-radius: var(--ticket-ref-radius);
  background: #fff;
}

.ticket-ref-top-left,
.ticket-ref-actions,
.ticket-ref-homeowner-actions,
.ticket-ref-owner-cell,
.ticket-ref-side-title,
.ticket-ref-linked-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ticket-ref-back {
  width: 32px;
  height: 32px;
  border: 1px solid var(--ticket-ref-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ticket-ref-mid);
  font-size: 17px;
  font-weight: 900;
}

.ticket-ref-crumb {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--ticket-ref-faint);
  font-size: 11.5px;
}

.ticket-ref-crumb a {
  color: var(--ticket-ref-primary);
  font-weight: 800;
}

.ticket-ref-title-small {
  margin-top: 2px;
  color: var(--ticket-ref-text);
  font-size: 14px;
  font-weight: 700;
}

.ticket-ref-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 7px 11px;
  border: 1px solid var(--ticket-ref-line);
  border-radius: 7px;
  background: #fff;
  color: var(--ticket-ref-mid);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.ticket-ref-btn.primary {
  border-color: var(--ticket-ref-primary);
  background: var(--ticket-ref-primary);
  color: #fff;
}

.ticket-ref-btn.green {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.ticket-ref-btn.blue {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.ticket-ref-info-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 0;
  overflow: hidden;
}

.ticket-ref-info-status,
.ticket-ref-homeowner {
  padding: 16px 18px;
}

.ticket-ref-info-status {
  border-right: 1px solid var(--ticket-ref-line);
}

.ticket-ref-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.ticket-ref-info-status h1 {
  margin: 0 0 4px;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

.ticket-ref-summary {
  max-width: 860px;
  margin: 0;
  color: var(--ticket-ref-muted);
  line-height: 1.45;
}

.ticket-ref-stage-bar {
  display: flex;
  gap: 0;
  margin: 14px 0 11px;
  overflow-x: auto;
}

.ticket-ref-stage-step {
  min-width: 112px;
  padding: 7px 12px;
  border: 1px solid var(--ticket-ref-line);
  background: #fff;
  color: var(--ticket-ref-muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.ticket-ref-stage-step:first-child {
  border-radius: 8px 0 0 8px;
}

.ticket-ref-stage-step:last-child {
  border-radius: 0 8px 8px 0;
}

.ticket-ref-stage-step + .ticket-ref-stage-step {
  border-left: 0;
}

.ticket-ref-stage-step.done {
  background: #f0fdf4;
  color: #166534;
}

.ticket-ref-stage-step.active {
  border-color: var(--ticket-ref-primary);
  background: var(--ticket-ref-primary);
  color: #fff;
}

.ticket-ref-progress-row {
  display: grid;
  gap: 6px;
  margin-bottom: 11px;
}

.ticket-ref-progress-label {
  display: flex;
  justify-content: space-between;
  color: var(--ticket-ref-muted);
  font-size: 12px;
  font-weight: 700;
}

.ticket-ref-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.ticket-ref-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ticket-ref-eng);
}

.ticket-ref-meta-chips span {
  padding: 5px 9px;
  border-radius: 7px;
  background: var(--ticket-ref-soft);
  color: var(--ticket-ref-muted);
  font-size: 12px;
}

.ticket-ref-meta-chips strong {
  color: var(--ticket-ref-mid);
}

.ticket-ref-homeowner-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.ticket-ref-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #fce7d9;
  color: var(--ticket-ref-primary);
  font-size: 11px;
  font-weight: 900;
}

.ticket-ref-avatar.large {
  width: 48px;
  height: 48px;
  font-size: 15px;
}

.ticket-ref-homeowner-name {
  color: var(--ticket-ref-text);
  font-size: 16px;
  font-weight: 800;
}

.ticket-ref-contact-list {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.ticket-ref-contact-item {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ticket-ref-mid);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.ticket-ref-chat-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 14px;
  align-items: start;
}

.ticket-ref-chat-main {
  overflow: hidden;
}

.ticket-ref-tabs,
.ticket-ref-disc-subtabs,
.ticket-ref-task-filters {
  display: flex;
  gap: 0;
  overflow-x: auto;
  background: #fff;
}

.ticket-ref-tabs {
  border-bottom: 1px solid var(--ticket-ref-line);
}

.ticket-ref-tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ticket-ref-muted);
  cursor: pointer;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.ticket-ref-tab.active {
  border-bottom-color: var(--ticket-ref-primary);
  color: var(--ticket-ref-primary);
}

.ticket-ref-tab-badge,
.ticket-ref-count-badge {
  padding: 2px 7px;
  background: #f3f4f6;
  color: var(--ticket-ref-muted);
}

.ticket-ref-tab-pane {
  display: none;
  padding: 16px;
  background: #f7f7f8;
}

.ticket-ref-tab-pane.active {
  display: block;
}

.ticket-ref-disc-subtabs {
  border-bottom: 2px solid var(--ticket-ref-line);
  margin-bottom: 14px;
}

.ticket-ref-disc-subtab {
  flex: 1 0 190px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--ticket-ref-muted);
  cursor: pointer;
  padding: 11px;
  font-weight: 900;
}

.ticket-ref-disc-subtab.active {
  border-bottom-color: var(--ticket-ref-primary);
  color: var(--ticket-ref-primary);
}

.ticket-ref-disc-pane {
  display: none;
}

.ticket-ref-disc-pane.active {
  display: grid;
  gap: 12px;
}

.ticket-ref-composer,
.ticket-ref-comment,
.ticket-ref-customer-thread,
.ticket-ref-section-card,
.ticket-ref-task-card,
.ticket-ref-file-card,
.ticket-ref-activity-card,
.ticket-ref-add-task-form,
.ticket-ref-todo-banner {
  border: 1px solid var(--ticket-ref-line);
  border-radius: var(--ticket-ref-radius);
  background: #fff;
}

.ticket-ref-composer {
  display: grid;
  gap: 10px;
  padding: 13px;
}

.ticket-ref-composer-head,
.ticket-ref-comment-head,
.ticket-ref-bubble-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.ticket-ref-internal-badge,
.ticket-ref-channel-badge,
.ticket-ref-demo-chip {
  padding: 4px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--ticket-ref-muted);
  font-size: 10.5px;
  font-weight: 900;
}

.ticket-ref-internal-badge {
  background: #fef3c7;
  color: #92400e;
}

.ticket-ref-channel-badge.sms {
  background: #eff6ff;
  color: #1d4ed8;
}

.ticket-ref-channel-badge.whatsapp {
  background: #f0fdf4;
  color: #15803d;
}

.ticket-ref-channel-badge.email {
  background: #fff7ed;
  color: #9a3412;
}

.ticket-ref-textarea {
  min-height: 82px;
  resize: vertical;
}

.ticket-ref-file-preview-strip {
  display: flex;
  gap: 6px;
  min-height: 34px;
}

.ticket-ref-file-preview-item {
  width: 42px;
  height: 34px;
  border-radius: 7px;
  background: linear-gradient(135deg, #dbeafe, #93c5fd);
}

.ticket-ref-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ticket-ref-muted);
  font-size: 12px;
}

.ticket-ref-feed {
  display: grid;
  gap: 10px;
}

.ticket-ref-feed-day {
  color: var(--ticket-ref-faint);
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.4px;
  text-align: center;
  text-transform: uppercase;
}

.ticket-ref-comment {
  padding: 12px;
}

.ticket-ref-comment.internal {
  border-left: 3px solid var(--ticket-ref-primary);
}

.ticket-ref-comment-body {
  margin: 9px 0 0 41px;
  color: var(--ticket-ref-mid);
  line-height: 1.45;
}

.ticket-ref-mention {
  color: var(--ticket-ref-primary);
  font-weight: 900;
}

.ticket-ref-media-row {
  display: flex;
  gap: 8px;
  margin: 10px 0 0 41px;
}

.ticket-ref-media-thumb {
  width: 72px;
  height: 54px;
  border-radius: 8px;
  background: linear-gradient(135deg, #93c5fd, #3b82f6);
}

.ticket-ref-customer-thread {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.ticket-ref-bubble-feed {
  display: grid;
  gap: 10px;
}

.ticket-ref-bubble-row {
  display: grid;
  gap: 4px;
}

.ticket-ref-bubble-row.outgoing {
  justify-items: end;
}

.ticket-ref-bubble-label,
.ticket-ref-bubble-meta {
  color: var(--ticket-ref-faint);
  font-size: 10.5px;
  font-weight: 700;
}

.ticket-ref-bubble {
  max-width: min(620px, 88%);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--ticket-ref-line);
  background: #fff;
  color: var(--ticket-ref-mid);
  line-height: 1.42;
}

.ticket-ref-bubble.out {
  border-color: var(--ticket-ref-primary);
  background: var(--ticket-ref-primary);
  color: #fff;
}

.ticket-ref-bubble.out.whatsapp {
  border-color: #25d366;
  background: #25d366;
}

.ticket-ref-bubble.out.email {
  border-color: var(--ticket-ref-service);
  background: var(--ticket-ref-service);
}

.ticket-ref-channel-row,
.ticket-ref-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.ticket-ref-input-row textarea {
  flex: 1 1 260px;
  min-height: 42px;
}

.ticket-ref-todo-banner {
  padding: 10px 12px;
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.ticket-ref-issues-filter,
.ticket-ref-task-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.ticket-ref-issues-filter input {
  flex: 1 1 260px;
}

.ticket-ref-filter-pill,
.ticket-ref-type-filter {
  border: 1px solid var(--ticket-ref-line);
  border-radius: 999px;
  background: #fff;
  color: var(--ticket-ref-mid);
  cursor: pointer;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 800;
}

.ticket-ref-filter-pill.active,
.ticket-ref-type-filter.active {
  border-color: var(--ticket-ref-primary);
  background: #fff7ed;
  color: var(--ticket-ref-primary);
}

.ticket-ref-section-card {
  overflow: hidden;
}

.ticket-ref-section-card + .ticket-ref-section-card {
  margin-top: 12px;
}

.ticket-ref-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  color: #fff;
}

.ticket-ref-section-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ticket-ref-section-title {
  font-weight: 900;
}

.ticket-ref-ticket-badge {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.ticket-ref-count-badge.light {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.ticket-ref-issues-table tbody tr {
  cursor: pointer;
}

.ticket-ref-task-chip {
  padding: 4px 8px;
  background: #f3f4f6;
  color: var(--ticket-ref-mid);
}

.ticket-ref-po-chip {
  padding: 4px 8px;
  background: #eff6ff;
  color: #1d4ed8;
}

.ticket-ref-po-chip.pending,
.ticket-ref-po-status.pending {
  background: #fffbeb;
  color: #92400e;
}

.ticket-ref-po-status {
  padding: 4px 8px;
  background: #dcfce7;
  color: #166534;
}

.ticket-ref-wo-link {
  color: #1d4ed8;
  font-weight: 900;
}

.ticket-ref-block-dot {
  display: inline-flex;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}

.ticket-ref-view-btn {
  border: 1px solid var(--ticket-ref-line);
  border-radius: 7px;
  background: #fff;
  color: var(--ticket-ref-primary);
  cursor: pointer;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 900;
}

.ticket-ref-task-list,
.ticket-ref-file-list,
.ticket-ref-activity-feed,
.ticket-ref-side-stack {
  display: grid;
  gap: 10px;
}

.ticket-ref-task-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ticket-ref-faint);
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.ticket-ref-task-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 11px 12px;
}

.ticket-ref-task-check {
  width: 20px;
  height: 20px;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  color: #fff;
  text-align: center;
  line-height: 16px;
  font-size: 11px;
  font-weight: 900;
}

.ticket-ref-task-check.done {
  border-color: #22c55e;
  background: #22c55e;
}

.ticket-ref-task-name {
  color: var(--ticket-ref-text);
  font-weight: 800;
  line-height: 1.35;
}

.ticket-ref-task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  color: var(--ticket-ref-muted);
  font-size: 11.5px;
}

.ticket-ref-task-due {
  padding: 3px 7px;
  border-radius: 999px;
  background: #f0fdf4;
  color: #166534;
  font-weight: 800;
}

.ticket-ref-task-due.soon {
  background: #fffbeb;
  color: #92400e;
}

.ticket-ref-task-due.overdue {
  background: #fee2e2;
  color: #991b1b;
}

.ticket-ref-task-priority {
  font-weight: 800;
}

.ticket-ref-add-task-form {
  display: none;
  gap: 10px;
  padding: 13px;
}

.ticket-ref-add-task-form.open {
  display: grid;
}

.ticket-ref-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.ticket-ref-file-card,
.ticket-ref-activity-card {
  display: flex;
  gap: 10px;
  padding: 11px 12px;
  align-items: center;
}

.ticket-ref-file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 10px;
  font-weight: 900;
}

.ticket-ref-activity-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ticket-ref-primary);
}

.ticket-ref-activity-dot.blue {
  background: var(--ticket-ref-service);
}

.ticket-ref-activity-dot.green {
  background: var(--ticket-ref-eng);
}

.ticket-ref-activity-dot.red {
  background: #dc2626;
}

.ticket-ref-chat-sidebar {
  display: grid;
  gap: 10px;
}

.ticket-ref-side-block {
  padding: 13px;
}

.ticket-ref-side-title {
  justify-content: space-between;
  margin-bottom: 9px;
  color: var(--ticket-ref-text);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.ticket-ref-side-title a,
.ticket-ref-side-action {
  color: var(--ticket-ref-primary);
  font-size: 11px;
  font-weight: 900;
}

.ticket-ref-side-row,
.ticket-ref-fin-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  color: var(--ticket-ref-mid);
  font-size: 12px;
}

.ticket-ref-side-label,
.ticket-ref-fin-label {
  color: var(--ticket-ref-faint);
  font-weight: 800;
}

.ticket-ref-side-value,
.ticket-ref-fin-value {
  color: var(--ticket-ref-text);
  font-weight: 800;
  text-align: right;
}

.ticket-ref-pay-row,
.ticket-ref-change-item,
.ticket-ref-linked-item,
.ticket-ref-history-item,
.ticket-ref-task-mini {
  padding: 8px;
  border: 1px solid var(--ticket-ref-line);
  border-radius: 8px;
  background: var(--ticket-ref-soft);
}

.ticket-ref-pay-row + .ticket-ref-pay-row,
.ticket-ref-change-item + .ticket-ref-change-item,
.ticket-ref-linked-item + .ticket-ref-linked-item,
.ticket-ref-history-item + .ticket-ref-history-item,
.ticket-ref-task-mini + .ticket-ref-task-mini {
  margin-top: 6px;
}

.ticket-ref-pay-status,
.ticket-ref-change-status {
  display: inline-flex;
  margin-top: 4px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--ticket-ref-muted);
  font-size: 10.5px;
  font-weight: 900;
}

.ticket-ref-pay-status.received,
.ticket-ref-change-status.signed {
  background: #dcfce7;
  color: #166534;
}

.ticket-ref-pay-status.pending,
.ticket-ref-change-status.pending {
  background: #fffbeb;
  color: #92400e;
}

.ticket-ref-linked-item {
  display: flex;
  align-items: center;
  gap: 9px;
}

.ticket-ref-linked-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 900;
}

.ticket-ref-empty {
  padding: 18px;
  color: var(--ticket-ref-faint);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 1180px) {
  .ticket-ref-chat-area,
  .ticket-ref-info-bar {
    grid-template-columns: 1fr;
  }

  .ticket-ref-info-status {
    border-right: 0;
    border-bottom: 1px solid var(--ticket-ref-line);
  }

  .ticket-ref-chat-sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .ticket-ref-summary-grid,
  .ticket-ref-chat-sidebar,
  .ticket-ref-form-grid {
    grid-template-columns: 1fr;
  }

  .ticket-ref-board-head,
  .ticket-ref-top-bar,
  .ticket-ref-actions {
    display: grid;
    justify-content: stretch;
  }

  .ticket-ref-filter-bar > *,
  .ticket-ref-actions > *,
  .ticket-ref-homeowner-actions > * {
    width: 100%;
  }
}

.detail-list,
.financial-summary {
  display: grid;
  gap: 8px;
  margin: 0;
}

.detail-list div,
.financial-summary div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, auto);
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0f2f5;
}

.detail-list div:last-child,
.financial-summary div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.financial-summary .is-total {
  padding-top: 2px;
  border-bottom: 0;
  color: var(--text);
}

.detail-list dd,
.financial-summary dd {
  margin: 0;
  font-weight: 900;
  text-align: right;
}

.financial-card .panel-head {
  align-items: start;
}

.financial-edit-actions {
  display: flex;
  gap: 6px;
}

.financial-edit-field {
  display: none;
}

.financial-card.is-editing .financial-readonly {
  display: none;
}

.financial-card.is-editing .financial-edit-field {
  display: block;
}

.financial-card.is-editing .payment-status-picker {
  position: relative;
  display: inline-grid;
  justify-items: end;
}

.financial-summary .financial-edit-field input,
.financial-payment-row .financial-edit-field,
.inline-order-form select,
.linked-order-actions select {
  width: 100%;
}

.financial-summary .financial-edit-field input {
  min-height: 32px;
  padding: 6px 8px;
  text-align: right;
}

.financial-summary .is-total .financial-edit-field {
  color: var(--text);
}

.job-calculator {
  display: grid;
  gap: 18px;
  min-height: 520px;
  padding: 26px 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.job-calculator-head,
.job-calculator-items-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.job-calculator-head h3 {
  margin: 0;
  font-size: 15px;
}

.job-calculator-profit-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.job-calculator-profit-chip.is-negative {
  background: #fee2e2;
  color: #991b1b;
}

.job-calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 42px;
  align-items: start;
}

.job-calculator-column {
  display: grid;
  gap: 22px;
}

.calc-field-row {
  display: grid;
  grid-template-columns: 220px minmax(220px, 1fr);
  gap: 18px;
  align-items: center;
}

.calc-field-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  margin: 0;
  color: #6b6878;
  font-size: 12px;
  font-weight: 900;
}

.calc-help {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #7a7787;
  border-radius: 50%;
  background: #fff;
  color: #6b6878;
  cursor: help;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.calc-field-control,
.calc-custom-control {
  display: grid;
  gap: 7px;
}

.calc-input-wrap {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #c7c9d1;
  border-radius: 4px;
  background: #fff;
  padding: 0 13px;
}

.calc-input-wrap span {
  flex: 0 0 auto;
  color: #767386;
  font-size: 12px;
  font-weight: 800;
}

.calc-input-wrap input {
  width: 100%;
  min-height: 38px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #403d4f;
  font-size: 12px;
  font-weight: 700;
}

.calc-input-wrap input[readonly] {
  color: #5e5b6d;
}

.calc-input-wrap-stepper {
  padding-right: 7px;
}

.calc-stepper {
  flex: 0 0 auto;
  display: grid;
  gap: 2px;
  align-items: center;
}

.calc-stepper button {
  width: 22px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #767386;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.calc-stepper button:hover:not(:disabled) {
  background: #f3f4f8;
  color: #2f2b3d;
}

.calc-stepper button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.calc-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #454253;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
}

.calc-check input {
  width: 16px;
  height: 16px;
  accent-color: #ff4b5c;
}

.calc-percent-row .calc-field-label {
  display: grid;
  align-content: center;
  gap: 9px;
}

.job-calculator-custom-fields {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.job-calculator-custom-fields h4 {
  margin: 0;
  color: #333142;
  font-size: 12px;
  font-weight: 900;
}

.job-calculator-custom-list {
  display: grid;
  gap: 16px;
}

.calc-custom-control {
  grid-template-columns: minmax(220px, 1fr) auto 32px;
  align-items: center;
}

.calc-custom-control .calc-check {
  grid-column: 1 / 2;
}

.job-calculator-add-field {
  width: fit-content;
  min-height: 34px;
  padding: 0 17px;
  border: 0;
  border-radius: 6px;
  background: #ff4658;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.job-calculator-remove {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 4px;
  background: #fff;
  color: #ff4658;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.job-calculator-remove:hover {
  background: #fef2f2;
}

.job-calculator-readonly {
  margin-top: 12px;
}

.job-calculator-edit {
  margin-top: 12px;
}

.job-calculator-edit .job-calculator {
  padding: 10px;
}

.calculator-readout {
  display: grid;
  gap: 8px;
}

.calculator-readout div {
  padding: 9px 10px;
  border: 1px solid #edf0f5;
  border-radius: 8px;
  background: var(--surface-soft);
}

.calculator-readout dt {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 900;
  text-transform: uppercase;
}

.calculator-readout dd {
  display: block;
  margin: 4px 0 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.calculator-readout dd.is-negative {
  color: #b91c1c;
}

.financial-card .job-calculator-layout,
.financial-card .calc-field-row {
  grid-template-columns: 1fr;
}

.financial-card .job-calculator-layout {
  gap: 18px;
}

.financial-card .job-calculator-column {
  gap: 12px;
}

.financial-card .job-calculator-remove {
  width: 100%;
}

.modal-box.job-calculator-modal-box {
  width: min(1600px, calc(100vw - 28px));
}

.job-calculator-custom-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.32);
}

.job-calculator-custom-modal[hidden] {
  display: none;
}

.job-calculator-custom-dialog {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.job-calculator-custom-dialog h4 {
  margin: 0;
  color: #242233;
}

.job-calculator-custom-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.sidebar-section-title {
  margin: 12px 0 7px;
  color: #374151;
  font-size: 11.5px;
  font-weight: 900;
  text-transform: uppercase;
}

.payment-schedule {
  margin-top: 12px;
}

.payment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid #f0f2f5;
}

.payment-row:first-of-type {
  border-top: 0;
}

.payment-main {
  min-width: 0;
}

.payment-main strong {
  display: block;
  font-size: 13px;
}

.payment-main strong span,
.payment-main small {
  color: var(--muted);
  font-weight: 700;
}

.payment-main small {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
}

.payment-status,
.order-status {
  border: 0;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 10.5px;
  font-weight: 900;
  line-height: 1.25;
  white-space: nowrap;
}

button.payment-status {
  cursor: pointer;
}

button.payment-status:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

.payment-status-received,
.order-status.is-received {
  background: #dcfce7;
  color: #166534;
}

.payment-status-pending,
.order-status.is-pending {
  background: #fef3c7;
  color: #92400e;
}

.payment-status-not_due,
.order-status.is-work {
  background: #eff6ff;
  color: #1d4ed8;
}

.payment-status-overdue {
  background: #fee2e2;
  color: #991b1b;
}

.order-status.is-danger {
  background: #fee2e2;
  color: #991b1b;
}

.milestone-edit-grid {
  grid-column: 1 / -1;
  margin-top: 6px;
}

.financial-card.is-editing .milestone-edit-grid {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 6px;
}

.milestone-edit-grid label {
  display: grid;
  gap: 3px;
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 900;
  text-transform: uppercase;
}

.milestone-edit-grid input {
  min-height: 30px;
  padding: 5px 7px;
}

.milestone-edit-grid span {
  grid-column: 1 / -1;
  color: #374151;
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.payment-status-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: grid;
  min-width: 118px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
}

.payment-status-menu-option {
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 7px 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.payment-status-menu-option:hover,
.payment-status-menu-option:focus-visible {
  background: #f3f4f6;
  outline: 0;
}

.remaining-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--radius);
  background: #111827;
  color: #fff;
}

.remaining-balance span {
  color: #d1d5db;
  font-size: 12px;
  font-weight: 800;
}

.remaining-balance strong {
  font-size: 16px;
}

.sidebar-task-list,
.linked-list {
  display: grid;
  gap: 8px;
}

.sidebar-task,
.linked-list > div,
.linked-list > form {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 9px;
  text-align: left;
}

.sidebar-task {
  cursor: pointer;
}

.sidebar-task.is-overdue {
  border-color: #fecaca;
  background: #fff7f7;
}

.sidebar-task span,
.linked-list span:not(.order-status) {
  color: var(--muted);
  font-size: 12px;
}

.orders-panel .sidebar-section-title:first-of-type {
  margin-top: 0;
}

.linked-list.compact {
  gap: 6px;
}

.linked-list.compact .linked-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 8px;
}

.linked-list.compact .order-update-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.linked-order-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.linked-installer-summary,
.linked-installer-fields {
  grid-column: 1 / -1;
}

.linked-installer-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.linked-installer-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.linked-installer-fields input {
  min-height: 30px;
  padding: 5px 8px;
}

.linked-order-actions select,
.inline-order-form select {
  min-height: 30px;
  padding: 5px 8px;
}

.linked-row strong {
  display: block;
  font-size: 12.5px;
}

.linked-row span:not(.order-status) {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-compact {
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 12px;
}

.issue-order-cell {
  display: grid;
  min-width: 110px;
  gap: 6px;
}

.issue-order-cell strong {
  font-size: 12px;
}

.inline-order-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.empty-state,
.empty-inline {
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.4);
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
}

.modal-head {
  border-bottom: 1px solid #f0f0f0;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.modal-close:hover {
  background: #eef2f7;
  color: var(--text);
}

.send-update-form {
  display: grid;
  gap: 11px;
  padding: 16px 20px 18px;
}

.modal-foot {
  padding: 13px 0 0;
  justify-content: flex-end;
  border-top: 1px solid #f0f0f0;
}

.modal-alert {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  font-weight: 700;
}

.modal-alert ul {
  margin: 8px 0 0 18px;
  padding: 0;
  font-weight: 600;
}

.modal-alert-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.modal-alert-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.channel-toggle-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.channel-toggle-group legend {
  grid-column: 1 / -1;
  color: #374151;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 2px;
}

.channel-toggle {
  position: relative;
  display: grid;
  gap: 3px;
  min-height: 78px;
  padding: 11px 12px 11px 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
}

.channel-toggle input {
  position: absolute;
  left: 11px;
  top: 13px;
  width: 16px;
  height: 16px;
}

.channel-toggle span {
  font-size: 13px;
  font-weight: 900;
  color: var(--text);
}

.channel-toggle .channel-label-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.channel-warning-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fef3c7;
  color: #b45309;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.channel-toggle small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.channel-toggle.has-channel-warning {
  border-color: #fecaca;
}

.channel-toggle.has-channel-warning:has(input:checked) {
  border-color: #f87171;
  background: #fffafa;
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.1);
}

.channel-toggle:has(input:checked) {
  border-color: var(--accent);
  background: #fff7f5;
  box-shadow: 0 0 0 3px rgba(232, 87, 58, 0.08);
}

.channel-toggle.is-disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.provider-note {
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 1340px) {
  .dashboard-workspace {
    grid-template-columns: 1fr;
  }

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

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

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

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

  .ticket-workspace,
  .dashboard-grid,
  .dashboard-workspace,
  .content-grid,
  .task-columns,
  .files-grid {
    grid-template-columns: 1fr;
  }

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

  .dashboard-search {
    width: min(100%, 420px);
  }

  .ticket-sidebar {
    order: -1;
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    display: none;
  }

  .mobile-brand {
    display: block;
  }

  .app-main {
    padding: 16px;
  }

  .dashboard-topbar {
    display: grid;
  }

  .dashboard-tools {
    justify-content: stretch;
  }

  .dashboard-side-stack {
    grid-template-columns: 1fr;
  }

  .dashboard-search,
  .dashboard-tools form,
  .dashboard-tools .btn {
    width: 100%;
  }

  .ticket-hero {
    grid-template-columns: 1fr;
  }

  .ticket-status-panel {
    border-right: 0 !important;
    border-bottom: 1px solid var(--line) !important;
  }

  .form-grid.two,
  .form-grid.three,
  .form-grid.four,
  .contact-grid {
    grid-template-columns: 1fr;
  }

  .job-calculator-layout,
  .calc-field-row {
    grid-template-columns: 1fr;
  }

  .calc-custom-control {
    grid-template-columns: 1fr auto;
  }

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

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

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

  .unmatched-summary-grid,
  .unmatched-detail-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-header,
  .ticket-topbar {
    display: grid;
  }

  .header-actions,
  .filter-bar,
  .button-row {
    width: 100%;
  }

  .header-actions > *,
  .filter-bar input,
  .filter-bar select,
  .filter-bar button,
  .button-row > * {
    width: 100%;
  }

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

  .ticket-board-summary {
    grid-template-columns: 1fr;
  }

  .dashboard-title-group h1 {
    font-size: 26px;
  }

  .dashboard-summary-grid {
    grid-template-columns: 1fr;
  }

  .communication-item {
    display: grid;
  }

  .bubble {
    max-width: 94%;
  }

  .inline-form {
    display: grid;
  }

  .channel-toggle-group {
    grid-template-columns: 1fr;
  }

  .job-calculator-layout,
  .calc-field-row,
  .calc-custom-control {
    grid-template-columns: 1fr;
  }

  .job-calculator-remove {
    width: 100%;
  }

  .modal-foot {
    display: grid;
  }
}

@media (min-width: 561px) {
  .dashboard-new-ticket-modal .form-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-new-ticket-modal .modal-foot {
    display: flex;
  }
}

@media (max-width: 560px) {
  .dashboard-new-ticket-modal .form-grid.two {
    grid-template-columns: 1fr;
  }
}
