﻿:root {
  --bg: #0d1117;
  --bg-soft: #141a22;
  --bg-panel: #101722;
  --accent: #ffb347;
  --accent-2: #ff6b6b;
  --text: #f8f5f0;
  --muted: #9aa4b2;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #221a2c 0%, #0b0f16 40%, #0d1117 100%);
  min-height: 100vh;
}

body.app-body {
  background: #0c111a;
}

html {
  background: #0c111a;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-shell {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 40px;
  max-width: 1100px;
  width: 100%;
}

.login-hero {
  padding: 40px;
  background: linear-gradient(160deg, rgba(255, 179, 71, 0.2), rgba(255, 107, 107, 0.05));
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
  overflow: hidden;
}

.login-hero::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  right: -60px;
  top: -80px;
  background: radial-gradient(circle, rgba(255, 179, 71, 0.5), transparent 70%);
  filter: blur(10px);
}

.logo-badge {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: #161616;
  font-family: "Unbounded", sans-serif;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

h1 {
  font-size: 36px;
  margin: 0 0 12px;
}

p {
  margin: 0;
  color: var(--muted);
}

.hero-cards {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.hero-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-panel {
  background: var(--bg-panel);
  border-radius: 28px;
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-inner h2 {
  margin-top: 0;
}

.form-grid {
  display: grid;
  gap: 16px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.input-with-action {
  position: relative;
  padding-top: 2px;
}

.input-wrap {
  position: relative;
}

.input-wrap input {
  padding-right: 84px;
}

.input-action {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
}

.app-main .input-action {
  border: 1px solid #d0d7de;
  background: #f4f6f8;
  color: #111111;
}

.history-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  padding: 6px;
  display: none;
  max-height: 240px;
  overflow-y: auto;
  z-index: 5;
}

.history-dropdown.open {
  display: block;
}

.history-item {
  flex: 1;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  color: #111827;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item:hover {
  background: #f1f5f9;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-del {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #ef4444;
  font-size: 12px;
  cursor: pointer;
}

.history-del:hover {
  background: #fff1f2;
  border-color: #fecdd3;
}

.history-empty {
  padding: 10px 12px;
  color: #94a3b8;
  font-size: 12px;
}

button.primary {
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #111;
  font-weight: 700;
  cursor: pointer;
}

.app-body {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex: 0 0 260px;
  padding: 28px 20px;
  background: #0c111a;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Unbounded", sans-serif;
}

.nav-toggle {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  font-family: "Unbounded", sans-serif;
}

.brand-mark {
  background: var(--accent);
  color: #111;
  padding: 8px 12px;
  border-radius: 12px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  object-fit: cover;
  background: #0f172a;
}

.brand span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-family: "Space Grotesk", sans-serif;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-link {
  text-decoration: none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-link.logout {
  color: #ff9b9b;
}

.sidebar-footer {
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-contact {
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.balance {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 22px;
}

.balance small {
  color: var(--muted);
  font-size: 12px;
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 32px 48px;
  background: #ffffff;
  color: #111827;
  --text: #111827;
  --muted: #4b5563;
  --card: #ffffff;
  --card-border: #e5e7eb;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.user-pill {
  background: rgba(255, 255, 255, 0.08);
  padding: 10px 14px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.user-pill em {
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 0;
  backdrop-filter: none;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.card + .card {
  margin-top: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.tab-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}

.tab-btn.is-active {
  color: var(--text);
  font-weight: 600;
}

.tab-sep {
  color: var(--muted);
}

.tab-panel.is-hidden {
  display: none;
}

.contact-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rate-line {
  margin-top: 8px;
}

.referral-link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.referral-link input {
  width: 100%;
}

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

.stat-card {
  background: #f4f6f8;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}

.stat-card strong {
  display: block;
  font-size: 22px;
  color: #111111;
  margin-bottom: 6px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.agent-table {
  table-layout: fixed;
}

.agent-table th:nth-child(1),
.agent-table td:nth-child(1) {
  width: 50px;
}

.agent-table th:nth-child(2),
.agent-table td:nth-child(2) {
  width: 170px;
}

.agent-table th:nth-child(3),
.agent-table td:nth-child(3) {
  width: 80px;
}

.agent-table th:nth-child(4),
.agent-table td:nth-child(4) {
  width: 210px;
}

.agent-table th:nth-child(5),
.agent-table td:nth-child(5) {
  width: 120px;
}

.agent-table th:nth-child(6),
.agent-table td:nth-child(6) {
  width: 110px;
}

.agent-table th:nth-child(7),
.agent-table td:nth-child(7) {
  width: 360px;
}

.agent-table td {
  word-break: break-all;
}

.agent-table th,
.agent-table td {
  padding: 8px 10px;
  font-size: 13px;
}

.agent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.table th,
.table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--card-border);
  font-size: 14px;
  vertical-align: top;
  word-break: break-word;
}

.table th {
  color: var(--muted);
  font-weight: 500;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.link {
  color: var(--accent);
  text-decoration: none;
}

.link-btn {
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  cursor: pointer;
  color: var(--accent);
}

.link-btn.danger {
  color: #ff9b9b;
}

.flash {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.flash-success {
  background: rgba(74, 222, 128, 0.15);
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.flash-error {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.note {
  margin-top: 12px;
  padding: 12px;
  background: rgba(255, 179, 71, 0.15);
  border-radius: 12px;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 16px;
  margin-top: 8px;
}

.kv-item span {
  color: var(--muted);
  margin-right: 6px;
}

.section-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 14px;
}

.tier-list {
  display: grid;
  gap: 12px;
}

.tier-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

.ghost {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.ghost-small {
  padding: 8px 10px;
  border-radius: 10px;
}

.energy-toggle {
  display: flex;
  gap: 10px;
}

.toggle-btn {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.toggle-btn.active {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #111;
  border-color: transparent;
}

.period-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.period-grid-2 {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.period-grid span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.period-grid strong {
  font-size: 14px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.form-grid.compact {
  gap: 12px;
}

.form-grid.compact .form-row {
  align-items: end;
}

.form-grid.compact button.primary {
  width: auto;
  padding: 10px 16px;
}

.ledger-filters {
  grid-template-columns: repeat(4, minmax(200px, 1fr));
  align-items: end;
}

.ledger-type-select {
  min-height: 44px;
}

.table th,
.table td {
  vertical-align: middle;
}

.table td .muted {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qr-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.qr-card {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.qr-card img {
  margin-top: 8px;
  width: 140px;
  height: 140px;
  border-radius: 10px;
  background: #fff;
  padding: 8px;
}

.transfer-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px dashed #e5e7eb;
  background: #fbfbfc;
  margin-bottom: 14px;
}

.transfer-panel.is-hidden {
  display: none;
}

.transfer-panel .qr-block {
  text-align: center;
  padding: 8px 0;
}

.transfer-panel .qr-title {
  font-weight: 600;
  margin-bottom: 10px;
}

.transfer-panel .qr-image {
  width: 180px;
  height: 180px;
  border-radius: 16px;
  background: #fff;
  padding: 10px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.transfer-address {
  font-family: "Space Grotesk", sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f4f6f8;
  border: 1px solid #e2e8f0;
  word-break: break-all;
}

.chip {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 1px;
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.user-card {
  background: #f4f6f8;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  display: flex;
  align-items: center;
}

.user-info span {
  font-weight: 600;
  font-size: 16px;
}

.user-balance {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.user-balance strong {
  font-size: 16px;
}

@media (max-width: 980px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .app-body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    position: relative;
    padding: 6px 10px;
    gap: 12px;
  }

  .brand,
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

@media (max-width: 680px) {
  .referral-link {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

.app-main input {
  background: #ffffff;
  border: 1px solid #d0d7de;
  color: #111111;
}

.app-main p,
.app-main .muted {
  color: var(--muted);
}

.app-main h1,
.app-main h2,
.app-main h3,
.app-main h4,
.app-main h5,
.app-main h6 {
  color: var(--text);
}

.app-main .table {
  color: var(--text);
}

.app-main .table th {
  color: #6b7280;
}

.app-main .user-pill {
  background: #f4f6f8;
  border: 1px solid #e2e8f0;
}

.app-main .flash-success {
  background: rgba(22, 163, 74, 0.12);
  border: 1px solid rgba(22, 163, 74, 0.25);
}

.app-main .flash-error {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.25);
}

@media (max-width: 720px) {
  .app-main {
    padding: 18px 16px;
  }

  .sidebar {
    background: #0c111a;
    background-image: none;
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 0;
    height: auto;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding: 4px 10px;
    gap: 0;
    flex: 0 0 auto;
    max-height: 56px;
    overflow: hidden;
  }

  .mobile-topbar {
    display: flex;
    padding: 2px 0;
    background: #0c111a;
  }

  .mobile-brand .brand-mark {
    padding: 6px 10px;
  }

  .brand-logo {
    width: 30px;
    height: 30px;
    border-radius: 10px;
  }

  .brand {
    display: none;
  }

  .nav {
    display: none;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .sidebar-open .nav {
    display: grid;
  }

  .nav-link {
    text-align: left;
    font-size: 14px;
    padding: 10px 12px;
  }

  .sidebar-footer {
    display: none;
  }

  .sidebar-open .sidebar-footer {
    display: block;
    padding: 12px;
  }

  .sidebar-bottom {
    display: none;
  }

  .sidebar-open .sidebar-bottom {
    display: grid;
  }

  .sidebar-open {
    padding: 10px 12px;
    gap: 12px;
    max-height: none;
    overflow: visible;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .user-card {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .grid-two,
  .form-row,
  .tier-row,
  .period-grid-2 {
    grid-template-columns: 1fr;
  }

  .table {
    display: block;
    overflow-x: auto;
  }

  .table th,
  .table td {
    white-space: nowrap;
  }
}

.code-block {
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}
