:root {
  --bg: #edf2f7;
  --sidebar-bg: linear-gradient(180deg, #18233b 0%, #10192c 100%);
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --surface-muted: #eef3f9;
  --ink: #22304a;
  --muted: #72809b;
  --line: #dbe5f0;
  --accent: #1f78ff;
  --accent-strong: #1659cc;
  --accent-soft: rgba(31, 120, 255, 0.12);
  --success: #1d8f61;
  --danger: #d64545;
  --shadow: 0 14px 34px rgba(19, 31, 54, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Avenir Next", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  padding: 24px 20px;
  background: var(--sidebar-bg);
  color: #eff5ff;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-overline,
.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 700;
}

.brand-overline {
  color: rgba(239, 245, 255, 0.64);
}

.eyebrow,
.section-kicker {
  color: #8da3c7;
}

.brand-block h1 {
  margin: 0 0 10px;
  font-size: 1.8rem;
  line-height: 1.05;
}

.brand-copy {
  margin: 0;
  color: rgba(239, 245, 255, 0.72);
  line-height: 1.55;
  font-size: 0.94rem;
}

.sidebar-nav {
  display: grid;
  gap: 10px;
}

.nav-pill {
  display: block;
  padding: 12px 14px;
  border-radius: 14px;
  text-decoration: none;
  color: #eff5ff;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-weight: 600;
}

.nav-pill:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-card {
  align-self: end;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.scope-grid {
  display: grid;
  gap: 14px;
}

.scope-grid span {
  display: block;
  margin-bottom: 4px;
  color: rgba(239, 245, 255, 0.62);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.scope-grid strong {
  font-size: 0.98rem;
}

.main-shell {
  padding: 24px;
  display: grid;
  gap: 24px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 420px);
  gap: 20px;
  align-items: start;
}

.topbar h2 {
  margin: 0 0 10px;
  font-size: 2rem;
  line-height: 1.05;
}

.hero-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  max-width: 64ch;
}

.topbar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.control-block,
.session-card,
.panel,
.metric-card {
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.control-block,
.session-card {
  padding: 16px;
}

.control-block {
  display: grid;
  gap: 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  font-weight: 700;
}

.control-block.compact {
  min-width: 220px;
}

.session-card {
  display: grid;
  gap: 10px;
  align-content: start;
}

.session-label {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  font-weight: 700;
}

input,
select,
button {
  font: inherit;
}

select,
input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
}

button {
  padding: 12px 16px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:disabled,
select:disabled {
  cursor: wait;
  opacity: 0.7;
}

.auth-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-status[data-kind="success"] {
  color: var(--success);
}

.auth-status[data-kind="error"] {
  color: var(--danger);
}

.board-row {
  display: grid;
  gap: 14px;
}

.section-heading h3,
.panel-header h3 {
  margin: 0;
  font-size: 1.35rem;
}

.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 18px;
  border: 1px solid #e4ecf5;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), #31c6ff);
}

.metric-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
  text-transform: capitalize;
}

.metric-value {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 700;
}

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

.panel {
  padding: 20px;
  border: 1px solid #e4ecf5;
  position: relative;
  transition: opacity 140ms ease;
}

body.is-loading .panel,
body.is-loading .metric-card {
  opacity: 0.72;
}

body.is-loading .panel::after,
body.is-loading .metric-card::after {
  content: "Updating...";
  position: absolute;
  top: 14px;
  right: 16px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(34, 48, 74, 0.9);
  color: white;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

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

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

.stat-block {
  padding: 16px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid #e6edf5;
}

.stat-block-wide {
  grid-column: span 2;
}

.stat-block h4 {
  margin: 0 0 12px;
  font-size: 0.98rem;
}

.mini-stat-row,
.rank-row,
.template-row {
  display: grid;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
}

.mini-stat-row {
  grid-template-columns: 1fr auto;
}

.mini-stat-row span {
  color: var(--muted);
}

.template-row {
  grid-template-columns: minmax(0, 1fr) auto;
  border-bottom: 1px solid #e6edf5;
  gap: 14px;
}

.template-row:last-child {
  border-bottom: 0;
}

.template-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.template-attribute {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.template-value {
  overflow-wrap: anywhere;
}

.template-support {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.rank-row {
  grid-template-columns: 1fr auto;
  border-bottom: 1px solid #e6edf5;
}

.rank-row:last-child {
  border-bottom: 0;
}

.rank-value,
.table-shell td:first-child,
.cert-hash,
.dns-ascii {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
}

.rank-count {
  color: var(--muted);
}

.table-shell {
  overflow: auto;
}

.table-shell table {
  width: 100%;
  border-collapse: collapse;
}

.table-shell th,
.table-shell td {
  padding: 12px 10px;
  border-bottom: 1px solid #e6edf5;
  text-align: left;
}

.table-shell th {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
}

.anomaly-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 14px;
}

.anomaly-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid #dfe8f4;
  background:
    linear-gradient(180deg, #ffffff 0%, #f9fbfe 100%);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.anomaly-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.anomaly-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.anomaly-head h3 {
  margin: 0 0 8px;
  font-size: 1.02rem;
  overflow-wrap: anywhere;
}

.cert-hash {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.dns-sample {
  margin: 0;
  display: grid;
  gap: 4px;
}

.dns-name-row {
  display: grid;
  gap: 3px;
}

.dns-ascii,
.dns-unicode {
  overflow-wrap: anywhere;
}

.dns-ascii {
  font-size: 0.8rem;
  color: var(--muted);
}

.dns-unicode {
  font-size: 0.93rem;
  color: var(--ink);
}

.score-pill {
  min-width: 54px;
  padding: 10px 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff7f50, #f2495c);
  color: white;
  text-align: center;
  font-weight: 700;
  flex: 0 0 auto;
}

.signal-list {
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.detail-modal[hidden] {
  display: none;
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 25, 41, 0.58);
  backdrop-filter: blur(8px);
}

.detail-sheet {
  position: relative;
  width: min(960px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  margin: 12px auto;
  overflow: auto;
  padding: 24px;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(12, 23, 44, 0.24);
}

.detail-close {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: block;
  z-index: 2;
}

.detail-header h2 {
  margin: 0 0 10px;
  font-size: 1.95rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 18px;
}

.detail-block,
.detail-section {
  margin-top: 18px;
  padding: 18px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid #e4ecf5;
}

.detail-dl {
  display: grid;
  gap: 12px;
}

.detail-dl div {
  display: grid;
  gap: 4px;
}

.detail-dl dt {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-dl dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.detail-list {
  margin: 0;
  padding-left: 18px;
}

.detail-signal-grid,
.detail-finding-grid {
  display: grid;
  gap: 12px;
}

.detail-signal-card,
.detail-finding-row {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid #e4ecf5;
  background: #ffffff;
}

.detail-signal-head,
.detail-finding-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.detail-signal-card p {
  margin: 10px 0;
  color: var(--muted);
}

.json-block {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: 12px;
  background: #18233b;
  color: #eef5ff;
  font-size: 0.82rem;
}

.detail-loading {
  color: var(--muted);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, rgba(31, 120, 255, 0.14), transparent 30%), var(--bg);
}

.login-shell {
  width: min(100%, 460px);
  padding: 20px;
}

.login-card {
  padding: 28px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid #e4ecf5;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 12px;
  font-size: 2rem;
  line-height: 1;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.login-form label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 240px 1fr;
  }

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

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto;
  }

  .two-column,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .main-shell,
  .sidebar {
    padding: 18px;
  }

  .topbar-actions,
  .profile-grid,
  .attribute-grid,
  .metric-cards,
  .anomaly-list {
    grid-template-columns: 1fr;
  }

  .stat-block-wide {
    grid-column: span 1;
  }

  .panel-header {
    flex-direction: column;
  }
}
