/* === Fonts === */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/inter-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* === Tokens === */
:root {
  --bg: #0A0A0F;
  --surface: #14141F;
  --surface-hover: #1C1C2A;
  --border: #2A2A3A;
  --gold: #D4AF37;
  --gold-light: #F0D060;
  --gold-dim: #8B7320;
  --purple: #7C3AED;
  --purple-light: #9F67FF;
  --text: #E8E8ED;
  --text-secondary: #8888A0;
  --success: #22C55E;
  --danger: #EF4444;
  --radius: 12px;
  --radius-sm: 8px;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

/* === Layout === */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.main {
  flex: 1;
  padding: 1rem;
  padding-bottom: 5rem;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

/* === Top bar (mobile) === */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.topbar-logo { width: 2rem; height: 2rem; color: var(--gold); }
.topbar-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
}

/* === Bottom nav (mobile) === */
.bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottomnav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 0;
  font-size: 0.7rem;
  color: var(--text-secondary);
  transition: color 0.15s;
}
.bottomnav a:hover, .bottomnav a.active { color: var(--gold); }
.bottomnav svg { width: 1.4rem; height: 1.4rem; }

/* === Desktop sidebar (>=768px) === */
@media (min-width: 768px) {
  .app { flex-direction: row; }
  .sidebar {
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    position: sticky;
    top: 0;
    height: 100dvh;
  }
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
  }
  .sidebar-brand svg, .sidebar-brand img { width: 2rem; height: 2rem; color: var(--gold); }
  .sidebar-brand span {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 0.04em;
  }
  .sidebar a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
  }
  .sidebar a:hover { background: var(--surface-hover); color: var(--text); }
  .sidebar a.active { color: var(--gold); background: rgba(212,175,55,0.08); }
  .sidebar svg { width: 1.2rem; height: 1.2rem; }
  .sidebar-spacer { flex: 1; }
  .sidebar-logout {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
  }
  .bottomnav { display: none; }
  .topbar { display: none; }
  .main { padding: 2rem; padding-bottom: 2rem; max-width: 720px; }
}

/* === Cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}
.card-value { font-size: 1.5rem; font-weight: 600; }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-active { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-inactive { background: rgba(136,136,160,0.15); color: var(--text-secondary); }
.badge-expired { background: rgba(239,68,68,0.15); color: var(--danger); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-gold { background: var(--gold); color: #0A0A0F; }
.btn-gold:hover { background: var(--gold-light); color: #0A0A0F; }
.btn-outline { border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--gold-dim); color: var(--gold); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}
.form-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--gold); }

/* === Login page === */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1rem;
}
.login-box { width: 100%; max-width: 380px; }
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.login-brand svg, .login-brand img { width: 3rem; height: 3rem; color: var(--gold); }
.login-brand span {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
}
.login-tabs {
  display: flex;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.login-tab {
  flex: 1;
  padding: 0.6rem;
  text-align: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.login-tab:hover { color: var(--text); }
.login-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.login-panel { display: none; }
.login-panel.active { display: block; }

/* === Transaction list === */
.tx-list { list-style: none; }
.tx-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.tx-item:last-child { border-bottom: none; }
.tx-info { display: flex; flex-direction: column; gap: 0.15rem; }
.tx-type { font-size: 0.85rem; }
.tx-date { font-size: 0.75rem; color: var(--text-secondary); }
.tx-amount { font-weight: 600; font-size: 0.95rem; }
.tx-credit { color: var(--success); }
.tx-debit { color: var(--danger); }

/* === Code boxes === */
.code-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.85rem;
  word-break: break-all;
}
.code-box-text { flex: 1; }
.copy-btn {
  flex-shrink: 0;
  padding: 0.3rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.15s;
}
.copy-btn:hover { color: var(--gold); }

/* === QR Code === */
.qr-container {
  display: flex;
  justify-content: center;
  padding: 1.5rem;
  background: #fff;
  border-radius: var(--radius);
  margin: 1rem auto;
  width: fit-content;
}

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
}
.empty-state svg {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  opacity: 0.4;
}

/* === Page header === */
.page-header { margin-bottom: 1.5rem; }
.page-title { font-size: 1.5rem; font-weight: 600; }

/* === Alerts === */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.alert-info {
  background: rgba(124,58,237,0.1);
  border: 1px solid rgba(124,58,237,0.25);
  color: var(--purple-light);
}
.alert-success {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.25);
  color: var(--success);
}
.alert-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  color: var(--danger);
}

/* === Referral / gift items === */
.ref-item, .gift-item {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}
.ref-item-header, .gift-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.ref-stat { font-size: 0.8rem; color: var(--text-secondary); }

/* === Settings === */
.settings-section { margin-bottom: 2rem; }
.settings-section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* === htmx loading === */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* === Utilities === */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.text-secondary { color: var(--text-secondary); }
.text-gold { color: var(--gold); }
.text-sm { font-size: 0.8rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }

/* === Server cards with keys === */
.mt-3 { margin-top: 1.5rem; }

.server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.server-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s;
}
.server-summary::-webkit-details-marker { display: none; }
.server-summary:hover { background: var(--surface-hover); }
.server-flag { font-size: 1.3rem; line-height: 1; }
.server-name { flex: 1; font-weight: 500; }
.server-chevron { width: 1rem; height: 1rem; color: var(--text-secondary); transition: transform 0.2s; }
details[open] .server-chevron { transform: rotate(180deg); }
.server-body { padding: 1rem; border-top: 1px solid var(--border); }

/* Inline key tabs */
.key-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.key-tab {
  flex: 1;
  padding: 0.5rem;
  text-align: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.key-tab:hover { color: var(--text); }
.key-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.key-panel { display: none; }
.key-panel.active { display: block; }

/* AmneziaWG config block */
.awg-conf {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}
