/* ============================================================
   ОГРАНАНЕТ — brand purple palette
   Dark purple sidebar, violet accents, clean modern layout
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f5f3ff;
  --bg-sidebar: #1e1145;
  --surface: #ffffff;
  --surface-hover: #f5f3ff;
  --border: #e5e0f0;
  --border-light: #ede9fe;
  --text: #1a1033;
  --text-secondary: #6b5f80;
  --text-muted: #9f95b0;
  --accent: #7c3aed;
  --accent-light: #ede9fe;
  --accent-dark: #6d28d9;
  --accent-gradient: linear-gradient(135deg, #9333ea 0%, #6d28d9 100%);
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(30,17,69,0.05);
  --shadow: 0 1px 3px rgba(30,17,69,0.07), 0 1px 2px rgba(30,17,69,0.04);
  --shadow-md: 0 4px 6px -1px rgba(30,17,69,0.08), 0 2px 4px -2px rgba(30,17,69,0.05);
  --shadow-lg: 0 10px 25px -3px rgba(30,17,69,0.1), 0 4px 6px -4px rgba(30,17,69,0.05);
  --shadow-card: 0 0 0 1px var(--border-light), 0 4px 16px rgba(30,17,69,0.05);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --sidebar-w: 250px;
  --header-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-dark); }

/* ===== LAYOUT: sidebar + main ===== */
.layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar (dark purple) --- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: none;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.sidebar-brand {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand .brand-icon {
  width: 36px; height: 36px;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon img {
  width: 100%; height: 100%;
  border-radius: 10px;
}

.sidebar-brand .brand-text {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a, .sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  color: rgba(255,255,255,.6);
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
  text-decoration: none;
}

.sidebar-nav a:hover, .sidebar-nav .nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(147,51,234,.35);
  color: #fff;
  font-weight: 600;
}

.sidebar-nav .nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-nav .nav-spacer {
  flex: 1;
}

.sidebar-nav .nav-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: rgba(255,255,255,.3);
  padding: 16px 12px 6px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-footer .user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-xs);
  background: rgba(255,255,255,.06);
}

.sidebar-footer .user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-footer .user-info {
  overflow: hidden;
}

.sidebar-footer .user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer .user-email {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Main content area --- */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Top bar --- */
.topbar {
  height: var(--header-h);
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 20px;
  margin-right: 12px;
}

.hamburger:hover { background: var(--surface-hover); }

/* --- Content --- */
.content {
  flex: 1;
  padding: 32px;
  max-width: 960px;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 24px;
}

.card-header {
  margin-bottom: 20px;
}

.card-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.card-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ===== METRICS GRID ===== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-card .metric-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}

.metric-card .metric-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.02em;
}

.metric-card .metric-value.accent { color: var(--accent); }
.metric-card .metric-value.success { color: var(--success); }

.metric-card .metric-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== BUTTONS ===== */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: var(--radius-xs);
  border: none;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary, button[type="submit"] {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 1px 3px rgba(147,51,234,.3);
}

.btn-primary:hover, button[type="submit"]:hover {
  box-shadow: 0 4px 12px rgba(147,51,234,.4);
  transform: translateY(-1px);
}

.btn-primary:active, button[type="submit"]:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: #cbd5e1;
  color: var(--accent-gradient);;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 10px 16px;
}

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  font-size: 13px;
  padding: 6px 14px;
}

.btn-lg {
  font-size: 15px;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: var(--radius-xs);
  font-size: 16px;
}

.btn-support {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  color: #fff;
  box-shadow: 0 1px 3px rgba(6,182,212,.3);
}

.btn-support:hover {
  box-shadow: 0 4px 12px rgba(6,182,212,.4);
  transform: translateY(-1px);
  color: #fff;
}

/* ===== FORMS ===== */
.form label {
  display: block;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form label .label-text {
  display: block;
  margin-bottom: 6px;
}

.form input[type="email"],
.form input[type="password"],
.form input[type="text"],
.form input[type="number"],
.form input[type="tel"],
.form select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color .15s, box-shadow .15s;
  margin-top: 6px;
}

.form input:focus, .form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(147,51,234,.12);
}

.form input::placeholder {
  color: var(--text-muted);
}

/* ===== FLASH / ALERTS ===== */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-xs);
  background: var(--accent-light);
  color: var(--accent-dark);
  border: 1px solid #c4b5fd;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.flash::before {
  content: 'ℹ';
  font-size: 16px;
  flex-shrink: 0;
}

.err {
  color: var(--danger);
  background: var(--danger-light);
  padding: 12px 16px;
  border-radius: var(--radius-xs);
  border: 1px solid #fecaca;
  font-size: 14px;
  margin: 8px 0;
}

.warn {
  color: #92400e;
  background: var(--warning-light);
  padding: 12px 16px;
  border-radius: var(--radius-xs);
  border: 1px solid #fde68a;
  font-size: 14px;
}

.ok {
  color: #065f46;
  background: var(--success-light);
  padding: 12px 16px;
  border-radius: var(--radius-xs);
  border: 1px solid #a7f3d0;
  font-size: 14px;
}

.muted {
  color: var(--text-muted);
  font-size: 14px;
}

.muted a { color: var(--accent); }

/* ===== LISTS ===== */
.list {
  list-style: none;
}

.list li {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}

.list li:last-child { border-bottom: none; }

.list li strong { color: var(--text); font-weight: 600; }

/* ===== PAYMENT GRID ===== */
.payment-grid {
  display: flex;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin: 16px 0 24px;
}

.payment-grid button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 14px 8px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all .15s;
}

.payment-grid button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(147,51,234,.12);
  transform: translateY(-1px);
  color: var(--accent);
}

.fk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-hover);
  border-radius: var(--radius-xs);
  margin-bottom: 8px;
}

.fk-row .fk-amount {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  min-width: 80px;
}

.fk-row .fk-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.fk-row .fk-buttons button {
  font-size: 13px;
  padding: 6px 16px;
}

/* ===== CODE ===== */
code {
  font-size: 13px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-hover);
  border: 1px solid var(--border-light);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  word-break: break-all;
}

/* ===== CHECKBOX ===== */
.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 12px 0;
}

.check input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--accent);
  width: 16px; height: 16px;
}

/* ===== AUTH PAGES (no sidebar) ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1145 0%, #2d1854 50%, #1a0e2e 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  top: -30%; right: -10%;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(147,51,234,.2) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.auth-page::after {
  content: '';
  position: absolute;
  bottom: -20%; left: -10%;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(109,40,217,.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 40px 32px;
  position: relative;
  z-index: 1;
}

.auth-card .auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.auth-card .auth-brand .brand-icon {
  width: 40px; height: 40px;
  flex-shrink: 0;
}

.auth-card .auth-brand .brand-icon img {
  width: 100%; height: 100%;
  border-radius: 12px;
}

.auth-card .auth-brand .brand-text {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}

.auth-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-card .lead {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.auth-actions button[type="submit"] {
  width: 100%;
  padding: 12px;
  font-size: 15px;
}

.auth-actions .btn-secondary {
  width: 100%;
  text-align: center;
  justify-content: center;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== FOOTER ===== */
.footer {
  padding: 24px 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border-light);
  margin-top: auto;
}

.footer a { color: var(--accent); }

/* ===== INLINE FORMS ===== */
.inline { display: inline; }
.inline button { margin: 3px 4px 3px 0; }

/* ===== STATS LIST (referral) ===== */
.stats-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.stats-list li {
  background: var(--surface-hover);
  border-radius: var(--radius-xs);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.stats-list li strong {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 260px;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(30,17,69,.4);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.3);
    z-index: 99;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main-area {
    margin-left: 0;
  }

  .hamburger {
    display: flex;
  }

  .content {
    padding: 20px 16px;
  }

  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }

  .topbar {
    padding: 0 16px;
  }

  .auth-card {
    padding: 28px 20px;
  }
}

@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .payment-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .fk-row {
    flex-wrap: wrap;
  }

  .fk-row .fk-buttons {
    margin-left: 0;
    width: 100%;
  }
}

/* ===== MISC ===== */
.lead { color: var(--text-secondary); font-size: 14px; margin-bottom: 16px; }

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 24px 0 12px;
}

.divider {
  height: 1px;
  background: var(--border-light);
  margin: 24px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-info { background: var(--accent-light); color: var(--accent-dark); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .5;
}

.empty-state p {
  font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}
