:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #5d6a83;
  --accent: #006d77;
  --accent-2: #ff7f11;
  --danger: #c1121f;
  --ok: #2a9d8f;
  --border: #d9e0ea;
  --mono: "JetBrains Mono", monospace;
  --sans: "Space Grotesk", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: linear-gradient(130deg, #f2f6fb 0%, #ecf3e8 100%);
  min-height: 100vh;
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 10% 20%, rgba(0, 109, 119, 0.16), transparent 32%),
    radial-gradient(circle at 90% 15%, rgba(255, 127, 17, 0.2), transparent 35%),
    radial-gradient(circle at 30% 90%, rgba(33, 158, 188, 0.15), transparent 35%);
  filter: blur(30px);
  z-index: -1;
}

.topbar {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 20px 18px;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: flex-start;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.3rem, 2.2vw, 2.1rem);
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 10px 20px 40px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 6px 22px rgba(24, 40, 73, 0.08);
}

.card h2 {
  margin: 0 0 14px;
  font-size: 1.06rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.card-head h2 {
  margin: 0;
}

.help-anchor {
  position: relative;
}

.help-btn {
  border: 1px solid #b8c8de;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f7fbff;
  color: #17446d;
  font-weight: 700;
  line-height: 1;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
}

.help-btn:hover {
  background: #e6f2ff;
}

.help-anchor:hover .help-popover,
.help-anchor.open .help-popover {
  display: block;
}

.help-popover {
  display: none;
  position: absolute;
  right: 0;
  top: 32px;
  width: min(360px, 80vw);
  border: 1px solid #c7d6ea;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(18, 40, 66, 0.2);
  padding: 10px;
  z-index: 30;
}

.help-popover h4 {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.help-popover p {
  margin: 0 0 8px;
  color: #3d516f;
  font-size: 0.82rem;
  line-height: 1.35;
}

.help-popover ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.78rem;
  color: #203754;
  display: grid;
  gap: 5px;
}

.auth-card {
  max-width: 560px;
  margin: 0 auto 18px;
}

.role-note {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #d7e3f2;
  border-radius: 8px;
  background: #f7fbff;
  font-size: 0.82rem;
}

.role-note ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.micro-list {
  margin: 8px 0 10px;
  padding-left: 18px;
  font-size: 0.8rem;
  color: #374e6e;
  display: grid;
  gap: 4px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

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

input,
textarea,
select {
  border: 1px solid #bfc9d8;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 70px;
  resize: vertical;
}

.btn {
  border: 0;
  border-radius: 9px;
  padding: 10px 12px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.btn.ghost {
  background: #edf3f4;
  color: #163747;
}

.btn:hover {
  filter: brightness(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.inline-actions,
.inline-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.inline-group {
  font-size: 0.93rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: #edf3ff;
  color: #1f3f67;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-line {
  margin: 10px 0 0;
  font-size: 0.88rem;
  color: #22344d;
}

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

code,
pre {
  font-family: var(--mono);
}

.is-hidden {
  display: none !important;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #d9e3ef;
  border-top-color: #1b4965;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  opacity: 0;
}

.spinner.active {
  opacity: 1;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

.table th,
.table td {
  border-bottom: 1px solid #e8edf3;
  text-align: left;
  padding: 7px 6px;
}

.log {
  margin: 8px 0 0;
  padding-left: 16px;
  max-height: 160px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.odds-board {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.odds-value {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 700;
  padding: 6px 10px;
  background: #f5f8ff;
  border-radius: 10px;
}

.odds-up {
  animation: pulseUp 0.5s;
}

.odds-down {
  animation: pulseDown 0.5s;
}

@keyframes pulseUp {
  0% { background: #dff5ea; }
  100% { background: #f5f8ff; }
}

@keyframes pulseDown {
  0% { background: #fde6e8; }
  100% { background: #f5f8ff; }
}

.critical-error {
  margin-top: 10px;
  padding: 10px;
  border-left: 4px solid var(--danger);
  background: #ffebee;
  color: #8c0f1a;
  font-weight: 600;
}

.custom-select {
  position: relative;
  margin-bottom: 8px;
}

.custom-select-trigger {
  width: 100%;
}

.custom-options {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  position: absolute;
  width: 100%;
  background: #fff;
  border: 1px solid #cbd4e2;
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(13, 26, 41, 0.13);
  display: none;
  z-index: 5;
}

.custom-options.open {
  display: block;
}

.custom-options li {
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
}

.custom-options li:hover {
  background: #eef6ff;
}

.iframe-slot {
  margin-top: 12px;
  min-height: 170px;
  border: 1px dashed #afbdd1;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64738f;
}

.iframe-slot iframe {
  width: 100%;
  height: 170px;
  border: 0;
  border-radius: 8px;
}

.wizard-step {
  margin-bottom: 8px;
}

.invalid {
  border-color: #b80f1f !important;
  box-shadow: 0 0 0 2px rgba(184, 15, 31, 0.16);
}

.valid {
  border-color: #1e8a70 !important;
  box-shadow: 0 0 0 2px rgba(30, 138, 112, 0.14);
}

.fancy-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.fancy-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.fancy-check span {
  position: relative;
  padding-left: 28px;
}

.fancy-check span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1px;
  width: 18px;
  height: 18px;
  border: 1px solid #60708d;
  border-radius: 4px;
  background: #fff;
}

.fancy-check input:checked + span::before {
  background: linear-gradient(135deg, #2a9d8f, #80ed99);
  border-color: #2a9d8f;
}

.hover-menu {
  position: relative;
  display: inline-block;
  margin-bottom: 10px;
}

.hover-dropdown {
  list-style: none;
  margin: 0;
  padding: 8px;
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  min-width: 140px;
  border-radius: 8px;
  border: 1px solid #d2dbe8;
  background: #fff;
  display: none;
}

.hover-menu:hover .hover-dropdown {
  display: block;
}

.hover-dropdown li {
  padding: 6px;
}

.json-box {
  margin: 6px 0 0;
  border: 1px solid #dce4ef;
  border-radius: 8px;
  padding: 8px;
  background: #f8fbff;
  max-height: 180px;
  overflow: auto;
  font-size: 0.77rem;
}

.drag-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.drag-list,
.drop-zone {
  border: 1px dashed #95a7bf;
  border-radius: 8px;
  min-height: 80px;
  padding: 8px;
}

.drag-item {
  padding: 7px;
  border-radius: 7px;
  background: #eff5ff;
  border: 1px solid #c7d5eb;
  margin-bottom: 6px;
  cursor: grab;
}

.drag-item.dragging {
  opacity: 0.55;
}

.drag-col-title {
  font-size: 0.78rem;
  color: #4c5f7c;
  margin-bottom: 6px;
  font-weight: 700;
}

.drop-zone.over {
  border-color: #2a9d8f;
  background: #e7faf5;
}

.slider-shell {
  margin: 10px 0;
}

#path-slider {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: #dbe5f4;
  overflow: hidden;
}

#slider-knob {
  position: absolute;
  left: 0;
  top: -6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #006d77;
  box-shadow: 0 5px 9px rgba(0, 40, 47, 0.32);
  cursor: grab;
}

.locale-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.heavy-list {
  margin-top: 10px;
  border: 1px solid #d6dfeb;
  border-radius: 8px;
  max-height: 170px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.76rem;
  background: #fbfcfe;
}

.heavy-row {
  padding: 5px 7px;
  border-bottom: 1px solid #edf2f8;
}

.controls-form {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.mini-check {
  margin-bottom: 8px;
}

.toast-stack {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: grid;
  gap: 6px;
  z-index: 10;
}

.toast {
  background: #19324c;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 23, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal-card {
  width: min(460px, 90vw);
  background: #fff;
  border-radius: 12px;
  padding: 16px;
}

.modal-card h3 {
  margin-top: 0;
}

.app-shell {
  animation: reveal 0.32s ease;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 840px) {
  .topbar {
    flex-direction: column;
  }

  .drag-grid,
  .locale-grid {
    grid-template-columns: 1fr;
  }
}
