/* User Manager panel — RTL + responsive */
:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #38bdf8;
  --accent-dim: rgba(56, 189, 248, 0.15);
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --warning: #fbbf24;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "Vazirmatn", system-ui, sans-serif;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(56, 189, 248, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(52, 211, 153, 0.06), transparent);
  color: var(--text);
  line-height: 1.6;
}

a {
  color: var(--accent);
}

.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 0.9rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.header-title {
  margin: 0;
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.stats-grid-6 {
  grid-template-columns: repeat(6, 1fr);
}

.stats-grid-7 {
  grid-template-columns: repeat(7, 1fr);
}

.stats-grid-8 {
  grid-template-columns: repeat(8, 1fr);
}

@media (max-width: 1100px) {
  .stats-grid-8 {
    grid-template-columns: repeat(4, 1fr);
  }
  .stats-grid-7 {
    grid-template-columns: repeat(4, 1fr);
  }
  .stats-grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 700px) {
  .stats-grid-8,
  .stats-grid-7,
  .stats-grid-6 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-card-teal {
  border-color: rgba(20, 184, 166, 0.32);
  background: linear-gradient(145deg, var(--surface), rgba(20, 184, 166, 0.09));
}

.stat-card-teal .stat-card-value {
  color: #2dd4bf;
}

.stat-card-wan-pulse {
  animation: wan-pulse 0.4s ease-out;
}

@keyframes wan-pulse {
  0%   { opacity: 0.5; transform: scale(0.97); }
  100% { opacity: 1;   transform: scale(1); }
}

.stat-card-danger {
  border-color: rgba(248, 113, 113, 0.35);
  background: linear-gradient(145deg, var(--surface), rgba(248, 113, 113, 0.1));
}

.stat-card-danger .stat-card-value {
  color: var(--danger);
}

.stat-card {
  padding: 0.95rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card-accent {
  border-color: rgba(56, 189, 248, 0.3);
  background: linear-gradient(145deg, var(--surface), rgba(56, 189, 248, 0.08));
}

.stat-card-success {
  border-color: rgba(52, 211, 153, 0.28);
  background: linear-gradient(145deg, var(--surface), rgba(52, 211, 153, 0.07));
}

.stat-card-warn {
  border-color: rgba(248, 113, 113, 0.22);
  background: linear-gradient(145deg, var(--surface), rgba(248, 113, 113, 0.06));
}

.stat-card-purple {
  border-color: rgba(167, 139, 250, 0.28);
  background: linear-gradient(145deg, var(--surface), rgba(167, 139, 250, 0.07));
}

.stat-card-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 0.3rem;
  white-space: nowrap;
}

.stat-card-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: min(100%, 200px);
  max-width: 260px;
}

.btn-ghost-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.25);
}

.btn-ghost-danger:hover {
  background: var(--danger-bg);
  border-color: rgba(248, 113, 113, 0.45);
}

.search-wrap svg {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 0.65rem 2.75rem 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.search-wrap input::placeholder {
  color: var(--muted);
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #2d3d52;
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  border-color: transparent;
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
}

.btn-danger {
  background: var(--danger-bg);
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.22);
}

.btn-warn {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.35);
  color: var(--warning);
}

.btn-warn:hover {
  background: rgba(251, 191, 36, 0.18);
}

.btn-success {
  background: var(--success-bg);
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--success);
}

.btn-success:hover {
  background: rgba(52, 211, 153, 0.2);
}

.btn-info {
  background: var(--accent-dim);
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--accent);
}

.btn-info:hover {
  background: rgba(56, 189, 248, 0.22);
}

.panel {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.wg-panel {
  margin-top: 1rem;
}

.wg-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
}

.wg-panel-title {
  margin: 0;
  font-size: 0.95rem;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.um-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.um-table--ltr-cols {
  direction: ltr;
}

.um-table--ltr-cols thead th {
  text-align: right;
}

.um-table--ltr-cols tbody td {
  text-align: right;
}

.um-table--ltr-cols .cell-actions-th {
  width: 1%;
  min-width: 10rem;
}

.um-table thead th {
  text-align: right;
  padding: 0.85rem 1rem;
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.um-table tbody tr {
  border-top: 1px solid var(--border);
  transition: background 0.12s;
}

.um-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.um-table td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
}

.um-table .cell-actions {
  white-space: nowrap;
  min-width: fit-content;
}

.um-table .cell-actions .btn-wrap {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  justify-content: flex-end;
  align-items: center;
}

.um-table .cell-actions .btn-wrap .btn-sm {
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-online {
  background: var(--success-bg);
  color: var(--success);
}

.badge-offline {
  background: rgba(139, 156, 179, 0.15);
  color: var(--muted);
}

.badge-active {
  background: var(--success-bg);
  color: var(--success);
}

.badge-inactive {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-expired {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.pw-text {
  font-family: ui-monospace, "Vazirmatn", monospace;
  font-size: 0.82rem;
  word-break: break-all;
  color: var(--text);
}

.profile-tag {
  font-family: ui-monospace, "Vazirmatn", monospace;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

.usage-cell {
  font-family: ui-monospace, "Vazirmatn", monospace;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

/* ── ستون انقضا — badge‌های رنگی ── */
.expiry-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}

/* منقضی شده — قرمز */
.expiry-expired {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
}

/* امروز یا فردا — نارنجی/قرمز */
.expiry-critical {
  background: rgba(251, 146, 60, 0.15);
  color: #fb923c;
  border-color: rgba(251, 146, 60, 0.35);
}

/* ۲ تا ۷ روز — زرد */
.expiry-warn {
  background: rgba(251, 191, 36, 0.13);
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.3);
}

/* ۸ تا ۳۰ روز — آبی روشن */
.expiry-soon {
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.25);
}

/* بیش از ۳۰ روز — سبز */
.expiry-ok {
  background: rgba(52, 211, 153, 0.1);
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.25);
}

/* ردیف کاربر منقضی‌شده */
.um-table tbody tr.row-expired {
  background: rgba(248, 113, 113, 0.04);
}

.um-table tbody tr.row-expired:hover {
  background: rgba(248, 113, 113, 0.08);
}

/* ترتیب ستون‌ها در موبایل */
.um-col-expiry { order: 4; }

/* حجم مصرفی: عدد و واحد KB/MB/GB چپ‌به‌راست؛ واحد سمت راست عدد */
.usage-ltr {
  direction: ltr;
  display: inline-block;
  unicode-bidi: embed;
  text-align: left;
}

.usage-cell .usage-num {
  font-variant-numeric: tabular-nums;
}

.usage-cell .usage-unit {
  margin-inline-start: 0.35em;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.92em;
}

.um-table .cell-online-led {
  white-space: nowrap;
}

.online-led-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.online-led {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(139, 156, 179, 0.5);
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}

.online-led--on {
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.65);
  animation: online-led-blink 1.1s ease-in-out infinite;
}

@keyframes online-led-blink {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.65);
  }
  50% {
    opacity: 0.55;
    box-shadow: 0 0 14px 6px rgba(52, 211, 153, 0.4);
  }
}

.online-led-text {
  font-size: 0.78rem;
  min-width: 2.75rem;
}

.traffic-cell {
  cursor: help;
  font-size: 0.88rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.loading {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  max-width: min(90vw, 420px);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  z-index: 450;
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.err {
  border-color: rgba(248, 113, 113, 0.4);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: scale(0.96);
  transition: transform 0.2s;
}

.modal--create {
  max-width: 500px;
  padding: 0;
  max-height: calc(100vh - 2rem);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 156, 179, 0.45) transparent;
}

.modal--create::-webkit-scrollbar {
  width: 8px;
}

.modal--create::-webkit-scrollbar-thumb {
  background: rgba(139, 156, 179, 0.45);
  border-radius: 999px;
}

.modal-backdrop.open .modal {
  transform: scale(1);
}

.modal h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.modal label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* راهنمای کنار لیبل */
.field-hint {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 400;
}

/* نکته رمز خودکار دسته‌ای */
.bulk-pw-note {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  line-height: 1.4;
}

.bulk-pw-note svg {
  flex-shrink: 0;
  opacity: 0.85;
}

/* ── Create modal tabs ── */
.create-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(4px);
}

.create-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  min-height: 46px;
}

.create-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.create-tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}

.create-pane-title {
  margin: 0 0 1.1rem;
  font-size: 1.05rem;
  font-weight: 700;
}

#create-pane-single,
#create-pane-bulk,
#create-pane-wg {
  padding: 1.4rem 1.5rem 1.5rem;
}

.wg-helper-line {
  margin: -0.2rem 0 0.7rem;
  font-size: 0.76rem;
  color: var(--muted);
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  line-height: 1.45;
}

.wg-output {
  margin-top: 0.95rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.wg-output-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.wg-output-body {
  display: grid;
  gap: 0.65rem;
  justify-items: center;
}

.wg-qr-image {
  width: 220px;
  height: 220px;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.35rem;
}

.wg-config-text {
  width: 100%;
  min-height: 170px;
  max-height: 280px;
  resize: vertical;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "Vazirmatn", monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  direction: ltr;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.wg-config-text:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

#create-pane-wg .modal-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--surface) 72%, rgba(26, 35, 50, 0.4));
  padding-top: 0.75rem;
  margin-top: 0.6rem;
}

/* رمز عبور + دکمه تصادفی */
.pw-field-wrap {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pw-field-input {
  flex: 1;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "Vazirmatn", monospace;
  font-size: 0.92rem;
}

.pw-field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ردیف فیلدهای bulk */
.bulk-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  margin-bottom: 0.1rem;
}

.bulk-field label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.bulk-field input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  margin-bottom: 0.85rem;
}

.bulk-field-sm input {
  width: 70px;
}

/* Progress bar */
.bulk-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.45rem;
}

.bulk-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 99px;
  transition: width 0.25s ease;
  width: 0%;
}

.bulk-progress-text {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.85rem;
  text-align: center;
}

/* ── Bulk result modal ── */
.modal--bulk-result {
  max-width: 500px;
}

.bulk-result-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 1.1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.bulk-result-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.85rem;
  direction: ltr;
}

.bulk-result-item:last-child {
  border-bottom: none;
}

.bulk-result-user {
  font-weight: 700;
  color: var(--accent);
  font-family: ui-monospace, "Vazirmatn", monospace;
  min-width: 0;
}

.bulk-result-sep {
  color: var(--border);
  flex-shrink: 0;
}

.bulk-result-pass {
  color: var(--muted);
  font-family: ui-monospace, "Vazirmatn", monospace;
}

.bulk-result-failed {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  color: var(--danger);
  text-align: center;
}

.modal input[type="password"],
.modal input[type="text"],
.modal select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

.modal select {
  cursor: pointer;
}


.modal .modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.modal-backdrop--success {
  z-index: 400;
}

.modal-backdrop--info {
  z-index: 400;
}

.modal--info-sheet {
  max-width: 460px;
  padding: 1.65rem 1.5rem;
  border: 1px solid rgba(56, 189, 248, 0.22);
  background: linear-gradient(160deg, var(--surface) 0%, rgba(56, 189, 248, 0.05) 100%);
}

.info-sheet-icon {
  color: var(--accent) !important;
}

.modal--success-sheet {
  max-width: 460px;
  padding: 1.65rem 1.5rem;
  border: 1px solid rgba(52, 211, 153, 0.22);
  background: linear-gradient(160deg, var(--surface) 0%, rgba(52, 211, 153, 0.06) 100%);
}

.success-sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.15rem;
}

.success-sheet-icon {
  flex-shrink: 0;
  color: var(--success);
  line-height: 0;
}

.success-sheet-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.success-sheet-sub {
  margin: 0.3rem 0 0;
  line-height: 1.45;
}

.success-sheet-body {
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 1.1rem;
}

.cred-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.success-sheet-body > .cred-row:nth-child(3) {
  border-bottom: none;
  padding-bottom: 0;
}

.cred-row:first-child {
  padding-top: 0;
}

.cred-label {
  flex-shrink: 0;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.cred-value {
  margin: 0;
  font-size: 0.92rem;
  text-align: left;
  direction: ltr;
  unicode-bidi: embed;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.cred-plain.cred-value {
  background: transparent;
  padding: 0.35rem 0;
}

.cred-link-block {
  margin-top: 0.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.cred-link-block .cred-label {
  display: block;
  margin-bottom: 0.4rem;
}

.cred-link {
  display: inline-block;
  font-size: 0.88rem;
  font-weight: 600;
  word-break: break-all;
  line-height: 1.5;
}

.cred-link:hover {
  text-decoration: underline;
}

.success-sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
}

.btn-copy-share {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.btn-copy-share.btn-copy-done {
  background: var(--success-bg);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--success);
}

.meta-muted {
  font-size: 0.8rem;
  color: var(--muted);
}

.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;
}

/* Mobile cards */
@media (max-width: 768px) {
  .um-table thead {
    display: none;
  }

  .um-table tbody tr {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    margin: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
  }

  .um-table tbody td {
    display: grid;
    grid-template-columns: minmax(100px, 38%) 1fr;
    gap: 0.5rem;
    padding: 0.45rem 0;
    border: none;
    align-items: center;
  }

  .um-table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
  }

  .um-col-user    { order: 1; }
  .um-col-pw      { order: 2; }
  .um-col-profile { order: 3; }
  .um-col-expiry  { order: 4; }
  .um-col-usage   { order: 5; }
  .um-col-status  { order: 6; }
  .um-col-online  { order: 7; }
  .um-col-actions { order: 8; }

  .um-table .cell-actions {
    grid-template-columns: 1fr;
    padding-top: 0.75rem;
  }

  .um-table .cell-actions::before {
    display: none;
  }

  .um-table .cell-actions .btn-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: flex-start;
  }

  .um-table .cell-actions .btn-wrap .btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
  }
}

@media (min-width: 769px) {
  .um-table .cell-actions .btn-wrap {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.3rem;
    justify-content: flex-end;
  }
}

/* ── Profile Sales Card ────────────────────────────────────── */
.profile-sales-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem 1.35rem;
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
}

.profile-sales-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 60% at 100% 0%, rgba(52, 211, 153, 0.05), transparent);
  pointer-events: none;
}

.profile-sales-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.profile-sales-head-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--accent);
}

.profile-sales-head-title svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.profile-sales-title {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.profile-sales-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.profile-sales-total {
  text-align: right;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
}

.profile-sales-total-label {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
  text-align: right;
}

.profile-sales-total-value {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--success);
  direction: ltr;
  letter-spacing: -0.02em;
}

.profile-sales-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.85rem;
}

@media (max-width: 960px) {
  .profile-sales-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  .profile-sales-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.psi {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 1rem 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.15s, transform 0.15s;
}

.psi:hover {
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-2px);
}

.psi-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: ui-monospace, "Vazirmatn", monospace;
  padding: 0.28rem 0.7rem;
  border-radius: 6px;
  width: fit-content;
  letter-spacing: 0.05em;
}

.psi-badge-1 {
  background: rgba(56, 189, 248, 0.13);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.28);
}

.psi-badge-2 {
  background: rgba(52, 211, 153, 0.13);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.28);
}

.psi-badge-3 {
  background: rgba(251, 191, 36, 0.13);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.28);
}

.psi-badge-4 {
  background: rgba(167, 139, 250, 0.13);
  color: #a78bfa;
  border: 1px solid rgba(167, 139, 250, 0.28);
}

.psi-badge-5 {
  background: rgba(251, 113, 133, 0.13);
  color: #fb7185;
  border: 1px solid rgba(251, 113, 133, 0.28);
}

.psi-price-hint {
  font-size: 0.7rem;
  color: var(--muted);
  direction: rtl;
  line-height: 1.4;
}

.psi-count-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.32rem;
  margin-top: 0.15rem;
}

.psi-count {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.psi-unit {
  font-size: 0.72rem;
  color: var(--muted);
}

.psi-breakdown {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.68rem;
  direction: rtl;
  min-height: 1.1em;
  flex-wrap: wrap;
}
.psi-bd-created {
  color: var(--success);
  font-weight: 600;
}
.psi-bd-renewed {
  color: var(--accent);
  font-weight: 600;
}
.psi-bd-sep {
  color: var(--muted);
  font-size: 0.62rem;
}

.psi-amount {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--success);
  direction: ltr;
  font-family: ui-monospace, "Vazirmatn", monospace;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
  margin-top: 0.1rem;
}

/* --- Pagination ----------------------------------------------------------- */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.pagination-info strong {
  color: var(--text);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.pg-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  line-height: 1;
}

.pg-btn:hover:not(:disabled) {
  background: var(--surface3, #2a3550);
  color: var(--text);
  border-color: var(--border2, rgba(255,255,255,0.15));
}

.pg-btn.pg-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: default;
}

.pg-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pg-ellipsis {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0 0.2rem;
  user-select: none;
}

/* --- Filter Buttons ------------------------------------------------------- */
.filter-btns {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.btn-filter:hover {
  background: var(--surface3, #2a3550);
  color: var(--text);
}

.btn-filter--active {
  border-color: currentColor;
}

.btn-filter--active.btn-filter:has(.filter-dot-online) {
  color: var(--success);
  background: rgba(52,211,153,0.1);
  border-color: rgba(52,211,153,0.4);
}

.btn-filter--active.btn-filter:has(.filter-dot-expired) {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(248,113,113,0.4);
}

.filter-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-dot-online   { background: var(--success); }
.filter-dot-expired  { background: var(--danger); }
.filter-dot-inactive { background: #f59e0b; }
.filter-dot-unused   { background: var(--teal, #2dd4bf); }

.btn-filter--active.btn-filter:has(.filter-dot-unused) {
  color: var(--teal, #2dd4bf);
  background: rgba(45, 212, 191, 0.1);
  border-color: rgba(45, 212, 191, 0.45);
}

.btn-filter--active.btn-filter:has(.filter-dot-inactive) {
  color: #f59e0b;
  background: rgba(245,158,11,0.12);
  border-color: rgba(245,158,11,0.4);
}

/* --- Export unused CSV bar ----------------------------------------------- */
.unused-export-bar[hidden] { display: none !important; }

.unused-export-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
  padding: 0.55rem 0.85rem;
  margin-bottom: 0.65rem;
  background: color-mix(in srgb, var(--teal, #14b8a6) 12%, var(--surface2));
  border: 1px solid color-mix(in srgb, var(--teal, #14b8a6) 35%, transparent);
  border-radius: var(--radius, 8px);
  animation: bulk-bar-in 0.15s ease;
}

.unused-export-hint {
  font-size: 0.84rem;
  color: var(--text2);
  line-height: 1.45;
}

/* --- Bulk Action Bar ------------------------------------------------------ */
.bulk-action-bar[hidden] { display: none !important; }

.bulk-action-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-basis: 100%;
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-top: 0.25rem;
  background: color-mix(in srgb, var(--primary, #3b82f6) 10%, var(--surface2));
  border: 1px solid color-mix(in srgb, var(--primary, #3b82f6) 30%, transparent);
  border-radius: calc(var(--radius) - 2px);
  flex-wrap: wrap;
  animation: bulk-bar-in 0.15s ease;
}

@keyframes bulk-bar-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bulk-count-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary, #3b82f6);
  white-space: nowrap;
}

.bulk-action-btns {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* --- Checkbox Column ------------------------------------------------------- */
.cell-check-th,
.cell-check {
  width: 2.2rem;
  min-width: 2.2rem;
  text-align: center;
  padding-inline: 0.4rem;
}

.row-check {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--primary, #3b82f6);
}

#check-all {
  cursor: pointer;
  accent-color: var(--primary, #3b82f6);
  width: 1rem;
  height: 1rem;
}

/* --- Selected Row ---------------------------------------------------------- */
tr.row-selected > td {
  background: color-mix(in srgb, var(--primary, #3b82f6) 8%, transparent) !important;
}

/* --- Sales Date Navigation ------------------------------------------------ */
.sales-date-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.25rem 0.4rem;
}

.sales-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  min-width: 28px;
  padding: 0 0.4rem;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.sales-nav-btn:hover:not(:disabled) {
  background: var(--surface3, #2a3550);
  color: var(--text);
}
.sales-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.sales-today-btn {
  padding: 0 0.65rem;
  font-size: 0.75rem;
  color: var(--accent);
}
.sales-today-btn:hover:not(:disabled) { color: var(--text); }

.sales-date-input {
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0 0.2rem;
  outline: none;
  direction: ltr;
  min-width: 0;
  width: 120px;
}
.sales-date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}
