:root {
  color-scheme: dark;
  --bg: #070b14;
  --panel: rgba(18, 25, 41, 0.88);
  --panel-strong: #111827;
  --line: rgba(148, 163, 184, 0.18);
  --text: #e5edf8;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #2563eb;
  --success: #22c55e;
  --danger: #f43f5e;
  --warning: #f59e0b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.24), transparent 30rem),
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.18), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px;
  background: rgba(5, 10, 20, 0.72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 34px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  font-weight: 900;
  box-shadow: 0 14px 38px rgba(37, 99, 235, 0.35);
}
.brand strong, .brand span { display: block; }
.brand span { color: var(--muted); font-size: 0.9rem; }
.nav-list { display: grid; gap: 10px; margin-bottom: 28px; }
.nav-list a, .ghost-button {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.62);
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}
.nav-list a:hover, .ghost-button:hover { border-color: rgba(56, 189, 248, 0.65); transform: translateY(-1px); }
.ghost-button { width: 100%; }

.main-content { padding: 34px; overflow: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 26px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 4.2rem); letter-spacing: -0.06em; }
h2 { font-size: 1.2rem; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.74rem; font-weight: 800; margin-bottom: 8px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid rgba(34, 197, 94, 0.35); border-radius: 999px; padding: 10px 14px; color: #bbf7d0; background: rgba(34, 197, 94, 0.08); }
.status-pill span { width: 8px; height: 8px; border-radius: 99px; background: var(--success); box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.12); }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.metric-card, .panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  border-radius: 24px;
}
.metric-card { padding: 20px; min-height: 132px; display: grid; align-content: space-between; }
.metric-card span { color: var(--muted); }
.metric-card strong { font-size: clamp(1.8rem, 4vw, 3rem); letter-spacing: -0.05em; }
.metric-card.danger strong { color: var(--danger); }
.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.panel { padding: 22px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 20px; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; }
input, select {
  color: var(--text);
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 44px;
  padding: 0 14px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.gallery-actions {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.gallery-count {
  color: var(--muted);
  font-size: 0.9rem;
}
.load-more-button {
  border: 0;
  border-radius: 14px;
  min-height: 42px;
  padding: 0 18px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  font-weight: 800;
}
.load-more-button[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
}
.image-card { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: rgba(15, 23, 42, 0.7); }
.image-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #0f172a; }
.image-card-body { padding: 14px; display: grid; gap: 10px; }
.image-title { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 0.88rem; }
.url-row { display: flex; gap: 8px; }
.url-row input { width: 100%; min-width: 0; }
.url-row button, .domain-form button {
  border: 0;
  border-radius: 14px;
  padding: 0 14px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  font-weight: 800;
}

.bar-chart { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr auto; align-items: center; gap: 12px; color: var(--muted); }
.bar-track { height: 12px; border-radius: 999px; overflow: hidden; background: rgba(148, 163, 184, 0.16); }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--success)); min-width: 4px; }

.domain-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 16px; }
.danger-form button { background: linear-gradient(135deg, var(--danger), #be123c); }
.tag-list { display: flex; flex-wrap: wrap; gap: 10px; min-height: 38px; }
.tag { border: 1px solid rgba(56, 189, 248, 0.34); background: rgba(56, 189, 248, 0.08); color: #bae6fd; padding: 8px 10px; border-radius: 999px; }
.danger-tags .tag { border-color: rgba(244, 63, 94, 0.34); background: rgba(244, 63, 94, 0.08); color: #fecdd3; }

.table-wrap { overflow-x: auto; }
#logsTableWrap { max-height: 480px; overflow-y: auto; scroll-behavior: smooth; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 13px 10px; text-align: left; border-bottom: 1px solid var(--line); color: var(--muted); }
th { color: var(--text); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; }
.status { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-weight: 800; font-size: 0.78rem; }
.status.allowed { color: #bbf7d0; background: rgba(34, 197, 94, 0.12); }
.status.blocked { color: #fecdd3; background: rgba(244, 63, 94, 0.12); }
.toast { position: fixed; right: 22px; bottom: 22px; transform: translateY(140%); transition: transform 180ms ease; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-strong); color: var(--text); padding: 14px 16px; box-shadow: var(--shadow); }
.toast.show { transform: translateY(0); }
.empty-state { color: var(--muted); padding: 22px; border: 1px dashed var(--line); border-radius: 18px; text-align: center; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav-list { grid-template-columns: repeat(4, 1fr); }
  .metrics-grid, .content-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .main-content, .sidebar { padding: 18px; }
  .topbar, .panel-header.stacked-mobile { align-items: stretch; flex-direction: column; }
  .metrics-grid, .content-grid, .nav-list { grid-template-columns: 1fr; }
  .toolbar, .toolbar input, .toolbar select { width: 100%; }
  .domain-form { grid-template-columns: 1fr; }
  .domain-form button { min-height: 44px; }
  .bar-row { grid-template-columns: 1fr; }
}
