:root {
  --bg: #04110b;
  --bg-2: #071b11;
  --panel: rgba(13, 31, 21, .78);
  --panel-2: rgba(16, 43, 28, .74);
  --panel-3: rgba(6, 17, 12, .82);
  --text: #f4fff8;
  --muted: #9bb9a8;
  --muted-2: #6f8a7b;
  --line: rgba(222, 255, 235, .105);
  --line-strong: rgba(222, 255, 235, .18);
  --green: #24f27b;
  --green-2: #0dbc5b;
  --green-3: #0a7f43;
  --red: #ff5165;
  --yellow: #f5c849;
  --blue: #50a7ff;
  --shadow: 0 24px 70px rgba(0,0,0,.35);
  --soft-shadow: 0 16px 44px rgba(4, 12, 8, .28);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% -6%, rgba(36,242,123,.22), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(13,188,91,.11), transparent 28%),
    linear-gradient(135deg, var(--bg), var(--bg-2) 48%, #031009);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .28;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at top, #000 0%, transparent 72%);
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button:disabled { opacity: .55; cursor: not-allowed; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 3;
  width: 282px;
  padding: 22px 20px;
  background: linear-gradient(180deg, rgba(3,16,10,.94), rgba(4,18,12,.86));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: 18px 0 60px rgba(0,0,0,.22);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand.center { justify-content: center; }
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(145deg, #35ff91, #12bf60);
  color: #031108;
  display: grid;
  place-items: center;
  font-weight: 950;
  box-shadow: 0 14px 34px rgba(36,242,123,.24), inset 0 1px 0 rgba(255,255,255,.28);
}
.brand strong { display: block; letter-spacing: -.035em; font-weight: 900; }
.brand span, .eyebrow, .small { color: var(--muted); font-size: .88rem; }
.eyebrow { margin: 0 0 12px; color: #9ee7bd; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a, .logout-form button {
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: .18s ease;
}
.sidebar nav a:hover, .sidebar nav a.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(255,255,255,.085), rgba(36,242,123,.055));
  border-color: var(--line-strong);
  transform: translateX(2px);
}
.logout-form { margin-top: auto; }
.logout-form button { width: 100%; }
.logout-form button:hover { color: var(--text); background: rgba(255,255,255,.05); border-color: var(--line); }

.main { position: relative; z-index: 1; margin-left: 282px; padding: 34px; min-height: 100vh; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 26px; }
h1 { margin: 0; font-size: clamp(2rem, 3.2vw, 3.05rem); letter-spacing: -.06em; line-height: .98; text-shadow: 0 10px 26px rgba(0,0,0,.22); }
h2 { margin: 0 0 16px; letter-spacing: -.035em; }
h3 { margin: 24px 0 12px; letter-spacing: -.025em; }
.grid { display: grid; gap: 18px; }
.grid.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.027));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--soft-shadow);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(36,242,123,.055), transparent 35%, rgba(255,255,255,.025));
}
.card > * { position: relative; z-index: 1; }
.metrics .card { min-height: 116px; }
.metrics .card span { color: var(--muted); display: block; margin-bottom: 12px; }
.metrics .card strong { font-size: 2rem; letter-spacing: -.055em; }
.mt { margin-top: 18px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,.075);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: .82rem;
  font-weight: 850;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.pill.connected, .pill.sent, .pill.paid, .pill.received { background: rgba(36,242,123,.14); color: var(--green); border-color: rgba(36,242,123,.18); }
.pill.qr, .pill.pending, .pill.scheduled, .pill.connecting { background: rgba(245,200,73,.13); color: var(--yellow); border-color: rgba(245,200,73,.18); }
.pill.failed, .pill.error, .pill.canceled, .pill.expired { background: rgba(255,81,101,.13); color: var(--red); border-color: rgba(255,81,101,.2); }
.pill.disconnected, .pill.skipped { background: rgba(255,255,255,.07); color: var(--muted); }

.status-list { display: grid; gap: 12px; }
.status-list div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.status-list span { color: var(--muted); }
.status-list strong { text-align: right; }

.table-card { overflow: hidden; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 17px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: #a4d0b4; font-size: .76rem; text-transform: uppercase; letter-spacing: .095em; background: rgba(255,255,255,.025); }
td { color: rgba(244,255,248,.9); font-size: .94rem; }
tr:hover td { background: rgba(255,255,255,.025); }
.message-cell { max-width: 440px; white-space: pre-wrap; }
.error-cell { max-width: 300px; color: #ffb3bd; }

.qr-box {
  min-height: 330px;
  border: 1px dashed rgba(222,255,235,.23);
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at center, rgba(36,242,123,.06), rgba(0,0,0,.2));
  text-align: center;
  color: var(--muted);
  padding: 22px;
}
.qr-box img { max-width: 292px; width: 100%; border-radius: 16px; background: #fff; padding: 12px; box-shadow: 0 18px 42px rgba(0,0,0,.36); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 900;
  cursor: pointer;
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid var(--line);
  transition: transform .16s ease, filter .16s ease, border-color .16s ease;
}
.button:hover { transform: translateY(-1px); border-color: var(--line-strong); filter: brightness(1.05); }
.button.primary { color: #031108; background: linear-gradient(145deg, var(--green), var(--green-2)); border-color: rgba(36,242,123,.26); }
.button.danger { background: rgba(255,81,101,.14); color: #ff7484; border-color: rgba(255,81,101,.18); }

.form-stack { display: grid; gap: 15px; }
label { display: grid; gap: 8px; color: var(--muted); }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.28);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 15px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input:focus, textarea:focus, select:focus { border-color: rgba(36,242,123,.42); box-shadow: 0 0 0 4px rgba(36,242,123,.08); background: rgba(0,0,0,.34); }
textarea { resize: vertical; }
.alert { padding: 13px 15px; border-radius: 14px; margin: 12px 0; }
.alert.danger { color: #ff8794; background: rgba(255,81,101,.12); border: 1px solid rgba(255,81,101,.2); }
.alert.info { color: #c7f6d8; background: rgba(36,242,123,.09); border: 1px solid rgba(36,242,123,.16); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(450px, 100%); background: rgba(13,31,21,.9); border: 1px solid var(--line); border-radius: 26px; padding: 30px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.login-card h1 { text-align: center; margin: 22px 0; }
.filter-form select { min-width: 160px; }
.text-link { color: var(--green); font-weight: 850; }
.page-header.compact { margin-top: 18px; margin-bottom: 16px; }

.funnel-grid { align-items: start; }
.variable-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center; }
.variable-chip { border: 1px solid rgba(36,242,123,.25); background: rgba(36,242,123,.1); color: var(--green); padding: 8px 10px; border-radius: 999px; cursor: pointer; font-weight: 900; }
.variable-chip:hover { background: rgba(36,242,123,.16); }
.funnel-steps { display: grid; gap: 20px; }
.funnel-step textarea { min-height: 220px; line-height: 1.48; }
.step-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.step-header h2 { margin-top: 10px; }
.inline-check { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--text); background: rgba(255,255,255,.055); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; }
.inline-check input { width: auto; }
.preview-box, .warning-box { min-height: 185px; border: 1px solid var(--line); border-radius: 18px; padding: 15px; background: rgba(0,0,0,.24); white-space: pre-wrap; color: rgba(244,255,248,.92); }
.warning-box p { margin: 0 0 10px; color: #ffe09a; }
.sticky-actions { position: sticky; bottom: 0; margin-top: 20px; padding: 15px; border: 1px solid var(--line); border-radius: 20px; background: rgba(7,18,13,.9); backdrop-filter: blur(16px); display: flex; align-items: center; justify-content: flex-end; gap: 14px; box-shadow: var(--shadow); }
.sticky-actions .small { margin-right: auto; }

@media (max-width: 980px) {
  .sidebar { position: static; width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { margin-left: 0; padding: 20px; }
  .grid.metrics, .grid.two { grid-template-columns: 1fr; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .table-card { overflow-x: auto; }
  table { min-width: 900px; }
  .variable-list { grid-template-columns: 1fr; }
  .step-header { flex-direction: column; }
  .sticky-actions { flex-direction: column; align-items: stretch; }
}
