@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --navy: #213a87;
  --navy-d: #172a66;
  --navy-l: #e8ecf7;
  --red: #e0000f;
  --green: #4f9a2a;
  --green-l: #e9f5e1;
  --amber: #b26b00;
  --amber-l: #fff4e0;
  --red-l: #fdeaea;
  --blue-l: #e7f0fd;
  --text: #1d2433;
  --muted: #6b7385;
  --line: #dfe3eb;
  --bg: #f4f6fa;
  --card: #fff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .4rem; line-height: 1.5; }
h2 { font-size: 1.12rem; margin: 0 0 .8rem; line-height: 1.6; }
h3 { font-size: 1rem; margin: 0 0 .6rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
input, select, textarea, button { font: inherit; color: inherit; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 22px; padding-bottom: 48px; min-height: calc(100vh - 160px); }
.narrow { max-width: 560px; margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.danger { color: var(--red) !important; }

/* ---------- top bar */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.topbar-in { display: flex; align-items: center; gap: 18px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand img { width: 38px; height: 38px; background: #fff; border-radius: 50%; padding: 2px; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { color: #d7def5; padding: 6px 10px; border-radius: 8px; font-size: .92rem; }
.nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }
.nav a.active { background: #fff; color: var(--navy); }
.me { display: flex; align-items: center; gap: 10px; font-size: .9rem; margin-inline-start: auto; }
.me a { color: #fff; }
.me .badge { background: rgba(255,255,255,.15); color: #fff; }
.me .link { color: #ffd2d4; }
.topbar > .wrap > .btn { margin-inline-start: auto; background: #fff; color: var(--navy); }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; }

/* ---------- footer */
.footer { border-top: 1px solid var(--line); background: #fff; padding: 18px 0; font-size: .85rem; text-align: center; }

/* ---------- cards & layout */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; border: 1px solid #edf0f5; }
.card.empty, .empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.table-card { padding: 16px 0 8px; }
.table-card > h2, .table-card > .muted, .table-card > .alert, .table-card > .empty { margin-inline: 16px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.back { font-size: .88rem; display: inline-block; margin-bottom: 4px; }
.status-box { text-align: left; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.split-side .sticky { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--navy); color: #fff; border: 1px solid var(--navy);
  border-radius: 9px; padding: 8px 18px; cursor: pointer; font-weight: 600; font-size: .93rem;
  transition: background .15s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { background: var(--navy-d); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 4px 12px; font-size: .85rem; }
.btn-lg { padding: 11px 28px; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn-ghost { background: #fff; color: var(--navy); border-color: #c9d2ea; }
.btn-ghost:hover { background: var(--navy-l); }
.btn-green { background: var(--green); border-color: var(--green); }
.btn-green:hover { background: #3f7d20; }
.btn-amber { background: var(--amber); border-color: var(--amber); }
.link { background: none; border: 0; padding: 0; color: var(--navy); cursor: pointer; font-size: inherit; }
.link:hover { text-decoration: underline; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 6px; width: 28px; height: 28px; cursor: pointer; color: var(--muted); font-size: 1.15rem; line-height: 1; }
.icon-btn:hover { background: var(--red-l); color: var(--red); }

/* ---------- badges & alerts */
.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #eef0f4; color: #4b5263; white-space: nowrap; }
.badge.blue { background: var(--blue-l); color: #1e55b3; }
.badge.green { background: var(--green-l); color: #3a7a1c; }
.badge.red { background: var(--red-l); color: #b0000b; }
.badge.amber { background: var(--amber-l); color: var(--amber); }
.badge.gray { background: #eef0f4; color: #5b6272; }
.alert { padding: 11px 16px; border-radius: 10px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: var(--green-l); border-color: #cde7bd; color: #2f6416; }
.alert-error { background: var(--red-l); border-color: #f6c9cb; color: #9c0009; }
.alert-warning { background: var(--amber-l); border-color: #f5ddb0; color: #7a4a00; }
.alert-info { background: var(--blue-l); border-color: #cddcf7; color: #1b3f86; }

/* ---------- forms */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-weight: 600; margin-bottom: 5px; font-size: .93rem; }
.req { color: var(--red); }
input[type=text], input[type=tel], input[type=email], input[type=url], input:not([type]), select, textarea {
  width: 100%; border: 1px solid #cfd6e3; border-radius: 9px; padding: 8px 12px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(33, 58, 135, .12); }
input:disabled { background: #f2f4f8; }
textarea { resize: vertical; min-height: 44px; line-height: 1.8; }
.help { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.err { font-size: .84rem; color: var(--red); margin-top: 3px; }
.err:empty { display: none; }
.has-error input, .has-error select, .has-error textarea, .has-error .choices, .has-error .uploader { border-color: var(--red) !important; }
.has-error .choices, .has-error .uploader { border: 1px solid; border-radius: 9px; padding: 6px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices.vertical { flex-direction: column; gap: 4px; }
.choice { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; padding: 6px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.choice:hover { border-color: #b8c3dd; }
.choice input { margin-top: 7px; accent-color: var(--navy); flex-shrink: 0; }
.choice:has(input:checked) { border-color: var(--navy); background: var(--navy-l); }
.choice.confirm { border-style: dashed; padding: 12px; }
.axis-options { flex-direction: column; }
.axis-options .choice { width: 100%; }
.axis-problem { margin-top: 8px; padding: 10px 14px; background: var(--navy-l); border-radius: 9px; font-size: .9rem; }
.axis-problem::before { content: "مسئله محوری: "; font-weight: 700; }
.word-count { font-size: .8rem; color: var(--muted); text-align: left; }
.word-count.over { color: var(--red); font-weight: 700; }
.axis-checks { max-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--line); border-radius: 9px; padding: 6px; }
.axis-checks .choice { border: 0; padding: 2px 6px; }

/* ---------- auth */
.auth-card { max-width: 420px; margin: 32px auto; text-align: center; }
.auth-card .field, .auth-card form { text-align: right; }
.auth-logo { width: 72px; height: 72px; margin-bottom: 6px; }
.otp-input { text-align: center; font-size: 1.6rem; letter-spacing: .6em; padding: 10px !important; }
.resend { margin-top: 14px; font-size: .88rem; text-align: center !important; }

/* ---------- home */
.hero { display: flex; gap: 28px; align-items: center; background: linear-gradient(135deg, var(--navy) 0%, #2d4ca6 100%); color: #fff; border-radius: 16px; padding: 32px; margin-bottom: 20px; box-shadow: var(--shadow); }
.hero img { width: 140px; height: 140px; flex-shrink: 0; background: #fff; border-radius: 50%; padding: 4px; }
.hero h1 { font-size: 1.55rem; }
.hero-intro { color: #dfe6fb; margin: 8px 0 12px; }
.hero-meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: .92rem; color: #dfe6fb; }
.hero-actions { margin-top: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hero .btn { background: #fff; color: var(--navy); border-color: #fff; }
.hero .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; counter-reset: st; }
.steps li { counter-increment: st; background: var(--bg); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; font-size: .88rem; }
.steps li::before { content: counter(st, persian); width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; margin-bottom: 6px; font-weight: 700; }
.steps li span { color: var(--muted); }
.axes-list { display: flex; flex-direction: column; gap: 8px; }
.axis-item { border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; }
.axis-item summary, .axis-edit summary { cursor: pointer; font-weight: 600; }
.axis-item ul { margin: 6px 0; padding-inline-start: 22px; font-size: .9rem; }
.axis-q { color: var(--muted); font-size: .9rem; margin: 8px 0 4px; }
.axis-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--navy-l); color: var(--navy); font-size: .82rem; margin-inline-end: 6px; }

/* ---------- applicant */
.proposal-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.proposal h2 { margin: 0; }
.stage-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); margin-top: 10px; }
.stage-row .badge { margin-inline: 6px; }
.delete-draft { margin-top: 8px; text-align: left; }
.stage1-box summary { cursor: pointer; font-weight: 700; color: var(--navy); }
.stage1-box[open] summary { margin-bottom: 12px; }

/* wizard */
.wizard-steps { list-style: none; margin: 0 0 16px; padding: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.wizard-steps button { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px 4px 6px; cursor: pointer; white-space: nowrap; font-size: .88rem; color: var(--muted); }
.wizard-steps .num { width: 24px; height: 24px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.wizard-steps button.active { border-color: var(--navy); color: var(--navy); font-weight: 700; }
.wizard-steps button.active .num { background: var(--navy); color: #fff; }
.wizard-steps button.has-error { border-color: var(--red); color: var(--red); }
.wizard-steps button.has-error .num { background: var(--red); color: #fff; }
.wizard-steps button.locked { opacity: .55; }
.wizard-panel { display: none; }
.wizard-panel.active { display: block; }
.wizard-nav { display: flex; align-items: center; gap: 12px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.wizard-nav .save-state { flex: 1; text-align: center; font-size: .82rem; color: var(--muted); }
.wizard-nav .btn:last-child { margin-inline-start: auto; }

/* table input */
.table-scroll { overflow-x: auto; }
.table-input table { width: 100%; border-collapse: collapse; min-width: 560px; }
.table-input th { background: var(--bg); font-size: .82rem; font-weight: 600; padding: 6px 8px; text-align: right; border: 1px solid var(--line); }
.table-input td { border: 1px solid var(--line); padding: 3px; vertical-align: top; }
.table-input td textarea, .table-input td select { border: 0; border-radius: 4px; padding: 4px 6px; min-height: 34px; }
.table-input td textarea:focus, .table-input td select:focus { box-shadow: inset 0 0 0 2px rgba(33,58,135,.25); }
.table-input .n { width: 34px; text-align: center; color: var(--muted); font-size: .82rem; counter-increment: row; }
.table-input tbody { counter-reset: row; }
.table-input tbody .n::before { content: counter(row, persian); }
.table-input .x { width: 36px; text-align: center; }
.table-input .add-row { margin-top: 8px; }

/* uploader */
.uploader { border: 1px dashed #c3cce0; border-radius: 10px; padding: 10px; background: #fafbfd; }
.uploader.drag { border-color: var(--navy); background: var(--navy-l); }
.file-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list:empty { display: none; }
.file-item { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.file-item img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; display: block; }
.file-ico { width: 52px; height: 52px; border-radius: 6px; background: var(--navy-l); color: var(--navy); display: grid; place-items: center; font-size: .72rem; font-weight: 700; flex-shrink: 0; }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-meta a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta small { color: var(--muted); }
.featured { font-size: .8rem; display: flex; align-items: center; gap: 4px; cursor: pointer; }
.upload-hint { font-size: .78rem; color: var(--muted); margin-top: 6px; }
.progress-item { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: .84rem; margin-bottom: 6px; }
.progress-bar { height: 6px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s; }
.progress-item.failed { border-color: var(--red); color: var(--red); }

/* read-only view */
.ro-section + .ro-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.ro-section h3 { color: var(--navy); }
.ro { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.ro-row { padding: 7px 0; border-bottom: 1px dotted var(--line); }
.ro-row.wide { grid-column: 1 / -1; }
.ro dt { font-size: .82rem; color: var(--muted); font-weight: 600; }
.ro dd { margin: 0; word-break: break-word; }
.ro-table { width: 100%; border-collapse: collapse; font-size: .88rem; margin-top: 4px; }
.ro-table th, .ro-table td { border: 1px solid var(--line); padding: 5px 8px; text-align: right; vertical-align: top; }
.ro-table th { background: var(--bg); font-weight: 600; }
.file-list.ro .file-item { max-width: 520px; }

/* lists */
table.list { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.list th { text-align: right; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 9px 12px; border-bottom: 1px solid #f0f2f6; vertical-align: top; }
table.list tr:hover td { background: #fafbfe; }
table.list tr.todo td:first-child { box-shadow: inset -3px 0 0 var(--amber); }
table.list tr.inactive td { opacity: .5; }
table.list tr.sub td { background: #fafbfd; font-size: .85rem; padding-top: 4px; }
.score { color: var(--navy); font-size: 1.05rem; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 16px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--navy); border-color: var(--navy); font-weight: 700; }
.tabs a:hover { text-decoration: none; color: var(--navy); }
.tabs.inline { border: 0; margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px; }
.filters select, .filters input { width: auto; flex: 1 1 160px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-top: 3px solid #cfd6e3; display: flex; flex-direction: column; }
.stat span { font-size: .82rem; color: var(--muted); }
.stat b { font-size: 1.5rem; }
.stat.blue { border-color: #4a7bd6; } .stat.green { border-color: var(--green); } .stat.red { border-color: var(--red); } .stat.amber { border-color: #e2a23b; }

/* judge scoring */
.criterion { margin-bottom: 12px; }
.criterion label { font-weight: 600; font-size: .9rem; }
.score-input { max-width: 110px; text-align: center; font-weight: 700; }
.score-input.bad { border-color: var(--red); }
.score-total { background: var(--navy-l); border-radius: 9px; padding: 8px 12px; margin: 8px 0 14px; text-align: center; }
.score-total b { font-size: 1.3rem; color: var(--navy); }
.conflict { margin-top: 14px; font-size: .88rem; }
.conflict summary { cursor: pointer; color: var(--muted); }
.conflict form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.big-code { font-size: 3rem; font-weight: 800; color: var(--navy); }
.tpl { border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; margin-bottom: 8px; }
.tpl summary { cursor: pointer; font-weight: 600; }
.tpl[open] summary { margin-bottom: 10px; }
.sticky-bottom { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 16px 0 8px; }
.crit-table td { padding: 4px 6px; }
.crit-max { text-align: center; }

/* ---------- responsive */
@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
  .split-side .sticky { position: static; max-height: none; }
  .steps { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .nav-toggle { display: block; margin-inline-start: auto; }
  .nav, .me { display: none; width: 100%; }
  .nav-open .nav { display: flex; flex-direction: column; padding-bottom: 8px; }
  .nav-open .me { display: flex; padding-bottom: 12px; }
  .hero { flex-direction: column; text-align: center; padding: 24px 18px; }
  .hero img { width: 96px; height: 96px; }
  .hero-meta, .hero-actions { justify-content: center; }
  .steps { grid-template-columns: 1fr; }
  .ro, .grid2 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .cards { grid-template-columns: 1fr; }
  .wizard-steps .t { display: none; }
  .wizard-steps button.active .t { display: inline; }
  .status-box { align-items: flex-start; text-align: right; }
  table.list thead { display: none; }
  table.list tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 4px; }
  table.list td { display: flex; justify-content: space-between; gap: 10px; border: 0; padding: 3px 12px; }
  table.list td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .8rem; }
}
