:root {
  --bg: #041610;
  --bg-2: #07261d;
  --panel: rgba(4, 24, 18, 0.9);
  --panel-solid: #08281d;
  --panel-soft: rgba(12, 48, 35, 0.82);
  --text: #f2fff8;
  --muted: #a7cdbd;
  --accent: #0d8b5d;
  --accent-2: #19b378;
  --border: rgba(46, 181, 121, 0.42);
  --border-soft: rgba(46, 181, 121, 0.16);
  --danger: #ff667f;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --glow: 0 0 0 1px rgba(25, 179, 120, 0.1), 0 10px 30px rgba(7, 58, 40, 0.3);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Inter", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(25, 179, 120, 0.14), transparent 24%),
    radial-gradient(circle at top right, rgba(25, 179, 120, 0.08), transparent 20%),
    linear-gradient(180deg, #03110c 0%, var(--bg) 52%, #020b08 100%);
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1700px, calc(100vw - 40px));
  margin: 20px auto 32px;
}

.panel {
  position: relative;
  border-radius: 32px;
  border: 2px solid var(--border);
  background: linear-gradient(180deg, rgba(4, 23, 17, 0.96), rgba(3, 18, 13, 0.92));
  box-shadow: var(--shadow), var(--glow);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 28%);
  pointer-events: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  margin-bottom: 18px;
}

.hero-main,
.hero-total {
  padding: 24px 28px;
}

.hero-main__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.eyebrow::before,
.section-kicker::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent-2);
  box-shadow: 0 0 12px rgba(25, 179, 120, 0.6);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 12px var(--danger);
}

.dot.connected {
  background: var(--accent-2);
  box-shadow: 0 0 14px var(--accent-2);
}

#dashboardTitle {
  margin: 16px 0 18px;
  font-size: clamp(34px, 4vw, 62px);
  line-height: 0.95;
  font-weight: 500;
  letter-spacing: -0.05em;
  text-align: center;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.mini-stat {
  min-width: 110px;
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: rgba(14, 68, 47, 0.28);
}

.mini-stat__label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.mini-stat strong {
  font-size: 22px;
}

.hero-total {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 12px;
}

.hero-total__label {
  color: var(--muted);
  font-size: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-total__value {
  font-size: clamp(54px, 7vw, 84px);
  line-height: 0.9;
  font-weight: 800;
}

.hero-total__footer {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 18px;
}

.dashboard-grid > .panel {
  padding: 22px;
}

.card-global,
.card-users,
.card-api {
  min-width: 0;
}

.card-users {
  min-height: 420px;
}

.card-global {
  min-height: 0;
}

.card-global {
  grid-column: 1 / -1;
}

.card-users {
  grid-column: 1 / -1;
}

.card-gifters,
.card-feed,
.card-api {
  min-height: 260px;
}

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

.card-head h2 {
  margin: 6px 0 0;
  font-size: clamp(24px, 2vw, 34px);
  letter-spacing: -0.04em;
}

.goal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.legend {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: 6px;
}

.legend--complete {
  background: var(--accent-2);
}

.legend--current {
  background: linear-gradient(90deg, rgba(25,179,120,0.3), var(--accent-2));
}

.legend--locked {
  background: rgba(255,255,255,0.09);
}

.focus-goal {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 18px;
  margin-bottom: 22px;
}

.focus-goal__content,
.focus-goal__progress {
  padding: 22px;
  border-radius: 24px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(15, 67, 47, 0.3), rgba(7, 30, 22, 0.3));
}

.focus-goal__eyebrow {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.focus-goal__content h3 {
  margin: 12px 0 8px;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1;
}

.focus-goal__content p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.focus-goal__numbers {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

#focusGoalProgressText {
  font-size: 42px;
}

#focusGoalRatio {
  color: var(--muted);
  font-size: 14px;
}

.progress-track {
  width: 100%;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
  overflow: hidden;
}

.progress-track--large {
  height: 24px;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(25, 179, 120, 0.55);
  transition: width 0.35s ease;
}

.goal-grid {
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 14px;
}

.goals-accordion {
  border-radius: 24px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}

.goals-accordion summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  user-select: none;
}

.goals-accordion summary::-webkit-details-marker {
  display: none;
}

.goals-accordion summary strong {
  display: block;
  font-size: 18px;
}

.goals-accordion summary small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.accordion-icon {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(25, 179, 120, 0.12);
  color: var(--accent-2);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  transition: transform 0.2s ease;
}

.goals-accordion[open] .accordion-icon {
  transform: rotate(45deg);
}

.goals-accordion .goal-grid {
  padding: 0 18px 18px;
}

.goal-pill {
  position: relative;
  min-height: 106px;
  border-radius: 24px;
  border: 2px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
  isolation: isolate;
}

.goal-pill__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(12, 90, 60, 0.9), rgba(25, 179, 120, 0.65));
  z-index: -1;
  transition: width 0.35s ease;
}

.goal-pill__content {
  position: relative;
  z-index: 1;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-height: 106px;
}

.goal-pill__target {
  color: rgba(255,255,255,0.82);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.goal-pill__label {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.goal-pill__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.78);
  font-size: 12px;
}

.goal-pill.is-complete {
  border-color: rgba(25, 179, 120, 0.75);
}

.goal-pill.is-current {
  box-shadow: 0 0 0 1px rgba(25,179,120,0.25), 0 0 26px rgba(25,179,120,0.15);
}

.goal-pill.is-locked .goal-pill__fill {
  opacity: 0.22;
}

.user-goal-matrix {
  overflow-x: auto;
}

.matrix-grid {
  display: grid;
  grid-auto-rows: minmax(90px, auto);
  gap: 10px;
  min-width: fit-content;
}

.matrix-corner,
.matrix-user-head,
.matrix-goal-label,
.matrix-cell {
  border-radius: 22px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.02);
}

.matrix-corner {
  padding: 18px;
  color: var(--muted);
  display: flex;
  align-items: end;
  font-size: 14px;
  font-weight: 700;
}

.matrix-user-head {
  padding: 18px 16px;
  min-width: 170px;
}

.matrix-user-head strong {
  display: block;
  font-size: 20px;
  margin-bottom: 6px;
}

.matrix-user-head span {
  color: var(--muted);
  font-size: 13px;
}

.matrix-goal-label {
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 220px;
}

.matrix-goal-label strong {
  font-size: 18px;
}

.matrix-goal-label span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.matrix-cell {
  padding: 12px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 12px;
  min-height: 90px;
}

.matrix-bar {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  display: flex;
  align-items: end;
}

.matrix-bar__fill {
  width: 100%;
  height: 0%;
  background: linear-gradient(180deg, rgba(25,179,120,0.65), rgba(9,85,56,0.95));
  transition: height 0.35s ease;
}

.matrix-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 52px;
}

.matrix-meta strong {
  font-size: 14px;
}

.matrix-meta span {
  color: var(--muted);
  font-size: 12px;
}

.empty-state-block,
.empty,
.channel-details .empty {
  padding: 18px;
  border-radius: 20px;
  border: 1px dashed var(--border-soft);
  color: var(--muted);
  background: rgba(255,255,255,0.02);
}

.gifters,
.feed,
.channel-details {
  display: grid;
  gap: 10px;
}

.gifter-row,
.event,
.detail-row {
  display: grid;
  gap: 12px;
  align-items: center;
  border-radius: 20px;
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.025);
  padding: 14px 16px;
}

.gifter-row {
  grid-template-columns: 48px minmax(0, 1fr) auto;
}

.rank {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(25,179,120,0.12);
  color: var(--accent-2);
  font-weight: 800;
}

.name {
  font-weight: 700;
}

.login,
.event small,
.detail-label,
.api-status {
  color: var(--muted);
}

.gift-count {
  font-size: 26px;
  font-weight: 800;
}

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

.event strong {
  line-height: 1.4;
}

.detail-row {
  grid-template-columns: 140px 1fr;
}

.detail-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.detail-value {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.api-status {
  margin-bottom: 14px;
  font-weight: 700;
}

.api-error {
  display: none;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 102, 127, 0.1);
  border: 1px solid rgba(255, 102, 127, 0.3);
  color: #ffd9df;
}

.api-error.visible {
  display: block;
}

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

.api-stat-box {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.02);
}

.api-stat-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.api-stat-box strong {
  font-size: 28px;
}

.config-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 800;
  box-shadow: 0 14px 30px rgba(9, 85, 56, 0.35);
}

.config-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(2, 10, 8, 0.55);
  backdrop-filter: blur(4px);
}

.config-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100vw);
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #071e16, #04140e);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.35);
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.config-panel.open {
  transform: translateX(0);
}

.config-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 22px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.config-panel__head h2 {
  margin: 6px 0 0;
}

.config-panel__body {
  padding: 20px 22px 28px;
  overflow-y: auto;
}

.config-section + .config-section,
.debug-panel {
  margin-top: 22px;
}

.config-section h3 {
  margin: 0 0 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field + .field {
  margin-top: 14px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.field-help {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.field input,
.field textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(25, 179, 120, 0.14);
}

.field textarea {
  resize: vertical;
  min-height: 120px;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.color-field input {
  min-height: 48px;
  padding: 6px;
}

.config-actions,
.debug-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.ghost-button,
.debug-actions button,
.icon-button {
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  color: var(--text);
  background: rgba(255,255,255,0.05);
  padding: 11px 14px;
  font-weight: 700;
}

.primary-button {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 28px;
  line-height: 1;
}

.debug-panel {
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  overflow: hidden;
}

.debug-panel summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  font-weight: 700;
}

.debug-panel summary::-webkit-details-marker {
  display: none;
}

.debug-panel__content {
  padding: 0 18px 18px;
}

.debug-actions .danger {
  border-color: rgba(255, 102, 127, 0.3);
  color: #ffd9df;
}

@media (max-width: 1180px) {
  .hero,
  .dashboard-grid,
  .focus-goal {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 100%);
    margin: 10px auto 24px;
  }

  .hero-main,
  .hero-total,
  .dashboard-grid > .panel {
    padding: 18px;
  }

  .hero-main__topline,
  .card-head,
  .hero-total__footer {
    flex-direction: column;
    align-items: flex-start;
  }

  #dashboardTitle {
    text-align: left;
    font-size: 36px;
  }

  .goal-grid,
  .api-stats-grid,
  .color-grid {
    grid-template-columns: 1fr;
  }

  .matrix-user-head {
    min-width: 140px;
  }

  .matrix-goal-label {
    min-width: 170px;
  }
}