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

:root {
  --bg:      #0a0e1a;
  --bg2:     #111827;
  --accent:  #6c63ff;
  --accent2: #a78bfa;
  --text:    #f1f5f9;
  --muted:   #94a3b8;
  --card:    #1e2535;
  --border:  #2d3748;
  --radius:  12px;
  --sidebar: 220px;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-layout.no-sidebar .sidebar { display: none; }
.app-layout.no-sidebar .content { padding: 0; }

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar);
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo span { color: var(--accent); }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(108,99,255,0.1); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(108,99,255,0.18); color: var(--accent2); }
.nav-item svg { flex-shrink: 0; opacity: 0.8; }

.sidebar-user {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.user-email {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Main content ─────────────────────────────────────── */

.content {
  flex: 1;
  margin-left: var(--sidebar);
  min-height: 100vh;
  padding: 32px;
}

.page { max-width: 960px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.page-loader {
  color: var(--muted);
  padding: 60px 32px;
  text-align: center;
}

/* ── Cards ───────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* ── Buttons ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
}
.btn:hover { opacity: 0.88; text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-full     { width: 100%; justify-content: center; }
.btn-sm       { padding: 6px 14px; font-size: 0.82rem; }

.btn-logout {
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-logout:hover { border-color: #e05; color: #f87; }

/* ── Login ───────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 28px;
}
.login-logo span { color: var(--accent); }

.login-card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
}

.login-footer {
  text-align: center;
  margin-top: 18px;
  font-size: 0.83rem;
  color: var(--muted);
}

/* ── Forms ───────────────────────────────────────────── */

.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}
input[type="email"],
input[type="password"],
input[type="text"],
select {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }
select { cursor: pointer; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  padding: 0;
  border: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.form-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(220,50,50,0.12);
  border: 1px solid rgba(220,50,50,0.3);
  border-radius: 8px;
  color: #f87171;
  font-size: 0.85rem;
}

/* ── Stats grid ──────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card { text-align: center; padding: 20px; }

.accent-card {
  background: linear-gradient(135deg, rgba(108,99,255,0.25), rgba(167,139,250,0.15));
  border-color: rgba(108,99,255,0.4);
}

.stat-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.accent-card .stat-value { color: var(--accent2); }
.stat-unit  { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

/* ── Section row ─────────────────────────────────────── */

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-row h2 { font-size: 1rem; font-weight: 600; }
.link-more { font-size: 0.82rem; color: var(--accent2); }

/* ── Table ───────────────────────────────────────────── */

.table-card { padding: 0; overflow: hidden; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th {
  text-align: left;
  padding: 12px 24px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.data-table td {
  padding: 12px 24px;
  border-bottom: 1px solid rgba(45,55,72,0.5);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.table th {
  text-align: left;
  padding: 12px 16px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(45,55,72,0.5);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,0.02); }

.td-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-date { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

/* ── Status badges ───────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-pending    { background: rgba(148,163,184,0.15); color: var(--muted); }
.badge-processing { background: rgba(251,191,36,0.15);  color: #fbbf24; }
.badge-done       { background: rgba(52,211,153,0.15);  color: #34d399; }
.badge-failed     { background: rgba(248,113,113,0.15); color: #f87171; }

/* ── Spinner ─────────────────────────────────────────── */

@keyframes spin { to { transform: rotate(360deg); } }

.spinner-xs {
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid rgba(251,191,36,0.3);
  border-top-color: #fbbf24;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Upload ──────────────────────────────────────────── */

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(108,99,255,0.05);
}
.dropzone.has-file { border-color: rgba(52,211,153,0.5); background: rgba(52,211,153,0.04); }

.dropzone-icon { color: var(--muted); margin-bottom: 14px; display: flex; justify-content: center; }
.dropzone-text { font-size: 0.95rem; font-weight: 500; margin-bottom: 6px; }
.dropzone-sub  { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.dropzone-formats { font-size: 0.75rem; color: var(--border); letter-spacing: 0.03em; }

.link-choose { color: var(--accent2); cursor: pointer; }

.file-info {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.file-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}
.file-info-row svg { color: var(--accent2); flex-shrink: 0; }
.file-size { margin-left: auto; color: var(--muted); font-size: 0.8rem; }

.params-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 18px; }

.upload-progress {
  margin-top: 14px;
}
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  transition: width 0.3s ease;
}
#progress-text { font-size: 0.82rem; color: var(--muted); }

/* ── Empty state ─────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}
.empty-state p { margin-bottom: 20px; }

/* ── Error ───────────────────────────────────────────── */

.error-msg {
  color: #f87171;
  padding: 20px;
  background: rgba(248,113,113,0.08);
  border-radius: 8px;
}
.error-hint { color: #f87171; font-size: 0.8rem; white-space: normal; line-height: 1.35; }

/* ── Download button ─────────────────────────────────── */

.btn-download {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(52,211,153,0.12);
  color: #34d399;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-download:hover { background: rgba(52,211,153,0.22); color: #34d399; text-decoration: none; }

/* ── Billing ─────────────────────────────────────────── */

.balance-card {
  background: linear-gradient(135deg, rgba(108,99,255,0.2), rgba(167,139,250,0.1));
  border-color: rgba(108,99,255,0.35);
}
.balance-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.balance-value { font-size: 2.8rem; font-weight: 700; color: var(--accent2); line-height: 1; }
.balance-unit  { font-size: 1.1rem; font-weight: 400; color: var(--muted); }
.balance-hint  { margin-top: 10px; font-size: 0.82rem; color: var(--muted); }

.plans-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 4px;
}

.plan-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 16px 16px;
}
.plan-popular { border-color: rgba(108,99,255,0.5); }

.plan-badge {
  position: absolute;
  top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
  white-space: nowrap;
}
.plan-name   { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.plan-price  { font-size: 1.6rem; font-weight: 700; margin: 2px 0; }
.plan-minutes{ font-size: 0.9rem; color: var(--text); font-weight: 600; }
.plan-rate   { font-size: 0.75rem; color: var(--muted); margin-bottom: 12px; }

/* ── Mobile ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    min-height: auto;
    height: 56px;
    flex-direction: row;
    top: auto; bottom: 0; left: 0; right: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 100;
  }
  .sidebar-logo { display: none; }
  .sidebar-user  { display: none; }
  .sidebar-nav {
    flex-direction: row;
    padding: 0;
    width: 100%;
    justify-content: space-around;
    gap: 0;
  }
  .nav-item {
    flex-direction: column;
    gap: 3px;
    padding: 8px 4px;
    font-size: 0.68rem;
    border-radius: 0;
    flex: 1;
    justify-content: center;
    text-align: center;
  }
  .content {
    margin-left: 0;
    padding: 20px 16px 80px;
  }
  .stats-grid     { grid-template-columns: 1fr 1fr; }
  .upload-grid    { grid-template-columns: 1fr; }
  .plans-grid     { grid-template-columns: 1fr; }
  .table-card     { overflow-x: auto; }
}
