:root {
  --bg: #0b1021;
  --card: #121830;
  --panel: #11162b;
  --line: rgba(255, 255, 255, 0.06);
  --text: #e9ecf5;
  --muted: #9aa3c1;
  --accent: #6ae3ff;
  --ghost: #2b3655;
  --good: #34d399;
  --warn: #f59e0b;
  --bad: #ef4444;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 10% 10%, rgba(106, 227, 255, 0.1), transparent 20%),
    radial-gradient(circle at 80% 20%, rgba(180, 115, 255, 0.1), transparent 30%),
    var(--bg);
  min-height: 100vh;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 80px;
  position: relative;
  overflow: hidden;
}

.with-sidebar .app {
  padding-left: 280px;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-brand {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.nav-exit {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  background: transparent;
}

.nav-link:hover {
  border-color: var(--line);
  background: rgba(106, 227, 255, 0.08);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(106, 227, 255, 0.22), rgba(139, 123, 255, 0.2));
  border-color: rgba(106, 227, 255, 0.35);
}

.sidebar-balance {
  font-size: 14px;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
}

.bg-blur {
  position: absolute;
  inset: 0;
  background: radial-gradient(700px at 70% 20%, rgba(106, 227, 255, 0.08), transparent),
    radial-gradient(800px at 10% 50%, rgba(255, 147, 234, 0.08), transparent);
  filter: blur(60px);
  opacity: 0.8;
  pointer-events: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  position: relative;
  z-index: 1;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 4px;
}

h1 {
  margin: 0 0 8px;
  font-size: 32px;
}

.lede {
  margin: 0 0 12px;
  color: var(--muted);
  max-width: 640px;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  background: var(--accent);
  color: #07101f;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
}

.chip-ghost {
  background: var(--ghost);
  color: var(--text);
}

.chip-warn {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.1;
  text-transform: none;
  cursor: pointer;
  color: var(--text);
}

.btn.primary {
  background: linear-gradient(135deg, #6ae3ff, #8b7bff);
  color: #0a1020;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.cta-group {
  display: flex;
  gap: 10px;
}

.actions-row {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .with-sidebar .app {
    padding-left: 20px;
    padding-top: 100px;
  }

  .sidebar {
    position: fixed;
    width: calc(100% - 40px);
    height: auto;
    left: 20px;
    right: 20px;
    top: 16px;
    border-right: none;
    border: 1px solid var(--line);
    border-radius: 14px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .nav {
    grid-auto-flow: column;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
  }

  .nav-footer {
    margin-top: 0;
  }

  .nav-link {
    font-size: 12px;
    text-align: center;
    padding: 8px 10px;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-top: 24px;
  position: relative;
  z-index: 1;
}

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

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

.tabs {
  display: grid;
  gap: 16px;
}

.tab-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.tab-button.active {
  background: rgba(106, 227, 255, 0.12);
  border-color: rgba(106, 227, 255, 0.4);
}

.tab-panels {
  display: grid;
  gap: 12px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

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

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.stat h3 {
  margin: 0;
  font-size: 15px;
}

.stat .stat-value {
  margin: 4px 0 0;
  font-size: 24px;
  font-weight: 700;
}

.stat .stat-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

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

.ring-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.ring {
  display: grid;
  place-items: center;
  gap: 6px;
}

.ring svg {
  width: 72px;
  height: 72px;
}

.ring-label {
  font-size: 12px;
  color: var(--muted);
}

.ring-value {
  font-size: 16px;
  font-weight: 700;
}

.chart-line svg {
  width: 100%;
  height: 220px;
  display: block;
}

.chart-donut {
  display: grid;
  place-items: center;
  margin-top: 6px;
}

.chart-donut svg {
  width: 180px;
  height: 180px;
}

.legend {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.field-input.small {
  width: 140px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 12px;
}

.field-input.small.textarea {
  width: min(320px, 100%);
  min-height: 60px;
  resize: vertical;
}

.payload-box {
  margin: 0;
  background: #0f1322;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
}

.payload-row td {
  padding: 0 12px 12px;
}

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

.details-section {
  background: #0f1322;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.details-section h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.details-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

.details-row:last-child {
  border-bottom: none;
}

.details-label {
  color: var(--muted);
}

.details-value {
  text-align: right;
  color: var(--text);
}

.details-list {
  display: grid;
  gap: 6px;
  font-size: 12px;
  margin: 6px 0 0;
}

.modal-dialog.modal-large {
  width: min(720px, 92vw);
}

.modal-actions-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.modal-actions-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 4px;
  display: inline-block;
  margin-right: 6px;
}

.stat.good {
  border-color: rgba(52, 211, 153, 0.5);
}
.stat.bad {
  border-color: rgba(239, 68, 68, 0.5);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #0e1426;
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 10px;
}
.field.checkbox {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--ghost);
  transition: 0.2s;
  border-radius: 24px;
  border: 1px solid var(--line);
}

.slider:before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text);
  transition: 0.2s;
  border-radius: 50%;
}

.toggle input:checked + .slider {
  background: linear-gradient(135deg, #6ae3ff, #8b7bff);
  border-color: transparent;
}

.toggle input:checked + .slider:before {
  transform: translateX(22px);
  background: #0a1020;
}

.field.details {
  background: transparent;
  border: 1px dashed var(--line);
}

.field.details summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  list-style: none;
}

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

.field.details .extras {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

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

.field input,
.field select,
.field textarea {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  color: var(--text);
}

.table-wrapper {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

.collapse {
  margin-top: 12px;
  background: #0f1322;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.collapse summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.month-grid {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.month-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.month-table th,
.month-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: center;
}

.month-table th:first-child,
.month-table td:first-child {
  text-align: left;
}

.scenario-grid {
  display: none;
}

.scenario {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.scenario-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pill {
  background: var(--ghost);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.scenario-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(80px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.metric-item {
  background: #0f1322;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.metric-warn {
  border-color: rgba(245, 158, 11, 0.5);
}

.weekly-grid,
.upload,
.unmatched {
  display: none;
}

.preset-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.preset-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.preset-card h4 {
  margin: 0 0 4px;
}

.preset-card .muted {
  margin: 0 0 10px;
}

.preset-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-option {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f1322;
  border: 1px solid var(--line);
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
}

.preset-option.active {
  border-color: var(--accent);
  background: rgba(106, 227, 255, 0.08);
}

.preset-option input {
  pointer-events: none;
}

.placement-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.placement-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.placement-card.disabled {
  opacity: 0.5;
  filter: grayscale(0.2);
}

.row-warn {
  background: rgba(245, 158, 11, 0.08);
}

.dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 0 6px;
}

.placement-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.placement-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.placement-option {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #0f1322;
  border: 1px solid var(--line);
  padding: 6px;
  border-radius: 8px;
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.mode-smart .strategy-only,
.app.mode-smart .strategy-only {
  display: none !important;
}

.mode-strategy .smart-only,
.app.mode-strategy .smart-only {
  display: none !important;
}

.topup-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.topup-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: calc(33.33% - 8px);
  min-width: 240px;
}

@media (max-width: 960px) {
  .topup-card {
    width: calc(50% - 8px);
  }
}

@media (max-width: 640px) {
  .topup-card {
    width: 100%;
  }
}

.topup-card h3 {
  margin: 2px 0 0;
}

.platform-chip {
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(106, 227, 255, 0.12);
  border: 1px solid rgba(106, 227, 255, 0.3);
  color: var(--text);
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 20, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal.show {
  display: flex;
}

.modal-dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  width: min(480px, 90vw);
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.4);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.modal-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
  overflow: auto;
  max-height: 65vh;
}

.modal-step {
  display: grid;
  gap: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 8px;
  margin-top: auto;
}

.btn.small {
  padding: 6px 10px;
}

.btn.full {
  width: 100%;
}

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

.inline-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.notice {
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  color: #34d399;
}

.notice.error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.link {
  color: #6ae3ff;
  text-decoration: none;
  font-size: 13px;
  display: inline-block;
}

.link:hover {
  text-decoration: underline;
}

.access-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 8px;
  margin-top: 6px;
}

.access-list {
  display: grid;
  gap: 8px;
}

.access-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #0f1322;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.access-email {
  font-weight: 600;
  font-size: 13px;
}

.id-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 6px;
}

@media (max-width: 640px) {
  .access-row {
    grid-template-columns: 1fr;
  }

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

.fee-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: #0f1322;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-weight: 600;
}

.fee-note {
  font-size: 12px;
  color: var(--muted);
}

.fee-strong {
  font-weight: 700;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  color: #34d399;
}

.icon-btn.stat {
  color: #6ae3ff;
}

.icon-btn.refresh {
  color: #f59e0b;
}
.status {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
}

.status-active {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.4);
  color: #34d399;
}

.status-warn {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #f59e0b;
}

.status-paused {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #f59e0b;
}

.status-blocked {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #ef4444;
}

.status-closed {
  background: rgba(156, 163, 175, 0.12);
  border-color: rgba(156, 163, 175, 0.35);
  color: #d1d5db;
}

.login-app {
  display: flex;
  align-items: center;
  min-height: 100vh;
}

.login-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(320px, 0.9fr);
  gap: 24px;
  align-items: center;
  width: 100%;
  justify-items: center;
}

.auth-center .login-shell {
  grid-template-columns: 1fr;
  max-width: 480px;
  margin: 0 auto;
}

.login-intro {
  animation: fade-up 0.6s ease both;
}

.login-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(3, 6, 14, 0.6);
  animation: fade-up 0.6s ease 0.15s both;
  width: min(420px, 100%);
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.login-form .btn {
  margin-top: 6px;
}

.login-actions {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.login-actions .field.checkbox {
  flex: 0 0 auto;
  width: auto;
  padding: 6px 8px;
}

.login-link {
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
}

.login-link:hover {
  text-decoration: underline;
}

.login-status {
  margin: 12px 0 0;
  background: rgba(106, 227, 255, 0.08);
  border: 1px solid rgba(106, 227, 255, 0.2);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
}

.login-secondary {
  margin-top: 10px;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 920px) {
  .login-app {
    align-items: stretch;
  }

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