﻿
:root {
  --navy: #0f2b4f;
  --navy-2: #163a66;
  --gold: #d6a23a;
  --gold-soft: #f8edd1;
  --ice: #f4f7fb;
  --ink: #1f2937;
  --muted: #6b7280;
  --success: #1f9d63;
  --danger: #d64545;
  --warning: #c98216;
  --shadow: 0 24px 50px rgba(15, 23, 42, 0.12);
  --radius: 18px;
  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 16px;
  --space-lg: 22px;
  --space-xl: 28px;
  --body-pad: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: 'Vazirmatn', 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.75;
  font-weight: 500;
  font-feature-settings: 'ss01', 'ss02';
  text-rendering: optimizeLegibility;
  background: radial-gradient(circle at 20% 20%, rgba(214, 162, 58, 0.12), transparent 28%),
    radial-gradient(circle at 80% 30%, rgba(22, 58, 102, 0.12), transparent 30%),
    radial-gradient(circle at 65% 80%, rgba(15, 43, 79, 0.08), transparent 30%),
    #f9fbff;
  color: var(--ink);
  direction: rtl;
  padding: var(--body-pad);
  overflow: hidden;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

input,
select,
textarea {
  line-height: 1.4;
}

::placeholder {
  color: rgba(107, 114, 128, 0.8);
}

#root {
  max-width: 1520px;
  margin: 0 auto;
  width: min(96vw, 1520px);
  height: calc(100% - (var(--body-pad) * 2));
}

a {
  color: inherit;
  text-decoration: none;
}

.card h3 {
  margin: 18px 0 12px;
  color: var(--navy);
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 11px 18px;
  min-height: 44px;
  font-weight: 600;
  letter-spacing: -0.1px;
  cursor: pointer;
  transition: 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--navy-2), var(--navy));
  color: #fff;
}

.btn.secondary {
  background: #ecf1f8;
  color: var(--navy);
}

.btn.success {
  background: linear-gradient(135deg, #23b26b, #1f9d63);
  color: #fff;
}

.btn.danger {
  background: linear-gradient(135deg, #e05757, #d64545);
  color: #fff;
}

.btn.outline {
  border: 1px solid #d1d5db;
  background: transparent;
  color: var(--navy);
}

.btn.light {
  background: rgba(255, 255, 255, 0.92);
  color: var(--navy);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.notice-stack {
  position: fixed;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  z-index: 40;
  max-width: 360px;
  width: min(92vw, 360px);
  pointer-events: none;
}

.notice-stack .notice {
  pointer-events: all;
}

.notice {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 12px 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.notice.clickable {
  cursor: pointer;
}

.notice-content {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.notice-meta {
  display: grid;
  gap: 4px;
}

.notice-meta strong {
  font-weight: 800;
  color: var(--navy);
}

.notice-meta span {
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.93rem;
}

.notice-close {
  border: none;
  background: rgba(15, 23, 42, 0.05);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--navy);
}

.notice.success {
  border-color: rgba(34, 197, 94, 0.4);
}

.notice.warning {
  border-color: rgba(245, 158, 11, 0.5);
  border-right: 4px solid #f59e0b;
}

.notice.danger {
  border-color: rgba(239, 68, 68, 0.4);
}

.notice-timer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--navy));
  transform-origin: right center;
  animation: notice-progress var(--notice-duration, 10000ms) linear forwards;
}

@keyframes notice-progress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}
.landing {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 28px;
  align-items: center;
  min-height: 70vh;
}

.hero-panel {
  background: rgba(255, 255, 255, 0.88);
  border-radius: 28px;
  padding: 36px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(15, 43, 79, 0.08);
  display: grid;
  gap: 18px;
}

.hero-panel h1 {
  margin: 0;
  font-size: 2.4rem;
  color: var(--navy);
}

.hero-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.hero-badge {
  display: inline-flex;
  padding: 6px 12px;
  background: var(--gold-soft);
  color: #8a640c;
  border-radius: 999px;
  font-weight: 700;
  width: fit-content;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.95rem;
  color: var(--muted);
}

.portal-grid {
  display: grid;
  gap: 16px;
}

.portal-card {
  background: #fff;
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 43, 79, 0.08);
  display: grid;
  gap: 10px;
}

.portal-card h3 {
  margin: 0;
  font-size: 1.2rem;
}

.portal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.portal-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 22px;
}

.portal-icon.gold {
  background: var(--gold-soft);
  color: var(--gold);
}

.portal-icon.navy {
  background: rgba(15, 43, 79, 0.12);
  color: var(--navy);
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100%;
  height: 100%;
}

.auth-shell.wide {
  width: min(1200px, 96vw);
  margin: 0 auto;
  place-items: stretch;
}

.auth-card {
  width: min(460px, 94vw);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.88));
  border-radius: 28px;
  padding: 32px 30px;
  box-shadow: 0 30px 54px rgba(15, 23, 42, 0.2);
  display: grid;
  gap: 14px;
  text-align: center;
  border: 1px solid rgba(15, 23, 42, 0.08);
  position: relative;
  backdrop-filter: blur(12px);
}

.auth-card.compact {
  width: 100%;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  text-align: right;
}

.auth-card.compact::before {
  display: none;
}

.auth-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 28px;
  background: linear-gradient(130deg, rgba(214, 162, 58, 0.08), rgba(15, 43, 79, 0.04), transparent 62%);
  pointer-events: none;
}

.auth-card > * {
  position: relative;
  z-index: 1;
}

.customer-auth {
  border-color: rgba(214, 162, 58, 0.22);
}

.admin-auth {
  border-color: rgba(15, 43, 79, 0.24);
}

.login-page {
  position: relative;
  overflow: hidden;
  border-radius: 0;
  min-height: calc(100vh - (var(--body-pad) * 2));
  height: calc(100vh - (var(--body-pad) * 2));
  background: #ffffff;
  border: none;
  padding: 36px 38px 28px;
  margin: calc(-1 * var(--body-pad));
  width: calc(100% + (var(--body-pad) * 2));
}

.login-bg-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
}

.login-bg-orb.orb-1 {
  width: 420px;
  height: 420px;
  top: -170px;
  right: -130px;
  background: radial-gradient(circle, rgba(214, 162, 58, 0.28), rgba(214, 162, 58, 0));
}

.login-bg-orb.orb-2 {
  width: 480px;
  height: 480px;
  left: -170px;
  bottom: -230px;
  background: radial-gradient(circle, rgba(15, 43, 79, 0.22), rgba(15, 43, 79, 0));
}

.login-bg-orb.orb-3 {
  width: 300px;
  height: 300px;
  top: 42%;
  right: 36%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0));
}

.login-page.admin {
  background: linear-gradient(140deg, #e9eef7 0%, #f6f9ff 52%, #edf3fe 100%);
}

.login-stage {
  width: min(540px, 96vw);
  display: grid;
  gap: 14px;
  justify-items: center;
  position: relative;
  z-index: 1;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 48px;
  align-items: center;
}

.login-hero {
  display: grid;
  gap: 18px;
  align-content: center;
  text-align: center;
  justify-items: center;
}

.hero-badge {
  align-self: center;
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  color: #0f2b4f;
  font-weight: 600;
  font-size: 0.92rem;
  background: #fff;
}

.login-hero h1 {
  margin: 0;
  font-size: 2.2rem;
  color: var(--navy);
  line-height: 1.4;
}

.login-hero p {
  margin: 0;
  color: #4b5563;
  max-width: 520px;
}

.hero-illustration {
  background: transparent;
  border-radius: 24px;
  padding: 8px;
  border: none;
  box-shadow: none;
  display: flex;
  justify-content: center;
}

.hero-illustration svg {
  width: 100%;
  height: auto;
  max-width: 520px;
}

.login-form-panel {
  background: transparent;
  border-radius: 22px;
  padding: 12px 8px;
  box-shadow: none;
  border: none;
  display: grid;
  gap: 18px;
  text-align: right;
  justify-items: stretch;
  max-width: 360px;
  width: 100%;
  justify-self: center;
}

.login-lang {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 2;
}

.lang-button {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
  color: #1f2937;
}

.lang-button i {
  font-size: 0.85rem;
  color: #64748b;
}

.lang-flag {
  font-size: 1.1rem;
}

.login-mark {
  font-size: 2.6rem;
  font-weight: 700;
  color: #355cff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  align-self: flex-start;
}

.login-mark img {
  max-height: 64px;
  max-width: 140px;
  object-fit: contain;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--navy);
}

.login-brand span {
  font-size: 0.9rem;
  color: var(--muted);
}

.login-form-header h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  color: #1f2937;
}

.login-form-header p {
  margin: 0;
  color: #6b7280;
  font-size: 0.92rem;
}

.login-intro {
  text-align: center;
  display: grid;
  gap: 8px;
  max-width: 520px;
}

.login-intro h1 {
  margin: 0;
  color: var(--navy);
  font-size: 1.85rem;
  line-height: 1.3;
  letter-spacing: -0.4px;
}

.login-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.login-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(214, 162, 58, 0.2);
  color: #8a640c;
  font-weight: 800;
  font-size: 0.9rem;
}

.login-trust-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.login-trust-row span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(15, 43, 79, 0.12);
  color: var(--navy-2);
  font-size: 0.9rem;
  font-weight: 700;
}

.admin-login-head {
  text-align: center;
  display: grid;
  gap: 6px;
  margin-bottom: 6px;
}

.admin-login-head span {
  font-weight: 900;
  color: var(--navy);
  font-size: 1.25rem;
  letter-spacing: -0.2px;
}

.admin-login-head small {
  color: var(--muted);
  font-weight: 600;
}

.auth-logo {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  background: var(--gold-soft);
  color: var(--gold);
  display: grid;
  place-items: center;
  margin: 0 auto;
  font-size: 24px;
  box-shadow: 0 10px 20px rgba(214, 162, 58, 0.22);
  overflow: hidden;
}

.auth-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.auth-card h2 {
  margin: 2px 0 0;
  font-size: 1.85rem;
  line-height: 1.35;
  color: var(--navy);
  letter-spacing: -0.45px;
}

.auth-card > .muted {
  margin: 0 auto;
  max-width: 34ch;
  font-size: 0.98rem;
  line-height: 1.85;
}

.login-page .form-group {
  gap: 10px;
}

.login-page .form-group > label:not(.toggle) {
  font-size: 0.95rem;
  margin-bottom: 0;
}

.login-page .form-control {
  min-height: 48px;
  border-radius: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.9);
}

.login-form-panel .form-control {
  background: #fff;
  border: 1px solid #e5e7eb;
  min-height: 48px;
  border-radius: 10px;
}

.login-page .btn {
  min-height: 46px;
  border-radius: 13px;
}

.login-form-panel .btn.primary {
  width: 100%;
  background: #3457d5;
  border-radius: 10px;
  min-height: 46px;
}

.login-page .auth-mode {
  margin: 2px 0 4px;
}

.login-page .auth-actions {
  gap: 10px;
}

.login-page .captcha-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 56px;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.login-page .captcha-row > * {
  min-width: 0;
}

.login-page .captcha-question {
  height: 50px;
  min-height: 50px;
  border: 1px dashed #c7d2e0;
  border-radius: 13px;
  background: #f8fafc;
  color: var(--navy);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  direction: ltr;
  overflow: hidden;
  width: 100%;
  line-height: 0;
}

.login-page .captcha-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  display: block;
}

.login-page .alert {
  font-size: 0.92rem;
  line-height: 1.7;
}

.muted {
  color: var(--muted);
}

.app-shell {
  background: #fff;
  border-radius: 26px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 43, 79, 0.08);
  overflow: hidden;
  min-height: 100%;
  height: 100%;
}

.app-shell.user {
  background: #fdfdfd;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: linear-gradient(135deg, var(--navy-2), var(--navy));
  color: #fff;
  box-shadow: 0 12px 30px rgba(12, 30, 60, 0.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand h3 {
  margin: 0;
  font-size: 1.05rem;
}

.brand span {
  font-size: 0.9rem;
  opacity: 0.85;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.12);
  padding: 8px 14px;
  border-radius: 14px;
}

.user-chip small {
  display: block;
  font-size: 0.85rem;
  opacity: 0.8;
}

.shell-body {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 0;
  height: calc(100% - 86px);
  background: var(--ice);
}

.side-panel {
  background: var(--navy);
  color: #fff;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
  overflow: auto;
}

.side-panel.user {
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
}

.side-toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.side-toggle span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.side-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-item {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.2s ease;
}

.nav-item.active {
  background: #fff;
  color: var(--navy);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
}

.pending-badge {
  margin-right: auto;
  background: #ef4444;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: badge-blink 1s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes badge-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.9); }
}

.panel-card {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.panel-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
}

.content {
  padding: 24px;
  display: grid;
  gap: 18px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.card {
  background: #fff;
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(15, 23, 42, 0.06);
  animation: fadeUp 180ms ease-out;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 0;
  color: var(--navy);
}

.section-head .actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.section-head .actions .form-control {
  width: min(340px, 45vw);
}

.history-filters {
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  padding-bottom: 4px;
  justify-items: stretch;
}

.history-filters-row {
  width: 100%;
  margin: 4px 0 12px;
  display: block;
}

.history-filters .filter-control {
  min-height: 45px;
  padding: 7px 10px;
  font-size: 0.85rem;
  width: 100%;
  max-width: none;
  min-width: 0;
}

.history-filters .filter-control.filter-wide {
  width: 100%;
  max-width: none;
}

.section-head .actions.history-filters {
  width: 100%;
}

.history-filters-row .actions.history-filters {
  width: 100%;
  justify-content: stretch;
}

/* Ensure history filters stay in a single row on wide screens */
.actions.history-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.pill {
  background: #eef2f7;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  color: var(--navy);
}

.price-table {
  display: grid;
  gap: 12px;
}

.price-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.price-row.head {
  background: #eef2f7;
  font-weight: 700;
  color: var(--navy);
}

.price-row small {
  display: block;
  color: var(--muted);
}

.price {
  font-weight: 700;
}

.price.buy {
  color: var(--success);
}

.price.sell {
  color: var(--danger);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.market-grid {
  display: grid;
  gap: 12px;
}

.market-card {
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 16px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1.2fr 0.95fr 0.95fr 1.25fr;
  gap: 12px 14px;
  align-items: center;
}

.market-card h3 {
  margin: 0;
  font-size: 1.02rem;
  color: var(--navy);
}

.market-card .price-row {
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none !important;
  border-color: transparent !important;
  pointer-events: none;
}

.market-card .actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 10px;
}

.market-card .btn {
  width: 100%;
  min-height: 46px;
  padding: 11px 20px;
  font-weight: 700;
}

.market-card .sparkline {
  display: none;
}

.market-card svg,
.market-card .mini-chart,
.market-card .price-spark {
  display: none;
}

.sparkline {
  width: 100%;
  height: 46px;
  stroke: rgba(15, 43, 79, 0.7);
}

.chart-point-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: #f8fafc;
}

.chart-wrap {
  padding: 12px 12px 10px;
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: 18px;
  background: linear-gradient(180deg, #f8fafc 0%, #f3f6fb 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.price-chart {
  width: 100%;
  height: 350px;
}

.price-chart-grid-line {
  stroke: rgba(15, 23, 42, 0.08);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.price-chart-grid-label {
  fill: #7c8ba3;
  font-size: 11px;
  font-weight: 600;
}

.price-chart-area {
  fill: url(#chartAreaGradient);
}

.price-chart-line {
  stroke: rgba(15, 43, 79, 0.78);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.price-chart-cursor {
  stroke: rgba(15, 43, 79, 0.2);
  stroke-width: 1.25;
  stroke-dasharray: 4 4;
}

.price-chart-point {
  fill: #3f5f86;
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 1.5;
  opacity: 0.8;
  cursor: pointer;
  transition: fill 120ms ease, opacity 120ms ease, stroke 120ms ease;
}

.price-chart-point.active,
.price-chart-point:hover {
  fill: #0f2b4f;
  stroke: #c9d7ea;
  opacity: 1;
}

.chart-meta {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.apex-chart-container {
  width: 100%;
  direction: ltr;
}

.apex-chart-container .apexcharts-tooltip {
  font-family: 'Vazirmatn', sans-serif !important;
  direction: rtl;
  text-align: right;
}

.apex-chart-container .apexcharts-xaxis-label,
.apex-chart-container .apexcharts-yaxis-label {
  font-family: 'Vazirmatn', sans-serif !important;
}

.apex-chart-container .apexcharts-nodata-text {
  font-family: 'Vazirmatn', sans-serif !important;
}

@media (max-width: 980px) {
  .market-card {
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
  }
  .market-card .actions {
    grid-column: 1 / -1;
  }
  .market-card .sparkline {
    grid-column: 1 / -1;
  }
  .chart-point-info,
  .chart-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 600px) {
  .market-card {
    grid-template-columns: 1fr;
  }
  .market-card .actions {
    grid-template-columns: 1fr;
  }
}

.orders {
  display: grid;
  gap: 14px;
}

.finance-page {
  display: grid;
  gap: 18px;
}

.finance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.finance-table {
  display: grid;
  gap: 12px;
}

.finance-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.finance-row.head {
  background: #eef2f7;
  color: var(--navy);
  font-weight: 700;
}

.order-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
}

.order-card h4 {
  margin: 0 0 6px;
}

.order-meta {
  display: grid;
  gap: 6px;
  text-align: left;
}

.user-list {
  display: grid;
  gap: 12px;
}

.user-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  padding: 12px;
  background: #fff;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  text-align: right;
  cursor: pointer;
  transition: 0.2s ease;
}

.user-card:hover,
.user-card.active {
  border-color: rgba(15, 43, 79, 0.24);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.user-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--gold-soft);
  color: var(--navy);
  display: grid;
  place-items: center;
  font-weight: 700;
  overflow: hidden;
}

.user-avatar img,
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info {
  display: grid;
  gap: 6px;
}

.user-info span {
  color: var(--muted);
  font-size: 0.88rem;
}

.user-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: #eef2f7;
  color: var(--navy);
  font-weight: 700;
}

.tag.success {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.tag.warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.tag.danger {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.profile-card {
  display: grid;
  gap: 14px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-avatar {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  background: rgba(15, 43, 79, 0.12);
  color: var(--navy);
  display: grid;
  place-items: center;
  font-weight: 700;
  overflow: hidden;
}

.status {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  justify-content: center;
}

.status.pending {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.status.approved {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.status.rejected {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.quick-card {
  padding: 18px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
  display: grid;
  gap: 8px;
}

.quick-card i {
  font-size: 22px;
  color: var(--navy);
}

.form-group {
  display: grid;
  gap: 8px;
  align-content: start;
  justify-items: stretch;
}

.form-group > label:not(.toggle) {
  font-weight: 700;
  color: var(--navy);
  line-height: 1.6;
  padding: 0 2px;
  margin: 0 0 2px;
}

.form-control {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d3dae4;
  background: #fff;
  font-size: 0.95rem;
  min-height: 44px;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-field .form-control {
  width: 100%;
  padding-left: 44px;
  padding-right: 14px;
}

.password-toggle {
  position: absolute;
  left: 12px;
  right: auto;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.password-toggle:hover {
  color: #1f3f6b;
}

.form-group .toggle {
  margin-top: 0;
  justify-self: start;
}

.form-control:focus {
  outline: none;
  border-color: rgba(15, 43, 79, 0.5);
  box-shadow: 0 0 0 4px rgba(15, 43, 79, 0.12);
}

.form-control:disabled {
  background: #f3f6fb;
  color: rgba(31, 41, 55, 0.7);
}

.form-control.field-error {
  border-color: #ef4444 !important;
  background-color: #fff8f8;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.field-error-msg {
  font-size: 11px;
  color: #ef4444;
  margin-top: 3px;
  padding-right: 4px;
  min-height: 16px;
  line-height: 1.4;
  visibility: hidden;
}

.field-error-msg:not(:empty) {
  visibility: visible;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  column-gap: 20px;
  row-gap: 14px;
}

.share-page .form-grid {
  row-gap: 18px;
}

.share-page .form-group > label:not(.toggle) {
  margin-bottom: 6px;
}

.share-page .form-group .form-control,
.share-page .form-group textarea {
  margin-top: 2px;
}

.share-page .form-grid + .form-grid {
  margin-top: 18px;
}

.share-page .hint {
  margin-top: 12px;
}

.share-page .actions {
  margin-top: 14px;
}

.profile-title.centered {
  width: 100%;
  text-align: center;
}

.profile-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-direction: row-reverse;
  margin-bottom: 18px;
}

.profile-summary-text {
  display: grid;
  gap: 4px;
  text-align: right;
}

.profile-summary-text strong {
  color: var(--navy);
  font-size: 1.05rem;
}

.side-panel .btn.outline {
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.side-panel .btn.outline:hover {
  background: rgba(255, 255, 255, 0.18);
}

.table-logs .table-row {
  align-items: center;
  min-height: 54px;
}

.table-logs .table-row span {
  display: flex;
  align-items: center;
}

.divider {
  height: 1px;
  background: #e5e7eb;
  margin: 18px 0;
}

.table {
  display: grid;
  gap: 14px;
}

/* ── Expandable rows: wrapper divs invisible to desktop grid ──────── */
.row-primary-wrap,
.row-secondary-wrap {
  display: contents;
}

/* Toggle chevron hidden on desktop (not a grid item) */
.row-toggle {
  display: none;
}

.table-row {
  display: grid;
  /* Generic fallback — table-pending: کاربر|مبلغ|وضعیت|عملیات|محصول|نوع|مقدار */
  grid-template-columns: 1.6fr 1fr 0.9fr 1.1fr 1fr 0.7fr 0.8fr;
  gap: 12px;
  align-items: center;
  justify-items: stretch;
  padding: 14px 16px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.table-row.head {
  background: #eef2f7;
  font-weight: 700;
  color: var(--navy);
}

/* Table variants — columns in new primary-first order */

/* table-history (admin): کاربر|مبلغ|وضعیت|محصول|نوع|مقدار */
.table.table-history .table-row {
  grid-template-columns: 1.6fr 1.1fr 1fr 1.2fr 0.7fr 0.8fr;
  align-items: center;
}

/* table-history (user-detail view): محصول|مبلغ|وضعیت|نوع|مقدار */
.table.table-history-user .table-row {
  grid-template-columns: 1.4fr 1.1fr 1fr 0.7fr 0.8fr;
  align-items: center;
}

.table.table-logs .table-row {
  grid-template-columns: 1.15fr 0.85fr 1.7fr 1.05fr;
  align-items: center;
  gap: 14px;
  padding-top: 14px;
  padding-bottom: 14px;
  min-height: 72px;
}

.table.table-user-logs-auth .table-row {
  grid-template-columns: 1fr 1fr 1fr;
}

/* table-user-logs-orders (admin detail): محصول|وضعیت|زمان|نوع|مقدار */
.table.table-user-logs-orders .table-row {
  grid-template-columns: 1.3fr 0.9fr 1.1fr 0.7fr 0.9fr;
}

/* table-user-orders (user panel): محصول|مبلغ|وضعیت|نوع|مقدار|زمان|عملیات */
.table.table-user-orders .table-row {
  grid-template-columns: 1.4fr 1fr 0.9fr 0.7fr 0.9fr 1.1fr 0.9fr;
}

.table.table-user-orders {
  gap: 10px;
}

.table.table-user-orders .table-row {
  padding: 10px 12px;
  gap: 8px;
  min-height: 52px;
  font-size: 0.92rem;
}

.table.table-user-orders .btn {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

.table.table-logs .table-row > span:nth-child(3) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.table.table-logs .table-row > span:last-child {
  white-space: nowrap;
}

/* table-products: نام|واحد|نوع قیمت|قیمت پایه|ضریب|حاشیه خرید|حاشیه فروش|فعال|حذف */
.table.table-products .table-row {
  grid-template-columns: 1.3fr 0.75fr 0.85fr 1.2fr 0.7fr 0.9fr 0.9fr 0.55fr 0.6fr;
}

.table.table-products .table-row .table-input,
.table.table-products .table-row select,
.table.table-products .table-row input[type='number'] {
  min-height: 40px;
}

.toggle-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.table-row span small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 4px;
  line-height: 1.35;
}

.table-row > span,
.table-row > button,
.user-row > span,
.user-row > button {
  line-height: 1.4;
}

.table-row > span,
.table-row > button,
.table-row > input,
.table-row > select,
.user-row > span,
.user-row > button {
  text-align: center;
}

.table-row.head > span,
.user-row.head > span {
  text-align: center;
}

.table-row > button,
.user-row > button {
  width: 100%;
}

.table-row .link,
.user-row .user-cell {
  text-align: right;
  justify-self: stretch;
}

.table-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d3dae4;
  background: #fff;
  font-size: 0.85rem;
  min-height: 44px;
}

.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  align-self: center;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle span {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  transition: 0.2s;
}

.toggle span::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  right: 3px;
  transition: 0.2s;
}

.toggle input:checked + span {
  background: var(--success);
}

.toggle input:checked + span::after {
  transform: translateX(-18px);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 20;
}

.modal-card {
  width: min(520px, 100%);
  background: #fff;
  padding: 22px 24px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  animation: zoomIn 160ms ease-out;
}

.crop-modal .modal-card {
  width: min(680px, 96vw);
}

.cropper-shell {
  display: grid;
  gap: 16px;
  justify-items: center;
}

.cropper-box {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #f1f4f9;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
}

.cropper-box img {
  position: absolute;
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.cropper-box img:active {
  cursor: grabbing;
}

.cropper-controls {
  width: min(360px, 100%);
  display: grid;
  gap: 8px;
  justify-items: stretch;
}

.cropper-controls input[type='range'] {
  width: 100%;
}

.modal-head h3 {
  margin: 0;
}

.modal-head p {
  margin: 4px 0 0;
}

.modal-head.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.modal-head.split .unit-price {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .modal-card {
    animation: none;
  }
  .btn,
  .form-control {
    transition: none;
  }
}

.summary {
  display: grid;
  gap: 6px;
}

.trade-summary {
  min-height: 72px;
}

.trade-summary .fee-row {
  min-height: 24px;
  font-size: 0.88rem;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.summary .summary-error {
  font-size: 0.85rem;
  line-height: 1.6;
}

.calc-hint {
  font-size: 0.78rem;
  opacity: 0.6;
  white-space: nowrap;
}

.mobile-nav {
  display: none;
}

@media (max-width: 1100px) {
  .landing {
    grid-template-columns: 1fr;
  }
  .hero-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .shell-body {
    grid-template-columns: 1fr;
  }
  .side-panel {
    flex-direction: column;
    gap: 10px;
  }
  .panel-card {
    width: 100%;
  }
  .login-page {
    min-height: calc(100vh - (var(--body-pad) * 2));
    height: calc(100vh - (var(--body-pad) * 2));
    padding: 32px 24px;
  }
  .login-layout {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .login-hero {
    text-align: center;
    justify-items: center;
  }
  .hero-badge {
    align-self: center;
  }
  .hero-illustration {
    width: 100%;
  }
  .login-lang {
    position: static;
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
  }
  .branding-layout {
    grid-template-columns: 1fr;
  }
  .logo-preview {
    justify-self: center;
  }
}

@media (max-width: 820px) {
  :root {
    --body-pad: 14px;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .price-row {
    grid-template-columns: 1fr;
  }
  .order-card {
    flex-direction: column;
    text-align: right;
  }
  .order-meta {
    text-align: right;
  }
  .admin-split {
    grid-template-columns: 1fr;
  }
  .hero-kpis {
    grid-template-columns: 1fr;
  }
  .login-stage {
    width: min(95vw, 520px);
    gap: 12px;
  }
  .login-intro h1 {
    font-size: 1.45rem;
  }
  .login-trust-row {
    gap: 8px;
  }
  .login-trust-row span {
    font-size: 0.82rem;
    padding: 6px 10px;
  }
  .auth-card {
    width: min(95vw, 460px);
    padding: 26px 18px;
    border-radius: 20px;
  }
  .login-page .captcha-row {
    grid-template-columns: 1fr;
  }
  .auth-card h2 {
    font-size: 1.45rem;
  }
  .login-bg-orb.orb-1 {
    width: 270px;
    height: 270px;
    right: -100px;
    top: -120px;
  }
  .login-bg-orb.orb-2 {
    width: 320px;
    height: 320px;
    left: -130px;
    bottom: -170px;
  }
}

.alert {
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 600;
}

.alert.warning {
  background: rgba(245, 158, 11, 0.16);
  color: var(--warning);
}

.alert.danger {
  background: rgba(239, 68, 68, 0.14);
  color: #b42318;
  border: 1px solid rgba(239, 68, 68, 0.28);
}

.alert.success {
  background: rgba(34, 197, 94, 0.14);
  color: #166534;
  border: 1px solid rgba(34, 197, 94, 0.28);
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.sparkline {
  width: 100%;
  height: 80px;
  stroke: var(--navy);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.link {
  background: transparent;
  border: none;
  color: var(--navy);
  font-weight: 700;
  text-align: right;
  cursor: pointer;
  display: grid;
  gap: 4px;
}

.admin-split {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}

.stack {
  display: grid;
  gap: 12px;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
}

.toggle-item span {
  font-size: 0.92rem;
  color: var(--ink);
}

.inset {
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.auth-mode {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.auth-actions {
  display: grid;
  gap: 8px;
}

.otp-input {
  text-align: center;
  letter-spacing: 6px;
}

.table-row:not(.head):hover {
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
  border-color: rgba(15, 23, 42, 0.12);
}

.order-card {
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
}

.user-rows {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 360px);
  overflow-y: auto;
  padding-right: 4px;
}

.user-row {
  display: grid;
  /* کاربر|وضعیت|شماره همراه|کد ملی|نقش|مجوز|سفارشات|عملیات */
  grid-template-columns: 1.5fr 0.7fr 1fr 0.9fr 0.6fr 0.6fr 0.6fr 80px;
  gap: 10px;
  align-items: center;
  justify-items: stretch;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.05);
  min-height: 66px;
}

.user-row.head {
  background: #eef2f7;
  font-weight: 700;
  color: var(--navy);
  box-shadow: none;
  min-height: 56px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.user-row:hover {
  border-color: rgba(15, 23, 42, 0.14);
  box-shadow: 0 14px 26px rgba(15, 23, 42, 0.12);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-cell strong {
  display: block;
  line-height: 1.35;
}

.user-cell small {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
}

.user-row .btn {
  min-height: 40px;
  padding: 9px 14px;
}

.user-row .action-btns .btn {
  min-height: 30px;
  padding: 4px 10px;
}

.table-row {
  min-height: 58px;
}

.table-row.head {
  min-height: 52px;
}

.user-avatar {
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.profile-hero {
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
}

.profile-item {
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.04);
}

.price-row:not(.head):hover {
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

@media (max-width: 1024px) {
  .user-row {
    grid-template-columns: 1fr;
  }
}

.auth-mode {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.auth-actions {
  display: grid;
  gap: 8px;
}

.otp-input {
  text-align: center;
  letter-spacing: 6px;
}

.user-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.profile-page .section-head {
  align-items: flex-start;
}

.profile-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.profile-hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.08);
  margin-bottom: 12px;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.profile-actions.top {
  justify-self: end;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  grid-column: 3;
}

.profile-actions.top.align-right {
  justify-self: start;
  grid-column: 1;
  justify-content: flex-start;
  direction: rtl;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.profile-page .form-grid {
  margin-top: 10px;
  margin-bottom: 12px;
}

.profile-page .btn.primary {
  margin-top: 12px;
}

.profile-item {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  background: #fff;
  display: grid;
  gap: 6px;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.doc-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 10px;
}

.doc-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px dashed rgba(15, 23, 42, 0.2);
  background: #f8fafc;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.doc-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doc-actions {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 12px;
}

.doc-actions .btn {
  min-height: 40px;
  padding: 8px 16px;
}

.doc-caption {
  text-align: center;
  font-weight: 600;
  color: var(--navy);
}

.doc-input {
  display: none;
}

.doc-box.active {
  border-color: rgba(15, 23, 42, 0.35);
}

.doc-actions .btn.outline {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.6);
}

.doc-actions .btn.primary {
  background: #fff;
  color: var(--navy);
}

.doc-actions .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.doc-actions .btn {
  text-align: center;
}

.profile-item.full {
  grid-column: 1 / -1;
}

.price-row {
  grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr;
}

@media (max-width: 900px) {
  .price-row {
    grid-template-columns: 1fr;
  }
  .profile-hero {
    grid-template-columns: 1fr;
  }
  .profile-actions.top {
    justify-self: start;
  }
}

/* Security tab */
.sec-panel {
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 18px;
  padding: 28px 20px;
  margin-top: 8px;
}
.sec-panel-head {
  margin-bottom: 20px;
}
.sec-panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 4px;
}
.sec-panel-desc {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
}
.sec-panel-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  column-gap: 20px;
  row-gap: 28px;
}
.sec-field {
  display: grid;
  gap: 5px;
}
.sec-field > label {
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
  line-height: 1.4;
  padding: 0 2px;
  margin: 0;
}
.sec-field-hint {
  display: inline-block;
  font-size: 11px;
  color: #7a8fa8;
  background: #edf2fa;
  border-radius: 4px;
  padding: 1px 7px;
  white-space: nowrap;
  margin: 0 2px;
}
.sec-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.sec-field-row .form-control {
  width: 120px;
  max-width: 120px;
  flex: none;
  min-width: 0;
}
.sec-unit {
  font-size: 0.9rem;
  color: #8a97b0;
  white-space: nowrap;
  flex-shrink: 0;
}
.sec-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 18px;
  margin-top: 4px;
}

/* Settings redesign */
.settings-page .section-head {
  margin-bottom: 22px;
  align-items: flex-start;
}

.settings-head h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}

.settings-subtitle {
  margin: 0;
  font-size: 0.95rem;
}

.settings-layout {
  display: grid;
  gap: 18px;
}

.settings-grid {
  display: grid;
  gap: 16px;
}

.settings-grid .settings-section {
  display: none;
}

.settings-grid.tab-pricing .settings-section:nth-child(1),
.settings-grid.tab-fees .settings-section:nth-child(2),
.settings-grid.tab-admin .settings-section:nth-child(3),
.settings-grid.tab-branding .settings-section:nth-child(4),
.settings-grid.tab-messages .settings-section:nth-child(5) {
  display: grid;
}

.fee-mode-selector {
  display: flex;
  gap: 10px;
}

.fee-mode-btn {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.18s ease;
}

.fee-mode-btn.active {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}

.fee-mode-btn:not(.active):hover {
  border-color: var(--navy);
  color: var(--navy);
}

.saved-message-preview {
  margin-top: 10px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 10px;
  padding: 10px 14px;
  display: grid;
  gap: 4px;
}

.saved-message-preview p {
  margin: 0;
  color: var(--ink);
  font-size: 0.93rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.prices-card {
  display: flex;
  flex-direction: column;
}

.trading-disabled-full {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 60px 24px;
  text-align: center;
}

.trading-disabled-icon {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  color: #b45309;
  box-shadow: 0 8px 24px rgba(180, 83, 9, 0.18);
}

.trading-disabled-full h3 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--navy);
}

.trading-disabled-full p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
  max-width: 480px;
  white-space: pre-wrap;
}

.trading-disabled-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: linear-gradient(135deg, #fff8e1, #fff3cd);
  border: 1px solid rgba(214, 162, 58, 0.4);
  border-right: 4px solid var(--gold);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 4px;
}

.trading-disabled-banner i {
  color: var(--gold);
  font-size: 1.4rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.trading-disabled-banner p {
  margin: 0;
  color: var(--ink);
  line-height: 1.7;
  font-size: 1rem;
  white-space: pre-wrap;
}

.settings-section {
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 18px;
  padding: 40px 20px;
  display: grid;
  gap: 16px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.branding-grid {
  row-gap: 18px;
}

.branding-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: start;
  padding: 10px 8px;
}

.branding-logo {
  display: grid;
  gap: 10px;
}

.branding-colors .form-control {
  min-height: 40px;
  padding: 9px 12px;
  font-size: 0.9rem;
}

.branding-colors .color-input input[type='color'] {
  width: 40px;
  height: 38px;
}

.logo-preview {
  width: 160px;
  height: 160px;
  min-height: 0;
  background: #fff;
  border-radius: 16px;
  border: 1px dashed rgba(15, 23, 42, 0.2);
  display: grid;
  place-items: center;
  padding: 10px;
  justify-self: start;
  align-self: start;
  position: relative;
  overflow: hidden;
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.logo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: 0.2s ease;
  padding: 10px;
}

.logo-preview:hover .logo-overlay,
.logo-preview:focus-within .logo-overlay {
  opacity: 1;
}

.logo-overlay .btn {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.color-input {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-input input[type='color'] {
  width: 46px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  padding: 0;
  background: #fff;
}

.color-input .form-control {
  flex: 1;
}

.settings-section-head {
  margin-bottom: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-section-title h3 {
  margin: 0;
}

.settings-section-title i {
  color: var(--navy);
  background: rgba(15, 43, 79, 0.08);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
}

.settings-toggle-grid {
  display: grid;
  gap: 12px;
}

.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.settings-toggle strong {
  display: block;
}

.settings-actions-bar {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-inline-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.6;
}

.log-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 6px 0 16px;
}

.tabs .tab {
  margin: 0;
}

.tab {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  color: var(--navy);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.tab.active {
  background: var(--navy);
  color: #fff;
  border-color: transparent;
}

.product-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
}

.btn.compact {
  padding: 8px 12px;
  min-height: 36px;
  border-radius: 10px;
  font-size: 0.85rem;
}

.products-save {
  margin-top: 14px;
}

.save-bar {
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
  margin-top: auto;
  border-top: 1px solid rgba(15, 23, 42, 0.07);
  position: sticky;
  bottom: 0;
  background: #fff;
  padding-bottom: 4px;
  border-radius: 0 0 20px 20px;
}

.logs-page .table {
  flex: 1;
  min-height: 0;
  max-height: 632px;
  overflow-y: auto;
  padding-right: 4px;
}

.logs-page {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 300px);
}

.logs-page .table-row.head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 56px;
}

.products-page {
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

.products-page .table {
  flex: 1;
  min-height: 0;
  max-height: 640px;
  overflow-y: auto;
  padding-right: 4px;
}

.products-page .table-row.head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 56px;
}

@media (max-width: 820px) {
  .settings-section {
    padding: 14px;
  }
  .settings-actions-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .settings-actions-bar .btn {
    width: 100%;
  }
  .settings-toggle {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Responsive hardening */
@media (max-width: 1280px) {
  body {
    padding: 14px;
  }

  #root {
    max-width: 100%;
  }
}

@media (max-width: 1100px) {
  .topbar {
    padding: 14px 16px;
    gap: 10px;
  }

  .shell-body {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .content {
    overflow: visible;
    min-height: 0;
  }

  .side-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    overflow: hidden;
    height: auto !important;
    min-height: 0 !important;
    align-self: start;
  }

  .side-toggle {
    display: flex;
  }

  .side-menu {
    display: none;
  }

  .side-panel.open .side-menu {
    display: flex;
  }

  .side-panel .nav-item {
    width: 100%;
    justify-content: space-between;
  }

  .side-panel .panel-card {
    width: 100%;
  }

  .side-panel > .btn {
    width: 100%;
  }

  .content {
    padding: 16px;
  }

  .card {
    padding: 16px;
  }

  .section-head .actions .form-control {
    width: min(100%, 420px);
  }

  /* Card layout starts at 640px — tables still grid-based at 820px */
  .price-table,
  .finance-table {
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
  }
}

@media (max-width: 900px) {
  .brand h3 {
    font-size: 0.98rem;
  }

  .brand span {
    font-size: 0.84rem;
  }

  .user-chip {
    padding: 8px 10px;
    gap: 8px;
  }

  .grid-two,
  .quick-grid,
  .form-grid,
  .profile-grid,
  .finance-grid,
  .doc-grid {
    grid-template-columns: 1fr;
  }

  .price-row {
    grid-template-columns: 1fr;
  }

  .profile-hero {
    grid-template-columns: 1fr;
    text-align: right;
  }

  .profile-actions.top,
  .profile-actions.top.align-right {
    grid-column: auto;
    justify-self: start;
    width: 100%;
  }

  .tabs {
    gap: 8px;
  }

  .tab {
    min-height: 42px;
    padding: 9px 12px;
  }
}

@media (max-width: 1100px) {
  .history-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .actions.history-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  body {
    padding: 10px;
  }

  .app-shell,
  .login-page {
    border-radius: 16px;
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .brand {
    min-width: 0;
  }

  .brand h3,
  .brand span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .side-panel .nav-item {
    min-width: 164px;
    font-size: 0.92rem;
    min-height: 44px;
  }

  .side-panel .panel-card {
    min-width: 210px;
    font-size: 0.9rem;
  }

  .market-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .market-card .actions {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .orders .order-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .orders .order-meta {
    width: 100%;
    text-align: right;
  }

  .logs-page {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .auth-card {
    width: min(96vw, 460px);
    padding: 22px 14px;
  }

  .login-page .captcha-row {
    grid-template-columns: 1fr;
  }

  .tabs .tab {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
  }

  .actions {
    width: 100%;
  }

  .section-head .actions {
    width: 100%;
  }

  .section-head .actions .form-control {
    width: 100%;
  }

  .market-card .actions {
    grid-template-columns: 1fr 1fr;
  }

  .market-card .btn {
    min-height: 42px;
    padding: 9px 12px;
  }

  .btn {
    min-height: 42px;
  }

  .form-control,
  .table-input {
    min-height: 42px;
    padding: 10px 12px;
  }
}

.hidden-input {
  display: none;
}

.backup-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
}

.backup-page .section-head {
  align-items: flex-start;
}

/* ── Financial / Invoice styles ─────────────────────────────────── */

/* شماره فاکتور|مشتری|جمع کل|تاریخ|کد ملی|نوع|محصول|مقدار|عملیات */
.table.table-financial .table-row {
  grid-template-columns: 1fr 1.1fr 1fr 0.85fr 0.85fr 0.55fr 0.9fr 0.75fr 120px;
  align-items: center;
  gap: 10px;
  min-height: 52px;
}

/* table-pending: کاربر|مبلغ|وضعیت|محصول|نوع|مقدار|عملیات */
.table.table-pending .table-row {
  grid-template-columns: 1.6fr 1fr 0.9fr 1fr 0.7fr 0.8fr 1.1fr;
}

/* Financial table 900px: keep grid, handled by general card layout at 640px */

.action-btns {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
}

.btn.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  min-height: 30px;
  border-radius: 8px;
}

.btn.danger {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}
.btn.danger:hover {
  background: #dc2626;
}

.pill-buy {
  background: #dcfce7;
  color: #16a34a;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.pill-sell {
  background: #fee2e2;
  color: #dc2626;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.loading-row,
.empty-row {
  padding: 32px;
  text-align: center;
  color: #888;
  font-size: 14px;
}

/* Modal head with flex layout (title + close button) */
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}

.modal-body {
  display: grid;
  gap: 14px;
  max-height: 65vh;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid #f0f0f0;
}

.btn-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #888;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
}
.btn-close:hover {
  background: #f1f4f9;
  color: #333;
}

.invoice-preview {
  font-size: 13px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-row .filter-control {
  min-width: 0;
}

.color-buy { color: #16a34a; font-weight: 700; }
.color-sell { color: #dc2626; font-weight: 700; }

/* ─── Jalali Date Picker ─────────────────────────────────────────── */
.jcal-wrap { position: relative; display: inline-block; }
.jcal-trigger {
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  user-select: none;
  gap: 6px;
}
.jcal-trigger:focus-visible { outline: 2px solid var(--brand-accent, #43658f); outline-offset: 2px; }
.jcal-popup {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 9999;
  background: #fff;
  border: 1px solid #dde3ee;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.13);
  padding: 14px;
  min-width: 260px;
  font-family: Vazirmatn, sans-serif;
}
.jcal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.jcal-month-label { font-weight: 700; font-size: 14px; color: #2d3a4a; }
.jcal-nav {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  color: #43658f;
  border-radius: 6px;
  transition: background 0.15s;
}
.jcal-nav:hover { background: #f0f5fb; }
.jcal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.jcal-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  font-size: 13px;
  border-radius: 6px;
}
.jcal-hdr { font-size: 11px; color: #8a97b0; font-weight: 600; }
.jcal-empty { visibility: hidden; }
.jcal-day {
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  color: #2d3a4a;
}
.jcal-day:hover { background: #eef3fa; }
.jcal-today { font-weight: 700; color: #43658f; }
.jcal-sel { background: #43658f !important; color: #fff !important; font-weight: 700; }
.jcal-footer { margin-top: 8px; text-align: center; border-top: 1px solid #f0f3f8; padding-top: 8px; }
.jcal-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: #e74c3c;
  font-size: 12px;
  font-family: Vazirmatn, sans-serif;
}
.jcal-clear:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — global best-practice mobile & tablet overrides
   ═══════════════════════════════════════════════════════════════════ */

@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── 820px: break desktop fixed-height chain, restore nav ────────── */
@media (max-width: 820px) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }

  body {
    overflow-y: auto;
    overflow-x: hidden;
  }

  #root {
    height: auto;
    min-height: 100svh;
    min-height: 100vh; /* fallback */
  }

  .app-shell {
    height: auto;
    min-height: 100svh;
    min-height: 100vh;
  }

  .shell-body {
    position: relative; /* positioning context for absolute side-panel */
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  /* Side panel: overlay mode — floats above content, doesn't push it down */
  .side-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 50;
  }
  .side-panel.open {
    overflow: visible; /* allow expanded menu to render without clipping */
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.28);
  }

  /* Topbar: keep brand and user-chip on one row even on mobile */
  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  /* Tabs: horizontal scroll to prevent wrapping */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab { flex: 0 0 auto; white-space: nowrap; }

  /* Tables: horizontal scroll wrapper */
  .table,
  .user-rows,
  .price-table,
  .finance-table {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    min-width: 0;
  }

  /* Content/card: min-width:0 stops CSS grid auto-expansion cascading outward */
  .card {
    min-width: 0;
  }

  /* Content: padding-top clears the collapsed toggle bar (panel-pad 10 + toggle 44 + panel-pad 10) */
  .content {
    overflow: visible;
    min-height: 0;
    min-width: 0;
    padding-top: 64px;
  }
}

/* ── Desktop only: push action/delete columns to end via order ───── */
@media (min-width: 641px) {
  /* Financial: عملیات last */
  .table.table-financial .table-row .action-btns { order: 100; }
  .table.table-financial .table-row.head .row-primary-wrap > span:last-child { order: 100; }

  /* Users: عملیات last */
  .user-row .action-btns { order: 100; }
  .user-row.head .row-primary-wrap > span:last-child { order: 100; }

  /* Products: فعال and حذف last */
  .table.table-products .table-row .toggle-cell { order: 99; }
  .table.table-products .table-row button.btn.outline.compact { order: 100; }
  .table.table-products .table-row.head .row-primary-wrap > span:nth-child(2) { order: 99; }
  .table.table-products .table-row.head .row-primary-wrap > span:nth-child(3) { order: 100; }

  /* Pending: عملیات last */
  .table.table-pending .table-row .actions { order: 100; }
  .table.table-pending .table-row.head .row-primary-wrap > span:last-child { order: 100; }

  /* Center all column cells under their headers
     (display:contents on wrappers means > combinator must go through the wrapper) */
  .table-row .row-primary-wrap > span,
  .table-row .row-primary-wrap > button,
  .table-row .row-primary-wrap > div,
  .table-row .row-secondary-wrap > span,
  .table-row .row-secondary-wrap > div,
  .user-row .row-primary-wrap > span,
  .user-row .row-primary-wrap > div,
  .user-row .row-secondary-wrap > span {
    text-align: center;
  }
  /* user-cell is a flex container — center avatar+name as a unit */
  .user-row .user-cell {
    justify-content: center;
  }
  /* action button groups: center buttons within their column */
  .table-row .action-btns,
  .table-row .actions {
    justify-content: center;
  }
}

/* ── 640px: phone-first layout ───────────────────────────────────── */
@media (max-width: 640px) {
  :root {
    --body-pad: 0px;
  }

  body {
    padding: 0;
  }

  #root {
    width: 100%;
    max-width: 100%;
  }

  /* App shell: edge-to-edge, no decoration */
  .app-shell {
    border-radius: 0;
    box-shadow: none;
    border: none;
  }

  /* ── Topbar ─────────────────────────────────────────────────────── */
  .topbar {
    padding: 11px 14px;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    flex-shrink: 0;
  }

  .brand {
    min-width: 0;
    overflow: hidden;
  }

  .brand h3 {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
  }

  .brand span {
    display: none;
  }

  .user-chip {
    padding: 6px 8px;
    gap: 6px;
    font-size: 0.82rem;
    flex-shrink: 0;
    border-radius: 10px;
  }

  .user-chip small {
    display: none;
  }

  /* ── Side panel: compact collapsible strip ──────────────────────── */
  .side-panel {
    padding: 8px;
  }

  .side-toggle {
    min-height: 44px;
    font-size: 0.92rem;
    border-radius: 10px;
  }

  .side-panel.open .side-menu {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .side-panel.open .side-menu::-webkit-scrollbar {
    display: none;
  }

  .side-panel .nav-item {
    min-width: 120px;
    min-height: 42px;
    font-size: 0.88rem;
    padding: 10px 12px;
    flex: 1 1 auto;
  }

  .side-panel .panel-card {
    min-width: 0;
    width: 100%;
    font-size: 0.88rem;
  }

  .side-panel > .btn {
    width: 100%;
  }

  /* ── Content ────────────────────────────────────────────────────── */
  .content {
    padding: 12px;
    gap: 12px;
    min-width: 0;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
    min-width: 0;
  }

  /* ── Section head ───────────────────────────────────────────────── */
  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
  }

  .section-head h2 {
    margin: 0;
    font-size: 1.05rem;
  }

  .section-head .actions,
  .section-head .actions .form-control {
    width: 100%;
    max-width: none;
  }

  /* ── History filters ─────────────────────────────────────────────── */
  .history-filters,
  .actions.history-filters {
    grid-template-columns: 1fr 1fr;
  }

  /* ── Tables: expandable card layout (no horizontal scroll) ─────── */

  /* Table containers: remove scroll */
  .table,
  .user-rows {
    overflow: visible;
    gap: 8px;
  }

  /* Hide header row — labels shown via ::before on mobile */
  .table-row.head,
  .user-row.head {
    display: none !important;
  }

  /* Each data row becomes a card */
  .table-row:not(.head),
  .user-row:not(.head) {
    display: block !important;
    min-width: 0 !important;
    padding: 0 !important;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #e8ecf2;
    box-shadow: 0 1px 4px rgba(44, 51, 71, 0.07);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
  }

  .table-row.expanded:not(.head),
  .user-row.expanded:not(.head) {
    border-color: #b8c5d6;
    box-shadow: 0 2px 8px rgba(44, 51, 71, 0.12);
  }

  /* Primary section: always visible summary bar */
  .row-primary-wrap {
    display: flex !important;
    align-items: center;
    flex-wrap: nowrap;
    gap: 18px;
    padding: 11px 14px;
    min-width: 0;
  }

  .row-primary-wrap > * {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
  }

  /* First primary item (product name / user name) gets more space */
  .row-primary-wrap > *:first-child {
    flex: 1 1 0;
    font-weight: 600;
  }

  /* Status badges stay compact */
  .row-primary-wrap .status {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Action buttons stay compact, no shrink */
  .row-primary-wrap .action-btns,
  .row-primary-wrap .actions {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
  }

  /* Chevron toggle: pushed to far edge */
  .row-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-inline-start: auto;
    color: #a0aab8;
    font-size: 11px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #f0f3f8;
    transition: transform 0.2s ease, background 0.15s;
  }

  .table-row.expanded .row-toggle,
  .user-row.expanded .row-toggle {
    transform: rotate(180deg);
    background: #e0e8f4;
    color: #43658f;
  }

  /* Secondary section: hidden until expanded - max 4 items shown, rest hidden */
  .row-secondary-wrap {
    display: none !important;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 6px 8px;
    padding: 10px 14px 12px;
    border-top: 1px solid #e8ecf2;
    background: #fafbfd;
    border-radius: 0 0 14px 14px;
    font-size: 12.5px;
    color: #2c3347;
    align-items: center;
  }

  .table-row.expanded .row-secondary-wrap,
  .user-row.expanded .row-secondary-wrap {
    display: grid !important;
  }

  /* Each secondary item: display:contents splits label (::before) and value into separate grid cols */
  .row-secondary-wrap > span,
  .row-secondary-wrap > div {
    display: contents;
  }

  .row-secondary-wrap > span::before,
  .row-secondary-wrap > div::before {
    content: attr(data-label) ":";
    font-size: 10px;
    color: #8a97b0;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
    align-self: center;
  }

  .row-secondary-wrap > span::after,
  .row-secondary-wrap > div::after {
    display: none;
  }

  /* Wide items: full row width */
  .row-secondary-wrap > .wide-item,
  .row-secondary-wrap > [data-wide="true"] {
    grid-column: 1 / -1;
    justify-content: flex-start;
    display: flex;
    flex-direction: column;
    gap: 4px 8px;
  }

  .row-secondary-wrap > .wide-item::before,
  .row-secondary-wrap > [data-wide="true"]::before {
    content: attr(data-label);
    font-size: 10px;
    color: #8a97b0;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: none;
    flex: 0 0 100%;
    text-align: right;
    margin-bottom: 4px;
    order: 1;
  }

  .row-secondary-wrap > .wide-item::after,
  .row-secondary-wrap > [data-wide="true"]::after {
    order: 2;
    flex: 0 0 100%;
    min-width: 0;
  }

  /* Items 5+ hidden by default, shown when expanded */
  .row-secondary-wrap > :nth-child(n+5) {
    display: none;
  }

  /* Show all items when row is expanded */
  .table-row.expanded .row-secondary-wrap > :nth-child(n+5),
  .user-row.expanded .row-secondary-wrap > :nth-child(n+5) {
    display: contents;
  }

  /* Primary items: max 4 visible, rest hidden on mobile */
  .row-primary-wrap > :nth-child(n+5) {
    display: none;
  }

  /* Action buttons in secondary: full-width row */
  .row-secondary-wrap .action-btns {
    grid-column: 1 / -1;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  /* Inputs/selects inside secondary items */
  .row-secondary-wrap input,
  .row-secondary-wrap select {
    width: 100%;
    box-sizing: border-box;
    margin-top: 2px;
  }

  /* user-rows container: remove max-height */
  .user-rows {
    max-height: none;
    overflow-y: visible;
  }

  /* user-cell in primary: flex layout */
  .row-primary-wrap .user-cell {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  /* price-table and finance-table: keep scroll for market view */
  .price-table,
  .finance-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Price row: keep columns, horizontal scroll */
  .price-row {
    grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr;
    min-width: 480px;
  }

  /* Finance row */
  .finance-row {
    grid-template-columns: 1.4fr 0.8fr 0.8fr;
    min-width: 360px;
  }

  /* ── Market cards ────────────────────────────────────────────────── */
  .market-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .market-card .actions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .market-card .btn {
    min-height: 46px;
  }

  /* ── Order card ──────────────────────────────────────────────────── */
  .order-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .order-meta {
    text-align: right;
    width: 100%;
  }

  /* ── Admin split ─────────────────────────────────────────────────── */
  .admin-split {
    grid-template-columns: 1fr;
  }

  /* ── Grids → single column ───────────────────────────────────────── */
  .quick-grid,
  .finance-grid,
  .grid-two,
  .form-grid,
  .profile-grid,
  .doc-grid,
  .user-list-grid,
  .portal-grid {
    grid-template-columns: 1fr;
  }

  /* ── Landing / hero ──────────────────────────────────────────────── */
  .landing {
    grid-template-columns: 1fr;
    gap: 16px;
    min-height: auto;
  }

  .hero-panel {
    padding: 20px 16px;
    border-radius: 18px;
  }

  .hero-panel h1 {
    font-size: 1.55rem;
  }

  .hero-actions {
    flex-direction: column;
  }

  /* ── Profile ─────────────────────────────────────────────────────── */
  .profile-hero {
    grid-template-columns: 1fr;
  }

  .profile-actions.top,
  .profile-actions.top.align-right {
    grid-column: auto;
    justify-content: flex-start;
    width: 100%;
  }

  /* ── Tabs ────────────────────────────────────────────────────────── */
  .tabs {
    gap: 6px;
  }

  .tabs .tab {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
    min-height: 42px;
    padding: 8px 10px;
  }

  .log-tabs {
    flex-wrap: wrap;
  }

  /* ── Modal: bottom sheet ─────────────────────────────────────────── */
  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card {
    width: 100%;
    max-width: 100%;
    border-radius: 22px 22px 0 0;
    padding: 22px 16px 28px;
    max-height: 92svh;
    max-height: 92vh;
    overflow-y: auto;
    animation: slideUp 220ms ease-out;
  }

  .modal-body {
    max-height: 55svh;
    max-height: 55vh;
  }

  .crop-modal .modal-card {
    width: 100%;
    border-radius: 22px 22px 0 0;
  }

  /* ── Notice stack ────────────────────────────────────────────────── */
  .notice-stack {
    bottom: 16px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
  }

  /* ── Login page ──────────────────────────────────────────────────── */
  .login-page {
    border-radius: 0;
    padding: 20px 16px;
    min-height: 100svh;
    min-height: 100vh;
    height: auto;
    margin: 0;
    width: 100%;
  }

  .login-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .login-hero {
    display: none;
  }

  .login-form-panel {
    max-width: 100%;
    padding: 0;
    width: 100%;
  }

  .auth-card {
    width: 100%;
    padding: 20px 14px;
    border-radius: 18px;
  }

  .auth-card h2 {
    font-size: 1.25rem;
  }

  .login-page .captcha-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .auth-shell.wide {
    width: 100%;
    padding: 0;
  }

  /* ── Buttons & inputs ────────────────────────────────────────────── */
  .btn {
    min-height: 44px;
  }

  .form-control,
  .table-input {
    min-height: 44px;
  }

  /* ── Settings ────────────────────────────────────────────────────── */
  .settings-section {
    padding: 14px;
  }

  .settings-actions-bar {
    flex-direction: column;
  }

  .settings-actions-bar .btn {
    width: 100%;
  }

  .branding-layout {
    grid-template-columns: 1fr;
  }

  .logo-preview {
    justify-self: center;
  }

  .sec-panel {
    padding: 16px 12px;
  }

  .sec-panel-body {
    grid-template-columns: 1fr;
  }

  .fee-mode-selector {
    flex-direction: column;
  }

  /* ── Logs / Products: remove fixed max-height ────────────────────── */
  .logs-page {
    min-height: auto;
  }

  .logs-page .table,
  .products-page .table {
    max-height: none;
    overflow-y: visible;
  }

  .logs-page .table-row.head,
  .products-page .table-row.head {
    position: relative;
  }

  /* ── Filter row ──────────────────────────────────────────────────── */
  .filter-row {
    flex-direction: column;
  }

  .filter-row .filter-control {
    width: 100% !important;
  }

  /* jcal-wrap has inline width — override it */
  .filter-row .jcal-wrap {
    width: 100% !important;
  }

  /* ── Backup ──────────────────────────────────────────────────────── */
  .backup-actions {
    flex-direction: column;
  }

  .backup-actions .btn {
    width: 100%;
  }

  /* ── Product actions ─────────────────────────────────────────────── */
  .product-actions {
    flex-wrap: wrap;
  }

  /* ── Save bar ────────────────────────────────────────────────────── */
  .save-bar {
    flex-direction: column;
    gap: 8px;
  }

  .save-bar .btn {
    width: 100%;
  }
}

/* ── Very small phones (iPhone SE, Galaxy A series) ──────────────── */
@media (max-width: 390px) {
  .topbar {
    padding: 10px 12px;
  }

  .brand h3 {
    font-size: 0.85rem;
    max-width: 100px;
  }

  .content {
    padding: 10px;
    padding-top: 60px; /* keep room for the overlay toggle bar */
    gap: 10px;
    min-width: 0;
  }

  .card {
    padding: 12px;
    border-radius: 12px;
    min-width: 0;
  }

  .login-page {
    padding: 18px 12px;
  }

  .hero-panel h1 {
    font-size: 1.35rem;
  }

  .auth-card {
    padding: 18px 12px;
  }

  .tabs .tab {
    font-size: 0.88rem;
    padding: 7px 8px;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   COMPREHENSIVE PANEL & COMPONENT RESPONSIVE — all views
   ═══════════════════════════════════════════════════════════════════ */

/* ─── 820px: foundation fixes ──────────────────────────────────── */
@media (max-width: 820px) {
  /* Tabs: horizontal scroll on all screen sizes ≤820px */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .log-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .log-tabs::-webkit-scrollbar { display: none; }

  /* Tables: consistent scroll UX */
  .table,
  .user-rows,
  .price-table,
  .finance-table {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(15, 43, 79, 0.2) transparent;
    min-width: 0;
  }
  .table::-webkit-scrollbar,
  .user-rows::-webkit-scrollbar { height: 4px; }
  .table::-webkit-scrollbar-thumb,
  .user-rows::-webkit-scrollbar-thumb {
    background: rgba(15, 43, 79, 0.2);
    border-radius: 2px;
  }

  /* Section head: better wrapping */
  .section-head .actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }
  .section-head .actions .form-control {
    flex: 1 1 160px;
    min-width: 0;
    width: auto;
    max-width: none;
  }
}

/* ─── 640px: comprehensive phone layout ─────────────────────────── */
@media (max-width: 640px) {

  /* === SHELL & NAVIGATION === */

  .side-panel { padding: 8px; }
  .side-toggle { min-height: 44px; border-radius: 10px; font-size: 0.9rem; }

  /* Open: expand as overlay dropdown, each item on its own full-width row */
  .side-panel.open {
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.30);
    overflow: visible;
  }
  .side-panel.open .side-menu {
    display: flex !important;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 6px 0 4px;
    max-height: 72vh;
    overflow-y: auto;
  }
  .side-panel .nav-item {
    width: 100%;
    flex: none;
    min-height: 44px;
    font-size: 0.88rem;
    padding: 10px 12px;
    justify-content: flex-start;
  }
  .side-panel .panel-card { min-width: 0; width: 100%; font-size: 0.88rem; }
  .side-panel > .btn.outline { width: 100%; }

  /* === TOPBAR === */

  .topbar { padding: 11px 14px; flex-direction: row; align-items: center; flex-wrap: nowrap; gap: 8px; }
  .brand-logo { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; }
  .brand { min-width: 0; overflow: hidden; flex: 1; }
  .brand h3 {
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .brand span { display: none; }
  .user-chip {
    padding: 5px 8px;
    gap: 5px;
    font-size: 0.8rem;
    flex-shrink: 0;
    border-radius: 10px;
  }
  .user-chip small { display: none; }
  .user-chip .btn.ghost {
    min-height: 34px;
    padding: 4px 10px;
    font-size: 0.78rem;
    border-radius: 8px;
  }

  /* === CONTENT & CARDS === */

  /* padding-top keeps content below the collapsed side-panel toggle bar (pad 8 + toggle 44 + pad 8) */
  .content { padding: 12px; padding-top: 60px; gap: 12px; min-width: 0; }
  .card { padding: 14px; border-radius: 14px; min-width: 0; }

  /* === SECTION HEAD === */

  .section-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }
  .section-head h2 { margin: 0; font-size: 1.05rem; }
  .section-head .actions .btn { flex-shrink: 0; min-height: 42px; }
  .section-head .pill { align-self: flex-start; }

  /* === TABS === */

  .tabs {
    gap: 7px;
    margin: 4px 0 14px;
    padding-bottom: 2px;
  }
  .tabs .tab {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 0.88rem;
    border-radius: 10px;
  }
  .log-tabs { gap: 7px; }

  /* === TABLES: card layout overrides === */

  /* Logs/Products: remove fixed max-height */
  .logs-page { min-height: auto; }
  .logs-page .table { max-height: none; overflow-y: visible; }
  .products-page .table { max-height: none; overflow-y: visible; }

  /* Products table: name input takes full row width */
  .table.table-products .row-primary-wrap > input.table-input {
    flex: 1 1 0;
    min-width: 0;
  }

  /* === MARKET CARDS (Prices view) === */

  .market-grid { gap: 10px; }
  .market-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px;
    border-radius: 14px;
  }
  /* Product name row: full width */
  .market-card > *:first-child { grid-column: 1 / -1; }
  .market-card h3 { margin-bottom: 2px; font-size: 1rem; }

  /* Buy / Sell price blocks side-by-side */
  .market-card .price-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid rgba(15, 23, 42, 0.07);
    border-radius: 10px;
    min-width: 0;
    pointer-events: none;
    box-shadow: none !important;
    border-color: rgba(15, 23, 42, 0.07) !important;
  }

  /* Action buttons: full width, side-by-side */
  .market-card .actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .market-card .btn { min-height: 46px; border-radius: 10px; font-size: 0.92rem; }

  /* === ORDER CARD === */

  .order-card { flex-direction: column; align-items: flex-start; gap: 10px; }
  .order-meta { text-align: right; width: 100%; }

  /* === GRIDS === */

  .admin-split { grid-template-columns: 1fr; }
  .landing { grid-template-columns: 1fr; gap: 16px; min-height: auto; }
  .portal-grid { grid-template-columns: 1fr; }
  .user-list-grid { grid-template-columns: 1fr; }
  .toggle-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .grid-two { grid-template-columns: 1fr; gap: 10px; }

  /* 2-column on mobile (items small enough) */
  .quick-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .finance-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .profile-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .doc-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

  .quick-card { padding: 12px 14px; border-radius: 12px; gap: 6px; }
  .quick-card i { font-size: 20px; }

  /* === PROFILE PAGE === */

  .profile-hero { grid-template-columns: auto 1fr; gap: 12px; }
  .profile-actions.top {
    grid-column: 1 / -1;
    justify-self: stretch;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  .profile-actions.top.align-right {
    grid-column: 1 / -1;
    justify-content: flex-start;
    direction: rtl;
  }
  .profile-actions { flex-wrap: wrap; gap: 6px; }

  /* === HERO / LANDING === */

  .hero-panel { padding: 20px 16px; border-radius: 16px; }
  .hero-panel h1 { font-size: 1.5rem; line-height: 1.35; }
  .hero-actions { flex-direction: column; gap: 8px; }
  .hero-actions .btn { width: 100%; }
  .portal-card { padding: 18px; }
  .portal-icon { width: 44px; height: 44px; font-size: 18px; }

  /* === SETTINGS PAGE === */

  .settings-section { padding: 16px; }
  .settings-section-head { flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
  .settings-actions-bar { flex-direction: column; gap: 8px; }
  .settings-actions-bar .btn { width: 100%; }
  .settings-inline-actions .btn { width: 100%; }
  .fee-mode-selector { flex-direction: column; gap: 8px; }
  .fee-mode-btn { min-height: 46px; }
  .branding-layout { grid-template-columns: 1fr; }
  .logo-preview { justify-self: center; width: 120px; height: 120px; }
  .toggle-item { padding: 12px 14px; }
  .settings-toggle { padding: 12px 14px; }

  /* === SECURITY PANEL === */

  .sec-panel { padding: 16px 14px; }
  .sec-panel-body { grid-template-columns: 1fr; row-gap: 20px; }
  .sec-field-row .form-control { width: 100px; max-width: 100px; }

  /* === FORMS & INPUTS === */

  .form-control,
  .table-input { min-height: 44px; }
  .form-group > label:not(.toggle) { font-size: 0.92rem; }
  .btn { min-height: 44px; }
  .btn.compact { min-height: 36px; }
  .btn.btn-sm { min-height: 30px; }
  .action-btns { flex-wrap: wrap; }
  .product-actions { flex-wrap: wrap; }

  /* === FILTERS === */

  .history-filters,
  .actions.history-filters { grid-template-columns: 1fr 1fr; gap: 6px; }
  .history-filters-row { margin: 0 0 8px; }
  .filter-row { flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
  .filter-row .filter-control { flex: 1 1 100% !important; min-width: 0; width: 100% !important; }
  .filter-row .jcal-wrap { width: 100% !important; }

  /* === CHARTS === */

  .price-chart { height: 220px; }
  .apex-chart-container {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }
  .apexcharts-canvas { max-width: 100% !important; }
  .apexcharts-svg { overflow: visible; }
  .chart-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.85rem;
  }
  .chart-point-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 12px;
  }

  /* === MODALS: bottom sheet === */

  .modal { padding: 0; align-items: flex-end; }
  .modal-card {
    width: 100%;
    max-width: 100%;
    border-radius: 24px 24px 0 0;
    padding: 22px 16px max(20px, env(safe-area-inset-bottom));
    max-height: 92vh;
    overflow-y: auto;
    animation: slideUp 220ms ease-out;
  }
  .modal-head {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
  }
  .modal-body { max-height: 52vh; }
  .modal-foot { flex-direction: column; gap: 8px; }
  .modal-foot .btn { width: 100%; }
  .crop-modal .modal-card { width: 100%; border-radius: 24px 24px 0 0; }

  /* === LOGIN / AUTH === */

  .login-page {
    border-radius: 0;
    padding: 20px 16px;
    min-height: 100vh;
    height: auto;
    margin: 0;
    width: 100%;
  }
  .login-layout { grid-template-columns: 1fr; gap: 18px; }
  .login-hero { display: none; }
  .login-form-panel { max-width: 100%; padding: 0; width: 100%; }
  .auth-card { width: 100%; padding: 22px 16px; border-radius: 20px; }
  .auth-card h2 { font-size: 1.25rem; }
  .login-page .captcha-row { grid-template-columns: 1fr; gap: 8px; }
  .auth-shell.wide { width: 100%; padding: 0; }
  .auth-mode .btn { min-height: 40px; padding: 9px 14px; }

  /* === MISC === */

  .save-bar { flex-direction: column; gap: 8px; border-radius: 0 0 14px 14px; }
  .save-bar .btn { width: 100%; }
  .backup-actions { flex-direction: column; gap: 8px; }
  .backup-actions .btn { width: 100%; }
  .notice-stack { bottom: 16px; left: 10px; right: 10px; width: auto; max-width: none; }
  .trading-disabled-full { padding: 40px 16px; gap: 12px; }
  .trading-disabled-icon { width: 72px; height: 72px; font-size: 1.8rem; }
  .trading-disabled-full h3 { font-size: 1.15rem; }
  .trading-disabled-banner { padding: 14px 16px; }
  .summary-row { gap: 8px; }
  .otp-input { letter-spacing: 4px; font-size: 1.2rem; }
  .divider { margin: 10px 0; }
  .hint { font-size: 0.83rem; }
  .alert { font-size: 0.9rem; padding: 10px 12px; }
}

/* ─── 480px: small phones ───────────────────────────────────────── */
@media (max-width: 480px) {
  .quick-grid { grid-template-columns: 1fr; }
  .finance-grid { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .grid-two { grid-template-columns: 1fr; }
  .profile-hero { grid-template-columns: auto 1fr; }
  .history-filters,
  .actions.history-filters { grid-template-columns: 1fr; }
}

/* ─── 390px: tiny phones (iPhone SE, etc.) ──────────────────────── */
@media (max-width: 390px) {
  .topbar { padding: 9px 12px; }
  .brand h3 { font-size: 0.84rem; }
  .content { padding: 10px; padding-top: 60px; gap: 10px; min-width: 0; } /* keep room for overlay toggle bar */
  .card { padding: 12px; border-radius: 12px; min-width: 0; }
  .login-page { padding: 18px 12px; }
  .auth-card { padding: 18px 12px; border-radius: 16px; }
  .hero-panel h1 { font-size: 1.3rem; }
  .side-panel .nav-item { min-width: 90px; font-size: 0.83rem; padding: 8px 10px; }
  .market-card { padding: 12px; }
  .modal-card { padding: 20px 14px 20px; }
  .tabs .tab { padding: 7px 12px; font-size: 0.85rem; }
}
