/* ============================================================
   TAMX Professional Trading Platform - Unified Design System
   Mobile-First | Dark Theme | RTL Arabic | Production Ready
   ============================================================ */

/* ====== Design Tokens ====== */
:root {
  /* Backgrounds */
  --bg-base: #070B1A;
  --bg-elevated: #0B1020;
  --bg-card: #111827;
  --bg-card-hover: #162033;
  --bg-input: #0F1626;

  /* Brand */
  --gold: #D4AF37;
  --gold-light: #F5D67A;
  --gold-dark: #A88A28;
  --gold-soft: rgba(212, 175, 55, 0.12);
  --gold-border: rgba(212, 175, 55, 0.20);
  --gold-border-strong: rgba(212, 175, 55, 0.40);

  /* Status */
  --success: #22C55E;
  --success-soft: rgba(34, 197, 94, 0.12);
  --success-border: rgba(34, 197, 94, 0.30);
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.30);
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.30);
  --info: #3B82F6;
  --info-soft: rgba(59, 130, 246, 0.12);
  --info-border: rgba(59, 130, 246, 0.30);

  /* Text */
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-faint: #475569;

  /* Borders */
  --border-default: rgba(148, 163, 184, 0.10);
  --border-subtle: rgba(148, 163, 184, 0.06);

  /* Radii */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 22px;
  --r-2xl: 28px;
  --r-full: 999px;

  /* Spacing scale (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* Shadows */
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-gold: 0 8px 24px rgba(212, 175, 55, 0.20);

  /* Z-index scale */
  --z-base: 1;
  --z-header: 50;
  --z-backdrop: 90;
  --z-sidebar: 100;
  --z-modal: 110;
  --z-toast: 120;

  /* Transitions */
  --t-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* App width on mobile */
  --app-max-width: 100%;
  --content-padding: var(--sp-4);
}

@media (min-width: 1024px) {
  :root {
    --content-padding: var(--sp-6);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) var(--bg-base);
}

body {
  font-family: 'Tajawal', 'IBM Plex Sans Arabic', 'Cairo', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
}

@supports (min-height: 100dvh) {
  body { min-height: 100dvh; }
}

body::-webkit-scrollbar { width: 6px; }
body::-webkit-scrollbar-track { background: var(--bg-base); }
body::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, 0.30); border-radius: 4px; }

img, svg, video { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; cursor: pointer; background: none; border: none; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
hr { border: none; height: 1px; background: var(--border-default); }

/* ====== App Layout ====== */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: rgba(7, 11, 26, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-default);
  padding-top: env(safe-area-inset-top);
}

.app-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--content-padding);
  max-width: 1280px;
  margin: 0 auto;
  min-height: 60px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
}

.app-brand__logo {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  /* Transparent — new TAMX logo has its own self-contained navy badge */
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.app-brand__logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.app-brand__name {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.app-main {
  flex: 1;
  padding: var(--sp-4) var(--content-padding);
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: calc(var(--sp-8) + env(safe-area-inset-bottom));
}

/* ====== Header Buttons ====== */
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--t-fast);
  flex-shrink: 0;
  position: relative;
}
.icon-btn:hover, .icon-btn:focus-visible {
  background: var(--gold-soft);
  border-color: var(--gold-border);
  color: var(--gold);
}
.icon-btn:active { transform: scale(0.95); }

.icon-btn--badge::after {
  content: attr(data-badge);
  position: absolute;
  top: -4px;
  left: -4px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid var(--bg-base);
}
.icon-btn--badge[data-badge="0"]::after,
.icon-btn--badge:not([data-badge])::after {
  display: none;
}

.lang-btn {
  height: 42px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 700;
  font-size: 13px;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.lang-btn:hover {
  background: var(--gold-soft);
  border-color: var(--gold-border);
}

/* ====== Cards ====== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}

.card--lg { padding: var(--sp-6); border-radius: var(--r-xl); }
.card--sm { padding: var(--sp-4); border-radius: var(--r-md); }
.card--hover { transition: all var(--t-fast); }
.card--hover:hover {
  border-color: var(--gold-border);
  background: var(--bg-card-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.card-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.card-title i { color: var(--gold); font-size: 16px; }

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: var(--sp-1);
}

/* ====== Section ====== */
.section {
  margin-bottom: var(--sp-5);
}
.section:last-child { margin-bottom: 0; }

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--sp-3);
  padding-right: var(--sp-1);
}

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 52px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
  position: relative;
  user-select: none;
}
.btn:disabled,
.btn[disabled],
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--bg-base);
  font-weight: 800;
}
.btn--primary:hover { box-shadow: var(--shadow-gold); transform: translateY(-1px); }
.btn--primary:active { transform: translateY(0); }

.btn--secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn--secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--gold-border);
  color: var(--gold-light);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-default);
}
.btn--ghost:hover {
  color: var(--gold);
  border-color: var(--gold-border);
  background: var(--gold-soft);
}

.btn--danger {
  background: linear-gradient(135deg, #DC2626, var(--danger));
  color: white;
}
.btn--danger:hover { box-shadow: 0 8px 24px rgba(239, 68, 68, 0.25); }

.btn--success {
  background: linear-gradient(135deg, #16A34A, var(--success));
  color: white;
}

.btn--block { width: 100%; }
.btn--sm { min-height: 40px; padding: 0 var(--sp-3); font-size: 13px; }
.btn--lg { min-height: 56px; padding: 0 var(--sp-6); font-size: 16px; }

/* Button group */
.btn-group {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.btn-group .btn { flex: 1; min-width: 0; }

/* ====== Forms ====== */
.field {
  margin-bottom: var(--sp-4);
}
.field:last-child { margin-bottom: 0; }

.field__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}
.field__label .req { color: var(--danger); }

.input,
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]),
.field select,
.field textarea {
  width: 100%;
  min-height: 52px;
  padding: 0 var(--sp-4);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 16px; /* prevents iOS zoom */
  font-family: inherit;
  transition: all var(--t-fast);
  outline: none;
}

.field textarea {
  padding: var(--sp-3) var(--sp-4);
  min-height: 110px;
  resize: vertical;
  line-height: 1.6;
}

.input::placeholder,
.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-faint);
}

.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
  background: var(--bg-card);
}

.input--error,
.field input.is-error {
  border-color: var(--danger);
}

.field__hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--sp-2);
  line-height: 1.5;
}
.field__error {
  font-size: 12px;
  color: var(--danger);
  margin-top: var(--sp-2);
  display: none;
}
.field.has-error .field__error { display: block; }

/* Input with icon */
.input-wrap {
  position: relative;
}
.input-wrap .input { padding-right: 48px; padding-left: 48px; }
.input-wrap__icon-right,
.input-wrap__icon-left {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}
.input-wrap__icon-right { right: var(--sp-4); }
.input-wrap__icon-left { left: var(--sp-4); pointer-events: auto; cursor: pointer; padding: var(--sp-2); }
.input-wrap__icon-left:hover { color: var(--gold); }

/* Checkbox / Radio */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  color: var(--text-secondary);
  min-height: 32px;
}
.checkbox input[type="checkbox"],
.checkbox input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--gold);
}

/* Select */
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2394A3B8'%3E%3Cpath d='M4.293 6.293a1 1 0 011.414 0L8 8.586l2.293-2.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left var(--sp-4) center;
  background-size: 16px;
  padding-left: var(--sp-10);
}

/* File input */
.file-upload {
  display: block;
  border: 2px dashed var(--border-default);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  text-align: center;
  cursor: pointer;
  transition: all var(--t-fast);
  background: var(--bg-input);
}
.file-upload:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.file-upload i {
  font-size: 28px;
  color: var(--gold);
  margin-bottom: var(--sp-2);
  display: block;
}
.file-upload__hint {
  font-size: 13px;
  color: var(--text-secondary);
}
.file-upload input[type="file"] { display: none; }
.file-upload__name {
  display: block;
  margin-top: var(--sp-2);
  font-size: 12px;
  color: var(--gold-light);
  word-break: break-all;
}

/* ====== Badges ====== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 800;
  border: 1px solid;
  white-space: nowrap;
  line-height: 1.2;
}
.badge--success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge--warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }
.badge--info    { background: var(--info-soft);    color: var(--info);    border-color: var(--info-border); }
.badge--gold    { background: var(--gold-soft);    color: var(--gold-light); border-color: var(--gold-border); }
.badge--neutral { background: rgba(148, 163, 184, 0.08); color: var(--text-secondary); border-color: var(--border-default); }

/* ====== Alerts ====== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid;
  margin-bottom: var(--sp-4);
}
.alert__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: 700; font-size: 14px; margin-bottom: var(--sp-1); }
.alert__text { font-size: 13px; line-height: 1.6; color: var(--text-secondary); }

.alert--success { background: var(--success-soft); border-color: var(--success-border); }
.alert--success .alert__icon { background: var(--success); color: white; }
.alert--success .alert__title { color: var(--success); }

.alert--warning { background: var(--warning-soft); border-color: var(--warning-border); }
.alert--warning .alert__icon { background: var(--warning); color: white; }
.alert--warning .alert__title { color: var(--warning); }

.alert--danger { background: var(--danger-soft); border-color: var(--danger-border); }
.alert--danger .alert__icon { background: var(--danger); color: white; }
.alert--danger .alert__title { color: var(--danger); }

.alert--info { background: var(--info-soft); border-color: var(--info-border); }
.alert--info .alert__icon { background: var(--info); color: white; }
.alert--info .alert__title { color: var(--info); }

.alert--gold { background: var(--gold-soft); border-color: var(--gold-border); }
.alert--gold .alert__icon { background: var(--gold); color: var(--bg-base); }
.alert--gold .alert__title { color: var(--gold-light); }

/* ====== Sidebar (Offcanvas drawer from RIGHT for RTL) ====== */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  width: 86%;
  max-width: 320px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--gold-border);
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.6);
  transform: translateX(100%);
  transition: transform var(--t-base);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  visibility: hidden;
}

.sidebar.open {
  transform: translateX(0);
  visibility: visible;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 2;
}

.sidebar__close {
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--t-fast);
}
.sidebar__close:hover { color: var(--danger); background: var(--danger-soft); }

.sidebar__user {
  padding: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  border-bottom: 1px solid var(--border-default);
}
.sidebar__avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 20px;
  flex-shrink: 0;
}
.sidebar__user-info { flex: 1; min-width: 0; }
.sidebar__user-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__user-email {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__nav {
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  flex: 1;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
  transition: all var(--t-fast);
  border: 1px solid transparent;
  min-height: 48px;
}
.sidebar__link i {
  width: 22px;
  text-align: center;
  color: var(--gold);
  font-size: 15px;
}
.sidebar__link:hover {
  background: var(--gold-soft);
  color: var(--gold-light);
}
.sidebar__link.active {
  background: linear-gradient(135deg, var(--gold-soft), transparent);
  border-color: var(--gold-border);
  color: var(--gold);
  font-weight: 700;
}
.sidebar__link .pill {
  margin-inline-start: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}
.sidebar__link.danger { color: #FCA5A5; }
.sidebar__link.danger i { color: var(--danger); }
.sidebar__link.danger:hover { background: var(--danger-soft); }

.sidebar__footer {
  padding: var(--sp-4);
  border-top: 1px solid var(--border-default);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* Desktop: sidebar always visible */
@media (min-width: 1024px) {
  .sidebar {
    position: sticky;
    top: 60px;
    right: auto;
    height: calc(100vh - 60px);
    width: 280px;
    max-width: 280px;
    transform: none;
    visibility: visible;
    box-shadow: none;
    border-left: 1px solid var(--border-default);
  }
  .sidebar__close { display: none; }
  .app-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    max-width: 1280px;
    margin: 0 auto;
  }
  .icon-btn[data-action="open-sidebar"],
  .icon-btn--menu {
    display: none !important;
  }
}

/* ====== Backdrop ====== */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: var(--z-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base), visibility var(--t-base);
}
.backdrop.show {
  opacity: 1;
  visibility: visible;
}

/* Body scroll lock */
body.menu-open,
body.modal-open {
  overflow: hidden;
  touch-action: none;
}

/* ====== Modal ====== */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  pointer-events: none;
  visibility: hidden;
}
.modal.open {
  visibility: visible;
  pointer-events: auto;
}

.modal__content {
  background: var(--bg-elevated);
  border: 1px solid var(--gold-border);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-5);
  padding-bottom: calc(var(--sp-5) + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform var(--t-base);
  box-shadow: var(--shadow-lg);
}
.modal.open .modal__content { transform: translateY(0); }

.modal__handle {
  width: 40px;
  height: 4px;
  background: var(--text-faint);
  border-radius: 2px;
  margin: 0 auto var(--sp-4);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border-default);
}
.modal__title {
  font-size: 17px;
  font-weight: 800;
  color: var(--gold-light);
}
.modal__close {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--t-fast);
}
.modal__close:hover { color: var(--danger); background: var(--danger-soft); }

@media (min-width: 640px) {
  .modal {
    align-items: center;
    padding: var(--sp-4);
  }
  .modal__content {
    border-radius: var(--r-2xl);
    transform: scale(0.95);
    opacity: 0;
    transition: transform var(--t-base), opacity var(--t-base);
  }
  .modal.open .modal__content { transform: scale(1); opacity: 1; }
  .modal__handle { display: none; }
}

/* ====== Modal safety overrides ====== */
/* Defensive fix: when a modal is open, force-hide the sidebar even if the JS
   Sidebar.close() call somehow did not run (race conditions, slow JS load, etc).
   This guarantees the modal sheet visually covers the full viewport on mobile. */
body.modal-open .sidebar {
  transform: translateX(100%) !important;
  visibility: hidden !important;
  box-shadow: none !important;
  pointer-events: none !important;
}

/* Also hide any stray sidebar shadow when modal is open                        */
body.modal-open .sidebar::before,
body.modal-open .sidebar::after {
  display: none !important;
}

/* Strengthen modal stacking context to ensure it always paints above sidebar */
.modal {
  isolation: isolate;
}

/* ----- Global anti-overflow safety net for mobile -----
   Some admin pages (notif panel, sidebar) can grow document scrollWidth past
   the viewport on small phones. That makes 100vw resolve to scrollWidth, which
   in turn made the modal overflow horizontally. We clamp html/body width and
   block horizontal scrolling site-wide so 100vw == real viewport width. */
html, body {
  max-width: 100% !important;
  overflow-x: hidden !important;
}

/* Notification dropdown (admin pages) — never overflow the viewport.
   The dropdown is inline-styled in JS (admin-app.js), but these rules use
   !important to override any inline width/right values on narrow screens.   */
.admin-notif-panel {
  max-width: calc(100vw - 16px) !important;
  box-sizing: border-box;
}
@media (max-width: 639px) {
  .admin-notif-panel {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
  }
}

/* Sidebar — when closed it sits offscreen via transform: translateX(100%).
   That transform still contributes to document scrollWidth, so on mobile
   we additionally pin it with right: -100% to keep it out of the layout.   */
.sidebar:not(.open) {
  right: -100% !important;
}

/* Make sure the modal__content always fills the viewport width on mobile.
   IMPORTANT: use 100% (parent .modal which is position:fixed inset:0 == real
   viewport), NOT 100vw. 100vw == html.scrollWidth which may exceed viewport
   if any descendant overflows horizontally.                                   */
@media (max-width: 639px) {
  .modal__content {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-radius: var(--r-2xl) var(--r-2xl) 0 0 !important;
    box-sizing: border-box;
  }
  /* The modal backdrop itself: pin to viewport via fixed inset:0           */
  .modal {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ====== Toast ====== */
.toast-container {
  position: fixed;
  top: calc(env(safe-area-inset-top) + var(--sp-4));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
  width: calc(100% - var(--sp-8));
  max-width: 420px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--gold-border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  pointer-events: auto;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
}
.toast.toast--success { border-color: var(--success-border); }
.toast.toast--success .toast__icon { color: var(--success); }
.toast.toast--error { border-color: var(--danger-border); }
.toast.toast--error .toast__icon { color: var(--danger); }
.toast.toast--warning { border-color: var(--warning-border); }
.toast.toast--warning .toast__icon { color: var(--warning); }
.toast__icon { font-size: 18px; flex-shrink: 0; }
.toast.removing { animation: toastOut 0.25s ease forwards; }

@keyframes toastIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateY(-20px); opacity: 0; }
}

/* ====== Empty State ====== */
.empty-state {
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
}
.empty-state__icon {
  width: 72px;
  height: 72px;
  border-radius: var(--r-full);
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: var(--sp-4);
}
.empty-state__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
}
.empty-state__text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 360px;
  margin: 0 auto var(--sp-4);
}

/* ====== Skeleton ====== */
.skeleton {
  background: linear-gradient(90deg,
    rgba(148, 163, 184, 0.05) 0%,
    rgba(148, 163, 184, 0.12) 50%,
    rgba(148, 163, 184, 0.05) 100%
  );
  background-size: 200% 100%;
  animation: skel 1.5s infinite;
  border-radius: var(--r-sm);
  display: block;
}
@keyframes skel {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ====== Stat Card ====== */
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.stat__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat__icon--gold { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-border); }
.stat__icon--success { background: var(--success-soft); color: var(--success); border: 1px solid var(--success-border); }
.stat__icon--info { background: var(--info-soft); color: var(--info); border: 1px solid var(--info-border); }
.stat__icon--danger { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.stat__body { flex: 1; min-width: 0; }
.stat__label { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-bottom: 2px; }
.stat__value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  word-break: break-word;
}

/* ====== Quick Actions Grid ====== */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}
@media (min-width: 480px) {
  .quick-actions { grid-template-columns: repeat(4, 1fr); }
}

.quick-action {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-3);
  text-align: center;
  transition: all var(--t-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  min-height: 100px;
}
.quick-action:hover {
  border-color: var(--gold-border);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}
.quick-action__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.quick-action__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.quick-action.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ====== Transaction / Notification Card ====== */
.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  transition: all var(--t-fast);
}
.item-card:hover { border-color: var(--gold-border); }
.item-card.unread {
  background: linear-gradient(135deg, var(--gold-soft), transparent);
  border-color: var(--gold-border);
}
.item-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.item-card__body { flex: 1; min-width: 0; }
.item-card__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.item-card__text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  word-break: break-word;
}
.item-card__meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.item-card__amount {
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}
.item-card__amount--in { color: var(--success); }
.item-card__amount--out { color: var(--danger); }

/* ====== Filters / Tabs ====== */
.filter-bar {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--sp-2);
  margin-bottom: var(--sp-4);
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-full);
  padding: var(--sp-2) var(--sp-4);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--t-fast);
  min-height: 38px;
}
.filter-chip:hover { color: var(--gold-light); }
.filter-chip.active {
  background: var(--gold-soft);
  border-color: var(--gold-border);
  color: var(--gold);
}

/* ====== Chat / Messages ====== */
.chat-window {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.msg {
  max-width: 80%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.msg--in {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-bottom-right-radius: 4px;
}
.msg--out {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--bg-base);
  border-bottom-left-radius: 4px;
  font-weight: 600;
}
.msg__time {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
  display: block;
}

/* ====== Utility classes ====== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-gold { color: var(--gold); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.flex { display: flex; gap: var(--sp-3); }
.flex-col { display: flex; flex-direction: column; gap: var(--sp-3); }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--sp-1) !important; }
.gap-2 { gap: var(--sp-2) !important; }
.gap-3 { gap: var(--sp-3) !important; }
.gap-4 { gap: var(--sp-4) !important; }

.grid { display: grid; gap: var(--sp-3); }
.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) {
  .grid-sm-2 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
  .grid-md-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-md-3 { grid-template-columns: repeat(3, 1fr); }
}

.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.divider { height: 1px; background: var(--border-default); margin: var(--sp-4) 0; }

/* Welcome card */
.welcome-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
  border: 1px solid var(--gold-border);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
}
.welcome-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, var(--gold-soft) 0%, transparent 70%);
  pointer-events: none;
}
.welcome-card__greeting {
  font-size: 13px;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: var(--sp-1);
}
.welcome-card__name {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
  position: relative;
}
.welcome-card__text {
  font-size: 13px;
  color: var(--text-secondary);
  position: relative;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== Auth page layout ====== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5) var(--sp-4);
  background:
    radial-gradient(ellipse at top, rgba(212, 175, 55, 0.08) 0%, transparent 50%),
    var(--bg-base);
}
.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: var(--r-2xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-lg);
}
.auth-card__logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: var(--sp-6);
}
.auth-card__logo-box {
  width: 72px;
  height: 72px;
  border-radius: var(--r-lg);
  /* Transparent — the new TAMX logo has its own navy badge background */
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-3);
  /* Soft gold halo behind the logo */
  filter: drop-shadow(0 6px 20px rgba(212, 175, 55, 0.28));
}
.auth-card__logo-box img {
  width: 100%;
  height: 100%;
  display: block;
}
.auth-card__title {
  font-size: 24px;
  font-weight: 900;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: var(--sp-1);
}
.auth-card__subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: var(--sp-5);
}
.auth-card__footer {
  text-align: center;
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-default);
  font-size: 13px;
  color: var(--text-secondary);
}
.auth-card__footer a { color: var(--gold); font-weight: 700; }

/* ====== Print ====== */
@media print {
  .sidebar, .app-header, .backdrop, .modal, .toast-container { display: none !important; }
  body { background: white; color: black; }
}

/* ====== Reduced motion ====== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ====== Focus ring ====== */
*:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ============================================================
   ADMIN PANEL EXTENSIONS
   Cards-on-mobile / Table-on-desktop, action sheets, MT5 modal
   ============================================================ */

/* Admin page header (title + subtitle + actions) */
.admin-page-head {
  margin-bottom: var(--sp-5);
}
.admin-page-head__title {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-1);
}
.admin-page-head__title i {
  color: var(--gold);
  font-size: 20px;
}
.admin-page-head__subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
@media (min-width: 640px) {
  .admin-page-head__title { font-size: 26px; }
}

/* Admin stats grid */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
@media (min-width: 640px) {
  .admin-stats { grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
}
@media (min-width: 1024px) {
  .admin-stats { grid-template-columns: repeat(6, 1fr); }
}

/* Search bar */
.search-bar {
  position: relative;
  margin-bottom: var(--sp-4);
}
.search-bar input {
  width: 100%;
  height: 46px;
  border-radius: var(--r-md);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  padding: 0 var(--sp-10) 0 var(--sp-4);
  font-size: 14px;
  font-family: inherit;
}
.search-bar input:focus {
  outline: none;
  border-color: var(--gold-border-strong);
  background: var(--bg-card);
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar__icon {
  position: absolute;
  top: 50%;
  inset-inline-end: var(--sp-4);
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 14px;
}

/* Filter chip strip - horizontal scroll on mobile */
.filter-strip {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-1) 0;
  margin-bottom: var(--sp-4);
  scrollbar-width: none;
}
.filter-strip::-webkit-scrollbar { display: none; }
.filter-strip .filter-chip {
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-chip__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin-inline-start: var(--sp-2);
  border-radius: var(--r-full);
  background: var(--bg-base);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
}
.filter-chip.active .filter-chip__count {
  background: var(--gold);
  color: var(--bg-base);
}

/* ====== Responsive list ======
   Mobile: card list (default)
   Desktop (>=1024px): proper table
*/
.responsive-list { width: 100%; }

/* Mobile card layout */
.user-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.user-card__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.user-card__avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
  flex-shrink: 0;
}
.user-card__id { flex: 1; min-width: 0; }
.user-card__name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-card__email {
  font-size: 12px;
  color: var(--text-secondary);
  direction: ltr;
  text-align: start;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-card__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2) var(--sp-3);
  font-size: 12px;
}
.user-card__field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.user-card__field-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.user-card__field-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-card__field-value[dir="ltr"] {
  text-align: start;
}
.user-card__foot {
  display: flex;
  gap: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
}
.user-card__foot .btn { flex: 1; }

/* Desktop table */
.data-table-wrap {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead {
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-default);
}
.data-table th {
  padding: var(--sp-3) var(--sp-4);
  text-align: start;
  font-weight: 800;
  color: var(--gold);
  font-size: 12px;
  white-space: nowrap;
}
.data-table td {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--bg-card-hover); }
.data-table .col-actions { width: 1%; white-space: nowrap; }
.data-table code {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg-base);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--gold-light);
  direction: ltr;
  display: inline-block;
}

@media (min-width: 1024px) {
  .user-card-list { display: none; }
  .data-table-wrap { display: block; }
}

/* Cards list on mobile only */
.user-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* ====== Action sheet (bottom on mobile, centered popover on desktop) ====== */
.action-sheet {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.action-sheet__btn {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  text-align: start;
  transition: all var(--t-fast);
  min-height: 52px;
}
.action-sheet__btn i {
  width: 22px;
  text-align: center;
  color: var(--gold);
  font-size: 16px;
  flex-shrink: 0;
}
.action-sheet__btn:hover {
  background: var(--gold-soft);
  border-color: var(--gold-border);
}
.action-sheet__btn.danger { color: #FCA5A5; }
.action-sheet__btn.danger i { color: var(--danger); }
.action-sheet__btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger-border);
}
.action-sheet__btn.success i { color: var(--success); }
.action-sheet__btn:disabled,
.action-sheet__btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ====== MT5 Modal — enforce mobile bottom-sheet and desktop centered modal ====== */
.modal--compact .modal__content {
  max-width: 420px;
  width: min(100%, 420px);
  margin-inline: auto;
}
@media (min-width: 640px) {
  .modal--compact .modal__content {
    width: 92vw;
    max-width: 420px;
  }
}

/* ====== Field rows ====== */
.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-3);
}
@media (min-width: 480px) {
  .field-row.field-row--2 { grid-template-columns: 1fr 1fr; }
  .field-row.field-row--3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ====== Audit Log entry (mobile card) ====== */
.audit-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.audit-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-3);
}
.audit-card__action {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13px;
  font-weight: 800;
  color: var(--gold-light);
}
.audit-card__action i {
  color: var(--gold);
  font-size: 12px;
}
.audit-card__time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 600;
}
.audit-card__meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-2) var(--sp-3);
  font-size: 12px;
}
@media (min-width: 480px) {
  .audit-card__meta { grid-template-columns: 1fr 1fr; }
}
.audit-card__meta-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
}
.audit-card__meta-value {
  color: var(--text-primary);
  font-weight: 600;
  word-break: break-all;
}
.audit-card__meta-value[dir="ltr"] {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--gold-light);
}
.audit-card__details-btn {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  width: 100%;
  text-align: center;
  transition: all var(--t-fast);
}
.audit-card__details-btn:hover {
  border-color: var(--gold-border);
  color: var(--gold);
}

/* ====== KYC document card ====== */
.kyc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
}
.kyc-card__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.kyc-card__doctype {
  flex: 1;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
}
.kyc-card__user {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: var(--sp-3);
}
.kyc-card__preview {
  display: block;
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  margin-bottom: var(--sp-3);
}
.kyc-card__actions {
  display: flex;
  gap: var(--sp-2);
}
.kyc-card__actions .btn { flex: 1; }

/* ====== Deposit / Withdrawal request card ====== */
.req-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
}
.req-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.req-card__amount {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold-light);
  direction: ltr;
}
.req-card__amount--out { color: #FCA5A5; }
.req-card__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
}
.req-card__field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.req-card__field-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.req-card__field-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.req-card__actions {
  display: flex;
  gap: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
}
.req-card__actions .btn { flex: 1; }

/* ====== Result block (e.g., MT5 credentials returned once) ====== */
.cred-block {
  background: var(--bg-input);
  border: 1px solid var(--gold-border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.cred-block__label {
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: var(--sp-1);
}
.cred-block__value {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  direction: ltr;
  word-break: break-all;
  flex: 1;
  padding: var(--sp-2);
  background: var(--bg-base);
  border-radius: var(--r-sm);
}
.cred-block__row {
  display: flex;
  gap: var(--sp-2);
  align-items: stretch;
}
.cred-block__copy {
  width: 44px;
  flex-shrink: 0;
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  border-radius: var(--r-sm);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
.cred-block__copy:hover {
  background: var(--gold);
  color: var(--bg-base);
}

/* ====== Section ====== */
.section { margin-bottom: var(--sp-5); }
.section:last-child { margin-bottom: 0; }

/* ====== Skeleton card ====== */
.user-card.is-loading > * {
  background: linear-gradient(90deg,
    rgba(148, 163, 184, 0.05) 0%,
    rgba(148, 163, 184, 0.12) 50%,
    rgba(148, 163, 184, 0.05) 100%
  );
  background-size: 200% 100%;
  animation: skel 1.5s infinite;
  color: transparent;
  border-radius: var(--r-sm);
}

/* ====== Status pill on user card ====== */
.user-status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 800;
  border-radius: var(--r-full);
  border: 1px solid;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.pagination__info { font-size: 12px; }
.pagination__controls {
  display: flex;
  gap: var(--sp-2);
}
.pagination__btn {
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  font-size: 13px;
}
.pagination__btn:hover:not(:disabled) {
  border-color: var(--gold-border);
  color: var(--gold);
}
.pagination__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Loading inline */
.loading-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-8) var(--sp-4);
  color: var(--text-secondary);
  font-size: 14px;
}
.loading-inline i {
  color: var(--gold);
  font-size: 20px;
}

/* Admin-only utility: form grid 2col on tablet */
.form-grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: 1fr;
}
@media (min-width: 540px) {
  .form-grid--2 { grid-template-columns: 1fr 1fr; }
}

/* Visually-hidden helper */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   Admin Chat layout
   Mobile: single-pane swap (list OR chat). Desktop: 2-column.
   ============================================================ */
.chat-layout {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: 1fr;
  align-items: stretch;
}
.chat-layout__list,
.chat-layout__pane {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 60vh;
  max-height: calc(100dvh - 200px);
}
.chat-layout__list-head,
.chat-layout__pane-head {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
}
.chat-layout__pane-head .icon-btn {
  margin-inline-start: auto;
}
.chat-layout__pane-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
}
.chat-layout__list-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2);
}
.chat-layout__pane-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.chat-layout__pane-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-default);
  background: var(--bg-card);
  flex-shrink: 0;
}
.chat-layout__composer {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-end;
}
.chat-layout__composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  font-family: inherit;
}

/* Chat room item in list */
.chat-room-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: var(--sp-2);
  transition: background 0.15s, border-color 0.15s;
  align-items: flex-start;
}
.chat-room-item:hover {
  background: var(--bg-input);
}
.chat-room-item.active {
  background: var(--gold-soft);
  border-color: var(--gold-border, var(--gold));
}
.chat-room-item__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-input);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}
.chat-room-item__body {
  flex: 1;
  min-width: 0;
}
.chat-room-item__top {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  align-items: baseline;
  margin-bottom: 2px;
}
.chat-room-item__name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.chat-room-item__time {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.chat-room-item__preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-room-item__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 4px;
}
.chat-room-item__unread {
  background: var(--gold);
  color: var(--bg-base);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* Empty/placeholder state inside chat pane */
.chat-pane-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  padding: var(--sp-6);
  gap: var(--sp-3);
}
.chat-pane-empty i {
  font-size: 48px;
  color: var(--text-muted);
  opacity: 0.5;
}

/* System message style */
.msg--sys {
  align-self: center;
  background: var(--bg-input);
  border: 1px dashed var(--border-default);
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  max-width: 90%;
  text-align: center;
}

/* Mobile: single-pane swap */
@media (max-width: 1023px) {
  .chat-layout[data-view="list"] .chat-layout__pane { display: none; }
  .chat-layout[data-view="pane"] .chat-layout__list { display: none; }
  .chat-layout__list,
  .chat-layout__pane {
    max-height: calc(100dvh - 180px);
  }
}

/* Desktop: 2-column */
@media (min-width: 1024px) {
  .chat-layout {
    grid-template-columns: 320px 1fr;
    max-width: 100%;
  }
  .chat-layout__pane-back { display: none; }
}
