@font-face { font-family: Cairo; src: url(../assets/fonts/Cairo_400Regular.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: Cairo; src: url(../assets/fonts/Cairo_600SemiBold.ttf); font-weight: 600; font-display: swap; }
@font-face { font-family: Cairo; src: url(../assets/fonts/Cairo_700Bold.ttf); font-weight: 700; font-display: swap; }

:root {
  --maroon: #8A1538; --maroon-d: #6d0f2b; --maroon-l: #f6e9ed;
  --ink: #23262b; --muted: #6b7078; --line: #e5e1dc; --bg: #f4f1ec; --card: #fff;
  --ok: #1f7a4d; --warn: #a15c00; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Cairo, system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; }
[hidden] { display: none !important; }
code { background: var(--maroon-l); color: var(--maroon-d); padding: 0 5px; border-radius: 5px; font-size: 12.5px; }

/* buttons & inputs */
.btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 9px; padding: 7px 14px; cursor: pointer; transition: .15s; }
.btn:hover { border-color: var(--maroon); color: var(--maroon); }
.btn.primary { background: var(--maroon); color: #fff; border-color: var(--maroon); }
.btn.primary:hover { background: var(--maroon-d); color: #fff; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.35); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.12); color: #fff; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.tiny { padding: 2px 9px; font-size: 12.5px; border-radius: 7px; }
.btn.danger-ghost:hover { border-color: #b3261e; color: #b3261e; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.big { display: flex; flex-direction: column; align-items: flex-start; text-align: right; padding: 12px 16px; width: 100%; }
.btn.big small { opacity: .8; font-size: 12.5px; }
input, select, textarea { font: inherit; width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(138,21,56,.18); border-color: var(--maroon); }
textarea { resize: vertical; line-height: 1.7; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
label.split { display: flex; justify-content: space-between; align-items: center; }

/* gate */
.gate { position: fixed; inset: 0; display: grid; grid-template-columns: 1.05fr 1fr; background: #F6F2EC; }
.gate-brand { position: relative; overflow: hidden; color: #fff; background: radial-gradient(120% 90% at 85% 10%, #b3224f 0%, #8A1538 45%, #5e0c25 100%); display: grid; align-content: center; padding: 48px 56px; }
.gate-waves { position: absolute; inset: 0; opacity: .13; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='60' viewBox='0 0 240 60'%3E%3Cpath d='M0 30 Q30 10 60 30 T120 30 T180 30 T240 30' fill='none' stroke='white' stroke-width='2'/%3E%3C/svg%3E"); background-size: 240px 60px; mask-image: linear-gradient(180deg, transparent 0%, #000 55%, #000 100%); -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 55%, #000 100%); }
.gate-brand-in { position: relative; max-width: 440px; }
.gate-icon { width: 88px; height: 88px; border-radius: 22px; box-shadow: 0 18px 40px rgba(0,0,0,.28), 0 0 0 1px rgba(255,255,255,.18); }
.gate-brand h1 { font-size: 46px; margin: 22px 0 2px; line-height: 1.2; }
.gate-brand h1 span { font-size: 20px; font-weight: 400; opacity: .7; margin-right: 6px; }
.tagline { font-size: 17px; opacity: .9; margin: 0 0 28px; }
.feats { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.feats li { display: flex; gap: 12px; align-items: center; font-size: 15px; }
.feats b { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); font-size: 14px; flex: none; }
.gate-school { position: absolute; bottom: 22px; right: 56px; opacity: .7; font-size: 12.5px; }
.gate-form-wrap { display: grid; place-items: center; padding: 32px; }
.gate-form { width: min(380px, 100%); display: grid; gap: 10px; }
.gate-icon-sm { display: none; width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 6px; }
.gate-form h2 { margin: 0; font-size: 26px; color: var(--ink); }
.gate-form .muted { margin: -4px 0 14px; color: var(--muted); }
.gate-form label { margin: 0; }
.field { position: relative; display: flex; align-items: center; }
.field > svg { position: absolute; right: 14px; width: 20px; height: 20px; color: var(--maroon); opacity: .75; pointer-events: none; }
.field input { height: 52px; border-radius: 12px; padding: 0 46px; font-size: 20px; letter-spacing: 4px; text-align: center; background: #fff; border: 1.5px solid #e2dcd5; transition: .15s; }
.field input::placeholder { letter-spacing: 6px; color: #c9c2ba; }
.field input:focus { border-color: var(--maroon); outline: 4px solid rgba(138,21,56,.1); }
.eye { position: absolute; left: 8px; width: 36px; height: 36px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 8px; display: grid; place-items: center; }
.eye:hover { background: var(--maroon-l); color: var(--maroon); }
.eye svg { width: 20px; height: 20px; }
.gate-btn { height: 50px; border-radius: 12px; font-size: 16px; font-weight: 700; margin-top: 6px; display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 8px 20px rgba(138,21,56,.25); }
.gate-btn .spin { display: none; width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.gate-btn.busy .spin { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.gate-form.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
.err { color: #b3261e; min-height: 20px; font-size: 13.5px; text-align: center; }
.gate-foot { color: var(--muted); font-size: 12px; text-align: center; margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.brand-icon { width: 38px; height: 38px; border-radius: 10px; box-shadow: 0 0 0 1px rgba(255,255,255,.3); }
@media (max-width: 860px) {
  .gate { grid-template-columns: 1fr; }
  .gate-brand { display: none; }
  .gate-icon-sm { display: block; }
  .gate-form { text-align: center; }
  .gate-form label { text-align: right; }
}

/* layout */
.app { display: flex; flex-direction: column; height: 100vh; }
.top { background: var(--maroon); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand b { font-size: 19px; }
.brand .en { opacity: .75; font-size: 14px; }
.brand small { display: block; opacity: .8; font-size: 12px; margin-top: -4px; }
.layout { flex: 1; display: grid; grid-template-columns: 430px 1fr; min-height: 0; }
.panel { background: #fff; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; font: inherit; background: none; border: 0; padding: 12px 6px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; }
.tab i { font-style: normal; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--line); color: var(--ink); font-size: 12px; margin-left: 4px; }
.tab.active { color: var(--maroon); border-bottom-color: var(--maroon); }
.tab.active i { background: var(--maroon); color: #fff; }
.pill { background: var(--maroon-l); color: var(--maroon); border-radius: 20px; padding: 0 8px; font-size: 12px; }
.tabpane { display: none; padding: 16px 18px 24px; overflow: auto; flex: 1; }
.tabpane.active { display: block; }
.row { margin-bottom: 12px; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.inline { display: flex; gap: 6px; align-items: center; }
.inline.end { align-items: flex-end; justify-content: flex-start; padding-top: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 12px; }
.chip { font: inherit; font-size: 12px; border: 1px dashed var(--maroon); color: var(--maroon); background: var(--maroon-l); border-radius: 20px; padding: 1px 10px; cursor: pointer; }
.signers { display: grid; gap: 6px; }
.signer { display: grid; grid-template-columns: 74px 1fr 1fr; gap: 6px; align-items: center; }
.signer .pos { font-size: 12px; color: var(--muted); }
.more { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; }
.more summary { cursor: pointer; font-weight: 600; color: var(--maroon); }
.more[open] summary { margin-bottom: 10px; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.8; }

/* names */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; transition: .15s; }
.drop.over { border-color: var(--maroon); background: var(--maroon-l); }
.drop span { color: var(--muted); font-size: 12.5px; }
.list-tools { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.list-tools span { margin-right: auto; color: var(--muted); font-size: 12.5px; }
.table-wrap { border: 1px solid var(--line); border-radius: 10px; max-height: 46vh; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; background: #faf8f5; text-align: right; padding: 7px 8px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }
td { padding: 6px 8px; border-bottom: 1px solid #f1eee9; }
tr.cur td { background: var(--maroon-l); }
tr:hover td { background: #fbf7f8; cursor: pointer; }
td.email { direction: ltr; text-align: left; color: var(--muted); font-size: 12px; }
td.bad { color: #b3261e; }
td input { width: auto; }

/* output */
.modes { display: grid; gap: 8px; margin-bottom: 14px; }
.mode { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; margin: 0; color: var(--ink); font-weight: 400; font-size: 14px; }
.mode input { width: auto; margin-top: 6px; accent-color: var(--maroon); }
.mode small { display: block; color: var(--muted); font-size: 12.5px; }
.mode:has(input:checked) { border-color: var(--maroon); background: var(--maroon-l); }
.card-opts { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px 12px; margin-bottom: 14px; }
.out-btns { display: grid; gap: 8px; }
.progress { margin-top: 14px; }
.progress .bar { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--maroon); transition: width .2s; }
.progress span { font-size: 12.5px; color: var(--muted); }
.out-msg { margin-top: 12px; font-size: 13px; line-height: 1.8; }
.out-msg .ok { color: var(--ok); } .out-msg .warn { color: var(--warn); }

/* stage */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 14px 22px; }
.stage-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; min-height: 30px; }
.nav { display: flex; gap: 8px; align-items: center; }
#who { font-weight: 600; min-width: 160px; text-align: center; }
.warn { color: var(--warn); font-size: 12.5px; }
.sheet-wrap { flex: 1; display: grid; place-items: center; min-height: 0; }
.sheet { width: min(100%, calc((100vh - 170px) * 297 / 210)); aspect-ratio: 297 / 210; background: #fff; box-shadow: 0 10px 40px rgba(60,30,40,.16), 0 1px 3px rgba(0,0,0,.08); border-radius: 3px; overflow: hidden; }
.sheet svg { display: block; width: 100%; height: 100%; }
.stage-note { text-align: center; color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }

/* guide */
.guide { border: 0; border-radius: 16px; padding: 0; width: min(760px, 94vw); max-height: 88vh; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.guide::backdrop { background: rgba(30,10,18,.45); }
.guide-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; background: var(--maroon); color: #fff; position: sticky; top: 0; }
.guide-head h2 { margin: 0; font-size: 18px; }
.guide-body { padding: 8px 24px 24px; line-height: 1.9; font-size: 14px; }
.guide-body h3 { color: var(--maroon); margin: 18px 0 6px; font-size: 16px; }
.guide-body ol { padding-right: 20px; }
.guide-body li { margin-bottom: 6px; }
.guide-body .en { direction: ltr; unicode-bidi: isolate; font-family: system-ui, sans-serif; background: #f3f3f3; padding: 0 5px; border-radius: 4px; font-size: 13px; }
.guide-body .box { background: var(--maroon-l); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.guide-body pre { direction: ltr; text-align: left; background: #1f1f24; color: #f3f3f3; padding: 10px 12px; border-radius: 8px; font-size: 12.5px; overflow: auto; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .panel { border-left: 0; max-height: none; }
  .stage { order: -1; }
  .sheet { width: 100%; }
}

.gate-label { text-align: right; margin: 6px 0 -6px; }
.gate-note { color: var(--muted); font-size: 12px; }
.top-actions { display: flex; gap: 12px; align-items: center; }
.user { display: flex; gap: 8px; align-items: center; font-size: 13px; padding-right: 12px; border-right: 1px solid rgba(255,255,255,.3); }
.steps { display: grid; gap: 10px; margin-bottom: 12px; }
.step { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 4px; justify-items: start; text-align: right; }
.step b i { font-style: normal; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--maroon); color: #fff; font-size: 12px; margin-left: 4px; }
.step span { color: var(--muted); font-size: 12.5px; }
.step .btn { margin-top: 4px; }
.step.drop { margin: 0; border-style: dashed; border-width: 2px; }
