:root {
  color-scheme: dark;
  --bg: #0c0c10;
  --surface: #14141c;
  --surface-2: #1c1c28;
  --border: #2a2a3a;
  --text: #ececf1;
  --muted: #9898a8;
  --gold: #d4af37;
  --gold-dim: #9a8230;
  --accent: #6b8cff;
  --ok: #3ecf8e;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(212, 175, 55, 0.12), transparent),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.header__mark {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #111;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.header__subtitle {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header__status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--muted);
}

.pulse {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(62, 207, 142, 0.5);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 8px rgba(62, 207, 142, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(62, 207, 142, 0);
  }
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.card {
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent), var(--surface);
  transition: border-color 0.15s, transform 0.15s;
}

.card:hover {
  border-color: rgba(212, 175, 55, 0.35);
  transform: translateY(-1px);
}

.card__label {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.card__value {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  word-break: break-word;
}

.card__value--link {
  color: var(--accent);
  text-decoration: none;
}

.card__value--link:hover {
  text-decoration: underline;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.panel__head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.panel__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.85rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
}

.btn--primary {
  border-color: var(--gold-dim);
  background: rgba(212, 175, 55, 0.12);
  color: var(--gold);
}

.btn--danger {
  border-color: #7a3030;
  color: #ff8a8a;
}

.btn--danger:hover {
  border-color: #a04040;
  color: #ffb0b0;
}

.monitoring-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.monitoring-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem 1rem;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.monitoring-item:last-child {
  border-bottom: none;
}

.monitoring-item--selected .monitoring-item__main {
  background: rgba(212, 175, 55, 0.08);
}

.monitoring-item--archived {
  opacity: 0.72;
}

.monitoring-item--paused .monitoring-item__title {
  color: var(--muted);
}

.monitoring-item__actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-right: 1rem;
}

.monitoring-item__main {
  display: block;
  width: 100%;
  padding: 1rem 1.1rem;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.monitoring-item__main:hover {
  background: rgba(212, 175, 55, 0.05);
}

.monitoring-item__title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.monitoring-item__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.monitoring-item__url {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: var(--accent);
  word-break: break-all;
}

.monitoring-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.monitoring-item__archive {
  margin-right: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge--archived {
  background: rgba(152, 152, 168, 0.15);
  color: var(--muted);
}

.badge--paused {
  background: rgba(107, 140, 255, 0.15);
  color: var(--accent);
}

.dialog {
  width: min(480px, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.dialog__head h2 {
  margin: 0;
  font-size: 1rem;
}

.dialog form {
  padding: 1rem 1.1rem 1.1rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.85rem;
}

.field span {
  color: var(--muted);
}

.field small {
  color: var(--muted);
  font-size: 0.78rem;
}

.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.field textarea {
  width: 100%;
  min-height: 5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.field--compact {
  max-width: 100%;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid rgba(212, 175, 55, 0.35);
  border-color: var(--gold-dim);
}

.form-error {
  margin: 0 0 0.85rem;
  color: #ff8a8a;
  font-size: 0.85rem;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.detection-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.detection-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem 1rem;
  align-items: start;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.detection-item:last-child {
  border-bottom: none;
}

.detection-item:hover {
  background: rgba(212, 175, 55, 0.05);
}

.detection-item__time {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: var(--gold);
  font-weight: 600;
}

.detection-item__monitor {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--accent);
}

.detection-item__preview {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.detection-item__action {
  align-self: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.empty__hint {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  width: min(640px, 100vw);
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.drawer__head h2 {
  margin: 0;
  font-size: 1rem;
}

.drawer__meta {
  margin: 0;
  padding: 0.75rem 1.1rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.drawer__preview {
  flex: 1;
  overflow: hidden auto;
  color: var(--text);
  display: grid;
  gap: 1rem;
  align-content: start;
}

.drawer__screenshot {
  display: block;
  width: 100%;
  height: auto;
}

.drawer__code {
  display: grid;
  gap: 0.5rem;
}

.drawer__code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.drawer__code pre {
  margin: 0;
  padding: 0.85rem;
  overflow: auto;
  max-height: 40vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.drawer__code code {
  font-family: "Cascadia Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.btn--small {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.55);
}

@media (max-width: 640px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header__actions {
    width: 100%;
    justify-content: space-between;
  }

  .monitoring-item {
    grid-template-columns: 1fr;
  }

  .monitoring-item__actions {
    margin: 0 1rem 1rem;
    justify-self: start;
  }

  .detection-item {
    grid-template-columns: 1fr;
  }
}
