/* DNZ Gateway — خفيف، RTL، بدون خطوط خارجية */
:root {
  --bg: #060b14;
  --bg-elevated: #0f1729;
  --surface: #111827;
  --surface-hover: #1a2130;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #f1f5f9;
  --muted: #8b9aaf;
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.14);
  --accent-text: #041018;
  --success: #4ade80;
  --success-bg: rgba(74, 222, 128, 0.12);
  --danger: #fb7185;
  --danger-bg: rgba(251, 113, 133, 0.1);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.1);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --sidebar-w: 258px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  direction: inherit;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.lang-switch {
  position: fixed;
  top: 0.85rem;
  inset-inline-end: 0.85rem;
  z-index: 2500;
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(15, 18, 25, 0.9);
  box-shadow: var(--shadow);
}
.lang-switch button {
  border: 0;
  border-radius: 999px;
  padding: 0.32rem 0.65rem;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.lang-switch button.active {
  background: var(--accent);
  color: var(--accent-text);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* ——— Toast ——— */
#flash-host {
  position: fixed;
  top: 1rem;
  inset-inline: 0.75rem;
  z-index: 2000;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
#flash-host > * {
  pointer-events: auto;
  max-width: min(520px, 100%);
}

.flash {
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-strong);
  background: var(--surface);
}
.flash.error {
  border-color: rgba(251, 113, 133, 0.35);
  background: var(--danger-bg);
  color: #fecdd3;
}
.flash.ok {
  border-color: rgba(74, 222, 128, 0.35);
  background: var(--success-bg);
  color: #bbf7d0;
}

/* ——— Auth ——— */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(56, 189, 248, 0.18), transparent),
    var(--bg);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}
.auth-brand .logo-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.75rem;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--bg);
}
.auth-brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}
.auth-brand p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ——— App shell ——— */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}

.sidebar {
  background: var(--bg-elevated);
  border-inline-start: 1px solid var(--border);
  padding: 1.25rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (max-width: 880px) {
  .sidebar {
    border-inline-start: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.75rem 1rem;
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.5rem 1rem;
  margin-bottom: 0.25rem;
}
@media (max-width: 880px) {
  .sidebar-brand {
    flex: 1 1 auto;
    padding-bottom: 0.5rem;
    margin-bottom: 0;
  }
}
.sidebar-brand .logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--bg);
  flex-shrink: 0;
}
.sidebar-brand .titles {
  min-width: 0;
}
.sidebar-brand strong {
  display: block;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}
.sidebar-brand span {
  font-size: 0.75rem;
  color: var(--muted);
}

.nav-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding: 0.5rem 0.65rem 0.35rem;
}
@media (max-width: 880px) {
  .nav-label {
    display: none;
  }
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: start;
  padding: 0.65rem 0.85rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.nav-item .ni {
  font-size: 1.05rem;
  opacity: 0.9;
  width: 1.35rem;
  text-align: center;
}

.sidebar-spacer {
  flex: 1;
  min-height: 0.5rem;
}

.sidebar-foot {
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}
.sidebar-foot .wa {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(37, 211, 102, 0.12);
  color: #86efac;
  border: 1px solid rgba(37, 211, 102, 0.25);
  font-size: 0.88rem;
  font-weight: 600;
}
.sidebar-foot .wa:hover {
  background: rgba(37, 211, 102, 0.2);
  text-decoration: none;
}

.btn-logout {
  margin-top: 0.5rem;
  width: 100%;
  padding: 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-logout:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

/* ——— Main ——— */
.shell-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 18, 25, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.toolbar h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.toolbar .user-email {
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  padding: 1.25rem 1.5rem 2rem;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
}

.view {
  animation: fadeIn 0.22s var(--ease);
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  margin-bottom: 1.25rem;
}
.page-head h1 {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-head .sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ——— Cards & forms ——— */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
}
.panel h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  margin-bottom: 0.85rem;
  transition: border-color 0.15s var(--ease);
}
input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.45);
}
textarea {
  min-height: 88px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: filter 0.15s var(--ease), transform 0.1s var(--ease);
}
.btn:active {
  transform: scale(0.98);
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7dd3fc);
  color: var(--accent-text);
}
.btn-primary:hover {
  filter: brightness(1.06);
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}
.stats-row.stats-row-5,
.stats-row.stats-row-6 {
  grid-template-columns: repeat(3, 1fr);
}
@media (min-width: 1200px) {
  .stats-row.stats-row-5 {
    grid-template-columns: repeat(5, 1fr);
  }
  .stats-row.stats-row-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 1100px) {
  .stats-row.stats-row-5,
  .stats-row.stats-row-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 900px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-row.stats-row-5,
  .stats-row.stats-row-6 {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 640px) {
  .stats-row {
    grid-template-columns: 1fr;
  }
}

.stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
}
.stat-box .k {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.stat-box .v {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.banner.error {
  background: var(--danger-bg);
  border: 1px solid rgba(251, 113, 133, 0.3);
  color: #fecdd3;
}
.banner.ok {
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: #a7f3d0;
}

.withdraw-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal.hidden {
  display: none !important;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}
.modal-card {
  position: relative;
  width: min(480px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.checkout-preview {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  word-break: break-all;
  font-size: 0.82rem;
}
.checkout-preview a {
  color: var(--accent);
}

/* ——— Links grid ——— */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.link-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.link-card:hover {
  border-color: rgba(56, 189, 248, 0.25);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.08);
}
.link-card .title {
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
  line-height: 1.35;
}
.link-card .meta {
  font-size: 0.82rem;
  color: var(--muted);
}
.link-card .desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-card .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.25rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
}
.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

/* ——— Table ——— */
.table-wrap {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: auto;
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
th,
td {
  padding: 0.65rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-elevated);
}
tr:last-child td {
  border-bottom: none;
}
tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge.ok {
  background: var(--success-bg);
  color: var(--success);
}
.badge.fail {
  background: var(--danger-bg);
  color: #fecdd3;
}
.badge.pending {
  background: var(--warn-bg);
  color: var(--warn);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.auth-toggle {
  width: 100%;
  margin-top: 0.75rem;
}
