:root {
  --bg: #0a0a12;
  --bg-elev: #141420;
  --bg-card: #1a1a28;
  --bg-input: #12121c;
  --bg-hover: #22222e;
  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.14);
  --text: #f5f5f7;
  --hint: #8e8e93;
  --muted: #5e5e68;
  --link: #2997ff;
  --accent: #2997ff;
  --accent-purple: #a78bfa;
  --accent-glow: rgba(41,151,255,0.35);
  --green: #34d399;
  --green-bg: rgba(52,211,153,0.12);
  --red: #f87171;
  --red-bg: rgba(248,113,113,0.12);
}

/* Адаптация под Telegram light theme */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f2f7;
    --bg-elev: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f2f2f7;
    --bg-hover: #e5e5ea;
    --border: rgba(0,0,0,0.06);
    --border-hover: rgba(0,0,0,0.12);
    --text: #1c1c1e;
    --hint: #8e8e93;
    --muted: #aeaeb2;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', system-ui, sans-serif;
  font-size: 15px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: 20px 16px 40px;
  max-width: 480px;
  margin: 0 auto;
}

h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.8px;
  text-align: center;
  margin-bottom: 2px;
}

.subtitle {
  text-align: center;
  color: var(--hint);
  font-size: 13px;
  margin-bottom: 20px;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex-shrink: 0;
  padding: 9px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--hint);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 4px 16px var(--accent-glow);
}

/* ── Card ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

/* ── Тарифы: 5 кружков ── */
.tariff-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.tariff-btn {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  justify-content: center;
  transition: transform 0.15s;
}

.tariff-btn:active {
  transform: scale(0.92);
}

.tariff-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 2px solid var(--border);
  color: var(--hint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.3px;
  transition: all 0.2s;
}

.tariff-btn.active .tariff-circle {
  background: linear-gradient(135deg, var(--accent), var(--accent-purple));
  border-color: var(--accent);
  color: white;
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: scale(1.05);
}

/* ── Fields ── */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  margin-bottom: 12px;
}

.row .field {
  margin-bottom: 10px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--hint);
  margin-bottom: 6px;
  font-weight: 500;
}

.field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.field input::placeholder {
  color: var(--muted);
  font-weight: 500;
}

.field input:focus {
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* hide number arrows */
.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field input[type=number] {
  -moz-appearance: textfield;
}

/* ── Result card ── */
.result-card {
  background: linear-gradient(145deg, #16162a 0%, #1a1a2e 100%);
  border: 1px solid rgba(41,151,255,0.2);
  border-radius: 22px;
  padding: 22px 18px;
  margin-top: 16px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

@media (prefers-color-scheme: light) {
  .result-card {
    background: linear-gradient(145deg, #ffffff 0%, #fafaff 100%);
  }
}

.result-card::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 160px;
  height: 160px;
  background: radial-gradient(var(--accent-glow), transparent 70%);
  pointer-events: none;
}

.result-header {
  text-align: center;
  margin-bottom: 18px;
  position: relative;
}

.net-label {
  font-size: 12px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
  font-weight: 600;
}

.net-value {
  font-size: 44px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: -2px;
  line-height: 1.1;
  transition: color 0.3s;
}

.net-value.negative {
  color: var(--red);
}

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

.stat-item {
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  padding: 13px 12px;
  text-align: center;
}

@media (prefers-color-scheme: light) {
  .stat-item {
    background: rgba(0,0,0,0.03);
  }
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1.1;
  margin-bottom: 3px;
}

.stat-label {
  font-size: 10px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

/* ── History ── */
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }

.history-date {
  font-size: 14px;
  font-weight: 600;
}
.history-hours {
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
}
.history-net {
  font-size: 16px;
  font-weight: 700;
  color: var(--green);
}

/* ── Privacy note ── */
.privacy {
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  font-family: 'SF Mono', Menlo, monospace;
  margin-top: 12px;
}
