:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #182026;
  --muted: #63717d;
  --line: #dce2e8;
  --blue: #1f6feb;
  --green: #16845b;
  --amber: #b7791f;
  --red: #c93535;
  --shadow: 0 16px 38px rgba(20, 31, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(31, 111, 235, 0.22);
  outline-offset: 2px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f6 55%, #e8f0ed 100%);
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel,
.panel,
.table-panel,
.filter-panel,
.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  padding: 32px;
}

.brand-block h1,
.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-form,
.filters {
  display: grid;
  gap: 16px;
}

.login-form {
  margin-top: 28px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(201, 53, 53, 0.24);
  border-radius: 6px;
  color: var(--red);
  background: rgba(201, 53, 53, 0.08);
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar form {
  display: flex;
  align-items: center;
  gap: 12px;
}

.signed-in {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghost-button {
  color: var(--ink);
  background: #eef2f6;
}

.danger-button {
  color: #fff;
  background: var(--red);
}

.tiny-button {
  min-height: 28px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 12px;
}

.page {
  width: min(1480px, calc(100vw - 32px));
  margin: 24px auto 48px;
  display: grid;
  gap: 18px;
}

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

.metric-card {
  min-height: 104px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  box-shadow: none;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  font-size: 30px;
  line-height: 1.05;
}

.metric-card.accent {
  border-color: rgba(22, 132, 91, 0.28);
  background: #f4fbf8;
}

.filter-panel,
.panel,
.table-panel {
  padding: 18px;
}

.filters {
  grid-template-columns: 1fr 1fr 1.4fr 1fr 1fr 1.2fr 1.2fr 0.8fr auto auto;
  align-items: end;
}

.whitelist-form {
  display: grid;
  grid-template-columns: 1fr 1.2fr minmax(260px, auto) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 16px;
}

.check-label {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
  color: var(--ink);
}

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

.port-checks,
.inline-actions {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.panel.wide {
  grid-column: 1 / -1;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 17px;
}

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

.rank-list {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(72px, auto);
  gap: 12px;
  align-items: center;
}

.rank-label {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rank-track,
.bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #ecf0f4;
}

.rank-track {
  grid-column: 1 / -1;
}

.rank-fill,
.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.bar-chart {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: 140px minmax(160px, 1fr) 130px;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact-table table {
  min-width: 760px;
}

table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  position: sticky;
  top: 0;
  color: #42505c;
  background: #f7f9fb;
  font-weight: 800;
}

td {
  color: #2b3640;
}

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

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.status-ok {
  color: var(--green);
  font-weight: 700;
}

.status-error {
  color: var(--red);
  font-weight: 700;
}

.raw-cell {
  max-width: 420px;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.client-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 170px;
}

.client-cell span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  height: 120px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

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

  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics-grid,
  .insights-grid,
  .filters,
  .whitelist-form {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .metric-card strong {
    font-size: 25px;
  }
}
