:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #5d6b73;
  --line: #d7dee2;
  --panel: #ffffff;
  --soft: #f3f6f8;
  --accent: #006d77;
  --accent-dark: #064d55;
  --danger: #b42318;
  --warn: #a15c00;
  --ok: #2f6f4e;
  --shadow: 0 16px 42px rgba(23, 32, 38, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #eef3f5;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px clamp(18px, 4vw, 56px);
  background:
    linear-gradient(90deg, rgba(0, 109, 119, 0.08), transparent 48%),
    #ffffff;
  border-bottom: 1px solid var(--line);
}

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1.08;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 92px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--soft);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.status-pill.busy {
  color: var(--accent-dark);
  border-color: rgba(0, 109, 119, 0.35);
  background: rgba(0, 109, 119, 0.1);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.small-button {
  min-height: 38px;
  padding: 0 12px;
}

.locked .workspace {
  display: none;
}

.login-shell {
  display: none;
  min-height: calc(100vh - 98px);
  place-items: center;
  padding: 24px;
}

.locked .login-shell {
  display: grid;
}

.login-panel {
  width: min(460px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-panel h2 {
  margin-bottom: 18px;
  font-size: 1.45rem;
}

.login-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.login-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--danger);
  font-weight: 800;
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 36px) 42px;
}

.scan-panel,
.results-shell,
.crawl-notes {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.scan-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 20px;
  padding: 18px;
}

.scan-form {
  min-width: 0;
}

.scan-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c6d0d5;
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

select {
  min-height: 44px;
  border: 1px solid #c6d0d5;
  border-radius: 8px;
  padding: 0 34px 0 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 109, 119, 0.16);
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 109, 119, 0.16);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

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

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

button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.scan-actions {
  display: flex;
  gap: 8px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  margin-top: 14px;
}

.control-group {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px 12px;
  min-width: 0;
}

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

.scan-form .control-field label {
  margin: 0;
}

.control-field.compact {
  width: 92px;
}

.export-controls {
  justify-content: end;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

#maxPages,
#deepSearchLimit {
  width: 92px;
}

#deepSearchMode {
  width: 156px;
}

#reverseMatchMode {
  width: 150px;
}

#pdfLimit {
  width: 132px;
}

.scan-form .toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
  padding: 0 8px;
  color: var(--ink);
  white-space: nowrap;
}

.toggle-control span {
  font-size: 0.9rem;
  font-weight: 800;
}

.notice {
  align-self: stretch;
  display: flex;
  align-items: center;
  border-left: 4px solid var(--accent);
  padding: 12px 14px;
  background: #f1faf9;
  color: #38555b;
  border-radius: 6px;
  line-height: 1.45;
}

.progress-panel {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid #b8d2d5;
  border-radius: 8px;
  background: #f7fbfb;
  box-shadow: var(--shadow);
}

.progress-panel div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.progress-panel strong {
  color: var(--accent-dark);
}

.progress-panel span,
.progress-panel p {
  color: var(--muted);
  font-size: 0.88rem;
}

.progress-track {
  position: relative;
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 8px;
  background: #d8e8eb;
}

.progress-track span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 44%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--accent), #d98145);
  animation: progressSweep 1.2s ease-in-out infinite;
}

.progress-panel p {
  margin: 8px 0 0;
}

@keyframes progressSweep {
  0% {
    transform: translateX(-105%);
  }
  100% {
    transform: translateX(230%);
  }
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.metrics article {
  min-height: 96px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metrics span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
  line-height: 1;
}

.results-shell {
  overflow: hidden;
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab {
  min-height: 34px;
  border-color: transparent;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
}

.tab.active {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

#searchInput {
  max-width: 420px;
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 40px;
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.lens-art {
  position: relative;
  width: 112px;
  height: 82px;
  margin-bottom: 6px;
}

.lens-art::before {
  content: "";
  position: absolute;
  inset: 2px 28px 16px 8px;
  border: 8px solid #4f8f95;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(0, 109, 119, 0.18), rgba(241, 250, 249, 0.55));
}

.lens-art::after {
  content: "";
  position: absolute;
  width: 42px;
  height: 8px;
  right: 12px;
  bottom: 12px;
  border-radius: 8px;
  background: #4f8f95;
  transform: rotate(42deg);
  transform-origin: center;
}

.lens-art span {
  position: absolute;
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #d98145;
}

.lens-art span:nth-child(1) {
  left: 28px;
  top: 24px;
}

.lens-art span:nth-child(2) {
  left: 48px;
  top: 30px;
  background: #75a47f;
}

.lens-art span:nth-child(3) {
  left: 38px;
  top: 46px;
  background: #b94f4f;
}

.lens-art span:nth-child(4) {
  left: 58px;
  top: 48px;
  background: #e0b348;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1320px;
  border-collapse: collapse;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.risk-badge {
  display: inline-block;
  min-width: 72px;
  padding: 5px 8px;
  border-radius: 6px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
  text-transform: capitalize;
}

.risk-badge.high {
  background: var(--danger);
}

.risk-badge.medium {
  background: var(--warn);
}

.risk-badge.low {
  background: var(--ok);
}

.image-cell {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  max-width: 520px;
}

.image-cell img {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

a {
  color: var(--accent-dark);
  overflow-wrap: anywhere;
}

.host {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.signals {
  margin: 0;
  padding-left: 18px;
  color: #33444b;
}

.signals li + li {
  margin-top: 5px;
}

.muted,
.reverse-meta,
.reverse-labels {
  color: var(--muted);
  font-size: 0.84rem;
}

.reverse-meta,
.reverse-labels {
  margin: 7px 0 0;
}

.reverse-details {
  max-width: 420px;
}

.reverse-details summary {
  width: fit-content;
  padding: 6px 8px;
  border: 1px solid #b8d2d5;
  border-radius: 6px;
  color: var(--accent-dark);
  background: #f1faf9;
  font-size: 0.84rem;
  font-weight: 900;
  cursor: pointer;
}

.reverse-match-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.reverse-match {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.match-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 82px;
  height: 62px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-decoration: none;
}

.match-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.match-thumb span {
  position: absolute;
  left: 5px;
  bottom: 5px;
  padding: 2px 5px;
  border-radius: 4px;
  color: #fff;
  background: rgba(23, 32, 38, 0.72);
}

.match-thumb.empty span {
  position: static;
  color: var(--muted);
  background: transparent;
}

.match-url {
  display: block;
  font-weight: 800;
}

.match-domain,
.match-title,
.match-kind {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.3;
}

.match-domain {
  color: #33444b;
  font-weight: 800;
}

.match-title {
  color: var(--ink);
}

.match-kind {
  text-transform: capitalize;
}

.result-badge {
  display: inline-block;
  min-width: 126px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.result-badge.danger {
  color: #fff;
  background: var(--danger);
}

.result-badge.warn {
  color: #6a3c00;
  background: #ffe6bd;
  border: 1px solid #e5af62;
}

.result-badge.ok {
  color: #1f5138;
  background: #dff1e6;
  border: 1px solid #9ec7ae;
}

.result-badge.neutral {
  color: #41525a;
  background: var(--soft);
  border: 1px solid var(--line);
}

.result-detail {
  max-width: 220px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.crawl-notes {
  margin-top: 16px;
  padding: 16px;
}

.crawl-notes h2 {
  font-size: 1rem;
  margin-bottom: 10px;
}

.crawl-notes ul {
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 1180px) {
  .scan-panel {
    grid-template-columns: 1fr;
  }

  .notice {
    min-height: auto;
  }
}

@media (max-width: 820px) {
  .app-header,
  .scan-panel,
  .results-toolbar {
    display: block;
  }

  .status-pill {
    width: fit-content;
    margin-top: 14px;
  }

  .header-actions {
    margin-top: 14px;
  }

  .notice,
  #searchInput {
    margin-top: 14px;
  }

  .input-row,
  .metrics {
    grid-template-columns: 1fr;
  }

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

  .scan-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .export-controls {
    justify-content: start;
    padding: 14px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }
}
