:root {
  color-scheme: light;
  --bg: #eef2f3;
  --surface: #ffffff;
  --surface-2: #f6f8f8;
  --surface-3: #e8eef0;
  --ink: #111b22;
  --muted: #64727c;
  --line: #d8e0e4;
  --accent: #116c8d;
  --accent-2: #0d5874;
  --green: #16765a;
  --amber: #a76513;
  --red: #ad3835;
  --shadow: 0 18px 36px rgba(17, 27, 34, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.dark {
  color-scheme: dark;
  --bg: #11161a;
  --surface: #182126;
  --surface-2: #202b31;
  --surface-3: #28343b;
  --ink: #edf3f6;
  --muted: #9dacb5;
  --line: #324049;
  --accent: #58b7d8;
  --accent-2: #8ad2e8;
  --green: #5ed1a7;
  --amber: #f1b45e;
  --red: #f07c78;
  --shadow: 0 18px 36px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  font-size: 12px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 25px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.header-actions,
.toolbar,
.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button,
.tab,
.icon-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-height: 38px;
  border-radius: 7px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.icon-button {
  width: 38px;
  padding: 0;
}

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

.button.primary:hover {
  background: var(--accent-2);
}

.button.danger {
  background: color-mix(in srgb, var(--red) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--red) 45%, var(--line));
  color: var(--red);
}

.button.ghost:hover,
.tab:hover,
.icon-button:hover {
  background: var(--surface-2);
}

.button.disabled,
.button:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.app-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.workspace {
  min-width: 0;
}

.control-bar {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(520px, 1.55fr) minmax(260px, 0.6fr);
  gap: 12px;
}

.panel,
.control-panel,
.metric,
.toolbar,
.table-wrap,
.report-card,
.quality-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.control-panel {
  padding: 14px;
}

.panel-heading,
.section-head,
.report-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.panel-heading {
  align-items: center;
  margin-bottom: 14px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
}

.panel-heading .status-dot {
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  font-weight: 800;
}

.panel-heading .status-dot.active {
  color: #047857;
  border-color: rgba(4, 120, 87, 0.32);
  background: rgba(16, 185, 129, 0.1);
}

.panel-heading .status-dot.warn {
  color: #a16207;
  border-color: rgba(161, 98, 7, 0.3);
  background: rgba(245, 158, 11, 0.12);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.field.inline {
  grid-auto-flow: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

.field.inline.compact {
  width: auto;
}

.field.inline.compact select {
  min-width: 78px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
  min-height: 38px;
}

textarea {
  resize: vertical;
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.grid.three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.grid.four {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
}

.filter-grid .field {
  grid-column: span 2;
}

.filter-grid .field,
.scan-panel .field {
  margin-bottom: 0;
}

.scan-actions,
.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.scan-actions .button {
  flex: 1;
}

.ops-mini,
.ops-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.ops-mini div,
.ops-status div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.ops-mini span,
.ops-status span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.ops-mini strong,
.ops-status strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
}

.ops-status p {
  grid-column: 1 / -1;
  margin: 0;
}

.scanner-status {
  margin-top: 12px;
}

.ops-plan-status {
  margin-bottom: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ops-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.ops-layout .quality-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ops-layout .ops-actions {
  margin-top: 2px;
}

.scanner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
}

.scanner-head h3 {
  margin: 0;
}

.scanner-head .check-line,
.ops-master-toggle {
  margin: 0;
  white-space: nowrap;
}

.scanner-section {
  display: grid;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.scanner-section h4 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.scanner-field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.scanner-field-grid .wide-field {
  grid-column: auto;
}

.scanner-field-grid .field {
  min-width: 0;
  margin-bottom: 0;
}

.scanner-field-grid .field span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-layout input[type="time"] {
  min-width: 0;
}

.ops-master-toggle {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
}

.field-check {
  align-self: end;
  min-height: 38px;
  margin: 0;
}

.ops-log-card {
  margin-top: 12px;
}

.ops-log-card .scanner-head {
  align-items: baseline;
}

.ops-log-card .hint {
  text-align: right;
}

.ops-live-log {
  max-height: 220px;
}

.button.full {
  width: 100%;
}

.ai-panel {
  display: flex;
  flex-direction: column;
}

.ai-panel .button {
  margin-top: auto;
}

.checks {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
}

.checks input {
  width: 18px;
  min-height: 18px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-bottom: 0;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.metric {
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  margin-bottom: 6px;
}

.metric strong {
  font-size: 28px;
}

.toolbar {
  justify-content: space-between;
  padding: 10px;
  box-shadow: none;
}

.tab.active {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent-2);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.section-head .section-actions {
  margin-bottom: 0;
  justify-content: flex-end;
}

.section-head h2 {
  margin-bottom: 4px;
}

.table-wrap {
  overflow: auto;
  box-shadow: none;
  max-width: 100%;
  scrollbar-color: var(--accent) var(--surface-3);
}

.data-table-wrap {
  height: var(--database-table-height, clamp(420px, 58vh, 760px));
  max-height: none;
  min-height: 360px;
}

table {
  width: max-content;
  border-collapse: collapse;
  min-width: 3220px;
  table-layout: fixed;
}

.logs-table {
  width: 100%;
  min-width: 1180px;
  table-layout: fixed;
}

.logs-table th:nth-child(1),
.logs-table td:nth-child(1) {
  width: 190px;
}

.logs-table th:nth-child(2),
.logs-table td:nth-child(2) {
  width: 210px;
}

.logs-table th:nth-child(3),
.logs-table td:nth-child(3) {
  width: 210px;
}

.logs-table th:nth-child(4),
.logs-table td:nth-child(4) {
  width: 240px;
}

.logs-table th:nth-child(5),
.logs-table td:nth-child(5) {
  width: 100px;
}

.logs-table th:nth-child(6),
.logs-table td:nth-child(6) {
  width: 430px;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th:first-child,
td:first-child {
  width: 44px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 280px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 180px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 140px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 160px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 270px;
}

th:nth-child(7),
td:nth-child(7) {
  width: 300px;
}

th:nth-child(8),
td:nth-child(8) {
  width: 330px;
}

th:nth-child(9),
td:nth-child(9) {
  width: 150px;
}

th:nth-child(10),
td:nth-child(10) {
  width: 160px;
}

th:nth-child(11),
td:nth-child(11) {
  width: 230px;
}

th:nth-child(12),
td:nth-child(12) {
  width: 270px;
}

th:nth-child(13),
td:nth-child(13) {
  width: 165px;
}

th:nth-child(14),
td:nth-child(14) {
  width: 165px;
}

th:nth-child(15),
td:nth-child(15) {
  width: 260px;
}

th:nth-child(16),
td:nth-child(16) {
  width: 170px;
}

th:nth-child(17),
td:nth-child(17) {
  width: 140px;
}

th:nth-child(18),
td:nth-child(18) {
  width: 120px;
}

td input[type="checkbox"],
th input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}

.sort-head {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  font-weight: 850;
  text-transform: uppercase;
  cursor: pointer;
}

.sort-head.active::after {
  content: " " attr(data-dir);
  color: var(--accent);
}

tbody tr:hover {
  background: var(--surface-2);
}

.company,
.contact-path,
.score,
.signal-stack,
.contact-cell {
  display: grid;
  gap: 4px;
}

.company strong,
.contact-path strong,
.contact-cell strong {
  font-size: 15px;
}

.small,
.company span,
.contact-path span,
.contact-cell span,
.muted-line,
.score span {
  color: var(--muted);
  font-size: 12px;
}

.contact-cell a {
  color: var(--accent-2);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.nowrap-cell {
  white-space: nowrap;
}

.signal-stack strong {
  font-size: 13px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 750;
  background: var(--surface-3);
  color: var(--ink);
}

.pill.small {
  min-height: 21px;
  padding: 2px 7px;
  font-size: 11px;
}

.pill.green {
  background: color-mix(in srgb, var(--green) 18%, transparent);
  color: var(--green);
}

.pill.cyan {
  background: color-mix(in srgb, #2afafe 14%, transparent);
  color: #0c7280;
}

.pill.pink {
  background: color-mix(in srgb, #e91e8c 14%, transparent);
  color: #c21873;
}

.pill.blue {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}

.pill.amber {
  background: color-mix(in srgb, var(--amber) 18%, transparent);
  color: var(--amber);
}

.pill.red {
  background: color-mix(in srgb, var(--red) 18%, transparent);
  color: var(--red);
}

.pill.inactive {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.compliance-row {
  max-width: 260px;
}

.score strong {
  font-size: 18px;
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  min-width: 88px;
}

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

.live-grid,
.score-docs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

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

.live-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 15px;
}

.live-card h2 {
  margin-bottom: 8px;
}

.progress {
  display: grid;
  gap: 7px;
  margin: 14px 0;
}

.progress > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

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

.facts div {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
}

.facts dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.facts dd {
  margin: 4px 0 0;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.live-log {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.log-row {
  display: grid;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
}

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

.log-row strong {
  font-size: 13px;
}

.report-list,
.quality-list {
  display: grid;
  gap: 12px;
}

.report-card,
.quality-card {
  padding: 15px;
  box-shadow: none;
}

.report-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
}

.page-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 6px 10px;
  font-weight: 800;
  cursor: pointer;
}

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

.page-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.page-ellipsis {
  color: var(--muted);
  padding: 0 2px;
}

.queue-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.queue-counter {
  border: 1px solid rgba(42, 250, 254, 0.28);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(42, 250, 254, 0.08);
  font-size: 12px;
  font-weight: 900;
  padding: 4px 9px;
  white-space: nowrap;
}

.queue-setting {
  min-width: 168px;
}

.queue-setting input {
  width: 76px;
  min-height: 34px;
  padding: 6px 8px;
}

.queue-progress {
  display: grid;
  grid-template-columns: minmax(160px, 280px) auto auto;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.queue-progress strong,
.queue-progress span {
  color: var(--muted);
  font-size: 12px;
}

.report-card h3,
.quality-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.quality-card p {
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

.quality-card ul {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--ink);
  color: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 420px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.auth-overlay,
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 12, 16, 0.76);
  backdrop-filter: blur(8px);
}

.auth-overlay.active,
.modal.active {
  display: flex;
}

.auth-card,
.modal-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-card {
  width: min(980px, 100%);
}

.twofa-box {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.twofa-box code {
  display: block;
  padding: 10px;
  border-radius: 7px;
  background: var(--surface-3);
  overflow-wrap: anywhere;
}

.soft-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

.user-admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(0, 1.25fr);
  gap: 16px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(280px, 1fr));
  gap: 16px;
}

.admin-grid .quality-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-grid .field,
.admin-grid .check-line {
  margin-bottom: 0;
}

.task-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
}

.task-layout.ops-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.task-layout.ops-layout > .quality-card {
  min-width: 0;
}

.task-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 8px 0 14px;
  color: var(--muted);
  font-weight: 750;
}

.check-line input {
  width: 18px;
  min-height: 18px;
}

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

.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.user-row strong,
.user-row span {
  display: block;
}

.user-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.user-permissions {
  margin-top: 8px;
}

.section-head.flat {
  box-shadow: none;
  padding: 0 0 14px;
  border-width: 0 0 1px;
  border-radius: 0;
  margin-bottom: 14px;
}

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

  .control-bar,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .filter-grid .field {
    grid-column: auto;
  }

  .live-grid,
  .score-docs {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-header,
  .toolbar,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs,
  .field.inline {
    width: 100%;
  }

  .button,
  .tab {
    flex: 1;
    text-align: center;
  }

  .summary-grid,
  .grid.two,
  .grid.three,
  .grid.four,
  .admin-grid,
  .user-admin-grid,
  .task-layout {
    grid-template-columns: 1fr;
  }

  .section-head,
  .report-card {
    flex-direction: column;
  }

  h1 {
    font-size: 21px;
  }
}
