:root {
  --bg: #f6f3fb;
  --panel: rgba(255, 255, 255, 0.92);
  --text: #2b2436;
  --muted: #746a82;
  --line: #ded4ea;
  --primary: #7c4dff;
  --primary-dark: #5f35d6;
  --accent: #c084fc;
  --soft: #eee7fb;
  --danger: #b4235a;
  --danger-bg: #fde8f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.88) 0 1.4px, transparent 2px) 18px 24px / 92px 92px,
    radial-gradient(circle, rgba(124, 77, 255, 0.34) 0 1.6px, transparent 2.4px) 62px 70px / 128px 128px,
    radial-gradient(circle at top left, rgba(192, 132, 252, 0.28), transparent 32rem),
    linear-gradient(135deg, #f7f2fb 0%, #ece7f3 52%, #f7f6fa 100%);
  color: var(--text);
  font-family: "Emilys Candy", cursive;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.72;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cpath d='M24 10 L28 22 L40 26 L28 30 L24 42 L20 30 L8 26 L20 22 Z' fill='%237c4dff' fill-opacity='.34'/%3E%3Cpath d='M88 54 L91 63 L100 66 L91 69 L88 78 L85 69 L76 66 L85 63 Z' fill='%23746a82' fill-opacity='.28'/%3E%3Cpath d='M48 84 L51 92 L59 95 L51 98 L48 106 L45 98 L37 95 L45 92 Z' fill='%23c084fc' fill-opacity='.36'/%3E%3C/svg%3E");
  background-size: 150px 150px;
  background-position: 0 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 30px auto;
}

.hidden {
  display: none !important;
}

.login-card {
  width: min(440px, 100%);
  margin: 76px auto;
  border: 1px solid rgba(124, 77, 255, 0.18);
  border-radius: 18px;
  background: var(--panel);
  padding: 30px;
  box-shadow: 0 24px 70px rgba(72, 51, 102, 0.16);
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
  border: 1px solid rgba(124, 77, 255, 0.16);
  border-radius: 22px;
  padding: 26px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(239, 232, 252, 0.92));
  box-shadow: 0 22px 50px rgba(72, 51, 102, 0.12);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 400;
}

h2 {
  margin-bottom: 14px;
  font-size: 20px;
}

p {
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats article,
.panel {
  border: 1px solid rgba(124, 77, 255, 0.14);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(72, 51, 102, 0.09);
}

.stats article {
  padding: 18px;
}

.stats span {
  display: block;
  color: var(--primary-dark);
  font-size: 30px;
  font-weight: 900;
}

.stats p {
  margin: 4px 0 0;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  border-radius: 16px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line);
}

.tab {
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
}

.tab:hover,
.tab.active {
  background: var(--primary);
  color: #fff;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.layout {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 20px;
}

label {
  display: block;
  margin-bottom: 14px;
  color: #43384f;
  font-size: 14px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 4px solid rgba(124, 77, 255, 0.14);
}

.actions,
.row-actions,
.query-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--primary-dark);
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

button.secondary:hover {
  background: var(--soft);
}

button.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

button.danger:hover {
  background: #f9d5e2;
}

.error {
  min-height: 20px;
  margin-bottom: 12px;
  color: var(--danger);
  font-weight: 800;
}

.table-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.table-head p {
  margin-bottom: 0;
}

.table-head input {
  max-width: 260px;
  margin-top: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #6b5b7d;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  color: #332a40;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--soft);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 12px;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #b794f4, #6b7280);
  vertical-align: -1px;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.query-buttons {
  margin-bottom: 18px;
}

#queryText {
  margin-bottom: 12px;
  resize: vertical;
  background: #fbfaff;
}

@media (max-width: 860px) {
  .header,
  .table-head {
    flex-direction: column;
  }

  .stats,
  .layout {
    grid-template-columns: 1fr;
  }

  .table-head input {
    max-width: none;
  }
}
