/* FixProxy — светлая тема по референсу */
:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --bg-hover: #f0f0f2;
  --border: #e5e5ea;
  --border-light: #ebebed;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #86868b;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-subtle: rgba(0, 113, 227, 0.08);
  --balance: #e85d04;
  --balance-soft: rgba(232, 93, 4, 0.1);
  --success: #34c759;
  --danger: #ff3b30;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: var(--safe-bottom);
  line-height: 1.45;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px;
  overflow-x: hidden;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 12px 0 14px;
  padding-top: calc(12px + var(--safe-top));
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.header-balance { display: block; }

.header-balance-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.header-balance-value {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--balance);
}

.header-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Main */
.main { padding: 16px 0 28px; }

.screen { display: none; animation: fadeIn 0.2s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Dashboard */
.dashboard { display: flex; flex-direction: column; gap: 16px; }

/* Warning banner */
.warn-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fffbf0;
  border: 1px solid #f0e6c8;
  border-radius: var(--radius);
  padding: 12px 14px;
}

.warn-banner.hidden { display: none !important; }

.warn-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  background: var(--balance);
  color: #fff;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.warn-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.45;
  margin: 0;
}

.warn-close {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.warn-close:hover { color: var(--text); }

/* Balance block (centered, as on screenshot) */
.balance-block {
  text-align: center;
  padding: 8px 0;
}

.balance-block-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 4px;
}

.balance-block-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--balance);
  line-height: 1.2;
}

.balance-block-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Main CTA */
.btn-main {
  width: 100%;
  padding: 16px 20px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-main:hover { background: var(--accent-hover); }

.btn-main-icon {
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 300;
}

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

.action-tile {
  padding: 16px 12px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.action-tile:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
}

.action-tile-icon { font-size: 1.4rem; }
.action-tile-label { display: block; }

/* Section head (Мой прокси + Добавить) */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.section-head-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 2px 0 0 0;
}

.link-add {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

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

/* Proxy status / device */
.proxy-status, .proxy-details { margin-top: 0; }
.proxy-status.hidden, .proxy-details.hidden { display: none !important; }

.proxy-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 12px 0;
}

.device-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.device-icon { font-size: 1.5rem; flex-shrink: 0; }

.device-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.device-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.device-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Tariff line */
.tariff-line {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin: 4px 0;
}

/* Card (base) */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 12px 0;
}

/* Referral card on dashboard */
.referral-card {
  padding: 20px 18px;
}

.referral-emojis {
  font-size: 1.8rem;
  text-align: center;
  margin: 0 0 10px 0;
  letter-spacing: 4px;
}

.referral-card .referral-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px 0;
  line-height: 1.35;
}

.referral-card .referral-title strong { color: var(--balance); }

.referral-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.referral-actions {
  display: flex;
  gap: 10px;
}

.referral-actions .btn { flex: 1; }

.btn-send { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-icon { font-size: 0.9rem; opacity: 0.9; }

/* Instructions section */
.instructions-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 20px 0 10px 0;
}

.instructions-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.instruction-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.instruction-row:hover { background: var(--bg-hover); }

.instruction-name { flex: 1; }
.instruction-chevron {
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid var(--text-muted);
  flex-shrink: 0;
}

.nav-card { margin-top: 8px; }

.referral-input-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Section title */
.section-title {
  margin-bottom: 12px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* Nav list */
.nav-list { display: flex; flex-direction: column; gap: 2px; }

.nav-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 0;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.nav-tile:hover { background: var(--bg-hover); }

.nav-chevron {
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid var(--text-muted);
  flex-shrink: 0;
}

/* Buttons */
.btn {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 12px 18px;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-outline {
  background: var(--bg-card);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 10px 16px;
}

.btn-outline:hover {
  background: var(--accent-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  font-size: 0.85rem;
  padding: 6px 0;
}

.btn-ghost:hover { text-decoration: underline; }

.btn-block { width: 100%; margin-top: 12px; padding: 12px; }

.btn-sm { padding: 6px 10px; font-size: 0.8rem; }

.back-btn {
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  margin-bottom: 10px;
  padding: 0;
  cursor: pointer;
}

.back-btn:hover { color: var(--text); }

.screen-bar { margin-bottom: 8px; }

.screen-head {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.screen-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  line-height: 1.5;
}

/* Plans */
.plans {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  max-width: 100%;
}

.plan {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
  box-shadow: var(--shadow);
}

.plan--featured {
  border-color: var(--accent);
  background: var(--accent-subtle);
  padding-top: 28px;
}

.plan--featured .plan-tag { top: 8px; left: 12px; right: auto; }

.plan-tag {
  position: absolute;
  top: 10px;
  right: 12px;
  left: auto;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  white-space: nowrap;
}

.plan-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.plan-name { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.plan-price { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.plan-meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; display: block; }
.plan .plan-btn { width: 100%; }

.form-note { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

/* Extend */
.extend-empty { margin-bottom: 16px; }
.extend-hint { font-size: 0.9rem; color: var(--text-muted); }
.extend-hint a { color: var(--accent); text-decoration: none; }
.extend-hint a:hover { text-decoration: underline; }

/* Support */
.support-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  margin-bottom: 16px;
}

.support-link:hover { border-color: var(--accent); background: var(--accent-subtle); }
.support-link-label { font-size: 0.9rem; font-weight: 500; }
.support-link-account { font-size: 0.85rem; color: var(--accent); }

.support-form { margin-top: 16px; }

.label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.input {
  width: 100%;
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  margin-bottom: 12px;
}

.input:focus { outline: none; border-color: var(--accent); }
.input--textarea { min-height: 100px; resize: vertical; }

/* History */
.history-wrap { margin-top: 8px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-empty {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  padding: 32px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.history-item .title { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.history-item .date { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.history-item .amount { font-size: 0.9rem; font-weight: 600; white-space: nowrap; }
.history-item .amount.plus { color: var(--success); }
.history-item .amount.minus { color: var(--danger); }

/* FAQ */
.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.faq-item summary {
  padding: 14px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; float: right; color: var(--text-muted); }
.faq-item[open] summary::after { content: '−'; }

.faq-item p {
  padding: 0 16px 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
  border-top: 1px solid var(--border);
  margin: 0 16px 14px;
  padding-top: 12px;
}

/* Referral page */
.referral-stats-text { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 12px; }
.referral-stats-text strong { color: var(--text); }
.referral-link-row { display: flex; gap: 8px; margin-bottom: 12px; }
.referral-link-row .input { flex: 1; margin-bottom: 0; }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 10px 18px;
  font-size: 0.85rem;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 100;
  max-width: calc(100% - 32px);
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.hidden { display: none !important; }

@media (min-width: 420px) {
  .plans { display: grid; grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 560px) {
  .plans { grid-template-columns: repeat(3, 1fr); }
}
