:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #162033;
  --muted: #657085;
  --line: #e4e8f0;
  --primary: #195bff;
  --primary-dark: #0f43c8;
  --good: #0f8a4b;
  --good-bg: #eaf8f0;
  --bad: #d92323;
  --bad-bg: #fff0f0;
  --warn: #9a6a00;
  --warn-bg: #fff7da;
  --shadow: 0 10px 30px rgba(22, 32, 51, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 5% 5%, rgba(25, 91, 255, 0.09), transparent 24rem),
    radial-gradient(circle at 95% 95%, rgba(14, 165, 233, 0.08), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.wrap {
  width: min(980px, calc(100% - 24px));
  margin: 24px auto;
}

.wrap.wide { width: min(1240px, calc(100% - 24px)); }

.card {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  padding: 20px;
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  overflow: hidden;
  position: relative;
}

.hero::after {
  position: absolute;
  right: -60px;
  bottom: -90px;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(25, 91, 255, 0.12), rgba(8, 145, 178, 0.04));
  content: '';
  pointer-events: none;
}

.hero > * { position: relative; z-index: 1; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 44px); }
h2 { margin-bottom: 10px; font-size: 22px; }

.eyebrow {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.label { margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.unnamed { color: var(--warn); }
.hidden { display: none !important; }

.sr-only {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.status-card h2 {
  overflow-wrap: anywhere;
  font-size: clamp(24px, 4vw, 34px);
}

.hero-links {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.nav-link,
button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  padding: 12px 16px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

button:hover,
.nav-link:hover { background: var(--primary-dark); }

.secondary-link,
button.secondary { background: #eef2ff; color: var(--primary); }
.secondary-link:hover,
button.secondary:hover { background: #dfe6ff; }
button.danger { background: var(--bad); color: #fff; }
button.danger:hover { background: #ad1717; }
button.ghost { border: 1px solid #ffd0d0; background: transparent; color: var(--bad); }
button.ghost:hover { background: var(--bad-bg); }

button.mini {
  min-height: 32px;
  margin: 2px;
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 12px;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
}

input:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(25, 91, 255, 0.18);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.button-row.right { justify-content: flex-end; margin-top: 0; }

.message,
.duplicate-box {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.message.ok,
.duplicate-box.good { border-color: #c9efd7; background: var(--good-bg); color: var(--good); }
.message.bad,
.duplicate-box.bad { border-color: #ffd0d0; background: var(--bad-bg); color: var(--bad); }
.message.warn { border-color: #f3dea0; background: var(--warn-bg); color: var(--warn); }

.note p:last-child { margin-bottom: 0; }
.metric span { display: block; margin-bottom: 8px; color: var(--muted); }
.metric b { font-size: 34px; }
.danger-metric b { color: var(--bad); }

.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.duplicate-summary-section {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.duplicate-summary-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.duplicate-summary-heading h3 { margin: 0; font-size: 19px; }
.duplicate-summary-heading .eyebrow { margin-bottom: 5px; }
.duplicate-summary-heading > span { max-width: 440px; text-align: right; }
.dup-groups { margin: 12px 0 0; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; min-width: 980px; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 12px; text-align: left; vertical-align: middle; }
th { background: #f8faff; color: var(--muted); font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.row-bad { background: var(--bad-bg); }
.row-offline { opacity: 0.62; }
.empty { padding: 30px; color: var(--muted); text-align: center; }

.duplicate-table-wrap {
  margin-top: 12px;
  background: var(--card);
}

.dup-groups > .duplicate-table-wrap { margin-top: 0; }

.duplicate-summary-table { min-width: 620px; }
.duplicate-summary-table th:nth-child(1) { width: 210px; }
.duplicate-summary-table th:nth-child(2) { width: 110px; text-align: center; }
.duplicate-summary-table td:nth-child(2) { text-align: center; }
.duplicate-summary-table td { background: var(--card); }
.duplicate-summary-table .row-bad td { background: var(--bad-bg); }

.duplicate-count {
  display: inline-flex;
  min-width: 72px;
  justify-content: center;
  border-radius: 999px;
  background: var(--bad);
  padding: 6px 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.duplicate-device-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.duplicate-device-list span {
  display: inline-flex;
  align-items: center;
  border: 1px solid #ffd0d0;
  border-radius: 999px;
  background: #fff;
  padding: 6px 9px;
  color: var(--bad);
  font-size: 12px;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
}

.pill.ok { background: var(--good-bg); color: var(--good); }
.pill.off { background: #eef1f6; color: var(--muted); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

@media (max-width: 760px) {
  .hero,
  .form-row,
  .toolbar { align-items: stretch; flex-direction: column; }

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

  .hero-links { display: grid; grid-template-columns: 1fr 1fr; }
  .duplicate-summary-heading { align-items: flex-start; flex-direction: column; }
  .duplicate-summary-heading > span { max-width: none; text-align: left; }
  button,
  .nav-link { width: 100%; }
  .button-row.right { justify-content: stretch; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1220;
    --card: #141d2e;
    --text: #eef3ff;
    --muted: #a6b1c7;
    --line: #29354a;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  }

  .secondary-link,
  button.secondary { background: #202d4e; color: #9ebaff; }
  th { background: #101827; }
  .row-bad { background: rgba(217, 35, 35, 0.13); }
  .duplicate-summary-table .row-bad td { background: rgba(217, 35, 35, 0.13); }
  .duplicate-device-list span {
    border-color: rgba(255, 108, 108, 0.3);
    background: #141d2e;
    color: #ff9b9b;
  }
  input { background: #0f1726; color: var(--text); }
}
