/* ============================================================
   SITE SURVEY QUEUE — js/site-survey-queue.js (KAN-193)
   ------------------------------------------------------------
   The New Jersey site survey queue, in two homes: the Review Center's third
   tab (#siteSurveysScreen > #siteSurveysBody.ssq-root) and the Sales
   dashboard's "Site surveys" view (#salesBody > .ssq-root). Mythril Version 1:
   the scene shows through the page, group heads are a name and a count, the
   table is the board table (a rule on every cell, sentence-case header),
   states are quiet tiles, and one gold fill marks the step. In .ssq-* classes
   from the design-system tokens (css/design-system.css), so it reads the
   same in light and dark on either screen and nothing here reaches past its
   own classes. Phones (≤ 640px) stack every row as a card.
   ============================================================ */

/* ---- the frame ---- */
#siteSurveysScreen { padding: 0; }
#siteSurveysBody.ssq-root {
  max-width: none; margin: 0; padding: 18px var(--page-gutter) var(--page-end);
  background: transparent; min-height: calc(100% - 80px);
}
.ssq-root {
  color: var(--text-body); font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
}
/* The Sales view's doors (js/sales-crm.js, js/sales-dashboard.js) stay shut
   until the queue's module opens them, whatever display a skin gives them. */
[data-ssq-door][hidden] { display: none !important; }

.ssq-loading, .ssq-none { color: var(--text-muted); font-size: 13.5px; line-height: 1.5; margin: 8px 0; }
.ssq-none-queue { padding: 40px 8px; text-align: center; }
.ssq-error {
  color: var(--red-ink); background: var(--red-bg); border-radius: var(--my-r);
  padding: 10px 14px; font-size: 13.5px; line-height: 1.45; margin: 10px 0;
}
.ssq-dim { color: var(--text-faint); }

/* ---- the head ---- */
.ssq-head { margin: 4px 0 22px; }
.ssq-back {
  display: inline-block; margin-bottom: 10px; font-size: 13px; font-weight: 500;
  color: var(--gold-ink); text-decoration: none;
}
.ssq-back:hover { color: var(--text-head); text-decoration: underline; text-underline-offset: 3px; }
.ssq-title {
  margin: 0; font-family: var(--font-serif); font-size: 26px; font-weight: 600;
  letter-spacing: -0.01em; line-height: 1.15; color: var(--text-head);
}
.ssq-count, .ssq-group-count {
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 400; color: var(--text-muted);
  letter-spacing: 0; margin-left: 6px;
}
.ssq-sub { margin: 6px 0 0; font-size: 13.5px; color: var(--text-muted); line-height: 1.5; }

/* ---- Assigned to you ---- */
.ssq-mine {
  background: color-mix(in oklab, var(--surface) 62%, transparent); border: 0; border-radius: var(--my-r-lg);
  box-shadow: inset 0 0 0 1px var(--hairline);
  padding: 14px 16px; margin: 0 0 30px;
}
.ssq-h2 {
  margin: 0 0 6px; font-family: var(--font-serif); font-size: 17px; font-weight: 600; color: var(--text-head);
}
.ssq-mine .ssq-none { margin: 2px 0 0; }
.ssq-mine-list { list-style: none; margin: 0; padding: 0; }
.ssq-mine-row {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  padding: 9px 0; border-top: 1px solid var(--rule);
}
.ssq-mine-row:first-child { border-top: 0; }
.ssq-mine-meta { font-size: 12.5px; color: var(--text-muted); }
.ssq-addr {
  color: var(--text-head); font-weight: 500; text-decoration: underline;
  text-decoration-color: var(--rule-strong); text-underline-offset: 3px;
}
.ssq-addr:hover, .ssq-addr:focus-visible { text-decoration-color: currentColor; }
.ssq-addr:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; border-radius: 2px; }

/* ---- the groups: THE TABLE's grouped sheet (design-system.css). Each group
   is one lifted sheet: a 46px tinted band (fold chevron, number tile, name,
   count), then the table with its own head row. Colour comes from --gc. ---- */
.ssq-group {
  --gc: var(--royal);
  --ssq-band: color-mix(in oklab, var(--gc) 13%, var(--surface));
  --ssq-band-ink: color-mix(in oklab, var(--gc) 40%, var(--text-strong));
  --ssq-band-ink-2: color-mix(in oklab, var(--gc) 26%, var(--text-muted));
  --ssq-band-tile: color-mix(in oklab, var(--gc) 25%, var(--surface));
  margin: 16px 0 0; background: var(--surface); border-radius: 14px;
  box-shadow: var(--ds-shadow-card); overflow: hidden;
}
[data-theme="dark"] .ssq-group {
  --ssq-band: color-mix(in oklab, var(--gc) 14%, var(--surface));
  --ssq-band-ink: color-mix(in oklab, var(--gc) 26%, var(--text-strong));
  --ssq-band-ink-2: color-mix(in oklab, var(--gc) 22%, var(--text-muted));
  --ssq-band-tile: color-mix(in oklab, var(--gc) 38%, var(--surface));
}
.ssq-group[data-status="returned"] { --gc: var(--amber); }
.ssq-group[data-status="assigned"] { --gc: var(--green); }
.ssq-group[data-status="with_agent"] { --gc: var(--info); }
.ssq-group-head {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 46px;
  margin: 0; padding: 0 16px 0 0; border: 0; background: var(--ssq-band); font: inherit;
  color: var(--ssq-band-ink); text-align: left; cursor: pointer; user-select: none;
  transition: box-shadow .15s ease-out;
}
.ssq-group-head:hover { box-shadow: inset 0 0 0 200px color-mix(in oklab, var(--gc) 7%, transparent); }
.ssq-group-head:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.ssq-caret {
  flex: none; width: 46px; height: 46px; margin-right: -10px; display: grid; place-items: center;
  color: var(--ssq-band-ink-2); transition: transform .3s var(--my-ease-out);
}
.ssq-caret svg { width: 16px; height: 16px; }
.ssq-group-folded .ssq-caret { transform: rotate(-90deg); }
.ssq-group-num {
  flex: none; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  font: 700 12px var(--font-serif); color: var(--ssq-band-ink); background: var(--ssq-band-tile);
}
.ssq-group-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 600 16.5px/1.2 var(--font-serif); letter-spacing: -.01em; color: var(--ssq-band-ink);
}
.ssq-group-head .ssq-group-count { margin-left: 0; color: var(--ssq-band-ink-2); white-space: nowrap; }

/* ---- the table: 34px head, 40px rows, centred cells (text columns left),
   a line under every row and a divider between every column ---- */
.ssq-tablewrap { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--hairline) transparent; }
.ssq-table {
  width: 100%; table-layout: auto;
  border-collapse: separate; border-spacing: 0; font-size: 13.5px; color: var(--text-strong);
}
.ssq-table th, .ssq-table td {
  text-align: center; vertical-align: middle; white-space: nowrap;
  border-right: 1px solid var(--rule); border-bottom: 1px solid var(--hairline);
}
.ssq-table th {
  height: 34px; padding: 0 10px; font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none;
  color: var(--text-muted); background: var(--surface); border-bottom-color: var(--rule-strong);
}
.ssq-table td {
  height: 40px; padding: 0 12px; font-size: 13.5px; font-variant-numeric: tabular-nums;
  transition: background .15s ease-out;
}
.ssq-table .ssq-left { text-align: left; }
.ssq-table th:last-child, .ssq-table td:last-child { border-right: 0; }
.ssq-table tbody tr:last-child td { border-bottom: 0; }
.ssq-table tbody tr { cursor: pointer; }
.ssq-table tbody tr:hover td { background: var(--hover); }
@media (prefers-reduced-motion: reduce) { .ssq-caret, .ssq-group-head, .ssq-table td { transition: none; } }

/* ---- round 1's progress ---- */
.ssq-progress { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.ssq-pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 7px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 0;
}
.ssq-pill-ok { color: var(--green-ink); background: var(--green-bg); }
.ssq-pill-info { color: var(--royal-ink); background: var(--royal-tint); }
.ssq-pill-bad { color: var(--red-ink); background: var(--red-bg); }
.ssq-pill-mute { color: var(--text-muted); background: var(--surface-2); }
.ssq-fact { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.ssq-togo { color: var(--amber-ink); font-weight: 600; }
.ssq-ready { color: var(--green-ink); font-weight: 600; }

/* ---- one survey ---- */
.ssq-dhead {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  padding-bottom: 0; margin-bottom: 20px; border-bottom: 0;
}
.ssq-dhead-l { min-width: 0; }
.ssq-daddr {
  margin: 0; font-family: var(--font-serif); font-size: 22px; font-weight: 600;
  letter-spacing: -0.01em; line-height: 1.2; color: var(--text-head); overflow-wrap: anywhere;
}
.ssq-daddr-link { color: inherit; text-decoration: none; }
.ssq-daddr-link:hover, .ssq-daddr-link:focus-visible { text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 1px; text-underline-offset: 4px; }
.ssq-dmeta { margin: 8px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13px; color: var(--text-muted); }
.ssq-status {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 7px;
  font-size: 12px; font-weight: 600; border: 0;
  background: var(--royal-tint); color: var(--royal-ink);
}
.ssq-status-returned { background: var(--red-bg); color: var(--red-ink); }
.ssq-status-assigned { background: var(--green-bg); color: var(--green-ink); }
.ssq-status-with_agent { background: var(--surface-2); color: var(--text-muted); }

.ssq-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ssq-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 14px;
  border-radius: 10px; border: 0; background: none; box-shadow: inset 0 0 0 1px var(--border-btn);
  font: inherit; font-size: 13px; font-weight: 500; color: var(--text-strong); cursor: pointer; white-space: nowrap;
  transition: box-shadow .16s var(--my-ease-out), background .16s var(--my-ease-out);
}
.ssq-btn:hover { box-shadow: inset 0 0 0 1.5px var(--gold); }
.ssq-btn:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
/* The one gold fill on the view: the step being taken. While its form is
   open the form's own submit is that step, so the head's button goes quiet. */
.ssq-btn-go, .ssq-btn-go:hover { background: var(--gold); box-shadow: none; color: var(--sidebar-deep); font-weight: 600; }
.ssq-btn-go:hover { background: var(--gold-dark); }
.ssq-detail:has(.ssq-form) .ssq-actions .ssq-btn-go,
.ssq-detail:has(.ssq-form) .ssq-actions .ssq-btn-go:hover { background: none; box-shadow: inset 0 0 0 1px var(--border-btn); color: var(--text-strong); font-weight: 500; }
[data-theme="dark"] .ssq-btn-go:hover { background: var(--gold-soft); }
.ssq-btn[disabled], .ssq-btn[disabled]:hover { opacity: .55; cursor: default; }

.ssq-flash {
  margin: 0 0 16px; padding: 10px 14px; border-radius: 8px;
  background: var(--red-bg); color: var(--red-ink); font-size: 13.5px; line-height: 1.45;
}
.ssq-callout {
  display: flex; flex-direction: column; gap: 4px; margin: 0 0 16px; padding: 12px 14px;
  border-radius: 8px; background: var(--red-bg);
  font-size: 13.5px; line-height: 1.5; color: var(--text-body);
}
.ssq-callout b { color: var(--text-head); font-weight: 600; }
.ssq-callout-warn { background: var(--amber-bg); }
.ssq-missing { margin: 2px 0 0; padding-left: 18px; }

/* ---- the step forms ---- */
.ssq-form {
  display: flex; flex-direction: column; gap: 12px; max-width: 560px;
  margin: 0 0 20px; padding: 16px; border: 0; border-radius: var(--my-r-lg);
  background: var(--surface); box-shadow: var(--ds-shadow-card);
}
.ssq-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.ssq-field-k { font-weight: 600; color: var(--text-head); }
.ssq-field-k i { font-weight: 400; font-style: normal; color: var(--text-muted); }
.ssq-input {
  font: inherit; font-size: 13.5px; color: var(--text-strong); background: var(--surface);
  border: 0; box-shadow: inset 0 0 0 1px var(--border-btn); border-radius: 10px; padding: 8px 10px; min-height: 36px;
  box-sizing: border-box; width: 100%;
}
.ssq-input:hover { box-shadow: inset 0 0 0 1.5px var(--gold); }
.ssq-input:focus { outline: none; box-shadow: inset 0 0 0 1.5px color-mix(in oklab, var(--text-strong) 44%, transparent); }
textarea.ssq-input { resize: vertical; line-height: 1.45; }
.ssq-check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; line-height: 1.4; color: var(--text-body); cursor: pointer; }
.ssq-check input { margin: 2px 0 0; width: 16px; height: 16px; accent-color: var(--gold-dark); flex: none; }
.ssq-owed { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text-muted); }
.ssq-form-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- the detail's sections ---- */
.ssq-dgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ssq-sec {
  min-width: 0; padding: 16px 18px; border: 0; border-radius: var(--my-r-lg);
  background: var(--surface); box-shadow: var(--ds-shadow-card);
}
.ssq-h3 { margin: 0 0 10px; font-size: 13.5px; font-weight: 600; color: var(--text-head); }
.ssq-kv { margin: 0; }
.ssq-kv-row {
  display: grid; grid-template-columns: minmax(120px, 40%) minmax(0, 1fr); gap: 12px;
  padding: 7px 0; border-top: 1px solid var(--rule); font-size: 13px;
}
.ssq-kv-row:first-child { border-top: 0; padding-top: 0; }
.ssq-kv-row dt { color: var(--text-muted); }
.ssq-kv-row dd { margin: 0; color: var(--text-head); overflow-wrap: anywhere; }
.ssq-docs, .ssq-history { list-style: none; margin: 0; padding: 0; }
.ssq-doc {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: 100%; padding: 9px 4px; border: 0; border-top: 1px solid var(--rule); background: none;
  font: inherit; font-size: 13px; color: var(--text-body); text-align: left; cursor: pointer; border-radius: 0;
}
.ssq-docs li:first-child .ssq-doc { border-top: 0; }
.ssq-doc:hover { background: var(--hover); }
.ssq-doc:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: -2px; }
.ssq-doc-label { font-weight: 600; color: var(--text-head); white-space: nowrap; }
.ssq-doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ssq-doc-open { color: var(--gold-ink); font-size: 12px; font-weight: 500; white-space: nowrap; }
.ssq-history li {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px;
  padding: 8px 0; border-top: 1px solid var(--rule); font-size: 13px;
}
.ssq-history li:first-child { border-top: 0; padding-top: 0; }
.ssq-hist-what { font-weight: 600; color: var(--text-head); }
.ssq-hist-by { color: var(--text-body); }
.ssq-hist-when { margin-left: auto; color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* ---- tablets: the detail's sections in one column ---- */
@media (max-width: 1080px) {
  .ssq-dgrid { grid-template-columns: minmax(0, 1fr); }
}

/* ---- phones: every row a card ---- */
@media (max-width: 640px) {
  #siteSurveysBody.ssq-root { padding: 14px var(--page-gutter) var(--page-end); }
  .ssq-title { font-size: 22px; }
  .ssq-group { background: none; box-shadow: none; overflow: visible; border-radius: 0; }
  .ssq-group-head { border-radius: var(--my-r); margin-bottom: 10px; }
  .ssq-tablewrap { overflow: visible; }
  .ssq-table thead { display: none; }
  .ssq-table, .ssq-table tbody, .ssq-table tr, .ssq-table td { display: block; width: auto; }
  .ssq-table tr {
    margin: 0 0 10px; padding: 10px 12px; border: 0; border-radius: var(--my-r);
    background: var(--surface); box-shadow: var(--ds-shadow-card);
  }
  .ssq-table td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    height: auto; min-height: 30px; padding: 4px 0; border: 0; white-space: normal; text-align: left;
  }
  .ssq-table td::before {
    content: attr(data-label); flex: none; font-size: 12.5px; font-weight: 500; color: var(--text-muted);
  }
  .ssq-table td.ssq-c-addr { display: block; padding-bottom: 6px; font-size: 14.5px; }
  .ssq-table td.ssq-c-addr::before { content: none; }
  .ssq-table .ssq-c-addr, .ssq-table .ssq-c-prog, .ssq-table .ssq-c-days { width: auto; }
  .ssq-table tbody tr:hover td { background: none; }
  .ssq-progress { flex-wrap: wrap; justify-content: flex-end; }
  .ssq-btn { min-height: 44px; }
  .ssq-actions { width: 100%; }
  .ssq-actions .ssq-btn { flex: 1 1 auto; }
  .ssq-kv-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .ssq-hist-when { margin-left: 0; width: 100%; }
}
