:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --panel: #ffffff;
  --panel-soft: #f9faf7;
  --text: #15221e;
  --muted: #617067;
  --line: #d8dfd7;
  --line-strong: #b9c5bb;
  --teal: #0d766f;
  --teal-dark: #0a5f59;
  --blue: #265f9f;
  --amber: #9a5b11;
  --red: #a33a30;
  --shadow: 0 18px 45px rgba(32, 43, 37, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0) 220px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  min-height: 40px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  color: #8c978f;
  cursor: not-allowed;
  background: #eef1ed;
}

button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input {
  min-height: 44px;
  padding: 0 12px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(13, 118, 111, 0.2);
  outline-offset: 1px;
}

select {
  padding: 0 34px 0 11px;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

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

.tool-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: #edf3ee;
}

.tab-button {
  min-width: 180px;
  border-color: transparent;
  background: transparent;
  color: #405046;
}

.tab-button.active {
  border-color: var(--line-strong);
  background: var(--panel);
  color: var(--teal-dark);
  box-shadow: 0 4px 14px rgba(32, 43, 37, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(13, 118, 111, 0.28);
  border-radius: 8px;
  background: #e5f2ee;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p,
.results-header p,
.status-text {
  color: var(--muted);
}

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

.scanner-panel {
  padding: 18px;
}

.scan-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 124px minmax(180px, auto) auto;
  gap: 12px;
  align-items: end;
}

.url-field,
.small-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.url-field span,
.small-field span,
.metric-label {
  color: #405046;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  color: #405046;
  font-size: 14px;
  font-weight: 650;
}

.toggle-field input {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--teal);
}

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

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

.primary-button:hover:not(:disabled) {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.secondary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled) {
  border-color: #819089;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.status-grid > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.status-grid strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 20px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  height: 8px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e9e2;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #2b6da8);
  transition: width 180ms ease;
}

.status-text {
  min-height: 22px;
  margin-top: 10px;
  overflow-wrap: anywhere;
}

.results-panel {
  margin-top: 18px;
  overflow: hidden;
}

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

.results-header select {
  width: 190px;
  flex: 0 0 auto;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #ebefea;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f5f0;
  color: #405046;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

th:nth-child(1),
td:nth-child(1) {
  width: 72px;
}

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

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

.rank-cell {
  color: var(--muted);
  font-weight: 800;
}

.count-cell {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.url-cell a {
  color: #174d7f;
  font-weight: 750;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.url-cell a:hover {
  text-decoration: underline;
}

.page-title {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.evidence-cell {
  color: #405046;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.email-cell {
  color: #103f69;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.snippet {
  margin-top: 6px;
  color: var(--muted);
}

body[data-mode="emails"] th:nth-child(1),
body[data-mode="emails"] td:nth-child(1) {
  width: 260px;
}

body[data-mode="emails"] th:nth-child(2),
body[data-mode="emails"] td:nth-child(2) {
  width: 96px;
}

body[data-mode="emails"] th:nth-child(4),
body[data-mode="emails"] td:nth-child(4) {
  width: 320px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 5px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge.high {
  background: #e2f3ed;
  color: var(--teal-dark);
}

.badge.medium {
  background: #eef3fb;
  color: var(--blue);
}

.badge.low {
  background: #fff0d9;
  color: var(--amber);
}

.badge.error {
  background: #fde8e5;
  color: var(--red);
}

.empty-cell {
  padding: 38px 18px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .scan-form,
  .status-grid {
    grid-template-columns: 1fr 1fr;
  }

  .url-field,
  .toggle-field,
  .form-actions {
    grid-column: 1 / -1;
  }

  .form-actions {
    justify-content: stretch;
  }

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

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .topbar,
  .tool-tabs,
  .results-header {
    align-items: stretch;
    flex-direction: column;
  }

  .tool-tabs {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .tab-button {
    min-width: 0;
  }

  .ghost-button,
  .results-header select {
    width: 100%;
  }

  .scan-form,
  .status-grid {
    grid-template-columns: 1fr;
  }

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

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  tr {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
  }

  td {
    width: 100% !important;
    border: 0;
    padding: 4px 0;
  }

  .rank-cell,
  .count-cell {
    display: inline-block;
    margin-right: 10px;
  }
}
