/* ═══════════════════════════════════════════════════════════
   PHPV1 — Global Stylesheet
   Palette reference: strategic-analysis-v5 (charcoal + green)
   Font: Vazirmatn · Tahoma fallback
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-dark:    #111111;
  --bg-sidebar: #181818;
  --bg-card:    #1e1e1e;
  --bg-input:   #242424;
  --bg-hover:   #2a2a2a;

  /* Borders */
  --border:     #2e2e2e;
  --border-l:   #3a3a3a;

  /* Text */
  --text:       #e8e8e8;
  --text-muted: #8e8ea0;
  --text-dim:   #5c5c72;

  /* Accent */
  --primary:    #10a37f;
  --primary-h:  #0d8a6a;
  --primary-bg: rgba(16,163,127,.1);
  --primary-bg2:rgba(16,163,127,.18);

  /* Status */
  --danger:     #ff6b6b;
  --danger-bg:  rgba(255,107,107,.1);
  --success:    #10a37f;
  --warning:    #ffa94d;

  /* Subtle overlays (theme-aware — light theme below overrides these) */
  --overlay-1:  rgba(255,255,255,.036);
  --overlay-2:  rgba(255,255,255,.05);

  /* Text sitting on a saturated green/mint tinted background (AI table
     headers, "copied" state) — needs to flip to a dark shade in light
     theme or it goes pale-on-pale and unreadable. */
  --mint-accent-text: #a8f0d8;
}

/* ── Light theme (تنظیمات > عمومی) ────────────────────────────
   Same variable names, light values — primary green stays the same
   accent color so the app is recognizable in either mode. */
html[data-theme="light"] {
  --bg-dark:    #f7f7f8;
  --bg-sidebar: #ffffff;
  --bg-card:    #ffffff;
  --bg-input:   #f0f0f2;
  --bg-hover:   #e9e9ec;

  --border:     #e2e2e6;
  --border-l:   #d3d3d9;

  --text:       #1f1f24;
  --text-muted: #6b6b7a;
  --text-dim:   #9a9aa8;

  --primary:    #10a37f;
  --primary-h:  #0d8a6a;
  --primary-bg: rgba(16,163,127,.08);
  --primary-bg2:rgba(16,163,127,.14);

  --danger:     #e0363f;
  --danger-bg:  rgba(224,54,63,.08);
  --success:    #10a37f;
  --warning:    #d97a1f;

  --overlay-1:  rgba(0,0,0,.035);
  --overlay-2:  rgba(0,0,0,.05);

  --mint-accent-text: #0b6b52;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  background: var(--bg-dark);
  color: var(--text);
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  margin: 0;
}

/* Universal font override */
input, textarea, select, button,
.form-control, .form-select,
.modal-title, .dropdown-item,
h1, h2, h3, h4, h5, h6 {
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-l); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a4a; }

/* ── Selections ────────────────────────────────────────────── */
::selection { background: var(--primary-bg2); color: var(--text); }

/* ── Form Controls (dark) ──────────────────────────────────── */
.form-control-dark, .form-select-dark,
.form-control, .form-select {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: 8px;
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
  font-size: 13px;
  transition: border-color .2s, box-shadow .2s;
}
.form-control-dark:focus, .form-select-dark:focus,
.form-control:focus, .form-select:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(16,163,127,.15) !important;
  background: var(--bg-input) !important;
  color: var(--text) !important;
  outline: none;
}
.form-control-dark::placeholder, .form-control::placeholder {
  color: var(--text-dim);
  opacity: 1;
}
.form-select-dark option, .form-select option {
  background: var(--bg-card);
  color: var(--text);
}
.form-label, .form-label-dark {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: .35rem;
}
.form-text { color: var(--text-dim); font-size: 11px; margin-top: 3px; }
.form-check-input {
  background-color: var(--bg-input);
  border-color: var(--border-l);
}
.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}
.form-check-label { color: var(--text-muted); font-size: 13px; }

/* Textarea */
textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.6; }

/* ── Streaming AI Indicator ────────────────────────────────── */
.streaming::after {
  content: '●';
  color: var(--primary);
  font-size: .5em;
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
  animation: aiPulse 1.4s ease-in-out infinite;
}
@keyframes aiPulse {
  0%, 100% { opacity: .15; transform: scale(.5); }
  50%       { opacity: 1;   transform: scale(1.3); filter: drop-shadow(0 0 4px var(--primary)); }
}

/* ── Processing dots ───────────────────────────────────────── */
.proc-dots { display: inline-flex; gap: 3px; align-items: center; margin-left: 5px; }
.proc-dots span {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--primary);
  animation: dotRise .9s ease-in-out infinite;
}
.proc-dots span:nth-child(2) { animation-delay: .18s; }
.proc-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes dotRise {
  0%, 100% { transform: translateY(0);    opacity: .25; }
  50%       { transform: translateY(-4px); opacity: 1; }
}

/* ── AI Thinking Spinner ───────────────────────────────────── */
.ai-thinking-spinner { position: relative; width: 50px; height: 50px; flex-shrink: 0; }
.ats-ring { position: absolute; border-radius: 50%; border: 2px solid transparent; }
.ats-ring-1 {
  inset: 0;
  border-top-color: var(--primary);
  border-right-color: rgba(16,163,127,.25);
  animation: atsRot 1.3s linear infinite;
}
.ats-ring-2 {
  inset: 9px;
  border-top-color: var(--warning);
  border-left-color: rgba(255,169,77,.25);
  animation: atsRot 1.9s linear infinite reverse;
}
.ats-core {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  animation: atsPulse 2s ease-in-out infinite;
}
@keyframes atsRot   { to { transform: rotate(360deg); } }
@keyframes atsPulse {
  0%, 100% { opacity: .5;  color: var(--primary); }
  50%       { opacity: 1;  color: var(--primary); filter: drop-shadow(0 0 5px var(--primary)); }
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast-msg {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--border-l);
  color: var(--text); padding: 10px 24px; border-radius: 10px;
  font-size: 13px; z-index: 9999; box-shadow: 0 4px 20px rgba(0,0,0,.5);
  white-space: nowrap; animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

/* ── Alerts ────────────────────────────────────────────────── */
.alert-app { border-radius: 10px; padding: .75rem 1rem; font-size: .88rem; margin-bottom: 1rem; display: none; }
.alert-app.show { display: block; }
.alert-danger-app  { background: rgba(255,107,107,.1); border: 1px solid rgba(255,107,107,.3); color: var(--danger); }
.alert-success-app { background: rgba(16,163,127,.1);  border: 1px solid rgba(16,163,127,.3);  color: var(--primary); }

/* ═══════════════════════════════════════════════════════════
   AUTH PAGES
   ═══════════════════════════════════════════════════════════ */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: #0d0d0d;
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(16,163,127,.07) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 80%, rgba(16,163,127,.05) 0%, transparent 50%);
}
.auth-wrapper { width: 100%; max-width: 400px; padding: 1.25rem; }
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-l);
  border-radius: 18px;
  padding: 2.5rem 2rem;
  box-shadow: 0 0 0 1px rgba(16,163,127,.05), 0 24px 64px rgba(0,0,0,.6);
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo-img {
  width: 80px; height: 80px; object-fit: contain;
  display: block; margin: 0 auto .75rem;
  border-radius: 20px;
  filter: drop-shadow(0 0 18px rgba(16,163,127,.35));
}
.auth-logo .app-name { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.navbar-logo-img {
  width: 28px; height: 28px; object-fit: contain;
  border-radius: 7px; margin-left: .45rem; vertical-align: middle;
  filter: drop-shadow(0 0 6px rgba(16,163,127,.3));
}
.auth-card .form-label { color: var(--text-muted); font-weight: 600; margin-bottom: .4rem; font-size: 13px; }
.auth-card .form-control {
  background: var(--bg-input) !important;
  border: 1px solid var(--border-l) !important;
  color: var(--text) !important;
  border-radius: 10px;
  padding: .75rem 1rem;
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 2px;
  direction: ltr;
  transition: border-color .2s, box-shadow .2s;
}
.auth-card .form-control:focus {
  background: var(--bg-input) !important;
  border-color: var(--primary) !important;
  color: var(--text) !important;
  box-shadow: 0 0 0 3px rgba(16,163,127,.18) !important;
}
.auth-card .form-control::placeholder { color: var(--text-dim); letter-spacing: 0; }

.btn-primary-app {
  background: var(--primary);
  border: none; color: #fff;
  border-radius: 10px; padding: .78rem;
  font-size: .95rem; font-weight: 700;
  width: 100%; cursor: pointer;
  transition: background .2s, box-shadow .2s;
  letter-spacing: .3px;
}
.btn-primary-app:hover {
  background: var(--primary-h);
  box-shadow: 0 4px 16px rgba(16,163,127,.3);
}
.btn-primary-app:disabled { background: var(--border-l); color: var(--text-dim); cursor: not-allowed; box-shadow: none; }

.auth-hint { font-size: .85rem; color: var(--text-muted); text-align: center; margin-top: 1rem; }
.auth-hint a { color: var(--primary); text-decoration: none; }
.auth-hint a:hover { text-decoration: underline; }

/* OTP inputs */
.otp-inputs { display: flex; gap: .5rem; justify-content: center; direction: ltr; }
.otp-inputs input {
  width: 46px; height: 54px;
  text-align: center; font-size: 1.5rem; font-weight: 700;
  background: var(--bg-input) !important;
  border: 1px solid var(--border-l) !important;
  color: var(--text) !important;
  border-radius: 10px;
  transition: border-color .2s, box-shadow .2s;
}
.otp-inputs input:focus {
  border-color: var(--primary) !important;
  outline: none; box-shadow: 0 0 0 3px rgba(16,163,127,.18) !important;
}

/* ═══════════════════════════════════════════════════════════
   APP LAYOUT — Navbar, Sidebar, Main
   ═══════════════════════════════════════════════════════════ */
.app-navbar {
  height: 54px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
}
.app-navbar .navbar-brand {
  color: var(--text); font-weight: 800; font-size: 1rem;
  display: flex; align-items: center; gap: .5rem;
  letter-spacing: -.2px;
}
.app-navbar .navbar-brand::before {
  content: '';
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--primary);
  box-shadow: 0 0 8px rgba(16,163,127,.6);
  flex-shrink: 0;
}

.app-version-badge {
  font-size: .68rem; font-weight: 600; color: var(--text-muted);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: .1rem .5rem; direction: ltr;
}

/* Navbar datetime */
.navbar-datetime {
  align-items: center; gap: .45rem;
  font-size: .75rem; font-family: monospace;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .28rem .85rem;
  letter-spacing: .3px;
}
.ndt-jalali { color: var(--primary); font-weight: 600; }
.ndt-greg   { color: var(--text-dim); }
.ndt-time   { color: var(--text); font-weight: 600; }
.ndt-sep    { color: var(--border); }

/* Theme picker (پنل کاربری > تنظیمات > عمومی, and پنل ادمین > تنظیمات کلی) */
.theme-pick { display:flex; gap:.6rem; flex-wrap:wrap; }
.theme-opt {
  display:flex; align-items:center; gap:.4rem; background:var(--bg-input); border:1px solid var(--border);
  color:var(--text-muted); border-radius:10px; padding:.55rem 1.1rem; font-size:.85rem; font-weight:600;
  cursor:pointer; transition:all .15s; font-family:'Vazirmatn',sans-serif;
}
.theme-opt-on { border-color:var(--primary); color:var(--primary); background:var(--primary-bg); }

/* Credit badge */
.credit-badge {
  background: var(--primary-bg);
  border: 1px solid rgba(16,163,127,.25);
  color: var(--primary);
  padding: .3rem .8rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 700;
  display: inline-flex; align-items: center; gap: .35rem;
}

/* Notification bell */
.notif-btn {
  position: relative; background: transparent; border: 1px solid var(--border-l);
  color: var(--text-muted); border-radius: 8px; padding: .3rem .55rem;
  font-size: 1rem; cursor: pointer; transition: all .15s; line-height: 1;
  display: inline-flex; align-items: center;
}
.notif-btn:hover { background: var(--bg-hover); color: var(--text); }
.notif-badge {
  position: absolute; top: -5px; left: -5px;
  background: var(--danger); color: #fff;
  font-size: .6rem; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; line-height: 1;
}
.notif-menu { min-width: 280px; max-height: 380px; overflow-y: auto; }
.notif-item { padding: .6rem 1rem; border-bottom: 1px solid var(--border); }
.notif-item.read .notif-msg { color: var(--text-muted); }
.notif-item:not(.read) { background: rgba(16,163,127,.04); }
.notif-item:not(.read) .notif-msg { color: var(--text); font-weight: 600; }
.notif-msg { font-size: .82rem; line-height: 1.5; }
.notif-date { font-size: .72rem; color: var(--text-dim); margin-top: .2rem; direction: ltr; text-align: right; }

/* Profile dropdown button */
.app-navbar .btn-outline-secondary {
  background: transparent !important;
  border: 1px solid var(--border-l) !important;
  color: var(--text-muted) !important;
  font-size: .8rem; padding: .3rem .7rem;
  border-radius: 8px;
  transition: all .15s;
}
.app-navbar .btn-outline-secondary:hover {
  background: var(--bg-hover) !important;
  color: var(--text) !important;
  border-color: var(--border-l) !important;
}

/* Sidebar */
.app-sidebar {
  width: 230px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  position: fixed; top: 54px; right: 0; bottom: 0;
  overflow: hidden;
  display: flex; flex-direction: column;
  z-index: 99;
  transition: width .25s, transform .25s;
  padding-top: .5rem;
}
.sidebar-nav { list-style: none; padding: .5rem .65rem; margin: 0; flex: 1; overflow-y: auto; }
.sidebar-link {
  display: flex; align-items: center; gap: .55rem;
  padding: .6rem .85rem;
  border-radius: 9px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  transition: background .12s, color .12s;
  margin-bottom: .15rem;
  white-space: nowrap; overflow: hidden;
}
.sidebar-link i { font-size: .95rem; flex-shrink: 0; }
.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.sidebar-link.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}
.sidebar-link.active i { filter: drop-shadow(0 0 4px rgba(16,163,127,.4)); }
.sidebar-admin-link { color: #f59e0b; border-top: 1px solid var(--border); margin-top: .35rem; padding-top: .6rem; }
.sidebar-admin-link:hover { background: rgba(245,158,11,.1); color: #fbbf24; }

/* Sidebar groups */
.sidebar-group { list-style: none; }
.sidebar-group-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: .6rem .85rem;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: .875rem; border-radius: 8px;
  gap: .55rem; transition: background .15s, color .15s;
  white-space: nowrap; overflow: hidden;
}
.sidebar-group-btn:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-group-btn:not(.collapsed) { color: var(--primary); }
.sidebar-group-arrow { font-size: .7rem; flex-shrink: 0; transition: transform .2s; }
.sidebar-group-btn:not(.collapsed) .sidebar-group-arrow { transform: rotate(180deg); }
.sidebar-sub-nav { list-style: none; padding: .2rem 0 .3rem .5rem; margin: 0; }
.sidebar-sub-link {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .85rem .45rem 1rem;
  border-radius: 8px; text-decoration: none;
  color: var(--text-muted); font-size: .84rem;
  transition: background .15s, color .15s;
  white-space: nowrap; overflow: hidden; position: relative;
}
.sidebar-sub-link::before {
  content: ''; position: absolute; right: .3rem; top: 50%; transform: translateY(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--border); transition: background .15s;
}
.sidebar-sub-link:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-sub-link:hover::before { background: var(--text-muted); }
.sidebar-sub-link.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.sidebar-sub-link.active::before { background: var(--primary); }
.sidebar-sub-link i { font-size: .88rem; flex-shrink: 0; }
/* Compact mode overrides */
.sidebar-compact .sidebar-group-btn { padding: .65rem; justify-content: center; }
.sidebar-compact .sidebar-group-arrow { display: none; }
.sidebar-compact .sidebar-sub-link { padding: .6rem; justify-content: center; }

/* Main content */
.app-main {
  margin-right: 230px;
  margin-top: 54px;
  min-height: calc(100vh - 54px);
  padding: 1.5rem;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card-app {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}
.card-app-hover { transition: border-color .15s; }
.card-app-hover:hover { border-color: rgba(16,163,127,.35); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-app-primary {
  background: var(--primary);
  color: #fff; border: none;
  border-radius: 9px; padding: .55rem 1.3rem;
  font-size: .88rem; font-weight: 700;
  cursor: pointer; transition: background .2s, box-shadow .2s;
  display: inline-flex; align-items: center; gap: .35rem;
}
.btn-app-primary:hover {
  background: var(--primary-h);
  box-shadow: 0 3px 12px rgba(16,163,127,.3);
  color: #fff;
}
.btn-app-primary:disabled {
  background: var(--border-l); color: var(--text-dim);
  cursor: not-allowed; box-shadow: none;
}

.btn-app-outline {
  background: transparent;
  border: 1px solid var(--border-l);
  color: var(--text-muted);
  border-radius: 9px; padding: .5rem 1.1rem;
  font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; gap: .35rem;
}
.btn-app-outline:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-l); }

/* ── Badges ────────────────────────────────────────────────── */
.badge-app {
  background: var(--primary-bg);
  border: 1px solid rgba(16,163,127,.25);
  color: var(--primary);
  font-size: 11px; padding: .2rem .6rem;
  border-radius: 20px; font-weight: 700;
  display: inline-flex; align-items: center; gap: .25rem;
}

/* ── Page title ────────────────────────────────────────────── */
.page-title { font-size: 1.15rem; font-weight: 800; margin-bottom: 1.25rem; display: flex; align-items: center; gap: .45rem; }
.page-title i { color: var(--primary); }

/* ── Dropdown overrides ────────────────────────────────────── */
.dropdown-menu {
  background: var(--bg-card);
  border: 1px solid var(--border-l);
  color: var(--text);
  border-radius: 10px;
  padding: .35rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.dropdown-item {
  color: var(--text-muted); border-radius: 7px;
  font-size: .85rem; padding: .45rem .75rem;
  transition: background .12s, color .12s;
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text); }
.dropdown-item.text-danger { color: var(--danger) !important; }
.dropdown-item.text-danger:hover { background: var(--danger-bg); }
.dropdown-item-text { color: var(--text-dim) !important; font-size: .78rem !important; padding: .35rem .75rem; }
.dropdown-divider { border-color: var(--border); margin: .25rem 0; }

/* ── Modals ────────────────────────────────────────────────── */
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-l);
  border-radius: 16px;
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 1.1rem 1.25rem; }
.modal-footer { border-top: 1px solid var(--border); padding: .9rem 1.25rem; }
.modal-title  { font-weight: 700; font-size: .95rem; }
.btn-close-white { filter: invert(1) brightness(.7); }
.btn-close-white:hover { filter: invert(1) brightness(1); }

/* ── Tables ────────────────────────────────────────────────── */
.table { color: var(--text); font-size: .88rem; }
.table thead th { color: var(--text-muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; border-color: var(--border); background: var(--bg-input); }
.table td, .table th { border-color: var(--border); padding: .7rem .85rem; vertical-align: middle; }
.table tbody tr:hover td { background: var(--bg-hover); }
.table-responsive { border-radius: 12px; overflow-x: auto; overflow-y: visible; border: 1px solid var(--border); }

/* ── AI Response Tables ─────────────────────────────────────────── */
.ai-table-wrap {
  position: relative;
  margin: 1.1rem 0;
  border-radius: 13px;
  overflow: hidden;
  border: 1px solid rgba(16,163,127,.22);
  box-shadow:
    0 4px 28px rgba(0,0,0,.38),
    0 0 0 1px rgba(16,163,127,.07),
    inset 0 1px 0 rgba(255,255,255,.05);
}
.ai-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ai-table-actions {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 3;
  display: flex; gap: .4rem;
  opacity: 0;
  transition: opacity .15s;
}
.ai-table-wrap:hover .ai-table-actions { opacity: 1; }
.ai-table-copy-btn {
  display: flex; align-items: center; gap: .3rem;
  background: rgba(16,163,127,.12);
  border: 1px solid rgba(16,163,127,.28);
  color: var(--primary);
  border-radius: 7px;
  padding: .22rem .6rem;
  font-size: .69rem;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  white-space: nowrap; line-height: 1.6;
  backdrop-filter: blur(4px);
}
.ai-table-copy-btn:hover { background: rgba(16,163,127,.24); border-color: rgba(16,163,127,.5); }
.ai-table-copy-btn.copied {
  background: rgba(82,196,122,.18); color: var(--mint-accent-text);
  border-color: rgba(82,196,122,.45);
}
.ai-table-actions:has(.copied) { opacity: 1; }
.ai-table {
  border-collapse: collapse;
  width: 100%; min-width: 280px;
  table-layout: fixed;
  font-size: .875rem;
  direction: rtl;
  text-align: right;
}
.ai-table thead {
  background: linear-gradient(120deg, rgba(16,163,127,.26) 0%, rgba(6,182,212,.14) 100%);
  position: relative;
}
.ai-table thead::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(16,163,127,.5) 20%,
    rgba(16,163,127,.9) 50%,
    rgba(16,163,127,.5) 80%,
    transparent 100%);
}
.ai-table thead th {
  color: var(--mint-accent-text);
  font-weight: 700;
  padding: .72rem .85rem;
  text-align: right;
  direction: rtl;
  overflow-wrap: break-word;
  word-break: break-word;
  font-size: .81rem;
  letter-spacing: .015em;
  border-left: 1px solid rgba(16,163,127,.12);
}
.ai-table thead th:last-child { border-left: none; }
.ai-table tbody tr {
  transition: background .1s;
  border-bottom: 1px solid var(--overlay-1);
}
.ai-table tbody tr:last-child { border-bottom: none; }
.ai-table tbody tr:nth-child(even) { background: var(--overlay-1); }
.ai-table tbody tr:hover { background: rgba(16,163,127,.065); }
.ai-table tbody td {
  padding: .56rem .85rem;
  color: var(--text);
  vertical-align: middle;
  direction: rtl;
  text-align: right;
  overflow-wrap: break-word;
  word-break: break-word;
  border-left: 1px solid var(--overlay-1);
  line-height: 1.55;
}
.ai-table tbody td:last-child { border-left: none; }
.ai-table tbody td:first-child { font-weight: 500; }
.ai-table-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: .4rem;
  padding: .28rem .8rem;
  background: rgba(0,0,0,.18);
  border-top: 1px solid var(--overlay-2);
  font-size: .67rem; color: var(--text-dim);
}

/* ── Nav pills/tabs ────────────────────────────────────────── */
.nav-pills .nav-link { color: var(--text-muted); font-size: .85rem; border-radius: 8px; padding: .45rem .9rem; }
.nav-pills .nav-link.active { background: var(--primary-bg); color: var(--primary); font-weight: 700; }
.nav-pills .nav-link:hover:not(.active) { background: var(--bg-hover); color: var(--text); }

/* Reusable dark-themed Bootstrap nav-tabs (data-bs-toggle="tab") — bare .nav-tabs
   inherits Bootstrap's light-mode look, which reads as broken on this dark admin UI. */
.admin-tabs { border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.admin-tabs .nav-link { color: var(--text-muted); border: none; border-bottom: 2px solid transparent; background: transparent; font-size: .85rem; padding: .5rem 1rem; border-radius: 0; }
.admin-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); background: transparent; }
.admin-tabs .nav-link:hover:not(.active) { color: var(--text); }

/* ── Pagination ────────────────────────────────────────────── */
.page-item .page-link { background: var(--bg-card); border-color: var(--border); color: var(--text-muted); font-size: .82rem; }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-item .page-link:hover { background: var(--bg-hover); color: var(--text); }

/* ── Spinner ───────────────────────────────────────────────── */
.spinner-border-sm { width: .9rem; height: .9rem; border-width: .13em; }
.spinner-border { border-color: var(--primary); border-right-color: transparent; }

/* ── Stub / Empty state ────────────────────────────────────── */
.stub-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 280px; color: var(--text-dim); text-align: center; gap: .75rem;
}
.stub-placeholder i { font-size: 3rem; color: var(--border-l); }
.stub-placeholder p { font-size: .88rem; }

/* ── Section cards (forms list, systems list, etc.) ────────── */
.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: .65rem;
  display: flex; align-items: center; gap: .9rem;
  transition: border-color .15s, transform .12s;
  cursor: pointer; text-decoration: none; color: var(--text);
}
.item-card:hover { border-color: rgba(16,163,127,.3); color: var(--text); transform: translateY(-1px); }
.item-card-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary-bg); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.item-card-body { flex: 1; min-width: 0; }
.item-card-title { font-size: .9rem; font-weight: 700; margin-bottom: .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-card-meta  { font-size: .75rem; color: var(--text-dim); }

/* ── Sidebar compact toggle button ─────────────────────────── */
.sidebar-compact-toggle {
  flex-shrink: 0;
  align-self: center;
  width: 28px; height: 28px;
  background: var(--bg-input); border: 1px solid var(--border-l);
  color: var(--text-muted); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; cursor: pointer; transition: all .15s;
  margin: .5rem 0 .75rem;
}
.sidebar-compact-toggle:hover { background: var(--bg-hover); color: var(--text); border-color: var(--primary); }

/* ── Compact sidebar mode (icon-only) ───────────────────────── */
.sidebar-compact .app-sidebar { width: 56px; overflow: visible; }
.sidebar-compact .sidebar-nav  { overflow: visible; }
.sidebar-compact .sidebar-link-lbl { opacity: 0; width: 0; overflow: hidden; margin: 0; }
.sidebar-compact .sidebar-link {
  padding: .65rem;
  justify-content: center;
  position: relative;
  overflow: visible;
}
.sidebar-compact .sidebar-link i { font-size: 1.05rem; }
/* Tooltip on hover in compact mode */
.sidebar-compact .sidebar-link::after {
  content: attr(title);
  position: absolute;
  right: calc(100% + 10px);
  top: 50%; transform: translateY(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-l);
  color: var(--text);
  padding: .3rem .7rem;
  border-radius: 7px;
  font-size: .82rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  z-index: 200;
}
.sidebar-compact .sidebar-link:hover::after { opacity: 1; }
/* Arrow icon flips when expanded */
.sidebar-expanded #sidebarToggleIcon { transform: rotate(180deg); }
/* Adjust main content margin in compact mode */
.sidebar-compact .app-main { margin-right: 56px; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 991px) {
  .app-sidebar { transform: translateX(100%); }
  .app-sidebar.open { transform: translateX(0); box-shadow: -8px 0 32px rgba(0,0,0,.5); }
  .app-main { margin-right: 0; }
  .app-navbar { padding: 0 .85rem; }
}
@media (max-width: 575px) {
  .app-main { padding: 1rem .75rem; }
  .auth-card { padding: 2rem 1.25rem; }

  /* iOS Safari auto-zooms the page when a focused input is under 16px —
     the #1 reason forms feel "broken" on mobile. Force 16px on touch. */
  input, select, textarea,
  .form-control, .form-select, .form-control-dark, .form-select-dark {
    font-size: 16px !important;
  }

  /* Bootstrap modals default to a small side margin — tighten further and
     let dialogs use the full width so content doesn't get cramped. */
  .modal-dialog { margin: .6rem; max-width: calc(100% - 1.2rem); }

  /* Credit badge + navbar datetime crowd the navbar on narrow phones */
  .app-navbar { gap: .4rem; }
  .credit-badge { font-size: .72rem; padding: .25rem .6rem; }
}

/* ── Package cards ─────────────────────────────────────────────
   Shared by pages/packages.php (real purchase grid) and
   admin/pages/packages.php (preview row + live modal preview) so the
   admin sees pixel-identical output to what the user sees. */
.pkg-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:1rem; }
.pkg-card {
    position:relative; border-radius:14px; padding:1.5rem 1.1rem;
    background:var(--bg-card); border:1.5px solid var(--border);
    text-align:center; transition:transform .22s, box-shadow .22s, border-color .22s;
    display:flex; flex-direction:column; gap:.55rem;
}
.pkg-card:hover { transform:translateY(-4px); box-shadow:0 12px 36px rgba(0,0,0,.32); border-color:rgba(16,163,127,.4); }
.pkg-card.featured {
    border-color:rgba(16,163,127,.6);
    background:linear-gradient(160deg,rgba(16,163,127,.12) 0%,var(--bg-card) 60%);
    box-shadow:0 6px 24px rgba(16,163,127,.16);
}
.pkg-badge {
    position:absolute; top:-10px; right:50%; transform:translateX(50%);
    background:linear-gradient(90deg,#10a37f,#0d8a6b);
    color:#fff; font-size:.66rem; font-weight:700;
    padding:.22rem .75rem; border-radius:20px; white-space:nowrap;
    box-shadow:0 4px 12px rgba(16,163,127,.4); letter-spacing:.04em;
}
.pkg-orig-price { text-decoration:line-through; font-size:.74rem; color:var(--text-muted); margin-bottom:.1rem; }
.pkg-discount-badge {
    display:inline-flex; align-items:center; gap:.25rem;
    background:rgba(245,158,11,.15); border:1px solid rgba(245,158,11,.3);
    color:#f59e0b; font-size:.66rem; font-weight:700;
    padding:.12rem .5rem; border-radius:20px; margin-bottom:.25rem;
}
.pkg-icon { font-size:2rem; line-height:1; }
.pkg-name { font-size:.92rem; font-weight:700; color:var(--text); }
.pkg-desc { font-size:.76rem; color:var(--text-muted); min-height:1.2em; }
.pkg-price-wrap { margin:.3rem 0; }
.pkg-amount { font-size:1.7rem; font-weight:800; color:var(--primary); line-height:1; }
.pkg-unit { font-size:.76rem; color:var(--text-muted); margin-top:.15rem; }
.pkg-divider { border:none; border-top:1px solid var(--border); margin:.1rem 0; }
.pkg-limits { display:flex; flex-direction:column; gap:.25rem; font-size:.68rem; color:var(--text-muted); }
.pkg-limit-item { display:flex; align-items:center; justify-content:center; gap:.3rem; }
.pkg-limit-item.low { color:#f59e0b; font-weight:700; }
.pkg-countdown {
    display:flex; align-items:center; justify-content:center; gap:.35rem;
    font-size:.72rem; font-weight:700; color:#f59e0b;
    background:rgba(245,158,11,.1); border:1px solid rgba(245,158,11,.25);
    border-radius:8px; padding:.35rem .5rem; font-variant-numeric:tabular-nums;
}
.pkg-countdown.urgent { color:#e05252; background:rgba(224,82,82,.1); border-color:rgba(224,82,82,.3); animation:pkgPulse 1s infinite; }
.pkg-countdown.expired { color:#e05252; }
@keyframes pkgPulse { 0%,100% { opacity:1; } 50% { opacity:.55; } }
.pkg-btn {
    display:flex; align-items:center; justify-content:center; gap:.4rem;
    width:100%; padding:.6rem .9rem; border-radius:10px; border:none; cursor:pointer;
    font-size:.82rem; font-weight:600; transition:all .18s;
    background:var(--primary); color:#fff;
}
.pkg-btn:hover { background:#0d8a6b; transform:scale(1.02); }
.pkg-btn.pkg-btn-static { cursor:default; }
.pkg-btn.pkg-btn-static:hover { transform:none; }
.pkg-card.featured .pkg-btn { background:linear-gradient(90deg,#10a37f,#0cc487); box-shadow:0 4px 16px rgba(16,163,127,.35); }
