@font-face {
  font-family: 'Fokaha';
  src: url('fonts/Fokaha-Regular.otf') format('opentype');
}
@font-face {
  font-family: 'Ebhaar';
  src: url('fonts/Ebhaar.otf') format('opentype');
}
@font-face {
  font-family: 'Blabeloo';
  src: url('fonts/Blabeloo.ttf') format('truetype');
}

@font-face {
  font-family: "Fokaha";
  src: url("/fonts/Fokaha-Regular.otf") format("opentype");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "Ebhaar";
  src: url("/fonts/Ebhaar.otf") format("opentype");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "Blabeloo  MagdySoliman";
  src: url("/fonts/Blabeloo.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}

/* v1160: متغيرات السمة انتقلت إلى css/tokens.css — مصدر الحقيقة الوحيد */

html, body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-wrapper {
  display: flex;
  min-height: 100vh;
  direction: rtl;
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #1a1f2e;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #12172a;
  min-height: 80px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
}

.nav-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase;
  padding: 12px 20px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  transition: all 0.15s;
  position: relative;
  margin: 2px 8px;
  border-radius: 8px;
}

.nav-link::before {
  content: "";
  position: absolute;
  right: 0;
  top: 20%;
  height: 60%;
  width: 0;
  background: #3b82f6;
  border-radius: 3px 0 0 3px;
  transition: width 0.15s;
}

.nav-link:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.nav-link.active {
  background: rgba(59,130,246,0.18);
  color: #93c5fd;
  font-weight: 600;
}

.nav-link.active::before {
  width: 3px;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  text-align: center;
  font-size: 11px;
  color: rgba(255,255,255,0.2);
}

/* ── Main area ── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 58px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}


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

.content {
  padding: 24px;
}

.grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
}

.grid.has-arc-col {
  grid-template-columns: 420px 320px 1fr;
}

.arc-groups-col {
  align-self: start;
}

.arc-col-head {
  font-weight: 800;
  font-size: 15px;
  color: #334155;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
}

.controls .field {
  margin-bottom: 14px;
  width: 100%;
  box-sizing: border-box;
}

.controls .field textarea,
.controls .field input[type="text"],
.controls .field input[inputmode="decimal"],
.controls .field select {
  width: 100%;
  box-sizing: border-box;
}

.controls .field.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--muted);
}

input, select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

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

button, .button {
  appearance: none;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
}

button.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.preview {
  min-height: 640px;
}

.status-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 14px;
}

.ok {
  margin-top: 14px;
  padding: 10px 12px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  font-weight: 700;
}
.bad { color: var(--bad); font-weight: 700; }

.svg-wrap {
  min-height: 520px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-svg {
  width: 100%;
  height: 520px;
}

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

.note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.error {
  margin-top: 14px;
  padding: 10px 12px;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 10px;
}

.preview-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.canvas-wrap {
  min-height: 520px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

#preview3dCanvas {
  width: 100%;
  height: 520px;
  display: block;
  touch-action: none;
}

button.success, .button.success {
  background: var(--ok);
  color: white;
  border-color: var(--ok);
}

button.danger, .button.danger {
  background: var(--bad);
  color: white;
  border-color: var(--bad);
}


.range-input {
  display: grid;
  grid-template-columns: 1fr 84px;
  gap: 0.65rem;
  align-items: center;
}

.range-input input[type="text"] {
  text-align: center;
}


/* Mobile mode */
@media (max-width: 900px) {
  .content {
    padding: 12px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .grid.has-arc-col {
    grid-template-columns: 1fr;
  }

  .arc-groups-col {
    order: 3;
  }

  .controls {
    order: 2;
  }

  .preview {
    order: 1;
    min-height: auto;
  }

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

  .controls .field.two {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .range-input {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  input, select, button, .button {
    min-height: 46px;
    font-size: 16px;
  }

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

  .actions > * {
    width: 100%;
  }

  .preview-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .svg-wrap,
  .canvas-wrap {
    min-height: 320px;
  }

  .preview-svg,
  #preview3dCanvas {
    height: 320px;
  }

  .status-row {
    font-size: 13px;
    margin-bottom: 10px;
  }

  .note {
    font-size: 13px;
    line-height: 1.6;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 12px 14px;
  }

  .brand {
    font-size: 18px;
  }

  .content {
    padding: 10px;
  }

  .card {
    padding: 12px;
  }

  .preview-tabs {
    gap: 6px;
  }

  .svg-wrap,
  .canvas-wrap {
    min-height: 280px;
  }

  .preview-svg,
  #preview3dCanvas {
    height: 280px;
  }
}

input[type=file] {
  width: 100%;
  padding: 10px;
  border: 1px dashed #c9c9c9;
  border-radius: 12px;
  background: #fff;
}

.hint {
  margin-top: 6px;
  color: #666;
  font-size: 12px;
}


.hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.font-picker-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: stretch;
}

.icon-button {
  position: relative;
  width: 46px;
  min-width: 46px;
  height: 46px;
  border-radius: 10px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.add-font-button {
  background: var(--primary);
  color: white;
}

.delete-font-button {
  background: var(--bad);
  color: white;
}

.delete-font-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.file-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-overlay input[type="file"] {
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Color picker fix */
input[type="color"] {
  padding: 2px 4px;
  height: 44px;
  cursor: pointer;
  border-radius: 8px;
}

/* معاينة الخط */
.font-preview {
  margin-top: 6px;
  font-size: 22px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
  direction: rtl;
  min-height: 44px;
  background: var(--card);
}

.bambu-btn {
  background: #1a9e3f;
  color: white;
  font-weight: 600;
  border: none;
}
.bambu-btn:hover {
  background: #158034;
}

/* +/- input control - inline style */
.plus-minus-input {
  display: flex !important;
  align-items: stretch !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  overflow: hidden !important;
  height: 44px !important;
  padding: 0 !important;
  gap: 0 !important;
}
.plus-minus-input input {
  flex: 1 !important;
  text-align: center !important;
  font-size: 17px !important;
  border: none !important;
  border-left: 1px solid var(--line) !important;
  border-right: 1px solid var(--line) !important;
  border-radius: 0 !important;
  padding: 0 4px !important;
  outline: none !important;
  background: var(--card) !important;
  color: var(--fg) !important;
  width: 0 !important;
  box-shadow: none !important;
  margin: 0 !important;
  height: 100% !important;
}
.plus-minus-input button {
  width: 44px !important;
  font-size: 22px !important;
  font-weight: 300 !important;
  border: none !important;
  border-radius: 0 !important;
  background: var(--card) !important;
  cursor: pointer !important;
  color: var(--fg) !important;
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background 0.15s !important;
  height: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}
.plus-minus-input button:hover {
  background: var(--line) !important;
}
.plus-minus-input button:active {
  background: var(--accent) !important;
  color: white !important;
}

/* ── Page header ── */
.page-header {
  margin-bottom: 28px;
}
.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 4px;
}
.page-header p {
  font-size: 14px;
  color: #64748b;
  margin: 0;
}

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
}
.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-title { font-size: 18px; font-weight: 600; color: #374151; margin-bottom: 8px; }
.empty-sub { font-size: 14px; color: #9ca3af; }

/* ── Responsive Sidebar ── */

/* Desktop: sidebar ثابتة، المحتوى بجانبها */
@media (min-width: 769px) {
  .sidebar-panel {
    transform: translateX(0) !important;
  }
  .main-body {
    margin-right: 230px;
  }
  .hamburger-btn {
    display: none !important;
  }
  .sidebar-overlay {
    display: none !important;
  }
}

/* Mobile: sidebar مخفية، تظهر عند الضغط */
@media (max-width: 768px) {
  .sidebar-panel {
    transform: translateX(100%);
  }
  .sidebar-panel.sidebar-open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: block !important;
  }
  .main-body {
    margin-right: 0 !important;
  }
  .hamburger-btn {
    display: flex !important;
  }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/*           مكتبة الخطوط (/fonts) — global              */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* مكتبة الخطوط — تصميم عصري بألوان هادئة                          */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.fonts-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 32px;
    direction: rtl;
    font-family: 'Segoe UI', Tahoma, Arial;
}

/* ── الترويسة ── */
.fonts-header {
    text-align: center;
    margin-bottom: 32px;
}
.fonts-header h1 {
    margin: 0 0 8px;
    font-size: 32px;
    color: #0f172a;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.fonts-header p {
    margin: 0;
    color: #64748b;
    font-size: 16px;
}

/* ── منطقة الرفع ── */
.upload-box {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    margin-bottom: 24px;
    transition: border-color 0.2s;
}
.upload-box:hover {
    border-color: #94a3b8;
}
.upload-icon {
    font-size: 44px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
}
.upload-text {
    color: #475569;
    margin: 10px 0 18px;
    font-size: 15px;
}
.upload-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.upload-kind {
    padding: 11px 18px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 15px;
    background: white;
    cursor: pointer;
    color: #1e293b;
    font-weight: 500;
    transition: all 0.15s;
}
.upload-kind:hover {
    border-color: #94a3b8;
}
.upload-button {
    padding: 11px 28px;
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: inline-block;
    transition: all 0.15s;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}
.upload-button:hover {
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

/* ── الرسائل ── */
.msg {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 15px;
}
.msg-ok {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}
.msg-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ── شريط الأدوات ── */
.toolbar {
    display: flex;
    gap: 14px;
    align-items: stretch;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.preview-controls {
    flex: 1;
    min-width: 320px;
    display: flex;
    gap: 12px;
    align-items: center;
    background: white;
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.preview-controls label {
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    font-size: 14px;
}
.preview-controls input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}
.preview-controls input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.filter-buttons {
    display: flex;
    gap: 6px;
    background: white;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.filter-btn {
    padding: 8px 18px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #475569;
    font-weight: 600;
    transition: all 0.15s;
    white-space: nowrap;
}
.filter-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}
.filter-btn.active {
    background: #2563eb;
    color: white;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/*                          الجدول                              */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.table-wrapper {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.02);
}

.fonts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}

/* ── رأس الجدول ── */
.fonts-table thead {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 2px solid #e2e8f0;
}

.fonts-table thead th {
    padding: 16px 20px;
    text-align: right;
    font-weight: 700;
    color: #1e293b;
    font-size: 13px;
    user-select: none;
    letter-spacing: 0.2px;
}

.fonts-table thead th.col-name,
.fonts-table thead th.col-lang,
.fonts-table thead th.col-size {
    cursor: pointer;
    transition: background 0.15s;
}

.fonts-table thead th.col-name:hover,
.fonts-table thead th.col-lang:hover,
.fonts-table thead th.col-size:hover {
    background: #e2e8f0;
}

.sort-icon {
    display: inline-block;
    margin-right: 6px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: normal;
}

/* ── صفوف الجدول ── */
.fonts-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.12s;
}
.fonts-table tbody tr:last-child {
    border-bottom: none;
}
.fonts-table tbody tr:hover {
    background: #f8fafc;
}

.fonts-table tbody td {
    padding: 16px 20px;
    vertical-align: middle;
    color: #1e293b;
}

/* ── عرض الأعمدة (مهم: مجموعها = 100%) ── */
.col-name    { width: 22%; }
.col-lang    { width: 12%; }
.col-preview { width: 42%; }
.col-size    { width: 10%; }
.col-actions { width: 14%; text-align: left; }

/* ── محتوى الأعمدة ── */
.font-name-cell {
    font-weight: 700;
    color: #0f172a;
    font-size: 15px;
}

.preview-text {
    font-size: 26px;
    line-height: 1.3;
    padding: 4px 0;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-size {
    color: #64748b;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    font-feature-settings: 'tnum';
}

/* ── شارة اللغة ── */
.lang-badge {
    padding: 5px 14px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 700;
    display: inline-block;
    letter-spacing: 0.3px;
}
.lang-ar {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}
.lang-en {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ── زر الحذف ── */
.btn-delete {
    padding: 7px 16px;
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
}
.btn-delete:hover {
    background: #fecaca;
    border-color: #fca5a5;
    transform: translateY(-1px);
}
.btn-delete:active {
    transform: translateY(0);
}

/* ── حالة فارغة ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
    background: white;
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    font-size: 15px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/*                         Responsive                          */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (max-width: 1024px) {
    .fonts-page { padding: 16px; }
    .col-name    { width: 25%; }
    .col-preview { width: 38%; }
    .preview-text { font-size: 22px; }
}

@media (max-width: 768px) {
    .fonts-header h1 { font-size: 24px; }
    .col-size { display: none; }
    .fonts-table thead th,
    .fonts-table tbody td { padding: 12px 10px; }
    .preview-text { font-size: 18px; }
    .col-name    { width: 30%; }
    .col-lang    { width: 18%; }
    .col-preview { width: 32%; }
    .col-actions { width: 20%; }
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/*       Range Sliders — تصميم موحّد عبر كل الصفحات                */
/*       مسار رمادي + جزء مملوء أحمر + نقطة كبيرة بارزة             */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 24px;
    background: transparent;
    cursor: pointer;
    outline: none;
    margin: 0;
}

/* ── المسار الكامل (Chrome, Safari, Edge) ── */
input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: linear-gradient(to left, var(--sld,#dc2626) var(--val,0%), #e2e8f0 var(--val,0%));
    border-radius: 999px;
}

/* ── النقطة المتحرّكة (Chrome, Safari, Edge) ── */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: var(--sld, #dc2626);
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25),
                0 0 0 1px rgba(0, 0, 0, 0.05);
    margin-top: -8px;  /* لتوسيط النقطة على المسار */
    cursor: grab;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3),
                0 0 0 1px rgba(0, 0, 0, 0.05);
}

input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.05);
}

/* ── المسار (Firefox) ── */
input[type="range"]::-moz-range-track {
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    border: none;
}

/* ── الجزء المملوء قبل النقطة (Firefox فقط) ── */
input[type="range"]::-moz-range-progress {
    height: 6px;
    background: var(--sld, #dc2626);
    border-radius: 999px;
}

/* ── النقطة (Firefox) ── */
input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--sld, #dc2626);
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25),
                0 0 0 1px rgba(0, 0, 0, 0.05);
    cursor: grab;
    transition: transform 0.12s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb:active {
    cursor: grabbing;
}

/* ── إلغاء الخطوط حول الـ slider عند التركيز ── */
input[type="range"]:focus {
    outline: none;
}

/* ── حالة معطّلة ── */
input[type="range"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
input[type="range"]:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
    background: #94a3b8;
    box-shadow: none;
}
input[type="range"]:disabled::-moz-range-thumb {
    cursor: not-allowed;
    background: #94a3b8;
    box-shadow: none;
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/*       Number Stepper — حقل رقمي مع زرّي + و −                  */
/*       تصميم موحّد عبر كل الصفحات                                */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.num-stepper {
    display: flex;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    height: 44px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.num-stepper:hover {
    border-color: #cbd5e1;
}

.num-stepper:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.stepper-btn {
    width: 44px;
    height: 100%;
    font-size: 22px;
    font-weight: 500;
    border: none;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.stepper-btn:active {
    background: #cbd5e1;
}

.stepper-btn:disabled {
    background: #f1f5f9;
    color: #cbd5e1;
    cursor: not-allowed;
}

.stepper-input {
    flex: 1;
    text-align: center;
    border: none;
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    border-radius: 0;
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
    outline: none;
    padding: 0;
    background: white;
    font-family: 'Segoe UI', Tahoma, Arial;
    width: 100%;
    min-width: 0;
}

.stepper-input:focus {
    background: #f8fafc;
}

/* ── Toggle switch (مفتاح تبديل) ── */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  direction: ltr;
}
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.switch .slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background .2s ease;
  z-index: 1;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform .2s ease;
}
.switch input:checked + .slider {
  background: var(--primary);
}
.switch input:checked + .slider::before {
  transform: translateX(18px);
}


/* ═══════════════════════════════════════════════════════════════
   نظام المظهر: نهاري / ليلي
   توكنز دلاليّة + قواعد موجَّهة لأكثر الأنماط المضمّنة تكرارًا
   ═══════════════════════════════════════════════════════════════ */
/* v1160: (انظر tokens.css) */
/* v1160: كتلة المتغيرات الداكنة انتقلت إلى tokens.css */

html, body { background: var(--bg); color: var(--text); }
body, header, aside, section, main, input, select, textarea, button, .card {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

/* الإطار العامّ والبطاقات والحقول في الليلي */
html[data-theme="dark"] header,
html[data-theme="dark"] aside,
html[data-theme="dark"] .card,
html[data-theme="dark"] .tb,
html[data-theme="dark"] .sb { background: var(--bg-card) !important; border-color: var(--border) !important; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: var(--bg-soft) !important; color: var(--text) !important; border-color: var(--border-2) !important;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: var(--text-3); }
html[data-theme="dark"] table { color: var(--text); }
html[data-theme="dark"] img.salla-img { filter: brightness(.92); }

/* قواعد موجَّهة: الخلفيّات المضمّنة الفاتحة */
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:#ffffff"] { background: var(--bg-card) !important; }
html[data-theme="dark"] [style*="background:#f8fafc"] { background: var(--bg-soft) !important; }
html[data-theme="dark"] [style*="background:#f5f5f5"],
html[data-theme="dark"] [style*="background:#f9fafb"] { background: var(--bg-soft) !important; }
html[data-theme="dark"] [style*="background:#f1f5f9"],
html[data-theme="dark"] [style*="background:#e9e5f8"] { background: var(--bg-soft-2) !important; }
html[data-theme="dark"] [style*="background:#eff6ff"] { background: var(--bg-tint) !important; }
html[data-theme="dark"] [style*="background:#faf5ff"],
html[data-theme="dark"] [style*="background:#f5f3ff"] { background: var(--bg-lib) !important; }
/* v1146: شبكة أمانٍ داكنة موسّعة — متغيرات المسافة، النصوص الداكنة السطرية،
   الحدود الفاتحة، والعناصر المنسية (option/th/td/hr/scrollbar) */
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background:white"],
html[data-theme="dark"] [style*="background: white"] { background: var(--bg-card) !important; }
html[data-theme="dark"] [style*="background: #f8fafc"],
html[data-theme="dark"] [style*="background: #f9fafb"] { background: var(--bg-soft) !important; }
html[data-theme="dark"] [style*="background: #f1f5f9"],
html[data-theme="dark"] [style*="background:#f3f4f6"],
html[data-theme="dark"] [style*="background: #f3f4f6"] { background: var(--bg-soft-2) !important; }
html[data-theme="dark"] [style*="background: #eff6ff"] { background: var(--bg-tint) !important; }
html[data-theme="dark"] [style*="background: #faf5ff"] { background: var(--bg-lib) !important; }
html[data-theme="dark"] [style*="color:#0f172a"],
html[data-theme="dark"] [style*="color: #0f172a"],
html[data-theme="dark"] [style*="color:#111827"],
html[data-theme="dark"] [style*="color: #111827"],
html[data-theme="dark"] [style*="color:#1f2937"],
html[data-theme="dark"] [style*="color: #1f2937"] { color: var(--text) !important; }
html[data-theme="dark"] [style*="#e2e8f0"] { border-color: var(--border-2) !important; }
html[data-theme="dark"] option { background: var(--bg-card); color: var(--text); }
html[data-theme="dark"] th, html[data-theme="dark"] td { border-color: var(--border) !important; }
html[data-theme="dark"] hr { border-color: var(--border); }
html[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg-soft); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3a4453; border-radius: 6px; }

/* v1151: مصيدة شريط التبويبات — تُعتم الشريط وحاويه المباشر أياً كان اسمه */
html[data-theme="dark"] .nr-tabs,
html[data-theme="dark"] .v2tabs,
html[data-theme="dark"] :has(> .nr-tabs),
html[data-theme="dark"] :has(> .v2tabs) { background: var(--bg-card) !important; }
html[data-theme="dark"] .nr-tabs button:not(.on),
html[data-theme="dark"] .v2tabs button:not(.on) { color: var(--text-3) !important; background: transparent !important; }
html[data-theme="dark"] .nr-tabs button.on,
html[data-theme="dark"] .v2tabs button.on { color: var(--text) !important; background: transparent !important; }

html[data-theme="dark"] [style*="background:#fef2f2"] { background: #2b1d1f !important; }
html[data-theme="dark"] [style*="background:#fff7ed"] { background: #2a2014 !important; }
html[data-theme="dark"] [style*="background:#f0fdf4"] { background: #16261c !important; }
html[data-theme="dark"] [style*="background:rgba(255,255,255"] { background: rgba(22,27,34,.92) !important; }

/* قواعد موجَّهة: الحدود الفاتحة */
html[data-theme="dark"] [style*="border:1px solid #ccc"],
html[data-theme="dark"] [style*="border:1px solid #cbd5e1"],
html[data-theme="dark"] [style*="border:1px solid #e5e7eb"],
html[data-theme="dark"] [style*="border:1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border:1px dashed #cbd5e1"] { border-color: var(--border-2) !important; }
html[data-theme="dark"] [style*="border:1px solid #e9d5ff"] { border-color: #463a66 !important; }
html[data-theme="dark"] [style*="border:1px solid #ddd6fe"] { border-color: #4a3f73 !important; }
html[data-theme="dark"] [style*="border:1px solid #fecaca"] { border-color: #5b3034 !important; }
html[data-theme="dark"] [style*="border:1px solid #fdba74"] { border-color: #5c4426 !important; }

/* قواعد موجَّهة: النصوص الداكنة على فاتح */
html[data-theme="dark"] [style*="color:#1e293b"],
html[data-theme="dark"] [style*="color:#334155"],
html[data-theme="dark"] [style*="color:#374151"],
html[data-theme="dark"] [style*="color:#111"] { color: var(--text) !important; }
html[data-theme="dark"] [style*="color:#475569"],
html[data-theme="dark"] [style*="color:#555"],
html[data-theme="dark"] [style*="color:#666"],
html[data-theme="dark"] [style*="color:#6b7280"],
html[data-theme="dark"] [style*="color:#64748b"] { color: var(--text-2) !important; }
html[data-theme="dark"] [style*="color:#94a3b8"] { color: var(--text-3) !important; }
html[data-theme="dark"] [style*="color:#0f766e"] { color: #34d3c3 !important; }
html[data-theme="dark"] [style*="color:#15803d"],
html[data-theme="dark"] [style*="color:#166534"] { color: #4ade80 !important; }
html[data-theme="dark"] [style*="color:#b45309"] { color: #fbbf24 !important; }
html[data-theme="dark"] [style*="color:#0d8c3f"] { color: #36c275 !important; }

/* شريط تمرير ليليّ */
html[data-theme="dark"] { scrollbar-color: #39404d transparent; }
html[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #39404d; border-radius: 8px; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4a5260; }
html[data-theme="dark"] ::-webkit-scrollbar-track { background: transparent; }

/* زرّ تبديل المظهر في الشريط العلويّ */
.theme-toggle {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border-2); background: var(--bg-card);
  color: var(--text-2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .2s ease, background-color .25s ease, color .25s ease, border-color .25s ease;
}
.theme-toggle:hover { transform: rotate(18deg) scale(1.07); color: var(--text); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: block; }


/* (حُذفت قواعد الأصناف المولَّدة — الأصناف نفسها صارت بالتوكنز) */

/* الموجة الثانية: ألوان مضمّنة مفلتة (من المسح الإحصائيّ) */
html[data-theme="dark"] [style*="background:#fef3c7"],
html[data-theme="dark"] [style*="background:#fffbeb"],
html[data-theme="dark"] [style*="background:#fefce8"] { background: #2a2014 !important; }
html[data-theme="dark"] [style*="background:#fed7aa"] { background: #33261a !important; }
html[data-theme="dark"] [style*="background:#f3e8ff"],
html[data-theme="dark"] [style*="background:#ede9fe"] { background: var(--bg-lib) !important; }
html[data-theme="dark"] [style*="background:#f3f4f6"],
html[data-theme="dark"] [style*="background:#fafbfc"],
html[data-theme="dark"] [style*="background:#f9f9f9"] { background: var(--bg-soft-2) !important; }
html[data-theme="dark"] [style*="background:#e0e7ff"],
html[data-theme="dark"] [style*="background:#f8f9ff"] { background: var(--bg-tint) !important; }
html[data-theme="dark"] [style*="background:#fee2e2"] { background: #2b1d1f !important; }
html[data-theme="dark"] [style*="background:#fce7f3"] { background: #2b1a26 !important; }
html[data-theme="dark"] [style*="color:#333"],
html[data-theme="dark"] [style*="color:#1f2937"],
html[data-theme="dark"] [style*="color:#0f172a"] { color: var(--text) !important; }
html[data-theme="dark"] [style*="color:#4b5563"],
html[data-theme="dark"] [style*="color:#444"] { color: var(--text-2) !important; }
html[data-theme="dark"] [style*="color:#888"],
html[data-theme="dark"] [style*="color:#999"],
html[data-theme="dark"] [style*="color:#9ca3af"] { color: var(--text-3) !important; }
html[data-theme="dark"] [style*="border:1px solid #ddd"],
html[data-theme="dark"] [style*="border:1px solid #d1d5db"],
html[data-theme="dark"] [style*="border:1px solid #eee"] { border-color: var(--border-2) !important; }

/* ═══ v1068: أرقام إنجليزية دائماً — بعض الأجهزة العربية كانت ترسم حقول الأرقام بأرقام هندية ═══ */
input[inputmode="decimal"], .nz-slider-bubble {
  font-variant-numeric: lining-nums;
  font-feature-settings: "locl" 0;
}
input[inputmode="decimal"] {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: center;
}


/* ═══ v1090: إنقاذ أزواج «صندوق + منزلق» عبر المشروع — تحويل v1068 جعل قاعدة
   width:100% (لصناديق type="text") تبتلع الصندوق فينكمش المنزلق المجاور إلى نقطة.
   قاعدتان سلوكيتان عامتان + تعداد الحاويات المعروفة احتياطاً للمتصفحات الأقدم. ═══ */
div:has(> input[inputmode="decimal"]):has(> input[type="range"]) {
  display: flex; align-items: center; gap: 10px;
}
div:has(> input[type="range"]) > input[inputmode="decimal"] {
  width: 72px; flex: 0 0 72px; text-align: center;
}
div:has(> input[inputmode="decimal"]) > input[type="range"] {
  flex: 1 1 auto; width: auto; min-width: 90px;
}
.mn-nr, .nz-nr, .kc-nr, .bk-nr, .sm-sliderrow, .pl-sliderrow, .lp-sliderrow {
  display: flex; align-items: center; gap: 10px;
}
.mn-nr input[inputmode="decimal"], .nz-nr input[inputmode="decimal"], .kc-nr input[inputmode="decimal"], .bk-nr input[inputmode="decimal"],
.sm-sliderrow input[inputmode="decimal"], .pl-sliderrow input[inputmode="decimal"], .lp-sliderrow input[inputmode="decimal"] {
  width: 72px; flex: 0 0 72px; text-align: center;
}
.mn-nr input[type="range"], .nz-nr input[type="range"], .kc-nr input[type="range"], .bk-nr input[type="range"],
.sm-sliderrow input[type="range"], .pl-sliderrow input[type="range"], .lp-sliderrow input[type="range"] {
  flex: 1 1 auto; width: auto; min-width: 90px;
}
