/* WebKit 537 compatible — no gap, no CSS variables, -webkit- prefixed flex */

html, body {
  height: 100%;
}

* {
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #0f1117;
  color: #e2e8f0;
  font-family: -apple-system, sans-serif;
  min-height: 100%;
  padding: 2rem;
}

header {
  margin-bottom: 1rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.manage {
  margin-bottom: 2.5rem;
}

#last-updated {
  font-size: 0.8rem;
  color: #64748b;
}

#loading {
  color: #64748b;
  font-size: 0.95rem;
}

/* ─── Error banner ─────────────────────────────────────────────────────── */

.error-banner {
  background: #7f1d1d;
  border: 1px solid #ef4444;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  color: #ef4444;
}

.error-banner ul {
  margin: 0.25rem 0 0 1.2rem;
}

/* ─── Account group ────────────────────────────────────────────────────── */

.account-group {
  margin-bottom: 2.5rem;
}

.account-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.9rem;
}

/* ─── Tile grid ─────────────────────────────────────────────────────────── */

.tiles {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
          flex-wrap: wrap;
  margin: -0.425rem;
}

.tile {
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
  width: 220px;
  margin: 0.425rem;
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 220px;
          flex: 1 1 220px;
  max-width: 400px;

  background: #1a1d27;
  border: 1px solid #2a2d3e;
  border-radius: 10px;
  padding: 1rem 1.1rem;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
          flex-direction: column;
}

/* ─── Status variants ──────────────────────────────────────────────────── */

.tile.up         { border-color: #166534; }
.tile.down       { border-color: #7f1d1d; }
.tile.seems-down { border-color: #78350f; }
.tile.paused,
.tile.unknown    { border-color: #2a2d3e; }

.tile.down {
  -webkit-animation: pulse-red 2s ease-in-out infinite;
          animation: pulse-red 2s ease-in-out infinite;
}

@-webkit-keyframes pulse-red {
  0%,100% { -webkit-box-shadow: 0 0 0 0 rgba(239,68,68,0.15); }
  50%     { -webkit-box-shadow: 0 0 12px 2px rgba(239,68,68,0.15); }
}
@keyframes pulse-red {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.15); }
  50%     { box-shadow: 0 0 12px 2px rgba(239,68,68,0.15); }
}

/* ─── Tile header row ──────────────────────────────────────────────────── */

.tile-header {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
          align-items: center;
  margin-bottom: 0.45rem;
}

.tile-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  -webkit-flex-shrink: 0;
          flex-shrink: 0;
  margin-right: 0.55rem;
}

.up         .tile-dot { background: #22c55e; -webkit-box-shadow: 0 0 6px #22c55e; box-shadow: 0 0 6px #22c55e; }
.down       .tile-dot { background: #ef4444; -webkit-box-shadow: 0 0 6px #ef4444; box-shadow: 0 0 6px #ef4444;
                        -webkit-animation: blink 1s step-start infinite;
                                animation: blink 1s step-start infinite; }
.seems-down .tile-dot { background: #f59e0b; -webkit-box-shadow: 0 0 6px #f59e0b; box-shadow: 0 0 6px #f59e0b; }
.paused     .tile-dot,
.unknown    .tile-dot { background: #475569; }

@-webkit-keyframes blink { 50% { opacity: 0; } }
@keyframes blink         { 50% { opacity: 0; } }

.tile-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-box-flex: 1;
  -webkit-flex: 1;
          flex: 1;
  margin-right: 0.55rem;
}

.tile-status {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.up         .tile-status { background: rgba(34,197,94,0.15);  color: #22c55e; }
.down       .tile-status { background: rgba(239,68,68,0.15);  color: #ef4444; }
.seems-down .tile-status { background: rgba(245,158,11,0.15); color: #f59e0b; }
.paused     .tile-status,
.unknown    .tile-status { background: rgba(71,85,105,0.15);  color: #475569; }

/* ─── Tile body ────────────────────────────────────────────────────────── */

.tile-url {
  font-size: 0.75rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.1rem;
}

.tile-uptime {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 0.1rem;
}

/* ─── Empty state ──────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #64748b;
}

.empty-state h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: #e2e8f0;
}

.empty-state code {
  background: #1a1d27;
  border: 1px solid #2a2d3e;
  border-radius: 6px;
  padding: 0.2rem 0.45rem;
  font-size: 0.85rem;
}

/* ─── Auth gate ────────────────────────────────────────────────────────── */

.auth-gate {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0f1117;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
          align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
          justify-content: center;
}

.auth-box {
  background: #1a1d27;
  border: 1px solid #2a2d3e;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.auth-box h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: #e2e8f0;
}

.auth-error {
  font-size: 0.82rem;
  color: #ef4444;
  margin-bottom: 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

#auth-form {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
          flex-direction: column;
}

#key-input {
  background: #0f1117;
  border: 1px solid #2a2d3e;
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 0.95rem;
  padding: 0.65rem 0.9rem;
  width: 100%;
  outline: none;
  -webkit-appearance: none;
  margin-bottom: 0.75rem;
}

#key-input:focus {
  border-color: #475569;
}

#auth-form button {
  background: #e2e8f0;
  border: none;
  border-radius: 8px;
  color: #0f1117;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1rem;
  width: 100%;
  -webkit-appearance: none;
}

#auth-form button:active {
  background: #cbd5e1;
}
