@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("../fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("../fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("../fonts/inter-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Cairo"; font-weight: 400; font-display: swap; src: url("../fonts/cairo-arabic-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Cairo"; font-weight: 700; font-display: swap; src: url("../fonts/cairo-arabic-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Revv Script"; font-weight: 600; font-display: block; src: url("../fonts/dancing-script-latin-600-normal.woff2") format("woff2"); }

:root {
  --midnight: #0B1F1A;
  --emerald: #0F3D2E;
  --deep: #14532D;
  --gold: #C6A75E;
  --champagne: #F5F5F0;
  --ink: #0B1F1A;
  --muted: #5B6B66;
  --line: #DFE3DA;
  --card: #FFFFFF;
  --danger: #9B1C1C;
  --ok: #14532D;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11,31,26,.06), 0 8px 24px rgba(11,31,26,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", "Cairo", system-ui, sans-serif;
  color: var(--ink); background: var(--champagne);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
:lang(ar), [dir="rtl"] { font-family: "Cairo", "Inter", sans-serif; }
h1, h2, h3, .display { font-family: "IBM Plex Sans", "Inter", sans-serif; letter-spacing: -0.01em; margin: 0 0 .4em; }
h1 { font-size: 28px; font-weight: 600; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
a { color: var(--deep); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
.hidden { display: none !important; }

/* top bar */
.topbar {
  background: var(--midnight); color: var(--champagne);
  border-bottom: 3px solid var(--gold);
}
.topbar-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 28px; padding: 12px 24px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--champagne); text-decoration: none; }
.brand-tile { background: var(--champagne); border-radius: 10px; padding: 6px 8px; display: flex; }
.brand-tile img { height: 22px; display: block; }
.brand-name { font-family: "IBM Plex Sans"; font-weight: 700; font-size: 19px; letter-spacing: .01em; }
.brand-name span { color: var(--gold); font-weight: 600; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: #C9D3CE; text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 500; font-size: 14px; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav a.active { color: #fff; box-shadow: inset 0 -2px 0 var(--gold); border-radius: 0; }
.userchip { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #C9D3CE; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--deep); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12px; }
.badge { background: var(--gold); color: var(--midnight); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 4px; }
.linkbtn { background: none; border: 0; color: #C9D3CE; cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }

main { max-width: 1280px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; border: 1px solid transparent;
  padding: 10px 16px; font: 600 14px "Inter"; cursor: pointer; text-decoration: none; transition: background .15s; }
.btn-primary { background: var(--deep); color: #fff; }
.btn-primary:hover { background: var(--emerald); }
.btn-primary:disabled { background: #8FA59A; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--deep); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--deep); }
.btn-gold { background: var(--gold); color: var(--midnight); }
.btn-block { width: 100%; }

label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 6px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: 15px "Inter"; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(198,167,94,.55); border-color: var(--gold); }
.code-input { font: 600 24px "IBM Plex Sans"; letter-spacing: .35em; text-align: center; }

.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.flash.error { background: #FDECEC; color: var(--danger); border: 1px solid #F5C2C2; }
.flash.info { background: #EAF3EE; color: var(--deep); border: 1px solid #C7DDD0; }

.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.pill.sent { background: #FFF6E0; color: #8A6A1F; }
.pill.completed, .pill.signed { background: #E3F1E8; color: var(--deep); }
.pill.draft, .pill.pending { background: #EEF0EC; color: var(--muted); }
.pill.bad { background: #FDECEC; color: var(--danger); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .title { font-weight: 600; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: var(--midnight); color: var(--champagne); padding: 56px; display: flex; flex-direction: column; justify-content: space-between; border-right: 3px solid var(--gold); }
.auth-side .tile { background: var(--champagne); border-radius: 16px; padding: 16px 20px; display: inline-flex; }
.auth-side .tile img { height: 54px; }
.auth-side h1 { font-size: 40px; margin-top: 36px; color: #fff; }
.auth-side p { color: #C9D3CE; max-width: 440px; }
.auth-main { display: grid; place-items: center; padding: 40px; }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* upload */
.drop { border: 2px dashed #C7CFC4; border-radius: var(--radius); background: #fff; padding: 48px; text-align: center; cursor: pointer; }
.drop.over { border-color: var(--gold); background: #FFFBF1; }

/* document workspace */
.workspace { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .workspace { grid-template-columns: 1fr; } }
.pages { display: flex; flex-direction: column; align-items: center; gap: 18px; background: #E9ECE5; border-radius: var(--radius); padding: 20px; min-height: 400px; }
.page-wrap { position: relative; box-shadow: 0 2px 10px rgba(11,31,26,.15); background: #fff; }
.page-wrap canvas { display: block; }
.page-label { position: absolute; left: -2px; top: -20px; font-size: 11px; color: var(--muted); }
.sidepanel { position: sticky; top: 16px; }

.chip { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; cursor: grab; user-select: none; margin-bottom: 8px; }
.chip:active { cursor: grabbing; }
.chip .dot { width: 12px; height: 12px; border-radius: 3px; }
.chip.disabled { opacity: .4; cursor: not-allowed; }
.signer-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.signer-row input { width: 18px; height: 18px; accent-color: var(--deep); }

.box { position: absolute; border: 2px solid; border-radius: 6px; background: rgba(255,255,255,.72); cursor: move; display: flex; flex-direction: column; justify-content: center; padding: 4px 8px; font-size: 12px; }
.box .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box .kind { font-size: 11px; opacity: .8; }
.box .del { position: absolute; top: -10px; right: -10px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--midnight); color: #fff; cursor: pointer; font-size: 13px; line-height: 22px; padding: 0; }
.box select { position: absolute; left: 0; bottom: -30px; width: auto; font-size: 12px; padding: 3px 6px; border-radius: 6px; }
.box.selected { box-shadow: 0 0 0 3px rgba(198,167,94,.5); z-index: 5; }

.sigfield { position: absolute; border: 2px dashed #9AA79F; border-radius: 6px; display: grid; place-items: center; font-size: 12px; color: var(--muted); background: rgba(245,245,240,.6); }
.sigfield.mine { border: 2px solid var(--gold); background: rgba(198,167,94,.14); color: var(--midnight); font-weight: 600; animation: pulse 2s infinite; cursor: pointer; }
.sigfield.signed { display: none; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(198,167,94,.45);} 50% { box-shadow: 0 0 0 7px rgba(198,167,94,0);} }

.tabs { display: flex; gap: 6px; margin: 10px 0; }
.tabs button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px; font: 600 13px "Inter"; cursor: pointer; color: var(--muted); }
.tabs button.on { border-color: var(--deep); color: var(--deep); background: #EAF3EE; }
.sigpad { width: 100%; height: 130px; border: 1px solid var(--line); border-radius: 10px; background: #fff; touch-action: none; display: block; }
.typed-preview { font-family: "Revv Script", cursive; font-size: 40px; color: var(--midnight); height: 70px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding-left: 34px; margin-bottom: 14px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--deep); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }

.timeline { list-style: none; padding: 0; margin: 0; font-size: 13.5px; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); }

.check-ok { color: var(--deep); font-weight: 600; }
.check-bad { color: var(--danger); font-weight: 600; }
.result-banner { border-radius: var(--radius); padding: 16px 18px; display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.result-banner.ok { background: #E3F1E8; border: 1px solid #BBD9C6; }
.result-banner.bad { background: #FDECEC; border: 1px solid #F5C2C2; }
.result-banner .icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; flex: none; }
.result-banner.ok .icon { background: var(--deep); }
.result-banner.bad .icon { background: var(--danger); }

.mailbox { display: grid; grid-template-columns: 360px 1fr; gap: 16px; }
.mailbox .msg { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.mailbox .msg.on { background: #EAF3EE; }
.mailbox iframe { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.devbar { background: #FFF6E0; color: #6B5317; font-size: 12.5px; text-align: center; padding: 4px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }

/* resize handles on all sides */
.box .rs { position: absolute; width: 12px; height: 12px; border-radius: 3px; background: var(--gold); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(11,31,26,.25); }
.box .rs-nw { left: -7px; top: -7px; cursor: nwse-resize; }
.box .rs-n  { left: calc(50% - 6px); top: -7px; cursor: ns-resize; }
.box .rs-ne { right: -7px; top: -7px; cursor: nesw-resize; }
.box .rs-e  { right: -7px; top: calc(50% - 6px); cursor: ew-resize; }
.box .rs-se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.box .rs-s  { left: calc(50% - 6px); bottom: -7px; cursor: ns-resize; }
.box .rs-sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.box .rs-w  { left: -7px; top: calc(50% - 6px); cursor: ew-resize; }
.box .del { top: -12px; right: 14px; }
.box { overflow: visible; }

.inline-label { display: inline; margin: 0; font-weight: 500; }
.linkbtn.dark { color: var(--deep); }
.inline-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* signing password dialog */
.modal-back { position: fixed; inset: 0; background: rgba(11,31,26,.55); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { width: 100%; max-width: 440px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
