*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f4f8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  color: #1a202c;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(0, 380px);
  gap: 1.5rem;
  align-items: stretch;
  width: 100%;
  max-width: 980px;
}

.card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
  padding: 2.5rem 2rem;
  width: 100%;
  text-align: center;
}

/* ── Audit log card ── */
.audit-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
  padding: 1.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.audit-heading {
  font-size: 1rem;
  font-weight: 700;
  color: #4a5568;
  margin-bottom: 1rem;
  text-align: left;
}

.audit-log {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

.audit-table th {
  text-align: left;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #a0aec0;
  padding: .35rem .5rem;
  border-bottom: 1px solid #e2e8f0;
}

.audit-table td {
  padding: .4rem .5rem;
  vertical-align: top;
}

.audit-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid #f0f4f8;
}

.audit-time {
  white-space: nowrap;
  color: #718096;
  padding-right: .75rem;
}

.audit-online .audit-event  { color: #22c55e; font-weight: 600; }
.audit-warning .audit-event { color: #f59e0b; font-weight: 600; }
.audit-offline .audit-event { color: #ef4444; font-weight: 600; }

/* ── Status section ── */
.status-section { margin-bottom: 2rem; }

.checkmark-wrap {
  width: 96px;
  height: 96px;
  margin: 0 auto 1rem;
}

.checkmark-circle {
  fill: none;
  stroke: #22c55e;
  stroke-width: 3;
  stroke-dasharray: 283;
  stroke-dashoffset: 283;
  animation: draw-circle .5s ease forwards;
}

.checkmark-check {
  fill: none;
  stroke: #22c55e;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: draw-check .4s ease .45s forwards;
}

@keyframes draw-circle {
  to { stroke-dashoffset: 0; }
}
@keyframes draw-check {
  to { stroke-dashoffset: 0; }
}

/* Offline state */
.card.offline .checkmark-circle { stroke: #ef4444; animation: none; stroke-dashoffset: 0; }
.card.offline .checkmark-check  { display: none; }
.cross-path {
  display: none;
  fill: none;
  stroke: #ef4444;
  stroke-width: 4;
  stroke-linecap: round;
}
.card.offline .cross-path { display: block; }

.status-label {
  font-size: 1.6rem;
  font-weight: 700;
  color: #22c55e;
}
.card.offline .status-label { color: #ef4444; }

.status-sub {
  font-size: .95rem;
  color: #718096;
  margin-top: .25rem;
}

/* ── Info grid ── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem 1rem;
  text-align: left;
  margin-bottom: 2rem;
}

.info-item {
  background: #f7fafc;
  border-radius: 10px;
  padding: .75rem 1rem;
}

.info-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #a0aec0;
  margin-bottom: .25rem;
}

.info-value {
  font-size: .95rem;
  font-weight: 500;
  color: #2d3748;
  word-break: break-all;
}

/* ── Timestamps ── */
.timestamps {
  border-top: 1px solid #e2e8f0;
  padding-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.ts-row {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  color: #718096;
}

.ts-label { font-weight: 600; }

/* ── Version credit ── */
.version-credit {
  text-align: right;
  font-size: .7rem;
  color: #a0aec0;
  margin-top: 1rem;
}

/* ── Offline cleared field placeholder ── */
.info-value.dim { color: #cbd5e1; font-style: italic; }

/* ── Latency quality labels ── */
.quality-good { color: #22c55e; }
.quality-fair { color: #f59e0b; }
.quality-poor { color: #ef4444; }

/* ── Theme toggle ── */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: none;
  border: 2px solid #cbd5e1;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a5568;
  transition: background .2s, color .2s, border-color .2s;
  z-index: 100;
  padding: 0;
}
.theme-toggle:hover {
  background: rgba(0,0,0,.06);
}

/* Light mode: show moon, hide sun */
.icon-sun  { display: none; }
.icon-moon { display: block; }

/* Dark mode: show sun, hide moon */
body.dark .icon-sun  { display: block; }
body.dark .icon-moon { display: none; }

/* ── Dark mode ── */
body.dark {
  background: #0f172a;
  color: #e2e8f0;
}

body.dark .card {
  background: #1e293b;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}

body.dark .status-sub { color: #94a3b8; }

body.dark .info-item { background: #0f172a; }

body.dark .info-label { color: #64748b; }

body.dark .info-value { color: #cbd5e1; }

body.dark .timestamps { border-top-color: #334155; }

body.dark .ts-row { color: #94a3b8; }

body.dark .audit-card { background: #1e293b; box-shadow: 0 4px 24px rgba(0,0,0,.4); }
body.dark .audit-heading { color: #94a3b8; }
body.dark .audit-table th { color: #64748b; border-bottom-color: #334155; }
body.dark .audit-table tbody tr:not(:last-child) td { border-bottom-color: #0f172a; }
body.dark .audit-time { color: #64748b; }

body.dark .theme-toggle {
  border-color: #475569;
  color: #e2e8f0;
}
body.dark .theme-toggle:hover {
  background: rgba(255,255,255,.08);
}

/* ── Responsive ── */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .audit-card { min-height: 260px; }
}

@media (max-width: 480px) {
  .info-grid { grid-template-columns: 1fr; }
  .ts-row { flex-direction: column; gap: .1rem; }
}
