/* ============================================================
   Design system — Uptime Dashboard
   ============================================================ */

/* ---- Tokens ---- */
:root {
  --brand-50:  #f5f7ff;
  --brand-100: #ebf0fe;
  --brand-200: #dce5fd;
  --brand-500: #738cf1;
  --brand-600: #4f69e8;
  --brand-700: #3d52d9;

  --emerald:   #10b981;
  --emerald-bg:#ecfdf5;
  --rose:      #f43f5e;
  --rose-bg:   #fff1f2;
  --amber:     #f59e0b;

  --bg:        #f8fafc;
  --bg-card:   #ffffff;
  --bg-input:  #f1f5f9;
  --bg-subtle: #f8fafc;

  --text:      #0f172a;
  --text-sub:  #475569;
  --text-muted:#94a3b8;
  --text-faint:#cbd5e1;

  --border:    #e2e8f0;
  --border-sub:#f1f5f9;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --shadow-brand: 0 8px 24px rgba(79,105,232,.18);

  --r-sm:  .75rem;
  --r-md:  1.25rem;
  --r-lg:  1.75rem;
  --r-xl:  2rem;
  --r-2xl: 2.5rem;
  --r-3xl: 3rem;

  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
}

.dark {
  --bg:        #0b0f1a;
  --bg-card:   rgba(15,23,42,.7);
  --bg-input:  rgba(15,23,42,.8);
  --bg-subtle: rgba(30,41,59,.4);

  --text:      #f1f5f9;
  --text-sub:  #94a3b8;
  --text-muted:#64748b;
  --text-faint:#334155;

  --border:    rgba(51,65,85,.6);
  --border-sub:rgba(51,65,85,.3);

  --emerald-bg:rgba(16,185,129,.1);
  --rose-bg:   rgba(244,63,94,.1);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .3s, color .3s;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
svg { display: block; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ---- Layout ---- */
.page { max-width: 105rem; margin: 0 auto; padding: 3rem 1.5rem; }

.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.gap-2  { gap: .5rem; }
.gap-3  { gap: .75rem; }
.gap-4  { gap: 1rem; }
.gap-6  { gap: 1.5rem; }
.gap-8  { gap: 2rem; }
.wrap   { flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 3fr 1fr; gap: 3rem; }

@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .md-col { flex-direction: column; }
  .md-full { width: 100%; }
}

.mb-2  { margin-bottom: .5rem; }
.mb-4  { margin-bottom: 1rem; }
.mb-6  { margin-bottom: 1.5rem; }
.mb-8  { margin-bottom: 2rem; }
.mb-10 { margin-bottom: 2.5rem; }
.mb-12 { margin-bottom: 3rem; }
.mb-16 { margin-bottom: 4rem; }
.mt-2  { margin-top: .5rem; }
.mt-4  { margin-top: 1rem; }
.mt-6  { margin-top: 1.5rem; }
.mt-8  { margin-top: 2rem; }
.hidden { display: none !important; }
.shrink-0 { flex-shrink: 0; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 12rem; }

/* ---- Typography ---- */
.label-caps {
  font-size: .625rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--text-muted);
}
.text-xl  { font-size: 1.25rem;  font-weight: 800; }
.text-2xl { font-size: 1.5rem;   font-weight: 800; }
.text-3xl { font-size: 1.875rem; font-weight: 800; }
.text-4xl { font-size: 2.25rem;  font-weight: 800; letter-spacing: -.04em; }
.text-sm  { font-size: .875rem; }
.text-xs  { font-size: .75rem; }
.text-xxs { font-size: .65rem; }
.font-bold   { font-weight: 700; }
.font-black  { font-weight: 800; }
.text-brand  { color: var(--brand-600); }
.text-muted  { color: var(--text-muted); }
.text-faint  { color: var(--text-faint); }
.text-sub    { color: var(--text-sub); }
.text-emerald { color: var(--emerald); }
.text-rose    { color: var(--rose); }

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}
.card-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  padding: 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.card-inset {
  background: var(--bg-subtle);
  border: 1px solid var(--border-sub);
  border-radius: var(--r-lg);
  padding: 2rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  height: 3rem;
  padding: 0 1.5rem;
  border-radius: var(--r-lg);
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  transition: background .15s, color .15s, opacity .15s, transform .1s;
  cursor: pointer;
  border: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.98); }

.btn-primary {
  background: var(--brand-600);
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--brand-600); }

.btn-ghost-danger {
  background: transparent;
  color: var(--rose);
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .15em;
}
.btn-ghost-danger:hover { color: #e11d48; }

.btn-dashed {
  height: 3.5rem;
  background: transparent;
  border: 2px dashed var(--border);
  color: var(--text-muted);
  border-radius: var(--r-lg);
  font-size: .8rem;
  font-weight: 800;
}
.btn-dashed:hover { border-color: var(--brand-600); color: var(--brand-600); }

.btn-icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: var(--r-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}
.btn-icon:hover { color: var(--brand-600); }

.btn-sm {
  height: 2rem;
  padding: 0 .75rem;
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  border-radius: var(--r-sm);
  background: var(--brand-50);
  color: var(--brand-600);
  transition: background .15s;
}
.dark .btn-sm { background: rgba(79,105,232,.15); }
.btn-sm:hover { background: var(--brand-100); }
.dark .btn-sm:hover { background: rgba(79,105,232,.25); }

.btn-danger-sm {
  height: 2rem;
  padding: 0 .75rem;
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  border-radius: var(--r-sm);
  background: var(--rose);
  color: #fff;
  transition: background .15s;
}
.btn-danger-sm:hover { background: #e11d48; }

/* ---- Inputs ---- */
.input {
  width: 100%;
  height: 3rem;
  padding: 0 1rem;
  background: var(--bg-input);
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 700;
  color: var(--text);
  outline: none;
  transition: box-shadow .15s;
}
.input:focus { box-shadow: 0 0 0 2px var(--brand-600); }
.input::placeholder { color: var(--text-muted); font-weight: 500; }

.input-lg {
  height: 3.5rem;
  padding: 0 1.5rem;
  font-size: 1rem;
  border-radius: var(--r-lg);
}

select.input { appearance: none; cursor: pointer; }

.form-group { display: flex; flex-direction: column; gap: .5rem; }
.form-label {
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-sub);
}
.form-hint { font-size: .7rem; color: var(--text-muted); margin-top: .25rem; }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: .75rem;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 2.75rem;
  height: 1.5rem;
  background: var(--border);
  border-radius: 99px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle input:checked + .toggle-track { background: var(--brand-600); }
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 1.125rem; height: 1.125rem;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-track::after { transform: translateX(1.25rem); }

/* ---- Header ---- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3rem;
}
.site-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.brand-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--brand-600);
  border-radius: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(79,105,232,.3);
  flex-shrink: 0;
}
.brand-name { font-size: 1.1rem; font-weight: 800; letter-spacing: -.01em; }
.brand-sub {
  font-size: .6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .2em;
  color: var(--text-muted);
}
.header-actions { display: flex; align-items: center; gap: 1rem; }

/* ---- Status hero ---- */
.hero-icon {
  width: 4rem;
  height: 4rem;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .5s, color .5s;
}
.hero-icon--up   { background: var(--emerald-bg); color: var(--emerald); }
.hero-icon--down { background: var(--rose-bg);    color: var(--rose); }
.hero-icon--pending { background: var(--bg-input); color: var(--text-muted); }

/* ---- Monitors grid ---- */
.monitors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: .75rem;
}

/* ---- Monitor cards ---- */
.monitor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  cursor: pointer;
  transition: box-shadow .25s, border-color .25s;
}
.monitor-card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(79,105,232,.3);
}

.monitor-card__header   { display: flex; align-items: center; gap: .75rem; }
.monitor-card__titles   { flex: 1; min-width: 0; }
.monitor-card__sparkline { height: 5rem; background: var(--bg-subtle); border-radius: var(--r-sm); }
.monitor-card__sparkline canvas { display: block; }
.monitor-card__bars     { min-height: 1rem; overflow: hidden; }
.monitor-card__footer   { display: flex; align-items: center; justify-content: space-between; }

.monitor-name {
  font-size: .875rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.monitor-url {
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
}

/* Status dot */
.status-dot {
  width: .625rem;
  height: .625rem;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.status-dot--up      { background: var(--emerald); }
.status-dot--down    { background: var(--rose); }
.status-dot--pending { background: var(--text-faint); }

.status-dot--up::after,
.status-dot--down::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: currentColor;
  opacity: .2;
  animation: ping 2s cubic-bezier(0,0,.2,1) infinite;
}
.status-dot--up::after   { color: var(--emerald); }
.status-dot--down::after { color: var(--rose); }
@keyframes ping { 75%, 100% { transform: scale(2); opacity: 0; } }

.status-label {
  font-size: .6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .15em;
}
.status-label--up      { color: var(--emerald); }
.status-label--down    { color: var(--rose); }
.status-label--pending { color: var(--text-muted); }

.monitor-latency {
  font-size: .6rem;
  font-weight: 700;
  color: var(--text-faint);
}

/* Uptime bars */
.uptime-bar {
  display: flex;
  gap: 2px;
  height: 1rem;
  align-items: flex-end;
  overflow: hidden;
  max-width: 100%;
}
.uptime-segment {
  width: 3px;
  border-radius: 1px;
  transition: transform .2s;
  height: 100%;
}
.uptime-segment:hover { transform: scaleY(1.5); opacity: 1 !important; }
.uptime-segment--up   { background: var(--emerald); opacity: .75; }
.uptime-segment--down { background: var(--rose); }
.uptime-empty { font-size: .5rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); }

/* Arrow chevron in monitor card */
.card-arrow {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--r-sm);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.monitor-card:hover .card-arrow { background: var(--brand-50); color: var(--brand-600); }
.dark .monitor-card:hover .card-arrow { background: rgba(79,105,232,.15); }

/* ---- Integrity card ---- */
.integrity-score {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -.04em;
  color: var(--brand-600);
  line-height: 1;
}
.integrity-score span { font-size: 1.1rem; color: var(--text-faint); margin-left: .25rem; }
.progress-bar {
  width: 100%;
  height: .5rem;
  background: var(--bg-input);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--brand-600);
  border-radius: 99px;
  transition: width 1s ease;
  box-shadow: 0 0 8px rgba(79,105,232,.4);
}

/* ---- Timeline ---- */
.timeline-entry {
  position: relative;
  padding-left: 2rem;
}
.timeline-entry::before {
  content: '';
  position: absolute;
  left: 0; top: .4rem;
  width: .75rem; height: .75rem;
  border-radius: 50%;
}
.timeline-entry--down::before {
  background: var(--rose);
  box-shadow: 0 0 0 4px rgba(244,63,94,.15);
}
.timeline-entry--up::before {
  background: var(--emerald);
  box-shadow: 0 0 0 4px rgba(16,185,129,.15);
}
.timeline-name { font-size: .875rem; font-weight: 800; }
.timeline-time { font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-top: .25rem; }

/* ---- Section headings ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

/* ---- Tabs ---- */
.tab-panel { display: block; }

.tab-nav {
  display: flex;
  gap: .25rem;
  padding: .25rem;
  background: var(--bg-input);
  border-radius: var(--r-lg);
  width: fit-content;
  margin-bottom: 2.5rem;
}
.tab-btn {
  padding: .5rem 1.25rem;
  border-radius: var(--r-sm);
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  transition: all .15s;
  background: transparent;
  cursor: pointer;
}
.tab-btn:hover:not(.active) { color: var(--brand-600); }
.tab-btn.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---- Admin service rows ---- */
.svc-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.svc-row__inputs { flex: 1; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; }
@media (max-width: 768px) { .svc-row__inputs { grid-template-columns: 1fr; } }
.drag-handle {
  color: var(--text-faint);
  cursor: grab;
  padding: .25rem;
  transition: color .15s;
  flex-shrink: 0;
}
.drag-handle:hover { color: var(--brand-600); }
.drag-handle:active { cursor: grabbing; }
.svc-remove {
  color: var(--text-faint);
  padding: .5rem;
  border-radius: .5rem;
  transition: color .15s;
  flex-shrink: 0;
}
.svc-remove:hover { color: var(--rose); }

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-sub);
  border-radius: var(--r-3xl);
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  width: 100%;
}
.modal-sm  { max-width: 24rem; padding: 2.5rem; }
.modal-lg  { max-width: 56rem; padding: 2.5rem 3rem; }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 3rem;
}

/* ---- Login modal icon ---- */
.login-icon {
  width: 5rem;
  height: 5rem;
  background: var(--brand-50);
  color: var(--brand-600);
  border-radius: var(--r-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}
.dark .login-icon { background: rgba(79,105,232,.15); }

/* ---- Confirmation banner ---- */
.confirm-banner {
  background: var(--rose-bg);
  border: 1px solid rgba(244,63,94,.3);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.dark .confirm-banner { background: rgba(244,63,94,.1); border-color: rgba(244,63,94,.2); }
.confirm-banner p { font-size: .875rem; font-weight: 700; color: var(--rose); }

/* ---- Settings sections ---- */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.5rem;
}
.settings-section + .settings-section { margin-top: 1rem; }
.settings-section__title {
  font-size: .625rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border-radius: var(--r-md);
  padding: 1rem;
  gap: 1rem;
}
.settings-toggle-label { font-size: .875rem; font-weight: 700; }
.settings-toggle-sub   { font-size: .7rem; color: var(--text-muted); margin-top: .2rem; }

/* ---- Incidents list ---- */
.incident-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.incident-row + .incident-row { margin-top: .5rem; }
.incident-row__left { display: flex; align-items: center; gap: 1rem; }
.incident-dot { width: .5rem; height: .5rem; border-radius: 50%; flex-shrink: 0; }
.incident-dot--down     { background: var(--rose); }
.incident-dot--up       { background: var(--emerald); }
.incident-service { font-size: .875rem; font-weight: 800; }
.incident-meta { font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin-top: .15rem; }
.incident-meta--down { color: var(--rose); }
.incident-meta--up   { color: var(--emerald); }
.incident-delete {
  opacity: 0;
  color: var(--text-faint);
  padding: .375rem;
  border-radius: .5rem;
  transition: opacity .15s, color .15s;
  flex-shrink: 0;
}
.incident-row:hover .incident-delete { opacity: 1; }
.incident-delete:hover { color: var(--rose); }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2rem;
}
.pagination-info { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.pagination-btn {
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  padding: .5rem 1rem;
  border-radius: var(--r-sm);
  transition: color .15s;
}
.pagination-btn:hover:not(:disabled) { color: var(--brand-600); }
.pagination-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-faint);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
}

/* ---- Chart modal ---- */
.stat-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-sub);
  border-radius: var(--r-xl);
  padding: 2rem;
}
.stat-value {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -.04em;
  color: var(--brand-600);
  line-height: 1;
}
