/* =========================================================
   تدارك — نظام المحاسبة المتكامل | Design System
   ========================================================= */
:root {
  --navy-950: #081735;
  --navy-900: #0E2250;
  --navy-800: #14306B;
  --navy: #1A3A81;
  --navy-600: #2B4FA3;
  --navy-500: #3D63BD;
  --navy-100: #DCE6F8;
  --navy-50: #EEF3FC;
  --gold: #C9A227;
  --gold-light: #E9CE7A;
  --bg: #F2F5FA;
  --surface: #FFFFFF;
  --line: #E4E9F2;
  --text: #1C2740;
  --text-2: #5A6residual: none;
  --text-2: #5B6B8C;
  --text-3: #93A1BE;
  --success: #0E9F6E;
  --success-bg: #E3F5EE;
  --danger: #E02424;
  --danger-bg: #FBE7E7;
  --warn: #C27803;
  --warn-bg: #FDF3DF;
  --info-bg: #E8F1FD;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(14, 34, 80, .05), 0 8px 24px -12px rgba(14, 34, 80, .18);
  --shadow-lg: 0 24px 60px -20px rgba(8, 23, 53, .35);
  --font: 'Cairo', 'Tajawal', system-ui, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box
}

html {
  scroll-behavior: smooth
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.65;
  min-height: 100vh
}

button {
  font-family: inherit;
  cursor: pointer
}

input,
select,
textarea {
  font-family: inherit
}

a {
  color: var(--navy);
  text-decoration: none
}

::selection {
  background: var(--navy-100)
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px
}

::-webkit-scrollbar-thumb {
  background: #C4CFE3;
  border-radius: 8px;
  border: 2px solid var(--bg)
}

::-webkit-scrollbar-track {
  background: transparent
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 14px;
  transition: .18s;
  white-space: nowrap
}

.btn-primary {
  background: linear-gradient(135deg, var(--navy-600), var(--navy-900));
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(26, 58, 129, .55)
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -6px rgba(26, 58, 129, .6)
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: var(--navy-950);
  box-shadow: 0 6px 16px -6px rgba(201, 162, 39, .5)
}

.btn-gold:hover {
  transform: translateY(-1px)
}

.btn-ghost {
  background: var(--navy-50);
  color: var(--navy)
}

.btn-ghost:hover {
  background: var(--navy-100)
}

.btn-outline {
  background: #fff;
  color: var(--navy);
  border: 1.5px solid var(--line)
}

.btn-outline:hover {
  border-color: var(--navy-500);
  background: var(--navy-50)
}

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

.btn-danger:hover {
  background: #F5D0D0
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: 10px
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: 10px
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none
}

/* ---------- Login ---------- */
#login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  z-index: 50;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(61, 99, 189, .35), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(201, 162, 39, .18), transparent 55%),
    linear-gradient(160deg, var(--navy-950) 0%, var(--navy-900) 45%, var(--navy-800) 100%)
}

.login-art {
  flex: 1.1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px;
  color: #fff;
  position: relative;
  overflow: hidden
}

.login-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cpath d='M0 30h60M30 0v60' stroke='%23ffffff10' stroke-width='1'/%3E%3C/svg%3E")
}

.login-art h1 {
  font-size: 40px;
  font-weight: 900;
  line-height: 1.35;
  position: relative
}

.login-art h1 span {
  color: var(--gold-light)
}

.login-art p {
  margin-top: 14px;
  font-size: 16px;
  color: #C9D6F0;
  max-width: 480px;
  position: relative
}

.login-badges {
  display: flex;
  gap: 12px;
  margin-top: 34px;
  flex-wrap: wrap;
  position: relative
}

.login-badges div {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(6px);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px
}

.login-badges i {
  color: var(--gold-light)
}

.login-panel {
  width: 480px;
  max-width: 100%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px 52px;
  border-start-start-radius: 32px;
  border-end-start-radius: 32px;
  box-shadow: var(--shadow-lg)
}

.login-logo {
  height: 64px;
  object-fit: contain;
  align-self: center;
  margin-bottom: 8px
}

.login-panel h2 {
  font-size: 24px;
  font-weight: 900;
  text-align: center;
  color: var(--navy-900)
}

.login-panel .sub {
  text-align: center;
  color: var(--text-2);
  font-size: 13.5px;
  margin: 6px 0 30px
}

.field {
  margin-bottom: 18px
}

.field label {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 7px;
  color: var(--navy-900)
}

.field label a {
  font-weight: 600;
  font-size: 12px
}

.input-wrap {
  position: relative
}

.input-wrap i {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3)
}

.input,
.select,
textarea.input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  background: #FAFBFE;
  transition: .15s;
  color: var(--text)
}

.input-wrap .input {
  padding-inline-start: 42px
}

.input:focus,
.select:focus,
textarea.input:focus {
  outline: none;
  border-color: var(--navy-500);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(43, 79, 163, .12)
}

.login-error {
  display: none;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px
}

.login-foot {
  margin-top: 26px;
  text-align: center;
  color: var(--text-3);
  font-size: 12px
}

.login-hint {
  margin-top: 14px;
  background: var(--navy-50);
  border: 1px dashed var(--navy-100);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  color: var(--navy-600);
  text-align: center
}

/* ---------- App layout ---------- */
#app {
  display: none;
  min-height: 100vh
}

#app.active {
  display: grid;
  grid-template-columns: 264px 1fr
}

.sidebar {
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900) 60%, var(--navy-800));
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh
}

.sidebar-logo {
  padding: 22px 20px 16px;
  display: flex;
  justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, .08)
}

.sidebar-logo img {
  height: 52px;
  filter: brightness(0) invert(1);
  opacity: .95
}

.side-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto
}

.side-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .15);
  border: none
}

.nav-label {
  font-size: 11px;
  color: #7E92C4;
  font-weight: 700;
  padding: 10px 12px 4px;
  letter-spacing: .4px
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  color: #C4D2F0;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 3px;
  transition: .15s;
  border: none;
  background: none;
  width: 100%;
  text-align: start
}

.nav-item i {
  width: 20px;
  text-align: center;
  font-size: 15px
}

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

.nav-item.active {
  background: linear-gradient(90deg, rgba(201, 162, 39, .22), rgba(255, 255, 255, .06));
  color: #fff;
  position: relative
}

.nav-item.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 4px;
  background: var(--gold-light)
}

.side-foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, .08)
}

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: var(--navy-950);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 15px;
  flex-shrink: 0
}

.side-user b {
  font-size: 13px;
  display: block;
  line-height: 1.3
}

.side-user span {
  font-size: 11px;
  color: #8FA3D2
}

.logout-btn {
  width: 100%;
  background: rgba(224, 36, 36, .14);
  color: #FF9F9F;
  border: none;
  border-radius: 10px;
  padding: 9px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: .15s
}

.logout-btn:hover {
  background: rgba(224, 36, 36, .28);
  color: #fff
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0
}

.topbar {
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20
}

.topbar .search {
  flex: 1;
  max-width: 420px;
  position: relative
}

.topbar .search i {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 13px
}

.topbar .search input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #F7F9FD;
  border-radius: 12px;
  padding: 9px 14px;
  padding-inline-start: 38px;
  font-size: 13.5px
}

.topbar .search input:focus {
  outline: none;
  border-color: var(--navy-500);
  background: #fff
}

.topbar-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 10px
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--navy-50);
  border: 1.5px solid var(--navy-100);
  color: var(--navy);
  border-radius: 12px;
  padding: 8px 14px;
  font-weight: 800;
  font-size: 13px;
  transition: .15s
}

.lang-btn:hover {
  background: var(--navy-100)
}

.icon-pill {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: .15s
}

.icon-pill:hover {
  border-color: var(--navy-500);
  color: var(--navy)
}

.icon-pill .dot {
  position: absolute;
  top: 8px;
  inset-inline-end: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid #fff
}

.content {
  padding: 28px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  animation: fadeUp .3s ease
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px)
  }

  to {
    opacity: 1;
    transform: none
  }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap
}

.page-head h1 {
  font-size: 23px;
  font-weight: 900;
  color: var(--navy-900)
}

.page-head p {
  color: var(--text-2);
  font-size: 13.5px;
  margin-top: 2px
}

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

/* ---------- Cards & stats ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow)
}

.card-pad {
  padding: 22px
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line)
}

.card-head h3 {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--navy-900)
}

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

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: .2s
}

.stat:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg)
}

.stat::after {
  content: "";
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--navy-500), transparent)
}

.stat.gold::after {
  background: linear-gradient(90deg, var(--gold), transparent)
}

.stat.green::after {
  background: linear-gradient(90deg, var(--success), transparent)
}

.stat.red::after {
  background: linear-gradient(90deg, var(--danger), transparent)
}

.stat .s-top {
  display: flex;
  justify-content: space-between;
  align-items: center
}

.stat .s-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2)
}

.stat .s-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  background: var(--navy-50);
  color: var(--navy)
}

.stat.gold .s-icon {
  background: #FBF3DC;
  color: var(--gold)
}

.stat.green .s-icon {
  background: var(--success-bg);
  color: var(--success)
}

.stat.red .s-icon {
  background: var(--danger-bg);
  color: var(--danger)
}

.stat .s-value {
  font-size: 24px;
  font-weight: 900;
  color: var(--navy-950);
  margin-top: 8px
}

.stat .s-value small {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 700
}

.stat .s-trend {
  font-size: 12px;
  font-weight: 800;
  margin-top: 4px;
  display: inline-flex;
  gap: 5px;
  align-items: center
}

.trend-up {
  color: var(--success)
}

.trend-down {
  color: var(--danger)
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px
}

@media(max-width:1050px) {
  .grid-2 {
    grid-template-columns: 1fr
  }
}

.bar-row {
  margin-bottom: 16px
}

.bar-row .bar-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px
}

.bar-row .bar-info span:last-child {
  color: var(--navy)
}

.bar-track {
  height: 9px;
  border-radius: 8px;
  background: var(--navy-50);
  overflow: hidden
}

.bar-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--navy-600), var(--navy-500));
  transition: width .8s ease
}

.bar-fill.gold {
  background: linear-gradient(90deg, var(--gold), var(--gold-light))
}

.bar-fill.green {
  background: linear-gradient(90deg, var(--success), #3ECF98)
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto
}

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px
}

.tbl thead th {
  background: #F7F9FD;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 800;
  text-align: start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap
}

.tbl tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle
}

.tbl tbody tr {
  transition: .12s
}

.tbl tbody tr:hover {
  background: var(--navy-50)
}

.tbl tbody tr:last-child td {
  border-bottom: none
}

.t-strong {
  font-weight: 800;
  color: var(--navy-900)
}

.t-muted {
  color: var(--text-3);
  font-size: 12px
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 100px;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 800
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor
}

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

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

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

.badge.info {
  background: var(--info-bg);
  color: var(--navy-600)
}

.badge.muted {
  background: #EEF1F7;
  color: var(--text-2)
}

.row-actions {
  display: flex;
  gap: 6px
}

.act {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  transition: .14s
}

.act:hover {
  color: var(--navy);
  border-color: var(--navy-500);
  background: var(--navy-50)
}

.act.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-bg)
}

.tbl-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  color: var(--text-2);
  font-size: 13px;
  flex-wrap: wrap;
  gap: 10px
}

.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--text-3)
}

.empty i {
  font-size: 38px;
  margin-bottom: 12px;
  display: block;
  color: #C4CFE3
}

/* ---------- Forms / modals ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px
}

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

@media(max-width:640px) {
  .form-grid {
    grid-template-columns: 1fr
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 23, 53, .55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px
}

.modal-overlay.open {
  display: flex;
  animation: fadeUp .2s ease
}

.modal {
  background: #fff;
  border-radius: 20px;
  width: 640px;
  max-width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg)
}

.modal.lg {
  width: 980px
}

.modal.xl {
  width: 1120px
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line)
}

.modal-head h3 {
  font-size: 17px;
  font-weight: 900;
  color: var(--navy-900)
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: var(--navy-50);
  color: var(--text-2);
  font-size: 15px
}

.modal-close:hover {
  background: var(--danger-bg);
  color: var(--danger)
}

.modal-body {
  padding: 24px;
  overflow-y: auto
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--line)
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0
}

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

.switch .track {
  position: absolute;
  inset: 0;
  background: #CBD5E6;
  border-radius: 100px;
  transition: .2s;
  cursor: pointer
}

.switch .track::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  inset-inline-start: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25)
}

.switch input:checked+.track {
  background: var(--navy-600)
}

.switch input:checked+.track::before {
  transform: translateX(-20px)
}

[dir=ltr] .switch input:checked+.track::before {
  transform: translateX(20px)
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line)
}

.toggle-row:last-child {
  border-bottom: none
}

.toggle-row b {
  font-size: 13.5px
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px
}

.perm-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  user-select: none
}

.perm-chip:hover {
  border-color: var(--navy-500)
}

.perm-chip input {
  accent-color: var(--navy);
  width: 16px;
  height: 16px
}

.perm-chip.on {
  background: var(--navy-50);
  border-color: var(--navy-500);
  color: var(--navy-900)
}

/* ---------- Invoice builder ---------- */
.lines-table th,
.lines-table td {
  padding: 8px 8px !important
}

.lines-table .input {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 9px
}

.totals-box {
  background: var(--navy-50);
  border: 1px solid var(--navy-100);
  border-radius: 14px;
  padding: 16px 20px;
  margin-top: 16px;
  max-width: 380px;
  margin-inline-start: auto
}

.totals-box .tr {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  padding: 5px 0;
  font-weight: 700;
  color: var(--text-2)
}

.totals-box .tr.grand {
  border-top: 2px solid var(--navy-100);
  margin-top: 8px;
  padding-top: 10px;
  font-size: 16px;
  color: var(--navy-950);
  font-weight: 900
}

/* ---------- Template picker ---------- */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px
}

.tpl-card {
  border: 2px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: .18s;
  background: #fff
}

.tpl-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow)
}

.tpl-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(201, 162, 39, .18)
}

.tpl-thumb {
  height: 150px;
  background: #F7F9FD;
  position: relative;
  overflow: hidden
}

.tpl-thumb .mini {
  position: absolute;
  top: 10px;
  inset-inline: 12px;
  bottom: 0;
  background: #fff;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 4px 14px rgba(14, 34, 80, .13);
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 5px
}

.mini .mh {
  height: 16px;
  border-radius: 4px
}

.mini .ml {
  height: 6px;
  border-radius: 3px;
  background: #E4E9F2
}

.mini .ml.w60 {
  width: 60%
}

.mini .ml.w40 {
  width: 40%
}

.mini .ml.w80 {
  width: 80%
}

.mini .mt {
  flex: 1;
  border-radius: 4px;
  background: repeating-linear-gradient(180deg, #F2F5FA 0 8px, #fff 8px 14px)
}

.tpl-name {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  font-size: 13px;
  color: var(--navy-900)
}

.tpl-name i {
  color: var(--gold);
  opacity: 0;
  transition: .15s
}

.tpl-card.selected .tpl-name i {
  opacity: 1
}

.preview-frame {
  background: #8f9dbb33;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  max-height: 56vh;
  overflow: auto
}

.preview-frame .inv {
  margin: 0 auto;
  transform-origin: top center;
  box-shadow: 0 10px 40px rgba(8, 23, 53, .25)
}

/* ---------- Toast ---------- */
#toasts {
  position: fixed;
  bottom: 22px;
  inset-inline-start: 22px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px
}

.toast {
  background: var(--navy-950);
  color: #fff;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .25s ease
}

.toast i {
  color: var(--gold-light)
}

.toast.ok i {
  color: #3ECF98
}

.toast.err i {
  color: #FF8A8A
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  background: #EDF1F8;
  padding: 5px;
  border-radius: 13px;
  width: max-content;
  margin-bottom: 20px;
  flex-wrap: wrap
}

.tab {
  border: none;
  background: none;
  padding: 9px 20px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13.5px;
  color: var(--text-2);
  transition: .15s
}

.tab.active {
  background: #fff;
  color: var(--navy-900);
  box-shadow: 0 2px 8px rgba(14, 34, 80, .1)
}

/* ---------- Client cards ---------- */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px
}

.client-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: .2s;
  position: relative
}

.client-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg)
}

.client-top {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px
}

.client-avatar {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--navy-600), var(--navy-900));
  color: #fff;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0
}

.client-top b {
  display: block;
  font-size: 14.5px;
  color: var(--navy-900);
  line-height: 1.4
}

.client-top span {
  font-size: 11.5px;
  color: var(--text-3)
}

.client-meta {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-2);
  border-top: 1px dashed var(--line);
  padding-top: 12px
}

.client-meta i {
  width: 18px;
  color: var(--navy-500)
}

.client-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px
}

/* =========================================================
   INVOICE TEMPLATES (screen preview + print)
   ========================================================= */
.inv {
  width: 800px;
  background: #fff;
  color: #1C2740;
  font-family: var(--font);
  padding: 44px 48px;
  position: relative;
  direction: rtl;
  font-size: 13px;
  line-height: 1.7
}

.inv * {
  box-sizing: border-box
}

.inv .inv-logo {
  height: 52px;
  object-fit: contain
}

.inv table.items {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-size: 12.5px
}

.inv table.items th {
  padding: 10px;
  font-weight: 800;
  text-align: start
}

.inv table.items td {
  padding: 9px 10px;
  vertical-align: top
}

.inv .totals {
  width: 300px;
  margin-inline-start: auto;
  margin-top: 18px;
  font-size: 13px
}

.inv .totals .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px
}

.inv .totals .grand {
  font-weight: 900;
  font-size: 15px
}

.inv .words {
  margin-top: 12px;
  font-weight: 800;
  font-size: 12.5px
}

.inv .terms {
  margin-top: 24px;
  font-size: 11px;
  color: #5B6B8C
}

.inv .terms b {
  display: block;
  font-size: 12px;
  color: inherit;
  margin-bottom: 4px
}

.inv .sig-row {
  display: flex;
  justify-content: space-between;
  margin-top: 44px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  clear: both
}

.inv .sig-row div {
  width: 180px;
  border-top: 1.5px dashed #B9C4DA;
  padding-top: 8px
}

.inv .qr {
  flex-shrink: 0;
  margin-left: 30px
}

.inv .qr svg {
  width: 96px;
  height: 96px
}

.inv .meta-line {
  font-size: 11.5px;
  color: #5B6B8C
}

/* --- Template 1: الكلاسيكي --- */
.tpl-classic {
  border-top: 8px solid var(--navy)
}

.tpl-classic .head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px
}

.tpl-classic .co b {
  font-size: 16px;
  color: var(--navy-900)
}

.tpl-classic .doc-title {
  background: var(--navy-50);
  border: 1px solid var(--navy-100);
  border-radius: 10px;
  padding: 10px 22px;
  text-align: center
}

.tpl-classic .doc-title h2 {
  font-size: 16px;
  color: var(--navy);
  font-weight: 900
}

.tpl-classic table.items th {
  background: var(--navy);
  color: #fff
}

.tpl-classic table.items td {
  border-bottom: 1px solid #E4E9F2
}

.tpl-classic table.items tr:nth-child(even) td {
  background: #F7F9FD
}

.tpl-classic .totals .grand {
  background: var(--navy);
  color: #fff;
  border-radius: 8px
}

.tpl-classic .parties {
  display: flex;
  gap: 16px;
  margin-top: 20px
}

.tpl-classic .party {
  flex: 1;
  border: 1px solid #E4E9F2;
  border-radius: 10px;
  padding: 12px 16px
}

.tpl-classic .party h4 {
  font-size: 11px;
  color: var(--navy);
  margin-bottom: 6px
}

/* --- Template 2: العصري --- */
.tpl-modern {
  padding: 0 0 44px
}

.tpl-modern .hero {
  background: linear-gradient(120deg, var(--navy-950), var(--navy-600));
  color: #fff;
  padding: 34px 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 5px solid var(--gold)
}

.tpl-modern .hero .inv-logo {
  filter: brightness(0) invert(1)
}

.tpl-modern .hero h2 {
  font-size: 22px;
  font-weight: 900
}

.tpl-modern .hero .meta-line {
  color: #C9D6F0
}

.tpl-modern .body {
  padding: 28px 48px 0
}

.tpl-modern .parties {
  display: flex;
  gap: 14px
}

.tpl-modern .party {
  flex: 1;
  background: #F5F8FD;
  border-radius: 14px;
  padding: 14px 18px
}

.tpl-modern .party h4 {
  font-size: 11px;
  color: var(--navy-600);
  margin-bottom: 6px
}

.tpl-modern table.items th {
  background: #F0F4FB;
  color: var(--navy-900);
  border-bottom: 2px solid var(--navy)
}

.tpl-modern table.items td {
  border-bottom: 1px solid #EDF1F8
}

.tpl-modern .totals {
  background: #F5F8FD;
  border-radius: 14px;
  padding: 10px
}

.tpl-modern .totals .grand {
  color: var(--navy);
  border-top: 2px solid var(--navy-100)
}

/* --- Template 3: المينيمال --- */
.tpl-minimal {
  padding: 56px 56px
}

.tpl-minimal .head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid #1C2740;
  padding-bottom: 22px
}

.tpl-minimal h2 {
  font-size: 26px;
  font-weight: 300;
  letter-spacing: 1px
}

.tpl-minimal h2 b {
  font-weight: 900
}

.tpl-minimal table.items th {
  border-bottom: 1.5px solid #1C2740;
  font-size: 11px;
  letter-spacing: .5px;
  color: #5B6B8C
}

.tpl-minimal table.items td {
  border-bottom: 1px solid #EDF0F5
}

.tpl-minimal .totals .row {
  padding: 5px 0
}

.tpl-minimal .totals .grand {
  border-top: 1.5px solid #1C2740;
  margin-top: 6px;
  padding-top: 10px
}

.tpl-minimal .parties {
  display: flex;
  gap: 40px;
  margin-top: 24px;
  font-size: 12.5px
}

.tpl-minimal .party h4 {
  font-size: 10.5px;
  letter-spacing: .5px;
  color: #93A1BE;
  margin-bottom: 5px
}

/* --- Template 4: الفاخر --- */
.tpl-luxury {
  border: 1px solid var(--gold);
  outline: 4px solid var(--navy-950);
  outline-offset: -12px;
  padding: 52px 56px;
  background: linear-gradient(180deg, #fff, #FDFBF4)
}

.tpl-luxury .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--gold)
}

.tpl-luxury h2 {
  font-size: 20px;
  font-weight: 900;
  color: var(--navy-950)
}

.tpl-luxury h2 small {
  display: block;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 800
}

.tpl-luxury table.items th {
  background: var(--navy-950);
  color: var(--gold-light)
}

.tpl-luxury table.items td {
  border-bottom: 1px solid #EAE2C8
}

.tpl-luxury .totals .grand {
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  color: var(--navy-950);
  border-radius: 6px
}

.tpl-luxury .parties {
  display: flex;
  gap: 16px;
  margin-top: 20px
}

.tpl-luxury .party {
  flex: 1;
  border: 1px solid #EAE2C8;
  background: #fff;
  border-radius: 8px;
  padding: 12px 16px
}

.tpl-luxury .party h4 {
  color: var(--gold);
  font-size: 11px;
  margin-bottom: 6px
}

/* --- Template 5: ثنائي اللغة --- */
.tpl-bilingual {
  border-top: 6px double var(--navy)
}

.tpl-bilingual .head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start
}

.tpl-bilingual .bi {
  font-size: 10.5px;
  color: #93A1BE;
  display: block;
  direction: ltr;
  text-align: end
}

.tpl-bilingual table.items th {
  background: var(--navy-50);
  color: var(--navy-900);
  border: 1px solid var(--navy-100)
}

.tpl-bilingual table.items td {
  border: 1px solid #E4E9F2
}

.tpl-bilingual table.items th small {
  display: block;
  font-size: 9.5px;
  color: #5B6B8C;
  font-weight: 600
}

.tpl-bilingual .totals .row {
  border-bottom: 1px dashed #E4E9F2
}

.tpl-bilingual .totals .grand {
  background: var(--navy-50);
  border-radius: 8px;
  border: 1px solid var(--navy-100)
}

.tpl-bilingual .parties {
  display: flex;
  gap: 14px;
  margin-top: 18px
}

.tpl-bilingual .party {
  flex: 1;
  border: 1px solid var(--navy-100);
  border-radius: 10px;
  padding: 12px 16px
}

.tpl-bilingual .party h4 {
  font-size: 11px;
  color: var(--navy);
  margin-bottom: 5px
}

/* --- Template 6: الإيصال المدمج --- */
.tpl-compact {
  width: 420px;
  padding: 28px 26px;
  font-size: 12px
}

.tpl-compact .c-head {
  text-align: center;
  border-bottom: 1.5px dashed #B9C4DA;
  padding-bottom: 14px
}

.tpl-compact .inv-logo {
  height: 42px
}

.tpl-compact h2 {
  font-size: 15px;
  font-weight: 900;
  margin-top: 6px;
  color: var(--navy-900)
}

.tpl-compact .c-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 0;
  border-bottom: 1.5px dashed #B9C4DA;
  font-size: 11.5px
}

.tpl-compact .c-meta div {
  display: flex;
  justify-content: space-between
}

.tpl-compact table.items {
  margin-top: 10px;
  font-size: 11px
}

.tpl-compact table.items th {
  border-bottom: 1.5px solid #1C2740;
  padding: 6px 4px
}

.tpl-compact table.items td {
  padding: 6px 4px;
  border-bottom: 1px dashed #E4E9F2
}

.tpl-compact .totals {
  width: 100%;
  border-top: 1.5px dashed #B9C4DA;
  margin-top: 10px;
  padding-top: 8px
}

.tpl-compact .totals .grand {
  font-size: 14px
}

.tpl-compact .c-qr {
  text-align: center;
  margin-top: 14px;
  border-top: 1.5px dashed #B9C4DA;
  padding-top: 14px
}

.tpl-compact .c-foot {
  text-align: center;
  font-size: 10px;
  color: #93A1BE;
  margin-top: 10px
}

/* ---------- Print ---------- */
#print-area {
  display: none
}

@media print {

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    width: 210mm;
    background: #fff
  }

  body>*:not(#print-area) {
    display: none !important
  }

  #print-area {
    display: block !important;
    width: 210mm;
    margin: 0;
    padding: 0
  }

  #print-area .inv {
    width: 210mm !important;
    max-width: 210mm !important;
    min-height: 296mm;
    box-sizing: border-box !important;
    box-shadow: none !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  #print-area .inv * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  #preview-page {
    display: none !important
  }

  @page {
    size: A4;
    margin: 0
  }
}

/* ---------- Full Preview ---------- */
#preview-page {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #e8ecf2;
  flex-direction: column;
  overflow: hidden
}

#preview-page.open {
  display: flex
}

.preview-toolbar {
  background: var(--navy);
  color: #fff;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .3)
}

.preview-toolbar .btn {
  min-width: 120px;
  justify-content: center
}

.preview-toolbar .btn-ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, .5);
  background: rgba(255, 255, 255, .15)
}

.preview-toolbar .btn-ghost:hover {
  background: rgba(255, 255, 255, .28)
}

.preview-toolbar-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px
}

.preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  justify-content: center;
  align-items: flex-start
}

.preview-body .inv {
  box-shadow: 0 4px 24px rgba(0, 0, 0, .12);
  border-radius: 8px
}

/* ---------- Report Modal Cards ---------- */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 8px 0
}

.report-card {
  background: #f7f9fc;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 24px 18px;
  text-align: center;
  cursor: pointer;
  transition: .2s
}

.report-card:hover {
  border-color: var(--navy);
  background: #eef3fc;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(26, 58, 129, .1)
}

.report-card .rc-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 22px;
  color: #fff
}

.report-card h4 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 800;
  color: var(--navy)
}

.report-card p {
  margin: 0;
  font-size: 12px;
  color: var(--text-3)
}


/* ---------- Responsive ---------- */
@media(max-width:960px) {
  #app.active {
    grid-template-columns: 1fr
  }

  .sidebar {
    position: fixed;
    inset-inline-start: -280px;
    width: 264px;
    z-index: 60;
    transition: .25s
  }

  .sidebar.open {
    inset-inline-start: 0;
    box-shadow: var(--shadow-lg)
  }

  .menu-toggle {
    display: flex !important
  }

  #login-screen {
    flex-direction: column
  }

  .login-art {
    padding: 40px 28px;
    flex: none
  }

  .login-panel {
    width: 100%;
    border-radius: 32px 32px 0 0;
    flex: 1
  }
}

.menu-toggle {
  display: none
}

/* =========================================================
   المرحلة الثانية — إضافات (لا تعدّل الأنماط الموجودة)
   ========================================================= */

/* ---------- إصلاح الصلاحيات + المودال فوق صفحة المعاينة ---------- */
.modal-overlay {
  z-index: 10000
}

#toasts {
  z-index: 10010
}

.modal,
.modal * {
  pointer-events: auto
}

.perm-select {
  position: relative;
  z-index: 2;
  cursor: pointer
}

/* ---------- أيقونة "تم الإصدار" بجانب أزرار الربط ---------- */
.link-act {
  position: relative
}

.link-done {
  position: absolute;
  top: -5px;
  inset-inline-end: -5px;
  color: var(--success);
  background: #fff;
  border-radius: 50%;
  font-size: 12px
}

/* ---------- شاشة الدخول: خلفية متحركة + 3D ---------- */
#login-screen {
  background: linear-gradient(-45deg, #081735, #14306B, #1A3A81, #0E2250);
  background-size: 300% 300%;
  animation: loginGradient 16s ease infinite;
  perspective: 1400px
}

@keyframes loginGradient {
  0% { background-position: 0% 50% }
  50% { background-position: 100% 50% }
  100% { background-position: 0% 50% }
}

#login-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(61, 99, 189, .35), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(201, 162, 39, .18), transparent 55%)
}

.login-art,
.login-panel {
  position: relative;
  z-index: 1
}

/* أشكال هندسية عائمة */
.login-shapes {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none
}

.shape {
  position: absolute;
  display: block;
  opacity: .14;
  border: 2px solid var(--gold-light)
}

.shape.sh1 { width: 120px; height: 120px; border-radius: 50%; top: 12%; inset-inline-start: 8%; animation: floatShape 11s ease-in-out infinite }
.shape.sh2 { width: 70px; height: 70px; border-radius: 18px; top: 65%; inset-inline-start: 15%; border-color: #7E9BE0; animation: floatShape 14s ease-in-out infinite reverse }
.shape.sh3 { width: 180px; height: 180px; border-radius: 50%; bottom: -40px; inset-inline-end: 12%; border-color: #7E9BE0; animation: floatShape 17s ease-in-out infinite }
.shape.sh4 { width: 46px; height: 46px; border-radius: 10px; top: 20%; inset-inline-end: 20%; animation: spinFloat 20s linear infinite }
.shape.sh5 { width: 90px; height: 90px; border-radius: 50%; top: 44%; inset-inline-start: 45%; opacity: .08; background: var(--gold-light); border: none; animation: floatShape 13s ease-in-out infinite }
.shape.sh6 { width: 26px; height: 26px; border-radius: 6px; bottom: 18%; inset-inline-start: 30%; border-color: #fff; animation: spinFloat 16s linear infinite reverse }

@keyframes floatShape {
  0%, 100% { transform: translateY(0) translateX(0) }
  50% { transform: translateY(-28px) translateX(14px) }
}

@keyframes spinFloat {
  0% { transform: rotate(0deg) translateY(0) }
  50% { transform: rotate(180deg) translateY(-20px) }
  100% { transform: rotate(360deg) translateY(0) }
}

/* بطاقة الدخول: 3D tilt (تُدار من JS) */
.login-panel {
  transform-style: preserve-3d;
  transition: transform .18s ease-out;
  will-change: transform
}

/* الشعار: حركة float خفيفة */
.login-logo {
  animation: logoFloat 4.5s ease-in-out infinite
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0) }
  50% { transform: translateY(-7px) }
}

/* أنيميشن دخول متتابع لعناصر الفورم */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(18px) }
  to { opacity: 1; transform: none }
}

.login-panel>* { animation: fadeInUp .55s both }
.login-panel>*:nth-child(1) { animation-delay: .06s }
.login-panel>*:nth-child(2) { animation-delay: .14s }
.login-panel>*:nth-child(3) { animation-delay: .22s }
.login-panel>*:nth-child(4) { animation-delay: .30s }
.login-panel>*:nth-child(5) { animation-delay: .38s }
.login-panel>*:nth-child(6) { animation-delay: .46s }
.login-panel>*:nth-child(7) { animation-delay: .54s }
.login-panel>*:nth-child(8) { animation-delay: .62s }

/* زر الدخول: glow عند التمرير + ripple عند الضغط */
#l-btn {
  position: relative;
  overflow: hidden
}

#l-btn:hover {
  box-shadow: 0 0 0 3px rgba(201, 162, 39, .25), 0 10px 30px -8px rgba(43, 79, 163, .85)
}

.ripple-ink {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .45);
  transform: scale(0);
  animation: rippleAnim .6s ease-out forwards;
  pointer-events: none
}

@keyframes rippleAnim {
  to { transform: scale(1); opacity: 0 }
}

@media(max-width:960px) {
  .login-panel {
    transform: none !important
  }
}

/* ---------- شريط أدوات التحرير في المعاينة ---------- */
.preview-toolbar {
  flex-wrap: wrap
}

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

.pv-tools .btn-ghost {
  color: #fff;
  background: rgba(255, 255, 255, .12)
}

.pv-tools .btn-ghost:hover {
  background: rgba(255, 255, 255, .24)
}

/* ---------- حاوية المستند في المعاينة ---------- */
#pv-doc {
  position: relative;
  width: max-content;
  margin: 0 auto
}

/* ---------- الأختام والتواقيع على المستند ---------- */
.pv-mark {
  position: absolute;
  z-index: 5;
  cursor: move;
  user-select: none
}

.pv-mark img {
  width: 100%;
  display: block;
  pointer-events: none
}

#pv-doc .pv-mark:hover {
  outline: 1.5px dashed var(--navy-500);
  outline-offset: 3px
}

.pv-mark-ctrl {
  position: absolute;
  top: -32px;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 4px;
  background: var(--navy-900);
  border-radius: 8px;
  padding: 3px 5px;
  box-shadow: 0 4px 12px rgba(8, 23, 53, .4)
}

[dir=rtl] .pv-mark-ctrl {
  transform: translateX(50%)
}

.pv-mark:hover .pv-mark-ctrl {
  display: flex
}

.pv-mark-ctrl button {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  font-weight: 900;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center
}

.pv-mark-ctrl button:hover {
  background: rgba(255, 255, 255, .32)
}

.pv-mark-ctrl button.del {
  background: var(--danger)
}

#print-area .pv-mark {
  cursor: default
}

#print-area .pv-mark-ctrl {
  display: none !important
}

/* ---------- مودال الأختام والتواقيع ---------- */
.stamp-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px
}

.stamp-item {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: .15s;
  position: relative;
  background: #fff
}

.stamp-item:hover {
  border-color: var(--navy-500);
  background: var(--navy-50);
  transform: translateY(-2px)
}

.stamp-item img {
  height: 64px;
  max-width: 100%;
  object-fit: contain
}

.stamp-item span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--navy-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.stamp-item .act {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 26px;
  height: 26px
}

.stamp-upload {
  border-top: 1px dashed var(--line);
  padding-top: 16px
}
