:root {
  --bg: #f5f7fb;
  --surface: #fff;
  --text: #18243b;
  --muted: #52617a;
  --border: #dce3ed;
  --primary: #1e40af;
  --primary-hover: #19358f;
  --soft: #edf2ff;
  --green: #166534;
  --red: #b91c1c;
  --radius: 10px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}
a {
  color: var(--primary);
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  transition: background 0.15s;
  border: 0;
}
button:disabled {
  cursor: default;
  opacity: 0.5;
}
button,
input,
select,
summary {
  min-height: 42px;
  border-radius: 6px;
}
button {
  padding: 9px 14px;
  font-weight: 600;
}
input,
select {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
  max-width: 100%;
}
input:focus,
select:focus {
  border-color: var(--primary);
}
:focus-visible {
  outline: 3px solid #93b3ff;
  outline-offset: 3px;
}
label {
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.primary {
  background: var(--primary);
  color: #fff;
}
.primary:hover {
  background: var(--primary-hover);
}
.secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.secondary:hover,
.quiet:hover {
  background: var(--soft);
}
.quiet {
  background: transparent;
  color: var(--primary);
}
.muted {
  color: var(--muted);
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 222px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 30px 18px;
  display: flex;
  flex-direction: column;
}
.brand {
  font-size: 23px;
  font-weight: 780;
  letter-spacing: -0.8px;
  text-decoration: none;
  color: var(--text);
  padding: 0 10px;
}
.brand span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 2.1px;
  margin-top: 5px;
  font-weight: 650;
}
.sidebar nav {
  margin-top: 42px;
  display: grid;
  gap: 7px;
}
.nav {
  text-align: left;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.nav.active {
  background: var(--soft);
  color: var(--primary);
}
.sidebar-bottom {
  margin-top: auto;
  font-size: 12px;
  color: var(--muted);
  padding: 12px 9px 0;
}
.sidebar-bottom p {
  line-height: 1.8;
}
.sidebar-bottom button {
  padding-left: 0;
}
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 100%;
  background: #15803d;
  margin-right: 6px;
}
main {
  margin-left: 222px;
  padding: 36px 38px 24px;
  max-width: 2200px;
}
.page-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 28px;
}
.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.7px;
  color: var(--primary);
  margin: 0 0 7px;
}
h1 {
  font-size: 30px;
  letter-spacing: -0.9px;
  line-height: 1.2;
  margin: 0 0 9px;
}
h2 {
  font-size: 18px;
  letter-spacing: -0.3px;
}
.page-header p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}
.metrics article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 133px;
}
.metrics article > span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.metrics strong {
  display: block;
  font-size: 29px;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 4px;
}
.metrics small {
  color: var(--muted);
  font-size: 11px;
  display: block;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 19px 20px;
}
.search-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.search {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 1;
  gap: 5px;
  font-size: 12px;
}
.search input {
  width: 100%;
  font-size: 14px;
}
.filter-heading {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  align-items: center;
}
.filter-heading select {
  border-color: transparent;
  padding-left: 2px;
  min-height: 34px;
  background: transparent;
  font-size: 12px;
}
.filter-heading label {
  font-size: 12px;
}
.filter-heading button {
  font-size: 12px;
}
.filters {
  display: grid;
  gap: 8px;
}
.filter-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 155px minmax(150px, 1.5fr) 42px;
  gap: 8px;
  align-items: center;
}
.filter-row select,
.filter-row input {
  width: 100%;
}
.platform-picker {
  min-width: 0;
}
.platform-picker summary {
  cursor: pointer;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 44px;
}
.platform-panel {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.platform-list {
  max-height: 240px;
  overflow-y: auto;
  margin-top: 8px;
}
.platform-list label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 5px;
  overflow-wrap: anywhere;
}
.platform-list label[hidden] {
  display: none;
}
.platform-list input {
  width: 18px;
  min-height: 18px;
  flex-shrink: 0;
}
.remove-filter {
  background: var(--bg);
  color: var(--muted);
  font-size: 20px;
  padding: 5px;
}
.view-tools {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--border);
  margin-top: 15px;
  padding-top: 12px;
  align-items: flex-start;
  font-size: 12px;
}
.view-tools label {
  font-size: 12px;
}
.view-tools select {
  max-width: 190px;
  min-height: 36px;
  padding: 5px 7px;
}
.view-tools button {
  font-size: 12px;
  padding: 7px 9px;
  min-height: 36px;
}
.columns {
  position: relative;
}
.columns summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  padding: 0 8px;
  min-height: 36px;
}
.columns[open] > div {
  position: absolute;
  z-index: 5;
  right: 0;
  top: 42px;
  min-width: 260px;
  max-height: 330px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 12px 32px #18243b1c;
}
.columns label {
  display: flex;
  padding: 3px 6px;
  font-size: 12px;
}
.columns input {
  min-height: 22px;
  width: 17px;
}
.results-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 10px;
  font-size: 12px;
}
.results-heading p {
  font-weight: 600;
}
.results-heading select {
  min-height: 32px;
  padding: 4px 8px;
}
.table-wrap {
  overflow: auto;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  font-size: 12px;
}
th {
  background: #f8faff;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  padding: 13px 15px;
  position: sticky;
  top: 0;
  z-index: 1;
}
th button {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  background: transparent;
  padding: 0;
  min-height: 25px;
  display: flex;
  align-items: center;
  gap: 7px;
}
td {
  border-bottom: 1px solid #edf0f5;
  padding: 13px 15px;
  max-width: 310px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: #f7f9ff;
}
.lead-name {
  color: var(--text);
  background: transparent;
  text-align: left;
  padding: 0;
  font-size: 12px;
  font-weight: 650;
  min-height: 24px;
}
.lead-name:hover {
  color: var(--primary);
  text-decoration: underline;
}
.tag {
  border-radius: 4px;
  background: var(--soft);
  color: var(--primary);
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 600;
  display: inline-block;
}
.tag.green {
  color: var(--green);
  background: #edf8f0;
}
.tag.red {
  color: var(--red);
  background: #fff0f0;
}
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 16px;
}
.pagination button {
  min-height: 36px;
  font-size: 12px;
  margin-left: 7px;
}
.footnote {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.7;
  margin: 20px 0 0;
}
.error {
  border: 1px solid #f0b3b3;
  background: #fff1f1;
  color: var(--red);
  padding: 12px 15px;
  border-radius: 7px;
  margin-bottom: 16px;
  font-size: 13px;
}
.empty {
  text-align: center;
  padding: 65px 20px;
  color: var(--muted);
}
.section-heading {
  display: flex;
  gap: 15px;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 12px;
}
.section-heading h2 {
  margin: 0;
}
.section-heading span {
  font-size: 12px;
  color: var(--muted);
}
.worker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.worker-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.worker-card h3 {
  font-size: 14px;
  margin: 0 0 9px;
}
.worker-card p {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0;
}
dialog {
  border: 1px solid var(--border);
  border-radius: 13px;
  width: min(880px, 94vw);
  max-height: 88vh;
  padding: 25px;
  color: var(--text);
}
dialog::backdrop {
  background: #111b32a1;
}
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 15px;
  margin-bottom: 15px;
}
.dialog-header h2 {
  margin: 0;
}
.detail-fields td {
  white-space: normal;
  overflow-wrap: anywhere;
}
.detail-fields td:first-child {
  font-weight: 600;
  width: 180px;
  color: var(--muted);
}
.detail-source {
  border: 1px solid var(--border);
  border-radius: 7px;
  margin: 12px 0;
  padding: 8px 12px;
}
.detail-source summary {
  cursor: pointer;
  padding: 6px;
  font-size: 12px;
  font-weight: 600;
}
.detail-source pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.65;
  max-height: 350px;
  overflow: auto;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 20px;
}
#save-dialog {
  max-width: 440px;
}
#save-form label {
  display: grid;
  gap: 8px;
}
#save-form input {
  width: 100%;
}
.toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 6px 20px #0002;
  z-index: 30;
}
.skip {
  position: fixed;
  top: -100px;
  left: 10px;
  z-index: 99;
  background: #fff;
  padding: 12px;
}
.skip:focus {
  top: 10px;
}
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
}
.login-card {
  margin: 20px;
  padding: 38px;
  width: min(420px, calc(100vw - 40px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 60px #18243b0a;
}
.login-card .brand {
  padding: 0;
  display: block;
  margin-bottom: 40px;
}
.login-card h1 {
  font-size: 26px;
}
.login-card label {
  display: grid;
  gap: 8px;
  margin: 25px 0 18px;
}
.login-card input,
.login-card form > button {
  width: 100%;
}
[hidden] {
  display: none !important;
}
@media (min-width: 1700px) {
  main {
    padding: 42px 55px;
  }
}
@media (max-width: 1150px) {
  main {
    padding: 25px 23px;
  }
  .sidebar {
    width: 190px;
    padding: 26px 13px;
  }
  main {
    margin-left: 190px;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .header-actions {
    flex-direction: column;
    gap: 7px;
    align-items: flex-end;
  }
  .filter-row {
    grid-template-columns: 1fr 130px 1fr 38px;
  }
  .view-tools > div {
    display: flex;
    flex-wrap: wrap;
  }
}
@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 15px 17px;
    gap: 12px;
  }
  .brand {
    font-size: 20px;
    padding: 0;
  }
  .brand span {
    font-size: 8px;
  }
  .sidebar nav {
    margin: 0;
    display: flex;
    gap: 3px;
    overflow: auto;
    width: 100%;
  }
  .nav {
    font-size: 11px;
    padding: 8px;
    white-space: nowrap;
  }
  .sidebar-bottom {
    display: none;
  }
  main {
    margin-left: 0;
    padding: 24px 16px;
  }
  .page-header {
    align-items: flex-start;
    gap: 8px;
  }
  h1 {
    font-size: 25px;
  }
  .page-header p:not(.eyebrow) {
    font-size: 12px;
  }
  .header-actions span {
    display: none;
  }
  .metrics {
    gap: 9px;
  }
  .metrics article {
    padding: 14px;
    min-height: 121px;
  }
  .metrics strong {
    font-size: 24px;
  }
  .metrics article > span {
    font-size: 11px;
  }
  .metrics small {
    font-size: 10px;
  }
  .panel {
    padding: 13px;
  }
  .search-row {
    flex-wrap: wrap;
  }
  .search {
    flex-basis: 100%;
  }
  .search-row button {
    flex: 1;
    font-size: 12px;
  }
  .filter-row {
    grid-template-columns: 1fr 1fr 38px;
  }
  .filter-row .filter-value {
    grid-column: 1/3;
    grid-row: 2;
  }
  .remove-filter {
    grid-column: 3;
    grid-row: 1/3;
    align-self: stretch;
  }
  .view-tools {
    flex-wrap: wrap;
  }
  .view-tools label {
    width: 100%;
  }
  .view-tools select {
    flex: 1;
  }
  .view-tools > div {
    gap: 5px;
  }
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }
  dialog {
    padding: 17px;
  }
  .pagination button {
    padding: 7px 10px;
  }
  .footnote {
    font-size: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.audit-dialog { width: min(960px, calc(100vw - 28px)); }
#audit-report { overflow-wrap: anywhere; }
#audit-report pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.audit-issue { border-top: 1px solid var(--border, #e2e8f0); padding: 18px 0; }
.audit-issue h4 { margin: 8px 0; }
.audit-issue p { margin: 6px 0; }
.audit-ids { overflow-wrap: anywhere; font-size: 12px; }
#audit-counts { margin-bottom: 22px; }
.view-tools > div { flex-wrap: wrap; }
