:root {
  --bg: #f4f6f8;
  --card: rgba(255, 255, 255, 0.86);
  --line: #cfd7df;
  --text: #0f1720;
  --muted: #475569;
  --accent: #006d77;
  --accent-soft: #83c5be;
  --ok: #0f766e;
  --error: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at 10% 10%, #fef3c7, transparent 30%),
              radial-gradient(circle at 90% 0%, #bae6fd, transparent 35%),
              linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
}

.bg-glow {
  position: fixed;
  pointer-events: none;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.35;
  z-index: 0;
}

.bg-glow-a {
  top: -80px;
  left: -70px;
  background: #0ea5e9;
}

.bg-glow-b {
  bottom: -90px;
  right: -50px;
  background: #22c55e;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1220px;
  margin: 1.8rem auto;
  padding: 0 1rem 2rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 14px;
  padding: 1rem;
  backdrop-filter: blur(6px);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

.hero {
  border-left: 6px solid var(--accent);
}

.hero-logo {
  width: 170px;
  max-width: 40vw;
  height: auto;
  margin: 0 0 0.55rem;
  display: block;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
}

.config-dialog {
  width: min(1200px, 96vw);
  max-height: 90vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  overflow: auto;
  background: #f8fbfd;
}

.config-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

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

.setup-group {
  margin-bottom: 1rem;
  padding: 0.6rem 0.2rem 0.2rem;
  border-top: 1px solid #d6e0e8;
}

.setup-hidden {
  display: none;
}

.config-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0.2rem 0 0.9rem;
}

.config-tab {
  background: #dbe7ee;
  color: #0f1720;
  border: 1px solid #c6d3dc;
  padding: 0.45rem 0.8rem;
}

.config-tab.is-active {
  background: linear-gradient(135deg, var(--accent) 0%, #0e9f6e 100%);
  color: #fff;
  border-color: transparent;
}

.setup-group-header h3 {
  margin: 0 0 0.2rem;
}

.setup-group-header .sub {
  margin: 0 0 0.8rem;
}

.endpoint-examples {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.welcome-image-preview img {
  margin-top: 0.4rem;
  max-width: 260px;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.snippet-dialog {
  width: min(900px, 94vw);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem;
  background: #ffffff;
}

.snippet-dialog::backdrop {
  background: rgba(15, 23, 42, 0.38);
}

h1,
h2,
h3 {
  margin: 0 0 0.45rem;
}

.sub {
  color: var(--muted);
  margin: 0 0 1rem;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.2rem 0 0.65rem;
}

.notice-card {
  border-left: 4px solid var(--accent-soft);
  background: rgba(131, 197, 190, 0.12);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

form {
  display: grid;
  gap: 0.75rem;
}

.inline-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  align-items: end;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.92rem;
}

input[type="email"],
input[type="text"],
input[type="password"],
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.58rem 0.68rem;
  font: inherit;
  width: 100%;
  background: #fff;
}

textarea {
  font: 0.84rem/1.35 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: #f8fafc;
}

.checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.45rem;
}

.export-checkbox {
  display: inline-grid;
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

button {
  width: fit-content;
  border: 0;
  border-radius: 10px;
  padding: 0.58rem 0.95rem;
  background: linear-gradient(135deg, var(--accent) 0%, #0e9f6e 100%);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.97);
}

.delete-inline-btn {
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  background: #9b1c1c;
}

.contact-lead-btn {
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  background: #0f766e;
}

.lead-flash {
  animation: leadFlash 1.1s ease-in-out infinite;
}

@keyframes leadFlash {
  0% { background: rgba(249, 115, 22, 0.18); }
  50% { background: rgba(239, 68, 68, 0.26); }
  100% { background: rgba(249, 115, 22, 0.18); }
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  border-bottom: 1px solid #dbe2e9;
  padding: 0.52rem;
  text-align: left;
}

th {
  color: #1e293b;
  font-weight: 700;
}

pre {
  margin: 0;
  padding: 0.72rem;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  overflow: auto;
}

.stat-grid {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 0.85rem 0;
}

.stat-card {
  border: 1px solid #dbe2e9;
  border-radius: 10px;
  background: #fff;
  padding: 0.62rem;
}

.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.04rem;
  font-weight: 700;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.bar-chart {
  border: 1px solid #dbe2e9;
  border-radius: 10px;
  background: #fff;
  padding: 0.5rem;
  min-height: 120px;
  display: grid;
  gap: 0.42rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 180px) 1fr auto;
  gap: 0.45rem;
  align-items: center;
}

.bar-label {
  font-size: 0.8rem;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  width: 100%;
  height: 11px;
  border-radius: 999px;
  background: #e6edf3;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-soft) 100%);
}

.bar-value {
  min-width: 2ch;
  text-align: right;
  font-size: 0.8rem;
  color: #0f172a;
}

.download-row {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
}

#form-message.ok,
#endpoint-message.ok,
#datapoint-message.ok,
#product-create-message.ok,
#product-edit-message.ok,
#admin-user-message.ok,
#origin-whitelist-message.ok {
  color: var(--ok);
}

#form-message.error,
#endpoint-message.error,
#datapoint-message.error,
#product-create-message.error,
#product-edit-message.error,
#admin-user-message.error,
#origin-whitelist-message.error {
  color: var(--error);
}

@media (max-width: 980px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px) {
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .bar-row {
    grid-template-columns: minmax(90px, 130px) 1fr auto;
  }
}
