@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&display=swap");

:root {
  --bg: #04120f;
  --bg-soft: #082820;
  --panel: rgba(8, 31, 25, 0.84);
  --panel-strong: #0d3a2f;
  --text: #f6f6ea;
  --muted: #c3d8cf;
  --border: rgba(243, 189, 74, 0.3);
  --accent: #f3bd4a;
  --accent-2: #44d39d;
  --warn: #f3bd4a;
  --error: #ff8a75;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(1100px 520px at -10% -20%, #0b5846 0%, transparent 55%),
    radial-gradient(900px 500px at 120% -10%, #57410c 0%, transparent 50%),
    linear-gradient(180deg, #0a2a22 0%, var(--bg) 52%, #020907 100%);
  color: var(--text);
  font-family: Manrope, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.bg-light {
  position: fixed;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

.bg-light-a {
  width: 300px;
  height: 300px;
  background: #f3bd4a;
  top: 80px;
  left: -90px;
  animation: floatA 8s ease-in-out infinite;
}

.bg-light-b {
  width: 360px;
  height: 360px;
  background: #2acb8f;
  right: -120px;
  top: 300px;
  animation: floatB 9s ease-in-out infinite;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  z-index: 0;
  background-image:
    linear-gradient(rgba(243, 189, 74, 0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(243, 189, 74, 0.15) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black 35%, transparent 100%);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1080px, 94vw);
  margin: 24px auto 40px;
}

.card {
  background: linear-gradient(170deg, rgba(16, 58, 46, 0.93) 0%, var(--panel) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  min-width: 0;
}

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

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 74px;
  height: 74px;
  border-radius: 12px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(243, 189, 74, 0.6);
  box-shadow: 0 8px 24px rgba(243, 189, 74, 0.3);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #f8ce74;
  font-weight: 700;
  font-size: 12px;
}

h1,
h2 {
  font-family: Manrope, "Segoe UI", sans-serif;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(28px, 4vw, 40px);
}

h2 {
  font-size: 20px;
}

.hint {
  margin: 0;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px solid rgba(243, 189, 74, 0.6);
  color: #f8d992;
  font-weight: 700;
  font-size: 12px;
  background: rgba(243, 189, 74, 0.12);
}

.topbar-link {
  width: auto;
  margin-top: 0;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}

.badge-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #46e282;
  box-shadow: 0 0 0 0 rgba(70, 226, 130, 0.55);
  animation: onlinePulse 1.5s ease-out infinite;
}

.kpi-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kpi-card {
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  right: -50px;
  top: -60px;
  background: radial-gradient(circle, rgba(243, 189, 74, 0.22) 0%, transparent 70%);
}

.kpi-label {
  margin: 0;
  color: #d9e8df;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  margin: 8px 0 0;
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 800;
  color: #ffe7b2;
}

.grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 700;
  color: #e8f3ee;
}

input,
select,
textarea,
button,
.link-btn {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 16px;
}

input,
select,
textarea {
  color: var(--text);
  background: rgba(2, 16, 13, 0.8);
  padding: 11px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(243, 189, 74, 0.9);
  box-shadow: 0 0 0 3px rgba(243, 189, 74, 0.22);
}

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

.field-help {
  display: block;
  margin-top: 6px;
  color: #9ebcb1;
  font-size: 12px;
}

button,
.link-btn {
  margin-top: 14px;
  cursor: pointer;
  font-weight: 800;
  background: linear-gradient(125deg, var(--accent) 0%, #db9f29 100%);
  color: #241507;
  padding: 12px 14px;
  transition: transform 0.18s ease, box-shadow 0.2s ease, filter 0.2s ease;
  border: 1px solid rgba(243, 189, 74, 0.86);
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

button:hover,
.link-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(243, 189, 74, 0.34);
}

button:disabled,
.link-btn.disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

.ghost {
  background: rgba(4, 22, 18, 0.5);
  color: #e9f5f0;
  border: 1px solid rgba(182, 211, 198, 0.34);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(243, 189, 74, 0.13);
  border: 1px solid rgba(243, 189, 74, 0.45);
  color: #f8d188;
  min-height: 42px;
  display: flex;
  align-items: center;
}

.status:empty {
  display: none;
}

#status:empty {
  display: none;
}

#adminLoginStatus:empty,
#adminPanelStatus:empty {
  display: none;
}

.status.success {
  background: rgba(68, 211, 157, 0.15);
  border-color: rgba(68, 211, 157, 0.45);
  color: #95f0ca;
}

.status.error {
  background: rgba(255, 125, 108, 0.14);
  border-color: rgba(255, 125, 108, 0.46);
  color: #ffc5bd;
}

.link-output {
  margin: 0 0 12px;
  min-height: 38px;
}

.link-output a {
  color: #f7dd9f;
  font-weight: 700;
  word-break: break-all;
}

.hint-panel {
  margin: 0 0 14px;
  color: #d2e3db;
}

.info-grid {
  margin-bottom: 14px;
}

.flow-list {
  margin: 0;
  padding-left: 20px;
  color: #deeee7;
}

.flow-list li + li {
  margin-top: 6px;
}

.campaigns-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  min-width: 0;
}

.campaign-item {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 1.3fr) minmax(180px, 220px);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border-radius: 12px;
  background: rgba(2, 16, 13, 0.72);
  border: 1px solid rgba(243, 189, 74, 0.22);
  overflow: hidden;
  min-width: 0;
}

.campaign-meta {
  margin: 0;
  color: #dbece4;
  font-size: 14px;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.campaign-meta strong {
  color: #ffe7b2;
}

.campaign-empty {
  margin: 0;
  color: #c3d8cf;
  font-size: 14px;
}

.campaign-item .ghost {
  margin-top: 0;
  width: auto;
  min-width: 120px;
  padding: 10px 12px;
}

.campaign-row-actions {
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
}

.campaign-delete-btn {
  border-color: rgba(255, 156, 140, 0.55) !important;
  color: #ffd0c8 !important;
  background: rgba(110, 25, 25, 0.42) !important;
}

.selected-slug {
  border-color: rgba(68, 211, 157, 0.7) !important;
  box-shadow: 0 0 0 2px rgba(68, 211, 157, 0.22);
}

.campaign-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 7px;
  min-width: 0;
}

.num-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid rgba(243, 189, 74, 0.35);
  background: linear-gradient(180deg, rgba(8, 33, 27, 0.86) 0%, rgba(5, 24, 19, 0.86) 100%);
  color: #f3f6ef;
  font-size: 12px;
  line-height: 1.2;
  min-width: 0;
}

.num-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: #46e282;
  box-shadow: 0 0 0 0 rgba(70, 226, 130, 0.6);
  animation: onlinePulse 1.5s ease-out infinite;
  margin-left: 0;
}

.num-chip.paused {
  opacity: 0.78;
  border-color: rgba(170, 170, 170, 0.4);
  background: rgba(25, 25, 25, 0.55);
}

.num-chip.paused::before {
  background: #ff6d5f;
  box-shadow: 0 0 0 0 rgba(255, 109, 95, 0.56);
  animation: pausedPulse 1.5s ease-out infinite;
}

.num-actions {
  display: inline-flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}

.num-value {
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #ecf4f0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.num-remove {
  border: 1px solid rgba(255, 156, 140, 0.5);
  color: #ffd0c8;
  background: rgba(110, 25, 25, 0.4);
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  width: auto;
  margin-top: 0;
}

.num-remove:hover {
  filter: brightness(1.08);
}

.num-toggle {
  border: 1px solid rgba(130, 213, 177, 0.5);
  color: #d6f5e8;
  background: rgba(16, 80, 58, 0.45);
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  width: auto;
  margin-top: 0;
}

.num-toggle:hover {
  filter: brightness(1.08);
}

pre {
  margin: 0;
  background: rgba(2, 13, 11, 0.9);
  border: 1px solid rgba(243, 189, 74, 0.26);
  border-radius: 12px;
  padding: 14px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.45;
}

.footer-note {
  margin-top: 10px;
  text-align: center;
  color: #a1bcb2;
  font-size: 12px;
}

.auth-shell {
  width: min(620px, 94vw);
}

.admin-shell {
  width: min(980px, 94vw);
}

.admin-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-width: 0;
}

.admin-users-card {
  min-width: 0;
}

.auth-card {
  display: grid;
  gap: 10px;
}

.auth-brand {
  align-items: flex-start;
}

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

.auth-tab {
  margin-top: 0;
  background: rgba(4, 22, 18, 0.42);
  color: #d7e7e0;
  border: 1px solid rgba(182, 211, 198, 0.34);
}

.auth-tab.active {
  background: linear-gradient(125deg, var(--accent) 0%, #db9f29 100%);
  color: #241507;
  border-color: rgba(243, 189, 74, 0.86);
}

.auth-form {
  display: grid;
  gap: 6px;
}

.auth-admin-entry {
  display: flex;
  justify-content: flex-end;
}

.auth-admin-top {
  margin-bottom: 2px;
}

.auth-admin-entry .topbar-link {
  margin-top: 0;
}

.auth-form label {
  margin: 8px 0 2px;
}

.auth-form input {
  font-size: 16px;
  padding: 10px 12px;
}

.auth-form button {
  margin-top: 8px;
}

.auth-form .field-help {
  margin-top: 2px;
}

.hidden {
  display: none !important;
}

.auth-note {
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(243, 189, 74, 0.35);
  background: rgba(243, 189, 74, 0.08);
  color: #f4ebd3;
  font-size: 14px;
}

.auth-note p {
  margin: 0;
}

.auth-note p + p {
  margin-top: 7px;
}

.auth-note-title {
  font-weight: 800;
}

.auth-note a {
  color: #ffe7b2;
  font-weight: 800;
}

.invite-result {
  padding: 16px;
}

.invite-result .actions .link-btn {
  margin-top: 0;
}

.invite-code-box {
  width: 100%;
  margin-top: 8px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(2, 16, 13, 0.85);
  color: #ffe7b2;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  resize: none;
}

.admin-user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(2, 16, 13, 0.72);
  border: 1px solid rgba(243, 189, 74, 0.22);
  min-width: 0;
}

.admin-user-details {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}

.admin-user-main {
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: #dbece4;
  font-size: 14px;
}

.admin-user-main strong {
  color: #ffe7b2;
}

.admin-user-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid rgba(243, 189, 74, 0.45);
  color: #f8d992;
}

.admin-user-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  box-shadow: 0 0 0 0 rgba(70, 226, 130, 0.55);
  animation: onlinePulse 1.5s ease-out infinite;
  background: #46e282;
}

.admin-user-state.inactive::before {
  background: #ff6d5f;
  box-shadow: 0 0 0 0 rgba(255, 109, 95, 0.56);
  animation: pausedPulse 1.5s ease-out infinite;
}

.admin-user-info {
  margin: 0;
  color: #dbece4;
  font-size: 14px;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.admin-user-wa {
  color: #9ff6d4;
  font-weight: 700;
  text-decoration: none;
}

.admin-user-wa:hover {
  text-decoration: underline;
}

.admin-user-id {
  color: #aac4ba;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  display: block;
  overflow-wrap: anywhere;
}

.admin-user-action {
  margin-top: 0;
  width: auto;
  white-space: nowrap;
  line-height: 1.2;
  min-height: 36px;
  padding: 8px 10px;
  flex: 0 0 auto;
}

.admin-user-action.is-danger {
  border: 1px solid rgba(255, 156, 140, 0.55);
  color: #ffd0c8;
  background: rgba(110, 25, 25, 0.42);
}

.admin-user-action.is-ok {
  border: 1px solid rgba(130, 213, 177, 0.5);
  color: #d6f5e8;
  background: rgba(16, 80, 58, 0.45);
}

@keyframes floatA {
  0% { transform: translateY(0); }
  50% { transform: translateY(16px); }
  100% { transform: translateY(0); }
}

@keyframes floatB {
  0% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
  100% { transform: translateY(0); }
}

@keyframes onlinePulse {
  0% {
    opacity: 0.95;
    box-shadow: 0 0 0 0 rgba(70, 226, 130, 0.58);
  }
  70% {
    opacity: 1;
    box-shadow: 0 0 0 8px rgba(70, 226, 130, 0);
  }
  100% {
    opacity: 0.95;
    box-shadow: 0 0 0 0 rgba(70, 226, 130, 0);
  }
}

@keyframes pausedPulse {
  0% {
    opacity: 0.95;
    box-shadow: 0 0 0 0 rgba(255, 109, 95, 0.56);
  }
  70% {
    opacity: 1;
    box-shadow: 0 0 0 8px rgba(255, 109, 95, 0);
  }
  100% {
    opacity: 0.95;
    box-shadow: 0 0 0 0 rgba(255, 109, 95, 0);
  }
}

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

  .grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .campaign-item {
    grid-template-columns: 1fr;
  }

  .campaign-row-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-user-item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .admin-user-action {
    width: 100%;
    white-space: normal;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(1080px, 96vw);
    margin-top: 16px;
  }

  .card {
    border-radius: 14px;
    padding: 16px;
  }

  h2 {
    font-size: 23px;
  }

  .brand-wrap {
    align-items: flex-start;
  }

  .brand-logo {
    width: 62px;
    height: 62px;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .campaign-item {
    grid-template-columns: 1fr;
  }

  .campaign-item .ghost,
  .campaign-row-actions .ghost {
    width: 100%;
  }

  .campaign-row-actions {
    grid-template-columns: 1fr;
  }

  .campaign-numbers {
    grid-template-columns: 1fr;
  }

  .num-chip {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    row-gap: 6px;
    column-gap: 8px;
    border-radius: 12px;
    padding: 8px 10px;
  }

  .num-chip::before {
    margin-top: 4px;
  }

  .num-actions {
    grid-column: 1 / -1;
    margin-left: 0;
    justify-content: flex-start;
  }

  .admin-shell {
    width: min(980px, 96vw);
  }

  .invite-result {
    padding: 14px;
  }

  .invite-result .actions {
    grid-template-columns: 1fr;
  }

  .admin-user-item {
    padding: 10px;
  }

  .admin-user-main {
    font-size: 13px;
  }

  .admin-user-info {
    font-size: 13px;
  }
}
