:root {
  color-scheme: dark;
  --bg: #07130f;
  --panel: rgba(15, 31, 25, 0.86);
  --panel-strong: #10231c;
  --line: rgba(160, 201, 181, 0.14);
  --text: #eef8f2;
  --muted: #91aa9e;
  --accent: #42e39a;
  --accent-strong: #1bc97e;
  --orange: #ff9f43;
  --red: #ff6b6b;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.26);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(27, 201, 126, 0.08), transparent 28rem),
    linear-gradient(180deg, #081711 0%, var(--bg) 42%, #050d0a 100%);
  color: var(--text);
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.08;
  pointer-events: none;
}
.ambient-one { top: 8rem; right: -8rem; background: var(--accent); }
.ambient-two { bottom: 4rem; left: -10rem; background: #32a8ff; }

.site-header {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  color: var(--text);
  text-decoration: none;
}
.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
}

.live-pill {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(15, 31, 25, 0.58);
  font-size: 0.78rem;
}
.live-pill span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(66, 227, 154, 0.1);
}

main { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding-top: 54px; }
.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 76px 0 54px;
}
.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.2em;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 760px;
  margin-bottom: 18px;
  font-size: clamp(2.65rem, 7vw, 5.5rem);
  line-height: 0.96;
  letter-spacing: -0.065em;
  font-weight: 650;
}
.hero-copy {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.7;
}

.button {
  border: 0;
  border-radius: 10px;
  padding: 12px 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, opacity 150ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible { outline: 3px solid rgba(66, 227, 154, 0.28); outline-offset: 2px; }
.button:disabled { cursor: wait; opacity: 0.55; }
.button-primary { background: var(--accent); color: #052116; }
.button-primary:hover:not(:disabled) { background: #63eeae; }
.button-secondary { border: 1px solid var(--line); background: rgba(255,255,255,0.035); color: var(--text); }
.button-secondary:hover:not(:disabled) { border-color: rgba(66, 227, 154, 0.35); background: rgba(66, 227, 154, 0.07); }
.button-danger { background: var(--red); color: #280909; }
.button-small { padding: 9px 13px; font-size: 0.78rem; }
.button-icon { font-size: 1.1rem; font-weight: 400; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.summary-card {
  position: relative;
  min-height: 150px;
  padding: 25px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(140deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015));
  overflow: hidden;
}
.summary-card::after {
  content: "";
  position: absolute;
  right: -35px;
  bottom: -65px;
  width: 150px;
  height: 150px;
  border: 20px solid rgba(255,255,255,0.018);
  border-radius: 50%;
}
.summary-label { color: var(--muted); font-size: 0.78rem; font-weight: 650; }
.summary-card strong { margin-top: 12px; font-size: 2.6rem; line-height: 1; font-weight: 600; }
.summary-note { margin-top: auto; color: #688076; font-size: 0.72rem; }
.summary-online strong { color: var(--accent); }
.summary-error strong { color: var(--orange); }

.panel {
  margin-bottom: 18px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 26px;
}
.panel-heading h2 { margin-bottom: 0; font-size: 1.35rem; letter-spacing: -0.025em; }
.panel-heading > p { max-width: 460px; margin-bottom: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.6; }
.panel-heading-actions { align-items: center; }

.add-form label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 0.76rem; font-weight: 700; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
input {
  width: 100%;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #081711;
  color: var(--text);
  font-size: 0.9rem;
}
input::placeholder { color: #536b60; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 0 14px 12px;
  color: #708a7e;
  text-align: left;
  font-size: 0.65rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
td { padding: 17px 14px; border-top: 1px solid var(--line); font-size: 0.82rem; vertical-align: middle; }
.actions-heading { text-align: right; }
.url-cell { min-width: 280px; }
.url-cell a { display: block; max-width: 520px; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.url-cell a:hover { color: var(--accent); }
.url-cell small, .time-cell small { display: block; margin-top: 5px; color: #60766b; }
.time-cell { min-width: 190px; color: var(--muted); }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 750;
  text-transform: capitalize;
}
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-online { color: var(--accent); background: rgba(66, 227, 154, 0.08); }
.status-error { color: var(--red); background: rgba(255, 107, 107, 0.09); }
.status-pending { color: var(--orange); background: rgba(255, 159, 67, 0.09); }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.row-button {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
  cursor: pointer;
}
.row-button:hover { color: var(--text); border-color: rgba(66, 227, 154, 0.35); }
.row-button.remove:hover { color: var(--red); border-color: rgba(255, 107, 107, 0.35); }

.loading-block, .empty-state { padding: 45px 20px; color: var(--muted); text-align: center; }
.loading-block { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 0.82rem; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(66,227,154,0.18); border-top-color: var(--accent); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state > div { width: 43px; height: 43px; margin: 0 auto 14px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); }
.empty-state h3 { margin-bottom: 7px; font-size: 1rem; }
.empty-state p { margin-bottom: 0; font-size: 0.8rem; }
.empty-state.compact { padding-block: 28px; }

.history-list { display: grid; gap: 12px; }
.history-item {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(4, 15, 10, 0.24);
  font-size: 0.78rem;
}
.history-item-header {
  display: grid;
  grid-template-columns: 110px minmax(180px, 1fr) 185px;
  gap: 20px;
  align-items: center;
}
.event-type { display: inline-flex; width: fit-content; padding: 5px 8px; border-radius: 6px; font-weight: 750; text-transform: capitalize; }
.event-change { color: var(--orange); background: rgba(255,159,67,0.09); }
.event-error { color: var(--red); background: rgba(255,107,107,0.09); }
.event-recovery { color: var(--accent); background: rgba(66,227,154,0.08); }
.history-url { color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.history-url:hover { color: var(--accent); }
.history-message { margin: 14px 0 0; color: var(--muted); line-height: 1.55; }
.history-time { color: #667e73; text-align: right; }
.event-details { margin-top: 14px; border-top: 1px solid var(--line); }
.event-details summary {
  width: fit-content;
  padding-top: 14px;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}
.event-details-body { padding-top: 18px; }
.change-summary { color: var(--text); line-height: 1.55; }
.change-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.change-block { min-width: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.change-block h3 { margin: 0; padding: 10px 12px; font-size: 0.72rem; }
.change-block pre {
  max-height: 310px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  background: #06110c;
  color: #b9cec4;
  font: 0.72rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.change-removed h3 { color: var(--red); background: rgba(255, 107, 107, 0.07); }
.change-added h3 { color: var(--accent); background: rgba(66, 227, 154, 0.07); }
.event-metadata {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr);
  gap: 9px 16px;
  margin: 18px 0 0;
  padding: 15px;
  border-radius: 10px;
  background: rgba(255,255,255,0.025);
}
.event-metadata dt { color: #6f887c; }
.event-metadata dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; }

footer {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 38px;
  display: flex;
  justify-content: space-between;
  color: #536b60;
  font-size: 0.72rem;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  width: min(390px, calc(100% - 44px));
  padding: 14px 15px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 11px;
  border: 1px solid rgba(66,227,154,0.28);
  border-radius: 12px;
  background: #12271f;
  box-shadow: 0 18px 50px rgba(0,0,0,0.38);
  font-size: 0.82rem;
}
.toast.error { border-color: rgba(255,107,107,0.38); }
#toast-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: rgba(66,227,154,0.12); color: var(--accent); }
.toast.error #toast-icon { background: rgba(255,107,107,0.12); color: var(--red); }
#toast-close { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.2rem; }

dialog {
  width: min(440px, calc(100% - 36px));
  padding: 0;
  border: 1px solid rgba(255,107,107,0.23);
  border-radius: 16px;
  background: #10231c;
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0,0,0,0.55);
}
dialog::backdrop { background: rgba(2, 8, 5, 0.78); backdrop-filter: blur(4px); }
dialog form { padding: 28px; }
.dialog-icon { width: 40px; height: 40px; margin-bottom: 18px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,107,107,0.1); color: var(--red); font-weight: 800; }
dialog h2 { margin-bottom: 10px; font-size: 1.25rem; }
dialog p { color: var(--muted); overflow-wrap: anywhere; line-height: 1.5; }
.dialog-note { font-size: 0.78rem; }
.dialog-actions { margin-top: 24px; display: flex; justify-content: flex-end; gap: 9px; }
.source-dialog { width: min(1120px, calc(100% - 36px)); }
.source-dialog-content { padding: 28px; }
.source-dialog-header { display: flex; justify-content: space-between; gap: 24px; }
.source-dialog-header h2 { margin-bottom: 7px; }
.source-dialog-header p { margin-bottom: 0; }
.dialog-close {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.35rem;
}
.source-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 22px 0 14px;
}
.source-meta > div { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,0.025); }
.source-meta span, .source-meta strong { display: block; }
.source-meta span { margin-bottom: 5px; color: #6f887c; font-size: 0.66rem; }
.source-meta strong { color: var(--text); font-size: 0.75rem; overflow-wrap: anywhere; }
.source-loading { min-height: 260px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.source-dialog pre {
  max-height: min(60vh, 650px);
  margin: 0;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #050d09;
  color: #b9cec4;
  font: 0.72rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

[hidden] { display: none !important; }

@media (max-width: 800px) {
  .hero { align-items: flex-start; flex-direction: column; padding-top: 48px; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card { min-height: 125px; }
  .panel-heading { flex-direction: column; }
  .panel-heading-actions { align-items: flex-start; }
  .history-item-header { grid-template-columns: 100px 1fr; }
  .history-time { text-align: left; }
  .change-grid { grid-template-columns: 1fr; }
  .source-meta { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .site-header, main, footer { width: min(100% - 28px, 1160px); }
  .site-header { padding-top: 20px; }
  .live-pill { font-size: 0; padding: 10px; }
  .header-actions { gap: 7px; }
  .hero { padding: 38px 0; }
  h1 { font-size: 3rem; }
  .panel { padding: 22px 17px; }
  .input-row { grid-template-columns: 1fr; }
  .input-row .button { width: 100%; }
  .row-actions { flex-direction: column; }
  .source-meta { grid-template-columns: 1fr; }
  .source-dialog-content { padding: 20px 16px; }
  .event-metadata { grid-template-columns: 1fr; }
  footer { gap: 18px; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
