:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e7eb;
  --border-soft: #eef2f7;
  --text: #111827;
  --muted: #6b7280;
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

body {
  min-height: 100vh;
}

body.modal-open {
  overflow: hidden;
}

.topbar {
  height: 6px;
  background: linear-gradient(90deg, #2563eb, #3b82f6, #60a5fa);
}

header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(229, 231, 235, 0.9);
}

.logo-box {
  display: block;
  width: auto;
  height: auto;
  border: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  flex-shrink: 0;
}

.logo-box img {
  display: block;
  width: auto;
  height: auto;
  max-width: 220px;
  max-height: 56px;
}

.title-wrap h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.title-wrap p {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}

main {
  width: calc(100vw - 24px);
  max-width: 2400px;
  margin: 20px auto 36px;
  padding: 0 12px;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar button {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

.toolbar button:hover {
  background: var(--surface-2);
  border-color: #cbd5e1;
}

.toolbar button:active {
  transform: translateY(1px);
}

.card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-wrap {
  padding: 18px;
  overflow: auto;
  min-height: 120px;
}

.table-wrap.is-loading::before {
  content: "Loading report…";
  display: block;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--muted);
}

.error {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 14px 16px;
  border-radius: 12px;
}

/* Webhook table styling */
#table-container table {
  width: 100%;
  min-width: 1100px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background: #fff;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

#table-container thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 14px 12px;
  background: var(--surface-2);
  color: #0f172a;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border-soft);
}

#table-container thead th:first-child {
  border-top-left-radius: 12px;
}

#table-container thead th:last-child {
  border-top-right-radius: 12px;
  border-right: 0;
}

#table-container tbody td {
  padding: 14px 12px;
  background: #fff;
  color: #334155;
  line-height: 1.45;
  vertical-align: top;
  border-bottom: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);
}

#table-container tbody td:last-child {
  border-right: 0;
}

#table-container tbody tr:last-child td {
  border-bottom: 0;
}

#table-container tbody tr:nth-child(even) td {
  background: #fcfdff;
}

#table-container tbody tr:hover td {
  background: #f8fbff;
}

#table-container tbody tr.is-hidden-low-risk {
  display: none;
}

#table-container td,
#table-container th {
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Sortable headers */
#table-container thead th.sortable {
  cursor: pointer;
  user-select: none;
}

#table-container thead th.sortable::after {
  content: " ↕";
  font-size: 11px;
  color: var(--muted);
}

#table-container thead th.sorted-asc::after {
  content: " ▲";
  color: var(--brand);
}

#table-container thead th.sorted-desc::after {
  content: " ▼";
  color: var(--brand);
}

/* Screenshot */
#table-container th:nth-child(1),
#table-container td:nth-child(1) {
  width: 215px;
  min-width: 215px;
  max-width: 215px;
  overflow: hidden;
}

#table-container td:nth-child(1) {
  padding: 10px;
}

#table-container td:nth-child(1) img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 140px;
  object-fit: contain;
  overflow: hidden;
  cursor: zoom-in;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

/* Domain */
#table-container th:nth-child(2),
#table-container td:nth-child(2) {
  width: 170px;
  min-width: 170px;
}

/* Current Status */
#table-container th:nth-child(3),
#table-container td:nth-child(3) {
  width: 170px;
  min-width: 170px;
}

/* Risk Score */
#table-container th:nth-child(4),
#table-container td:nth-child(4) {
  width: 90px;
  min-width: 90px;
  text-align: center;
  white-space: nowrap;
}

/* Score Explanation */
#table-container th:nth-child(5),
#table-container td:nth-child(5) {
  width: 315px;
  min-width: 315px;
}

/* Last Analysed */
#table-container th:nth-child(6),
#table-container td:nth-child(6) {
  width: 130px;
  min-width: 130px;
  white-space: nowrap;
}

/* Action */
#table-container th:nth-child(7),
#table-container td:nth-child(7) {
  width: 340px;
  min-width: 340px;
  white-space: nowrap;
}

/* Keep action controls aligned on one row */
#table-container td:nth-child(7) {
  white-space: nowrap;
}

#table-container td:nth-child(7) select,
#table-container td:nth-child(7) button {
  display: inline-block;
  vertical-align: middle;
}

#table-container td:nth-child(7) select {
  width: 220px;
  min-width: 220px;
  margin: 0 10px 0 0;
}

#table-container td:nth-child(7) button {
  width: 90px;
  min-width: 90px;
  margin: 0;
}

#table-container select {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  color: #111827;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#table-container select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

#table-container button {
  appearance: none;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.18);
}

#table-container button:hover {
  background: var(--brand-hover);
}

#table-container button:active {
  transform: translateY(1px);
}

#table-container a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}

#table-container a:hover {
  text-decoration: underline;
}

/* Image modal */
.image-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 1000;
}

.image-modal.is-open {
  display: block;
}

.image-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(2px);
}

.image-modal__dialog {
  position: absolute;
  inset: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.image-modal__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  background: #fff;
}

.image-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #111827;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.image-modal__close:hover {
  background: #ffffff;
}

@media (max-width: 900px) {
  header {
    padding: 16px 18px;
  }

  .title-wrap h1 {
    font-size: 18px;
  }

  .title-wrap p {
    font-size: 13px;
  }

  main {
    width: 100%;
    padding: 0 10px;
    margin-top: 16px;
  }

  .table-wrap {
    padding: 10px;
  }

  #table-container table {
    min-width: 1000px;
  }

  #table-container th:nth-child(1),
  #table-container td:nth-child(1) {
    width: 180px;
    min-width: 180px;
    max-width: 180px;
  }

  #table-container th:nth-child(5),
  #table-container td:nth-child(5) {
    width: 280px;
    min-width: 280px;
  }

  #table-container th:nth-child(7),
  #table-container td:nth-child(7) {
    width: 340px;
    min-width: 340px;
    white-space: nowrap;
  }

  #table-container td:nth-child(7) select {
    width: 220px;
    min-width: 220px;
  }

  .image-modal__dialog {
    inset: 12px;
    padding: 16px;
  }

  .image-modal__close {
    top: 10px;
    right: 10px;
  }
}