:root {
  --bg: #050b09;
  --bg-card: #0a1511;
  --bg-elevated: #102019;
  --accent: #24b65a;
  --accent-2: #168047;
  --accent-days: #6fbf4a;
  --text: #f7fff9;
  --muted: #789083;
  --success: #24b65a;
  --danger: #f87171;
  --border: rgba(36, 182, 90, 0.14);
  --radius: 16px;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.48), 0 0 24px rgba(36, 182, 90, 0.035);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at 70% 0%, rgba(36, 182, 90, 0.07), transparent 34%),
    radial-gradient(circle at 0% 25%, rgba(22, 128, 71, 0.05), transparent 32%),
    linear-gradient(180deg, #06100d 0%, var(--bg) 45%, #040907 100%);
  color: var(--text);
  min-height: 100%;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    calc(72px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
}

body.no-tabs {
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

.hero {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.04) 0%, rgba(36,182,90,0.055) 48%, rgba(5,11,9,0.92) 100%),
    #0a1511;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.hero.compact { padding: 16px; margin-bottom: 12px; }
.hero h1 { margin: 0 0 4px; font-size: 1.5rem; font-weight: 700; }
.hero h1,
.top-bar strong,
.card h2,
.mode-card h3 {
  color: #ffffff;
  text-shadow: 0 0 18px rgba(255,255,255,.12);
}
.hero .sub { color: var(--muted); font-size: 0.875rem; margin-bottom: 0; }
.hero.compact .sub { margin-bottom: 12px; }

.top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.btn-back {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.balance-row { display: flex; gap: 12px; }
.stat { flex: 1; background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.04); border-radius: 12px; padding: 12px; }
.stat .label { font-size: .75rem; color: var(--muted); margin-bottom: 4px; }
.stat .value { font-size: 1.25rem; font-weight: 700; }

.mode-grid { display: grid; gap: 12px; margin-top: 8px; }

.mode-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.mode-card:active { transform: scale(0.98); }
.mode-card.gb:hover, .mode-card.gb:focus { border-color: var(--accent); box-shadow: 0 0 22px rgba(36,182,90,.08); }
.mode-card.days:hover, .mode-card.days:focus { border-color: var(--accent-days); box-shadow: 0 0 22px rgba(111,191,74,.08); }

.mode-card .mode-icon { font-size: 2rem; margin-bottom: 8px; }
.mode-card h3 { margin: 0 0 6px; font-size: 1.1rem; }
.mode-card p { margin: 0; font-size: 0.85rem; color: var(--muted); line-height: 1.4; }

.mode-card.gb { background: linear-gradient(145deg, #0a1511 0%, #10251b 100%); }
.mode-card.days { background: linear-gradient(145deg, #0a1511 0%, #172712 100%); }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card h2 { margin: 0 0 12px; font-size: 1rem; font-weight: 600; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge.active { background: rgba(36,182,90,.12); color: #5bd083; }
.badge.inactive { background: rgba(248,113,113,.12); color: var(--danger); }

.progress-wrap { margin: 12px 0; }
.progress-bar { height: 8px; background: var(--bg-elevated); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 4px; box-shadow: 0 0 12px rgba(36,182,90,.22); }
.progress-fill.days { background: linear-gradient(90deg, var(--accent-days), var(--accent-2)); }

.meta { font-size: .875rem; color: var(--muted); line-height: 1.45; }
.meta strong { color: var(--text); }

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #eaffef; box-shadow: 0 0 14px rgba(36,182,90,.10); }
.btn-primary.days-theme { background: linear-gradient(135deg, var(--accent-days), var(--accent-2)); color: #eaffef; }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: rgba(36,182,90,.035); color: #58c782; border: 1px dashed var(--border); }
.btn-danger { background: rgba(248,113,113,.15); color: var(--danger); border: 1px solid rgba(248,113,113,.3); }

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-row .btn { margin-top: 0; }

.package-grid { display: grid; gap: 8px; }
.package-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  background: var(--bg-elevated);
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
}
.package-item:active { border-color: var(--accent); box-shadow: 0 0 12px rgba(36,182,90,.08); }
.package-item .price { font-weight: 700; color: var(--accent); }

.device-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.device-item:last-child { border-bottom: none; }
.device-item .dev-info { flex: 1; min-width: 0; }
.device-item .dev-info small { color: var(--muted); word-break: break-all; }

.btn-sm {
  padding: 8px 12px;
  font-size: 0.8rem;
  margin-top: 0;
  width: auto;
  flex-shrink: 0;
}

.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: rgba(4, 12, 9, .94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 100;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  font-size: 0.7rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
}
.tab.active { color: #58c782; text-shadow: none; }
.tab.active.days-theme { color: var(--accent-days); }
.tab .icon { display: block; font-size: 1.25rem; margin-bottom: 2px; }

.panel { display: none; }
.panel.active { display: block; }

.input-row { display: flex; gap: 8px; margin-top: 8px; }
input[type="text"], input[type="number"] {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 1rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.history-item:last-child { border-bottom: none; }

.loading, .error { text-align: center; padding: 48px 16px; color: var(--muted); }
.error { color: var(--danger); }
.error a { color: var(--accent); }

.pay-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.pay-method {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 10px;
  cursor: pointer;
  font-weight: 600;
}

.pay-method.active {
  border-color: var(--accent);
  color: var(--accent);
}

.notice {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(36,182,90,.055);
  border: 1px solid rgba(36,182,90,.13);
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.4;
}
