* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Tahoma", "Segoe UI", Arial, sans-serif;
  background: #f1f5f9; color: #0f172a; direction: rtl;
}
.hidden { display: none !important; }
.grow { flex: 1; }
.muted { color: #64748b; font-size: 12px; }
a { color: #2563eb; }

.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #0f172a;
}
.login-card {
  background: #fff; border-radius: 14px; padding: 34px 40px; width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.brand-name { font-weight: bold; color: #1e293b; }
.login-card .brand-name { font-size: 18px; display: block; text-align: center; }
.login-card .brand-sub { text-align: center; color: #64748b; font-size: 12px; margin: 6px 0 20px; }
.login-card label { display: block; margin: 12px 0 4px; font-size: 13px; color: #334155; }
.login-card input {
  width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px;
}
.design-rights { text-align: center; color: #94a3b8; font-size: 11px; margin-top: 22px; }

.alert {
  background: #fee2e2; color: #991b1b; border: 1px solid #fecaca;
  padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px;
}

.btn {
  background: #e2e8f0; border: 1px solid #cbd5e1; border-radius: 8px;
  padding: 8px 16px; font-size: 13px; cursor: pointer; color: #0f172a;
}
.btn:hover { background: #cbd5e1; }
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 18px; padding: 11px; font-size: 15px; }

.topbar {
  display: flex; align-items: center; gap: 18px; padding: 10px 20px;
  background: #0f172a; color: #fff; flex-wrap: wrap;
}
.topbar .brand-sub { color: #94a3b8; font-size: 12px; margin-right: 8px; }
.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent; border: none; color: #cbd5e1; font-size: 14px;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.tab:hover { color: #fff; }
.tab.active { background: #2563eb; color: #fff; }
.user-box { margin-right: auto; display: flex; align-items: center; gap: 10px; color: #cbd5e1; font-size: 13px; }

main { padding: 16px 20px; max-width: 1300px; margin: 0 auto; }

.upload-box {
  border: 2px dashed #94a3b8; border-radius: 14px; background: #fff;
  padding: 60px 20px; text-align: center; cursor: pointer; margin: 20px auto; max-width: 640px;
}
.upload-box:hover { border-color: #2563eb; background: #eff6ff; }
.upload-title { font-size: 17px; color: #334155; }
.upload-hint { color: #94a3b8; font-size: 12px; margin-top: 6px; }

.studio-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.doc-title { font-weight: bold; color: #1e293b; }

.gallery-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; background: #fff; border-radius: 10px; padding: 8px 12px; }
.gallery-title { font-size: 13px; font-weight: bold; color: #334155; min-width: 90px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.thumb {
  width: 52px; height: 52px; object-fit: contain; background: #f1f5f9;
  border: 2px solid #e2e8f0; border-radius: 8px; cursor: pointer; padding: 2px;
}
.thumb.active { border-color: #2563eb; background: #eff6ff; }

.tools-row { display: flex; gap: 6px; align-items: center; background: #fff; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; flex-wrap: wrap; font-size: 13px; }
.tool-btn { border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 13px; }
.tool-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }

.pages { background: #64748b33; border-radius: 12px; padding: 14px; min-height: 300px; }
.page-wrap { background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.15); border-radius: 6px; margin: 0 auto 18px; position: relative; width: fit-content; }
.page-label { position: absolute; top: 6px; right: 6px; background: #0f172acc; color: #fff; font-size: 11px; border-radius: 6px; padding: 2px 8px; z-index: 5; }
.page-wrap canvas { display: block; cursor: default; }
.overlay {
  position: absolute; cursor: move; user-select: none; z-index: 4;
  border: 2px dashed transparent;
}
.overlay.selected { border-color: #2563eb; }
.overlay:hover { border-color: #60a5fa; }

.studio-footer { display: flex; gap: 8px; align-items: center; padding: 10px 4px 0; }

.panel { background: #fff; border-radius: 12px; padding: 18px; }
.panel h3 { margin-bottom: 14px; color: #1e293b; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { background: #f1f5f9; padding: 8px 10px; text-align: right; color: #475569; }
.table td { padding: 8px 10px; border-bottom: 1px solid #e2e8f0; }
.inline-form { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; }
.inline-form input, .inline-form select { padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 8px; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: bold; }
.badge.unsigned { background: #e2e8f0; color: #475569; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.signed { background: #dcfce7; color: #166534; }

.panel-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.panel-head h3 { margin-bottom: 0; }
.filter-row { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
.filter-row input[type="search"] {
  padding: 7px 12px; border: 1px solid #cbd5e1; border-radius: 8px; width: 260px; font-size: 13px;
}
.filter-row select {
  padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 13px;
}
.sigpad {
  border: 2px dashed #94a3b8; border-radius: 10px; background: #fff;
  display: block; margin: 8px auto 14px; cursor: crosshair; touch-action: none;
  max-width: 100%;
}
.field-row.center { justify-content: center; align-items: center; margin-bottom: 12px; }
.field-row.center input[type="file"] { font-size: 12px; }
#verify-result { margin-top: 10px; }
.settings-form { max-width: 620px; }
.settings-form label { display: block; margin-bottom: 12px; font-size: 13px; color: #334155; }
.settings-form .field input, .settings-form .field select {
  display: block; width: 100%; margin-top: 4px; padding: 8px 12px;
  border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px;
}
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }
.field-row.btns { justify-content: flex-start; margin-top: 6px; }

.modal {
  position: fixed; inset: 0; background: #0f172a99; display: flex;
  align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: #fff; border-radius: 14px; padding: 28px 32px; width: 420px;
  max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.4); text-align: center;
}
.modal-box h3 { margin-bottom: 8px; }
.modal-box p { color: #475569; font-size: 13px; margin-bottom: 14px; }
.otp-inputs { display: flex; gap: 8px; justify-content: center; margin: 14px 0; }
#otp-code {
  font-size: 22px; letter-spacing: 6px; text-align: center; width: 140px;
  padding: 8px; border: 1px solid #cbd5e1; border-radius: 8px;
}
.modal-box .btn { margin: 4px; }