/**
 * استایل‌های اختصاصی طراح رنج عدسی (Lens Range Mapper)
 * منطبق بر کاتالوگ‌های تخصصی اپتومتری (نسخه 1.5.2)
 * 
 * @package LensRangeMapper
 * @author  vahid Nazarian
 * @version 1.5.2
 */

:root {
  --lrm-bg: #f8fafc;
  --lrm-panel: #ffffff;
  --lrm-line: #e2e8f0;
  --lrm-line-dark: #000000;
  --lrm-text: #0f172a;
  --lrm-muted: #64748b;
  --lrm-primary: #2563eb;
  --lrm-primary-hover: #1d4ed8;
  --lrm-success: #16a34a;
  --lrm-danger: #dc2626;
  --lrm-cell-size: 24px;
  --lrm-zero-cell-size: 42px; /* ردیف و ستون صفر تقریبا دوبرابر */
  --lrm-sph-col-w: 80px;
  --lrm-cyl-row-h: 60px;
}

.lrm-wrap {
  margin: 15px 20px 20px 2px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Vazirmatn", Tahoma, sans-serif;
  color: var(--lrm-text);
  direction: rtl;
}

.lrm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  background: var(--lrm-panel);
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px solid var(--lrm-line);
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.lrm-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
}

.lrm-subtitle {
  color: var(--lrm-muted);
  font-size: 13px;
  margin-top: 4px;
}

.lrm-badge {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* پنل تنظیمات اصلی - برند کوچیکتر و مدل عدسی عریض‌تر و بزرگتر */
.lrm-panel {
  background: var(--lrm-panel);
  border: 1px solid var(--lrm-line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.lrm-form-grid {
  display: grid;
  grid-template-columns: 1fr 2.6fr 0.9fr repeat(4, 0.85fr) 1fr;
  gap: 12px;
}

.lrm-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--lrm-muted);
  display: block;
  margin-bottom: 6px;
}

.lrm-field input,
.lrm-field select {
  width: 100%;
  height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  background: #ffffff;
  transition: all 0.2s;
  box-sizing: border-box;
}

.lrm-field input:focus,
.lrm-field select:focus {
  border-color: var(--lrm-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
  outline: none;
}

/* دکمه‌ها و اکشن‌ها */
.lrm-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--lrm-line);
}

.lrm-btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lrm-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
}

.lrm-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.lrm-btn-primary {
  background: var(--lrm-primary);
  border-color: var(--lrm-primary);
  color: #ffffff;
}

.lrm-btn-primary:hover {
  background: var(--lrm-primary-hover);
  border-color: var(--lrm-primary-hover);
  color: #ffffff;
}

.lrm-btn-success {
  background: var(--lrm-success);
  border-color: var(--lrm-success);
  color: #ffffff;
}

.lrm-btn-success:hover {
  background: #15803d;
  color: #ffffff;
}

/* وضعیت اولیه دکمه ذخیره (سبز ملایم) */
.lrm-btn-save-initial {
  background: #dcfce7 !important;
  border: 1.5px solid #86efac !important;
  color: #15803d !important;
  font-weight: 700 !important;
  transition: all 0.2s ease;
}

.lrm-btn-save-initial:hover {
  background: #bbf7d0 !important;
  border-color: #4ade80 !important;
  color: #166534 !important;
}

/* وضعیت ذخیره شده / آپدیت (سبز تیره و فعال) */
.lrm-btn-save-updated {
  background: #16a34a !important;
  border: 1.5px solid #15803d !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.35);
  transition: all 0.2s ease;
}

.lrm-btn-save-updated:hover {
  background: #15803d !important;
  color: #ffffff !important;
}

.lrm-btn-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--lrm-danger);
}

.lrm-btn-danger:hover {
  background: var(--lrm-danger);
  border-color: var(--lrm-danger);
  color: #ffffff;
}

/* دکمه تغییر جهت محور کنار زوم */
.lrm-btn-toggle-axis {
  background: #f8fafc;
  border: 1.5px solid #0f172a;
  color: #0f172a;
  font-weight: 700;
  padding: 5px 12px;
  font-size: 12px;
}
.lrm-btn-toggle-axis:hover {
  background: #0f172a;
  color: #ffffff;
}

/* محیط کاری گرید و سایدبار */
.lrm-workspace {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 16px;
  align-items: start;
}

.lrm-sidebar {
  position: sticky;
  top: 40px;
}

/* پنل جدول خروجی و مدیریت سکشن‌ها در بالای گرید */
.lrm-sections-table-panel {
  background: var(--lrm-panel);
  border: 1px solid var(--lrm-line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.lrm-sections-table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--lrm-line);
}

.lrm-table-add-sec-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.lrm-table-add-sec-bar input {
  height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
}

.lrm-table-sec-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
}

.lrm-table-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.25);
  flex-shrink: 0;
  cursor: pointer;
}

.lrm-table-active-badge {
  font-size: 10px;
  background: #2563eb;
  color: #ffffff;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

.lrm-table-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
}

.lrm-table-act-btn {
  padding: 3px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #ffffff;
  color: #475569;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.lrm-table-act-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.lrm-table-act-btn.act-delete {
  color: #dc2626;
  border-color: #fca5a5;
}

.lrm-table-act-btn.act-delete:hover {
  background: #fee2e2;
}

/* راهنمای ابزارها و فرمول محاسبه به صورت پاپ‌اور تولتیپ */
.lrm-help-wrap {
  position: relative;
  display: inline-block;
  z-index: 200;
}

.lrm-help-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}

.lrm-help-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

.lrm-help-popover {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0 !important;
  left: auto !important;
  width: 350px;
  max-width: 85vw;
  background: #ffffff !important;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 14px 35px rgba(0,0,0,0.25);
  padding: 14px;
  z-index: 99999 !important;
  direction: rtl;
  text-align: right;
}

.lrm-help-wrap:hover .lrm-help-popover,
.lrm-help-wrap:focus-within .lrm-help-popover,
.lrm-help-wrap.is-open .lrm-help-popover {
  display: block;
}

.lrm-popover-title {
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e2e8f0;
}

.lrm-popover-content {
  font-size: 12px;
  color: #334155;
  line-height: 1.7;
}

.lrm-popover-content ul {
  margin: 6px 0 10px;
  padding-right: 18px;
}

.lrm-popover-content li {
  margin-bottom: 4px;
}

.lrm-popover-code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
  color: #0f172a;
  direction: ltr;
  display: inline-block;
}

/* پنل گزارش و لاگ زنده تست پوشش نمرات */
.lrm-test-log-panel {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.lrm-test-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.lrm-test-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 700;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
  display: inline-flex;
  align-items: center;
}

.lrm-test-badge.badge-active {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
  animation: lrmPulseBadge 1.5s infinite ease-in-out;
}

@keyframes lrmPulseBadge {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.75; transform: scale(1.04); }
}

.lrm-test-badge.badge-success {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.lrm-test-badge.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.lrm-test-filter-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 10px;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.lrm-test-dia-select {
  width: 100%;
  height: 32px;
  font-size: 11.5px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  padding: 2px 8px;
}

.lrm-btn-sm {
  padding: 4px 8px;
  font-size: 11.5px;
  height: 32px;
  line-height: 22px;
}

.lrm-test-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #475569;
  background: #f1f5f9;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 10px;
}

/* ارتفاع افزایش یافته لاگ‌ها برای مشاهده همزمان ۶ الی ۸ لاگ */
.lrm-test-logs-container {
  max-height: 520px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}

.lrm-test-empty-hint {
  font-size: 11.5px;
  color: #64748b;
  text-align: center;
  line-height: 1.6;
  padding: 16px 10px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
}

/* کارت جمع و جورتر برای مشاهده گزارش‌های پرتعداد */
.lrm-test-log-card {
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11.5px;
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  transition: all 0.2s ease;
}

.lrm-test-log-card.covered {
  background: #f0fdf4;
  border-color: #86efac;
}

.lrm-test-log-card.uncovered {
  background: #fef2f2;
  border-color: #fca5a5;
}

.lrm-test-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.lrm-test-log-time {
  font-size: 10px;
  color: #64748b;
  direction: ltr;
}

.lrm-test-log-powers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-family: monospace;
  font-size: 11px;
  color: #0f172a;
  background: rgba(255,255,255,0.7);
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.lrm-test-sec-match {
  font-size: 11px;
  color: #15803d;
  line-height: 1.4;
}

.lrm-test-sec-pill {
  display: inline-block;
  padding: 1px 5px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-right-width: 3px;
  border-radius: 3px;
  font-size: 10.5px;
  margin-right: 3px;
  font-weight: 600;
}

.lrm-test-sec-unmatch {
  font-size: 10.5px;
  color: #b91c1c;
  font-weight: 600;
}

/* بخش ساخت سکشن در سایدبار با فیلد Dia اختصاصی */
.lrm-add-section-box {
  background: #f8fafc;
  border: 1px solid var(--lrm-line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 12px;
}

.lrm-add-section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.lrm-add-section-grid label {
  font-size: 11px;
  font-weight: 700;
  color: var(--lrm-muted);
  display: block;
  margin-bottom: 3px;
}

.lrm-add-section-grid input {
  width: 100%;
  height: 34px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  box-sizing: border-box;
}

/* کارت‌های سکشن */
.lrm-section-card {
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.2s;
}

.lrm-section-card.active {
  border-color: #0f172a;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

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

.lrm-swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
  cursor: pointer;
}

.lrm-section-name {
  font-weight: 700;
  font-size: 13px;
  flex: 1;
}

.lrm-section-dia {
  font-size: 12px;
  font-weight: 700;
  background: rgba(0,0,0,0.06);
  padding: 2px 8px;
  border-radius: 6px;
}

.lrm-section-meta {
  font-size: 11px;
  color: var(--lrm-muted);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
}

.lrm-mini-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.lrm-mini-actions button {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 5px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  cursor: pointer;
}

.lrm-mini-actions button:hover {
  background: #f1f5f9;
}

/* پنل گرید (Grid Area) */
.lrm-grid-panel {
  overflow: auto;
  position: relative;
  min-height: 540px;
  background: #ffffff;
}

.lrm-grid-toolbar {
  position: relative;
  z-index: 100; /* تضمین نمایش بالاتر از عناصر چارت و SVG */
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--lrm-line);
}

.lrm-grid-toolbar-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* گروه ابزارهای رسم در بالای جدول */
.lrm-toolbar-tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  padding: 3px 5px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
}

.lrm-tool-btn {
  padding: 5px 10px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.lrm-tool-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.lrm-tool-btn.active {
  background: #0f172a;
  color: #ffffff;
}

/* دکمه اختصاصی حالت تست رنج */
.lrm-tool-btn-test {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-weight: 700;
}

.lrm-tool-btn-test:hover {
  background: #dbeafe;
  color: #1e40af;
}

.lrm-tool-btn-test.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
  box-shadow: 0 0 8px rgba(37,99,235,0.35);
}

.lrm-toolbar-history-group {
  display: flex;
  align-items: center;
  gap: 3px;
}

.lrm-toolbar-divider {
  width: 1px;
  height: 24px;
  background: #cbd5e1;
  margin: 0 4px;
}

.lrm-toolbar-zoom-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lrm-grid-toolbar-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.lrm-hint-text {
  font-size: 13px;
  color: var(--lrm-muted);
}

.lrm-poly-hint {
  font-size: 11.5px;
  color: #2563eb;
  background: #eff6ff;
  border: 1px dashed #93c5fd;
  border-radius: 6px;
  padding: 4px 10px;
  display: none;
  line-height: 1.5;
}

/* نشانگر ماوس در حالت تست */
.lrm-grid-wrap.lrm-mode-test .lrm-cell {
  cursor: crosshair !important;
}

/* انیمیشن پالس سلول در حین تست (سبز و قرمز) */
@keyframes lrmTestPulseSuccess {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.9); z-index: 10; background-color: #86efac !important; }
  50% { transform: scale(1.35); box-shadow: 0 0 12px 4px rgba(22, 163, 74, 0.85); z-index: 10; background-color: #22c55e !important; }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); z-index: 1; }
}

@keyframes lrmTestPulseDanger {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.9); z-index: 10; background-color: #fca5a5 !important; }
  50% { transform: scale(1.35); box-shadow: 0 0 12px 4px rgba(220, 38, 38, 0.85); z-index: 10; background-color: #ef4444 !important; }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); z-index: 1; }
}

.lrm-cell.lrm-test-pulse-success {
  animation: lrmTestPulseSuccess 1.1s ease-out;
}

.lrm-cell.lrm-test-pulse-danger {
  animation: lrmTestPulseDanger 1.1s ease-out;
}

.lrm-grid-wrap {
  display: block;
  width: 100%;
  padding: 24px 20px 48px;
  text-align: center;
  direction: ltr;
  overflow-x: auto;
  box-sizing: border-box;
}

/* استایل چارت کامل (همانند تصویر ارسالی کاتالوگ) */
.lrm-chart-box {
  display: inline-block;
  margin: 0 auto;
  text-align: left;
  background: #ffffff;
  border: 2.5px solid #000000;
  position: relative;
  user-select: none;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

/* جدول ساختاری گرید */
.lrm-chart-table {
  border-collapse: collapse;
  margin: 0;
  padding: 0;
  border-spacing: 0;
}

/* هدر گوشه سمت چپ بالا: تقسیم مورب CYL و SPH */
.lrm-corner-header-cell {
  width: var(--lrm-sph-col-w);
  height: var(--lrm-cyl-row-h);
  padding: 0 !important;
  border-right: 2.5px solid #000000;
  border-bottom: 2.5px solid #000000;
  background: #ffffff;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.lrm-corner-split-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

.lrm-corner-split-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.lrm-corner-text,
.lrm-corner-label {
  position: absolute;
  font-family: -apple-system, BlinkMacSystemFont, "Arial Black", Arial, sans-serif;
  font-weight: 900;
  font-size: 11.5px;
  letter-spacing: 0.5px;
  color: #000000;
  line-height: 1;
  pointer-events: none;
}

/* مثلث بالا-راست: CYL */
.lrm-corner-cyl {
  top: 9px;
  right: 9px;
  text-align: right;
}

/* مثلث پایین-چپ: SPH */
.lrm-corner-sph {
  bottom: 9px;
  left: 9px;
  text-align: left;
}

/* سلول‌های هدر ردیف بالا (CYL) */
.lrm-cyl-header-cell {
  width: var(--lrm-cell-size);
  height: var(--lrm-cyl-row-h);
  padding: 0;
  margin: 0;
  border-bottom: 2.5px solid #000000;
  position: relative;
  background: #ffffff;
  box-sizing: border-box;
}

.lrm-cyl-header-cell.zero-cyl-col {
  width: var(--lrm-zero-cell-size);
  border-left: 3.5px solid #000000 !important;
  border-right: 3.5px solid #000000 !important;
}

/* امتداد خط ستون بعد از عدد صحیح تا نصف ارتفاع ستون هدر (دقیقاً ۵۰٪) */
.lrm-cyl-header-cell.has-major-tick {
  background-image: linear-gradient(to top, #000000 50%, transparent 50%);
  background-position: bottom right;
  background-size: 2px 100%;
  background-repeat: no-repeat;
}

.lrm-cyl-header-cell.has-major-tick::after {
  display: none !important;
}

/* امتداد خط افقی بعد از عدد صحیح */
.lrm-sph-label-cell.major-sph-boundary {
  border-bottom: none !important;
}

/* خطوط ستون و سطر اعداد صحیح در داخل جدول (Major Integer Lines) */
.lrm-cell.major-cyl-col {
  border-right: 2px solid #000000 !important;
}

.lrm-cell.major-sph-row {
  border-bottom: 2px solid #000000 !important;
}

/* تولتیپ شناور با نشانگر ماوس روی سلول‌های گرید */
.lrm-cell-tooltip {
  position: fixed;
  display: none;
  pointer-events: none;
  z-index: 999999;
  background: #0f172a;
  color: #ffffff;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 11.5px;
  font-family: monospace, sans-serif;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  white-space: nowrap;
  transform: translate(-50%, -100%);
  margin-top: -10px;
  will-change: left, top;
  contain: layout paint;
}

.lrm-cell-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #0f172a;
}

/* تراز اعداد سیلندر دقیقا در وسط ستون و روبروی باکس‌های مربعی */
.lrm-cyl-label {
  font-size: 11px;
  font-weight: 900;
  color: #000000;
  font-family: -apple-system, BlinkMacSystemFont, "Arial Black", Arial, sans-serif;
  white-space: nowrap;
  position: absolute;
  bottom: 8px;
  left: 50%;
}

.lrm-cyl-label.title-label {
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -0.5px;
}

.lrm-cyl-label.rotated {
  transform: translateX(-50%) rotate(-90deg);
  transform-origin: center center;
  font-size: 11px;
  bottom: 24px;
}

/* ستون سمت چپ (SPH Numbers Column) */
.lrm-sph-label-cell {
  width: var(--lrm-sph-col-w);
  height: var(--lrm-cell-size);
  text-align: right;
  vertical-align: middle;
  padding-right: 14px;
  font-size: 12px;
  font-weight: 900;
  font-family: -apple-system, BlinkMacSystemFont, "Arial Black", Arial, sans-serif;
  color: #000000;
  border-right: 2.5px solid #000000;
  background-color: #ffffff;
  box-sizing: border-box;
}

/* دو خط مرزی بالا و پایین سطر عدد صحیح تا نصف لبه ستون (یکی مشکی و یکی خاکستری) */
.lrm-sph-label-cell.top-tick-black.bottom-tick-gray {
  background-image: linear-gradient(to left, #000000 50%, transparent 50%), linear-gradient(to left, #cbd5e1 50%, transparent 50%) !important;
  background-position: top right, bottom right !important;
  background-size: 100% 2px, 100% 1.5px !important;
  background-repeat: no-repeat, no-repeat !important;
}

.lrm-sph-label-cell.top-tick-gray.bottom-tick-black {
  background-image: linear-gradient(to left, #cbd5e1 50%, transparent 50%), linear-gradient(to left, #000000 50%, transparent 50%) !important;
  background-position: top right, bottom right !important;
  background-size: 100% 1.5px, 100% 2px !important;
  background-repeat: no-repeat, no-repeat !important;
}

/* کم‌رنگ شدن دیاهای غیرفعال هنگام فیلتر یک دیا خاص (خاکستری روشن بدون افت پرفورمنس) */
.lrm-cell.lrm-cell-dimmed {
  background-color: #e2e8f0 !important;
}

.lrm-dia-badge.lrm-badge-dimmed {
  opacity: 0.25 !important;
}

/* سطر صفر با ارتفاع دوبرابر و هر دو خط بالا و پایین ضخیم */
.lrm-sph-label-cell.zero-sph-row {
  height: var(--lrm-zero-cell-size);
  font-size: 13px;
  background: #f8fafc;
  border-top: 3.5px solid #000000 !important;
  border-bottom: 3.5px solid #000000 !important;
}

/* سلول‌های ماتریس نمره با خطوط یکنواخت و زیبا */
.lrm-cell {
  width: var(--lrm-cell-size);
  height: var(--lrm-cell-size);
  background: #ffffff;
  position: relative;
  cursor: crosshair;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  box-sizing: border-box;
  padding: 0;
  transition: background-color 0.05s;
}

/* سطر و ستون صفر: هم بالا و هم پایین، هم چپ و هم راست کاملاً ضخیم (۳.۵ پیکسل) */
.lrm-cell.zero-sph-row {
  height: var(--lrm-zero-cell-size) !important;
  border-top: 3.5px solid #000000 !important;
  border-bottom: 3.5px solid #000000 !important;
}

.lrm-cell.zero-cyl-col {
  width: var(--lrm-zero-cell-size) !important;
  border-left: 3.5px solid #000000 !important;
  border-right: 3.5px solid #000000 !important;
}

/* کادر هُوِر روی سلول */
.lrm-cell:hover {
  outline: 2px solid #000000;
  z-index: 10;
}

/* لایه گرافیکی SVG برای ابزار ۴ نقطه */
.lrm-overlay-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}

/* برچسب‌های شناور قطر عدسی مانند ø65 و ø70 */
.lrm-dia-badge {
  position: absolute;
  background: #000000;
  color: #ffffff;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 900;
  font-family: Arial, sans-serif;
  letter-spacing: 0.5px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 25;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  white-space: nowrap;
}

/* کادر انتخاب مستطیلی (Marquee) */
.lrm-selection-marquee {
  position: absolute;
  border: 2px dashed #2563eb;
  background: rgba(37, 99, 235, 0.28);
  pointer-events: none;
  z-index: 20;
  display: none;
}

/* فوتر چارت با نام مدل عدسی (نگارش و جهت LTR) */
.lrm-chart-footer {
  border-top: 2.5px solid #000000;
  padding: 8px 12px;
  text-align: center;
  direction: ltr !important;
  unicode-bidi: isolate;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 1px;
  font-family: -apple-system, BlinkMacSystemFont, "Arial Black", Arial, sans-serif;
  background: #f1f5f9;
  color: #000000;
  min-height: 20px;
}

/* جدول نتایج محاسبات */
.lrm-table-wrap {
  overflow-x: auto;
}

.lrm-result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-top: 10px;
}

.lrm-result-table th,
.lrm-result-table td {
  border-bottom: 1px solid var(--lrm-line);
  padding: 10px 12px;
  text-align: center;
}

.lrm-result-table th {
  background: #f8fafc;
  color: #1e293b;
  font-weight: 800;
  white-space: nowrap;
}

.lrm-result-table tr:hover td {
  background: #f8fafc;
}

/* پیام کوتاه موقت (Toast) */
.lrm-toast {
  position: fixed;
  top: 35px;
  left: 50%;
  transform: translateX(-50%);
  bottom: auto;
  background: #0f172a;
  color: #ffffff;
  padding: 11px 24px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.1);
  display: none;
  z-index: 999999;
  direction: rtl;
  pointer-events: none;
}

@media (max-width: 1100px) {
  .lrm-workspace {
    grid-template-columns: 1fr;
  }
  .lrm-sidebar {
    position: static;
  }
  .lrm-form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* استایل مدال پیست از اکسل و سایر مدال‌های نرم‌افزار */
.lrm-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(3px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  direction: rtl;
  padding: 16px;
}

.lrm-modal-box {
  background: #ffffff;
  border-radius: 14px;
  width: 100%;
  max-width: 620px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: lrmModalFadeIn 0.2s ease-out;
  display: flex;
  flex-direction: column;
}

@keyframes lrmModalFadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.lrm-modal-header {
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--lrm-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lrm-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
}

.lrm-modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}

.lrm-modal-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.lrm-modal-body {
  padding: 20px;
}

.lrm-modal-body p {
  margin-top: 0;
}

.lrm-paste-textarea {
  width: 100%;
  height: 140px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px;
  font-family: monospace;
  font-size: 12.5px;
  direction: ltr;
  box-sizing: border-box;
  resize: vertical;
}

.lrm-paste-textarea:focus {
  border-color: #2563eb;
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.lrm-modal-footer {
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--lrm-line);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* استایل‌های سیستم آنالیز تطبیق گرید و جدول (Audit & Discrepancies) */
.lrm-cell.lrm-audit-cell {
  position: relative;
  z-index: 15 !important;
}

/* ۱. پوشش کاذب (اضافی در فرمول جدول): کادر خط‌چین قرمز با پس‌زمینه راه‌راه قرمز */
.lrm-cell.lrm-audit-fp {
  outline: 2.5px dashed #dc2626 !important;
  outline-offset: -1px;
  background-image: repeating-linear-gradient(45deg, rgba(220, 38, 38, 0.28), rgba(220, 38, 38, 0.28) 3px, transparent 3px, transparent 6px) !important;
}

/* ۲. جاافتادگی از فرمول جدول: کادر خط‌چین نارنجی با پس‌زمینه راه‌راه نارنجی */
.lrm-cell.lrm-audit-fn {
  outline: 2.5px dashed #d97706 !important;
  outline-offset: -1px;
  background-image: repeating-linear-gradient(-45deg, rgba(217, 119, 6, 0.35), rgba(217, 119, 6, 0.35) 3px, transparent 3px, transparent 6px) !important;
}

/* ۳. تداخل چند دیا: کادر خط‌چین بنفش */
.lrm-cell.lrm-audit-conflict {
  outline: 2.5px dashed #7c3aed !important;
  outline-offset: -1px;
  background-image: repeating-linear-gradient(45deg, rgba(124, 58, 237, 0.32), rgba(124, 58, 237, 0.32) 3px, transparent 3px, transparent 6px) !important;
}

/* کارت گزارش آنالیز تطبیق در سایدبار */
.lrm-audit-card {
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  animation: lrmFadeSlide 0.25s ease-out;
}

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

.lrm-audit-card.audit-success {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  color: #166534;
}

.lrm-audit-card.audit-warning {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  color: #92400e;
}

.lrm-audit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12.5px;
}

.lrm-audit-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.lrm-audit-close:hover {
  color: #0f172a;
}

.lrm-audit-desc {
  margin: 0 0 10px;
  font-size: 11.5px;
  color: #475569;
}

.lrm-audit-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}

.lrm-audit-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lrm-audit-item:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateX(-2px);
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.lrm-audit-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  margin-bottom: 4px;
}

.lrm-audit-item-msg {
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}

.badge-purple {
  background: #f5f3ff;
  color: #7c3aed;
  border: 1px solid #ddd6fe;
}


