/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f0f2f5;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --text-1:      #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;

  --green:       #16a34a;
  --green-bg:    #dcfce7;
  --green-soft:  #bbf7d0;
  --amber:       #d97706;
  --amber-bg:    #fef3c7;
  --amber-soft:  #fde68a;
  --red:         #dc2626;
  --red-bg:      #fee2e2;
  --red-soft:    #fecaca;
  --gray:        #94a3b8;
  --gray-bg:     #f1f5f9;
  --gray-soft:   #e2e8f0;

  --accent:      #2563eb;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.05);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-1);
  background: var(--bg);
}

/* ── Layout ────────────────────────────────────────────────── */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.container { max-width: 760px; margin: 0 auto; padding: 0 20px; }
.main { flex: 1; padding: 40px 0 60px; }

/* ── Header ────────────────────────────────────────────────── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
.brand:hover .brand-name { color: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 15px; font-weight: 700; color: var(--text-1); transition: color .15s; }
.brand-tag  { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: .8px; }

.header-actions { display: flex; align-items: center; gap: 14px; }
.countdown-text { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.countdown-text strong { color: var(--text-2); font-weight: 600; }

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-refresh:hover { background: var(--gray-bg); border-color: #cbd5e1; color: var(--text-1); }
.btn-refresh:active { background: #e2e8f0; }
.btn-icon { width: 14px; height: 14px; flex-shrink: 0; }
.btn-icon.spinning { animation: spin .7s linear infinite; }

/* ── Banner ────────────────────────────────────────────────── */
.banner { padding: 32px 0; transition: background .4s, border-color .4s; border-bottom: 1px solid transparent; }
.banner--operational { background: var(--green-bg); border-color: var(--green-soft); }
.banner--degraded    { background: var(--amber-bg); border-color: var(--amber-soft); }
.banner--outage      { background: var(--red-bg);   border-color: var(--red-soft);   }
.banner--checking    { background: var(--gray-bg);  border-color: var(--gray-soft);  }

.banner-inner { display: flex; align-items: center; gap: 18px; }
.banner-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .4s;
}
.banner-icon svg { width: 24px; height: 24px; }
.banner--operational .banner-icon { background: var(--green); color: #fff; }
.banner--degraded    .banner-icon { background: var(--amber); color: #fff; }
.banner--outage      .banner-icon { background: var(--red);   color: #fff; }
.banner--checking    .banner-icon { background: var(--gray);  color: #fff; }

.banner-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
  transition: color .4s;
}
.banner--operational .banner-title { color: #14532d; }
.banner--degraded    .banner-title { color: #78350f; }
.banner--outage      .banner-title { color: #7f1d1d; }
.banner--checking    .banner-title { color: var(--text-2); }

.banner-sub { font-size: 14px; transition: color .4s; }
.banner--operational .banner-sub { color: #166534; }
.banner--degraded    .banner-sub { color: #92400e; }
.banner--outage      .banner-sub { color: #991b1b; }
.banner--checking    .banner-sub { color: var(--text-3); }

/* ── Sections ──────────────────────────────────────────────── */
.section { margin-bottom: 28px; }
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-3); }
.section-hint  { font-size: 12px; color: var(--text-3); }

/* ── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.service-divider { height: 1px; background: var(--border); }

/* ── Service rows ──────────────────────────────────────────── */
.service-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 12px;
  transition: background .15s;
}
.service-row:hover { background: #fafbfc; }

.service-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.service-meta { display: flex; flex-direction: column; min-width: 0; }
.service-name { font-size: 14px; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.service-desc { font-size: 12px; color: var(--text-3); margin-top: 1px; }

.service-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.service-latency { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }

/* ── Status dot ────────────────────────────────────────────── */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background .4s;
}
.dot--operational { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,.2); animation: pulse-green 2s ease-in-out infinite; }
.dot--degraded    { background: var(--amber); }
.dot--timeout     { background: var(--amber); }
.dot--down        { background: var(--red);   animation: pulse-red 1.5s ease-in-out infinite; }
.dot--checking    { background: var(--gray);  animation: blink .8s ease-in-out infinite; }

/* ── Status pill ───────────────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2px;
  transition: background .4s, color .4s;
  white-space: nowrap;
}
.pill--operational { background: var(--green-bg); color: var(--green); }
.pill--degraded    { background: var(--amber-bg); color: var(--amber); }
.pill--timeout     { background: var(--amber-bg); color: var(--amber); }
.pill--down        { background: var(--red-bg);   color: var(--red);   }
.pill--checking    { background: var(--gray-bg);  color: var(--gray);  }

/* ── Turnstile (invisible widget — no visible UI) ──────────── */
#cf-turnstile { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ── 90-day history tiles ──────────────────────────────────── */
.history-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
}
.history-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  min-width: 160px;
  flex-shrink: 0;
}
.tile-track {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}
.tile {
  flex: 1;
  min-width: 3px;
  max-width: 12px;
  height: 28px;
  border-radius: 2px;
  cursor: default;
  transition: opacity .15s;
}
.tile:hover { opacity: .65; }
.tile--empty { background: var(--gray-soft); }
.tile--ok    { background: var(--green); }
.tile--warn  { background: var(--amber); }
.tile--down  { background: var(--red); }
.history-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  min-width: 52px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pct--ok   { color: var(--green); }
.pct--warn { color: var(--amber); }
.pct--down { color: var(--red); }
.history-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-3);
}

/* ── Footer ────────────────────────────────────────────────── */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 0;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-3);
  gap: 12px;
  flex-wrap: wrap;
}
.footer-note { color: var(--text-3); }

/* ── Animations ────────────────────────────────────────────── */
@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 3px rgba(22,163,74,.25); }
  50%       { box-shadow: 0 0 0 5px rgba(22,163,74,.08); }
}
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 3px rgba(220,38,38,.25); }
  50%       { box-shadow: 0 0 0 5px rgba(220,38,38,.08); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .35; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-in .3s ease forwards; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 540px) {
  .countdown-text { display: none; }
  .banner-title { font-size: 18px; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 4px; }
  .history-label { min-width: 110px; font-size: 12px; }
}
