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

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background-color: #1a1a1a;
  color: #ffffff;
  min-height: 100vh;
}

a { color: inherit; }

/* ── Top bar ─────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 64px;
  background: linear-gradient(to right, #7b3fe4 0%, #4a2a8c 100%);
}

.top-bar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.top-bar__logo {
  height: 36px;
  max-height: 36px;
  width: auto;
  max-width: 140px;
  display: block;
}
.top-bar__brand-mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
}
.top-bar__brand-title { font-size: 17px; font-weight: 800; letter-spacing: .02em; color: #fff; }

.top-bar__right { display: flex; align-items: center; gap: 14px; }
.top-bar__link {
  font-size: 12px; padding: 5px 12px; border: 1px solid rgba(255,255,255,.4);
  border-radius: 6px; background: transparent; color: #fff; cursor: pointer;
  text-decoration: none;
}
.top-bar__link:hover { background: rgba(255,255,255,.12); }
.refresh-info { font-size: 12px; color: rgba(255,255,255,.85); }

.top-bar__icons { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(0,0,0,.2);
  text-decoration: none;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(0,0,0,.35); }
.icon-btn svg { width: 18px; height: 18px; fill: #ffffff; }

.locked { opacity: .35; pointer-events: none; cursor: not-allowed; }

.text-input {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 9px 12px;
  color: #ffffff;
  font-size: 13px;
  margin-top: 4px;
}
.text-input:focus { outline: none; border-color: #f49976; }

.content { padding: 24px; max-width: 1100px; margin: 0 auto; }

/* ── Home: app-card launcher grid ───────────────────────── */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.5rem;
  padding: 2rem 0;
  max-width: 720px;
  margin: 0 auto;
}

.app-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 1.75rem 1rem;
  border-radius: 12px;
  background: #1e2a38;
  border: 1px solid #2b3b4d;
  color: #ffffff;
  text-decoration: none;
  transition: transform .15s ease, background .15s ease;
}
.app-card:hover { transform: translateY(-3px); background: #2a3a4e; }
.app-card__icon { width: 44px; height: 44px; }
.app-card__label { font-size: 1rem; font-weight: 700; letter-spacing: .02em; }

.app-card__badge {
  position: absolute; top: 10px; right: 10px;
  font-size: .7rem; font-weight: 800; padding: 2px 9px; border-radius: 20px;
  background: rgba(0,0,0,.35); color: #cccccc;
}
.app-card--down .app-card__icon  { color: #ff6b6b; }
.app-card--down .app-card__badge { color: #ff6b6b; }
.app-card--up   .app-card__icon  { color: #a8c832; }
.app-card--up   .app-card__badge { color: #a8c832; }
.app-card--setup .app-card__icon { color: #cccccc; }
.app-card--links .app-card__icon { color: #cccccc; }

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.back-link {
  color: #f49976;
  font-size: .875rem;
  text-decoration: none;
  white-space: nowrap;
}
.back-link:hover { text-decoration: underline; }
.page-title { font-size: 1.3rem; font-weight: 700; color: #ffffff; flex: 1; }
.page-count {
  font-size: .75rem; font-weight: 800; padding: 3px 10px; border-radius: 20px;
  background: #2a2a2a; color: #cccccc;
}

/* ── Summary bar ─────────────────────────────────────────── */
.summary {
  background: #232323;
  border: 1px solid #333333;
  border-radius: 10px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  font-size: 13px;
}
.last-run { margin-left: auto; color: #999999; font-size: 12px; }

/* ── Grid / cards ────────────────────────────────────────── */
.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.site-card {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  overflow: hidden;
}
.site-card.down { border-color: #8b2020; }
.site-card.up   { border-color: #4a6e50; }
.site-card.checking { border-color: #3a3a3a; }

.card-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(to right, #4a6e50, #2a3d35);
}
.site-card.down .card-header { background: linear-gradient(to right, #8b2020, #4a1010); }
.site-card.checking .card-header { background: #333333; }

.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: rgba(255,255,255,.7); }
.checking .status-dot { animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.3; } }

.site-name { font-size: 14px; font-weight: 700; flex: 1; color: #fff; }
.status-badge {
  font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .05em;
  background: rgba(0,0,0,.3); color: #fff;
}
.type-badge {
  font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
  background: rgba(255,255,255,.1); color: #cccccc; white-space: nowrap;
}

.card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.site-url  { font-size: 11px; color: #999999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-url a { color: #8fb4d9; text-decoration: none; }
.site-url a:hover { text-decoration: underline; }

.card-meta { display: flex; gap: 14px; font-size: 12px; color: #aaaaaa; }
.card-meta span b { color: #ffffff; }

.uptime-bar-wrap { margin-top: 2px; }
.uptime-label { font-size: 11px; color: #999999; margin-bottom: 3px; }
.uptime-bar   { height: 5px; border-radius: 3px; background: #3a3a3a; overflow: hidden; }
.uptime-fill  { height: 100%; border-radius: 3px; background: #a8c832; transition: width .4s; }
.down .uptime-fill { background: #ff6b6b; }

.error-msg { font-size: 11px; color: #ff6b6b; }

.empty-state, #loadingMsg { text-align: center; padding: 40px; color: #999999; font-size: 14px; }

/* ── SETUP page ──────────────────────────────────────────── */
.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.setup-field {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  padding: 14px 16px;
}
.setup-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; color: #999999; margin-bottom: 6px;
}
.setup-value { font-size: 15px; font-weight: 700; color: #ffffff; }

.setup-body-wrap { margin-bottom: 24px; }
.sms-bubble {
  background: #1e2a38;
  border: 1px solid #2b3b4d;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  color: #ffffff;
  white-space: pre-wrap;
  word-break: break-word;
}

.btn {
  font-size: 13px; font-weight: 700; padding: 9px 18px; border-radius: 8px;
  border: none; cursor: pointer;
  background: linear-gradient(to right, #f49976, #7b3fe4);
  color: #ffffff;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: default; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-overlay.open { display: flex; }

.modal-card {
  background: #232323;
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  overflow: hidden;
}
.modal-header {
  background: linear-gradient(to right, #7b3fe4, #4a2a8c);
  color: #ffffff;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-close {
  background: none; border: none; color: #ffffff;
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal-close:hover { opacity: .7; }
.modal-body { padding: 18px 20px 20px; }

.sms-field { margin-bottom: 14px; }
.sms-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; color: #999999; margin-bottom: 4px;
}
.sms-value { font-size: 14px; color: #ffffff; font-weight: 700; }
.sms-error { margin-top: 10px; font-size: 12px; color: #ff6b6b; }
.sms-error:empty { display: none; }

/* ── Links page ──────────────────────────────────────────── */
.link-form {
  display: flex; flex-wrap: wrap; gap: 10px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.link-form input {
  flex: 1; min-width: 160px;
  background: #1a1a1a;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 9px 12px;
  color: #ffffff;
  font-size: 13px;
}
.link-form input:focus { outline: none; border-color: #f49976; }
.link-form-error { width: 100%; font-size: 12px; color: #ff6b6b; }
.link-form-error:empty { display: none; }

.link-list { display: flex; flex-direction: column; gap: 10px; }
.link-row {
  display: flex; align-items: center; gap: 14px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  padding: 12px 16px;
}
.link-row__name { font-weight: 700; font-size: 14px; min-width: 160px; }
.link-row__url {
  flex: 1; font-size: 12px; color: #8fb4d9; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-row__url:hover { text-decoration: underline; }
.link-row__delete {
  background: none; border: 1px solid #3a3a3a; color: #ff6b6b;
  border-radius: 6px; padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.link-row__delete:hover { background: rgba(255,107,107,.12); }
