:root {
  --bg: #0b0f1a;
  --surface: #121826;
  --surface-2: #1a2233;
  --border: #232c40;
  --text: #eaf0f6;
  --muted: #8b96ac;
  --accent: #31e1c9;
  --accent-dim: #1c8f81;
  --amber: #f5b942;
  --danger: #ff6b6b;
  --radius: 14px;
  --radius-sm: 9px;
  --font-display: 'Cairo', 'Inter', sans-serif;
  --font-body: 'Inter', 'Cairo', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html[dir="rtl"] {
  --font-body: 'Tajawal', 'Cairo', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 20% 0%, #101a2b 0%, var(--bg) 45%);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0 0 4px; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.center { text-align: center; }
.center-text { text-align: center; }
.hidden { display: none !important; }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 24, 38, 0.6);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.2px;
}
.top-actions { display: flex; align-items: center; gap: 10px; }

.container { max-width: 1120px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, filter 0.12s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #06201c; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 20px; font-size: 15.5px; }

/* ---------- Cards / layout ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card {
  background: linear-gradient(180deg, var(--surface) 0%, #0f1523 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-num { font-family: var(--font-display); font-size: 28px; font-weight: 800; color: var(--accent); }
.stat-label { color: var(--muted); font-size: 13px; }

/* ---------- Dropzone / upload ---------- */
.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  padding: 20px;
}
.dropzone.drag-over { border-color: var(--accent); background: rgba(49, 225, 201, 0.06); }
.dz-idle { text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dz-idle p { font-size: 14px; }
.dz-progress { width: 100%; }
.progress-track { height: 8px; background: var(--surface-2); border-radius: 20px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--amber)); transition: width 0.15s ease; }
.progress-meta { display: flex; justify-content: space-between; margin-top: 10px; font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--muted); }
.form input, .form-inline input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  outline: none;
}
.form input:focus, .form-inline input:focus { border-color: var(--accent); }
.form-inline { display: flex; gap: 10px; }
.form-inline input { flex: 1; }

.alert-error {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin: 12px 0;
}

/* ---------- Tables ---------- */
.table-wrap, .mini-table-wrap { overflow-x: auto; margin-top: 8px; }
.files-table, .mini-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.files-table th, .files-table td, .mini-table th, .mini-table td {
  padding: 12px 10px;
  text-align: start;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.files-table th, .mini-table th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; }
.file-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.code-chip {
  font-family: var(--font-mono);
  background: var(--surface-2);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--accent);
}
.search-input { max-width: 220px; }

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  margin-inline-end: 4px;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Lang switch ---------- */
.lang-switch {
  position: fixed;
  top: 18px;
  inset-inline-end: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
  z-index: 20;
}
.lang-switch:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Auth / public pages ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-wrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.vault-mark { filter: drop-shadow(0 0 14px rgba(49, 225, 201, 0.35)); }
.auth-card {
  width: 100%;
  background: linear-gradient(180deg, var(--surface) 0%, #0f1523 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px;
}
.auth-card h2 { text-align: center; }
.auth-card .muted { display: block; text-align: center; margin-bottom: 18px; font-size: 13.5px; }
.auth-footnote { color: var(--muted); font-size: 12px; }

/* ---------- Download landing page ---------- */
.dl-card { text-align: center; }
.file-icon { font-size: 40px; margin-bottom: 8px; }
.file-title { font-size: 18px; word-break: break-word; }
.safe-badge { color: var(--accent); }
.eta-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; margin: 18px 0; }
.eta-row { display: flex; justify-content: space-between; font-size: 14px; }
.eta-row strong { color: var(--accent); font-family: var(--font-mono); }

.scan-state { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 20px 0; }
.scan-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 30px;
  font-size: 13.5px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr; }
  .topbar { padding: 14px 16px; }
}
