/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #242736;
  --border:    #2e3248;
  --accent:    #6c63ff;
  --accent-h:  #5a52e0;
  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --text:      #e2e8f0;
  --muted:     #8892a4;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

html { font-size: 16px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 0 20px 24px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.sidebar-logo .logo-icon { font-size: 1.5rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--muted);
  font-size: .93rem;
  border-radius: 0;
  transition: background .15s, color .15s;
}
.nav-item:hover, .nav-item.active {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active { border-left: 3px solid var(--accent); }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 1.1rem; }

.sidebar-bottom {
  margin-top: auto;
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
}
.user-info { font-size: .85rem; color: var(--muted); padding: 8px 0; }
.user-info strong { color: var(--text); display: block; }

.main-content {
  flex: 1;
  padding: 32px 40px;
  max-width: 960px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 16px;
  font-size: .8rem;
}
.card h2 { font-size: 1.4rem; margin-bottom: 8px; }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-paid   .stat-value { color: var(--green); }
.stat-free   .stat-value { color: var(--accent); }
.stat-total  .stat-value { color: var(--text); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: .93rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; color: var(--text); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger  { background: var(--red);   color: #fff; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-sm { padding: 6px 14px; font-size: .83rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .87rem; color: var(--muted); margin-bottom: 6px; }
.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-error { color: var(--red); font-size: .83rem; margin-top: 4px; }
.form-hint  { color: var(--muted); font-size: .82rem; margin-top: 4px; }

/* file input */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.file-drop:hover, .file-drop.dragover {
  border-color: var(--accent);
  background: rgba(108,99,255,.06);
}
.file-drop input[type=file] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.file-drop-icon { font-size: 2.5rem; margin-bottom: 8px; }
.file-drop-text { color: var(--muted); font-size: .9rem; }
.file-drop-text strong { color: var(--accent); }

/* ── Auth pages ── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow);
}
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo .icon { font-size: 3rem; margin-bottom: 8px; }
.auth-logo h1 { font-size: 1.4rem; font-weight: 700; }
.auth-logo p  { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.auth-divider {
  text-align: center;
  color: var(--muted);
  font-size: .83rem;
  margin: 20px 0;
  position: relative;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }
.auth-footer { text-align: center; margin-top: 20px; color: var(--muted); font-size: .87rem; }

/* code input */
.code-input {
  font-size: 2rem !important;
  font-weight: 700;
  letter-spacing: .3em;
  text-align: center;
  padding: 16px !important;
}

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: #86efac; }
.alert-error   { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.alert-info    { background: rgba(108,99,255,.12); border: 1px solid rgba(108,99,255,.3); color: #a5b4fc; }
.alert-warning { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.3); color: #fcd34d; }

/* ── Packages ── */
.packages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.package-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: border-color .2s;
  position: relative;
}
.package-card:hover { border-color: var(--accent); }
.package-card.featured { border-color: var(--accent); }
.package-badge {
  position: absolute;
  top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff;
  font-size: .7rem; font-weight: 700;
  padding: 2px 10px; border-radius: 20px;
  white-space: nowrap;
}
.package-limits { font-size: 2rem; font-weight: 700; color: var(--green); }
.package-name   { color: var(--muted); font-size: .85rem; margin-bottom: 12px; }
.package-price  { font-size: 1.3rem; font-weight: 600; margin-bottom: 16px; }

/* ── History ── */
.session-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.session-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s;
}
.session-card:hover { border-color: var(--accent); }
.session-thumb {
  width: 100%; aspect-ratio: 1/1;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 2rem;
  overflow: hidden;
}
.session-thumb img { width: 100%; height: 100%; object-fit: cover; }
.session-meta { padding: 12px; font-size: .82rem; color: var(--muted); }
.session-meta strong { color: var(--text); display: block; margin-bottom: 4px; }

/* ── Result image ── */
.result-wrap { text-align: center; }
.result-wrap img {
  max-width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Quality selector ── */
.quality-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
.quality-option { display: none; }
.quality-label {
  display: block;
  text-align: center;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: .87rem;
  transition: border-color .15s, background .15s;
}
.quality-option:checked + .quality-label {
  border-color: var(--accent);
  background: rgba(108,99,255,.1);
  color: var(--accent);
}

/* ── Page header ── */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; }
.page-header p   { color: var(--muted); margin-top: 4px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap;
    padding: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-logo { padding: 0 12px 0 0; border: none; margin: 0; font-size: 1rem; }
  .nav-item { padding: 8px 12px; font-size: .8rem; }
  .nav-item.active { border-left: none; border-bottom: 2px solid var(--accent); }
  .sidebar-bottom { display: none; }
  .main-content { padding: 20px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .packages-grid { grid-template-columns: repeat(2, 1fr); }
  .quality-grid { grid-template-columns: 1fr; }
}