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

:root {
  --ink: #1f2a37;
  --muted: #5b6573;
  --line: #d9dee5;
  --bg: #f6f4ef;
  --card: #ffffff;
  --accent: #1d5c63;
  --accent-ink: #ffffff;
  --accent-soft: #e3efef;
  --warn: #8a5a00;
  --warn-bg: #fff6e0;
  --error: #a3241d;
  --error-bg: #fdecea;
  --ok: #24663a;
  --ok-bg: #e8f5ec;
  --radius: 10px;
  font-size: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.55;
}
html[lang='fa'] body { font-family: 'Vazirmatn', system-ui, sans-serif; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid #f0a500; outline-offset: 2px; }

#app { max-width: 1100px; margin: 0 auto; padding: 0 1rem 2rem; }

header.top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  padding: 1.25rem 0 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem;
}
header.top h1 { margin: 0; font-size: 1.6rem; color: var(--accent); }
header.top p { margin: .2rem 0 0; color: var(--muted); }

.lang-btn {
  border: 1px solid var(--accent); background: var(--card); color: var(--accent);
  border-radius: 999px; padding: .35rem 1rem; cursor: pointer; white-space: nowrap;
}
html[lang='en'] .lang-btn { font-family: 'Vazirmatn', sans-serif; }

.layout { display: grid; grid-template-columns: 240px 1fr; gap: 1.5rem; align-items: start; }

nav.steps ol { list-style: none; margin: 0; padding: 0; position: sticky; top: 1rem; }
nav.steps button {
  width: 100%; text-align: start; background: none; border: 0; padding: .45rem .6rem;
  border-radius: 8px; cursor: pointer; color: var(--muted); display: flex; gap: .6rem; align-items: center;
}
nav.steps button:hover { background: var(--accent-soft); color: var(--ink); }
nav.steps button.current { background: var(--accent); color: var(--accent-ink); }
nav.steps .num {
  display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  border: 1px solid currentColor; font-size: .8rem; flex: none;
}

main { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem 1.75rem; min-width: 0; }

.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; width: 100%; background: var(--accent); transform-origin: left; transition: transform .2s; }
html[dir='rtl'] .progress div { transform-origin: right; }
.progress-text { margin: .3rem 0 0; font-size: .85rem; color: var(--muted); }
.step-title { margin: .5rem 0 1rem; font-size: 1.45rem; }
.sub-heading { margin: 1.5rem 0 .5rem; font-size: 1.1rem; }

.field { margin: 0 0 1.25rem; border: 0; padding: 0; min-width: 0; }
.label-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.label { font-weight: 600; }
.req { color: var(--error); }

input[type='text'], input[type='number'], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid #b9c1cc; border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

.field.check label, .radio-opt { display: flex; gap: .55rem; align-items: center; cursor: pointer; }
.field.check input, .radio-opt input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); flex: none; }
.radio-opt { padding: .3rem 0; }

.help-btn {
  flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 1px solid var(--accent);
  background: var(--card); color: var(--accent); font-weight: 700; font-size: .85rem; line-height: 1;
  cursor: pointer; display: inline-grid; place-items: center; padding: 0;
}
.help-btn[aria-expanded='true'] { background: var(--accent); color: var(--accent-ink); }
.help-panel {
  background: var(--accent-soft); border: 1px solid #bcd6d6; border-radius: 8px;
  padding: .7rem .9rem; margin: .2rem 0 .6rem; font-size: .95rem;
}

.field.list .row { display: flex; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.field.list .row.head { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.field.list .cell { flex: 1 1 0; min-width: 0; }
.field.list .cell.narrow { flex: 0 0 11rem; }
.field.list .cell.tiny { flex: 0 0 5.5rem; }
.field.list .cell.actions { flex: 0 0 5rem; display: flex; gap: .25rem; justify-content: flex-end; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; width: 2.1rem; height: 2.1rem; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { color: var(--error); border-color: var(--error); }
.add-btn {
  border: 1px dashed var(--accent); background: none; color: var(--accent); border-radius: 8px;
  padding: .35rem .9rem; cursor: pointer;
}
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: .3rem 0 1rem; }
.chip {
  border: 1px solid var(--accent); background: var(--card); color: var(--accent);
  border-radius: 999px; padding: .3rem .85rem; cursor: pointer; font-size: .92rem;
}
.chip:hover { background: var(--accent-soft); }
.chip.has { background: var(--accent-soft); font-weight: 600; }
.field.list .cell.asset-type { flex: 0 0 11rem; font-weight: 600; }
.pct { margin-top: .5rem; font-size: .9rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .3rem .9rem; }

.notice { border-radius: 8px; padding: .8rem 1rem; margin-bottom: 1rem; }
.notice p { margin: .3rem 0 0; }
.notice ul { margin: .4rem 0 0; padding-inline-start: 1.2rem; }
.notice.warn { background: var(--warn-bg); color: #4d3600; }
.notice.info { background: var(--accent-soft); }
.notice.error { background: var(--error-bg); color: var(--error); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.link-btn { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0 .3rem; }

.nav-btns { display: flex; justify-content: space-between; margin-top: 2rem; }
button.primary, .nav-btns button, .doc-actions button, .data-tools button, .file-btn {
  border: 1px solid var(--accent); background: #fff; color: var(--accent); border-radius: 8px;
  padding: .55rem 1.2rem; cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.danger { border-color: var(--error); color: var(--error); }

/* Review step: every document to print, one row each. */
.doc-list-wrap { margin: 1.75rem 0 1rem; }
.doc-list-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; }
.doc-list-head h3 { margin: 0; font-size: 1.2rem; }
.doc-progress { font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.doc-intro { margin: .3rem 0 .9rem; color: var(--muted); }
.doc-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.doc-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .4rem 1rem; padding: .9rem 1rem; }
.doc-row + .doc-row { border-top: 1px solid var(--line); }
.doc-row.is-current { background: var(--accent-soft); }
.doc-num {
  display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%;
  border: 2px solid var(--accent); color: var(--accent); font-weight: 700;
}
.doc-row.is-printed .doc-num { background: var(--ok); border-color: var(--ok); color: #fff; }
.doc-info { display: flex; flex-direction: column; min-width: 0; }
.doc-name { font-weight: 600; }
.doc-desc { font-size: .9rem; color: var(--muted); }
.doc-status { font-size: .85rem; font-weight: 600; color: var(--ok); }
.doc-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.doc-actions button { white-space: nowrap; }
button.ghost { background: transparent; }
button.ghost[aria-pressed='true'] { background: var(--card); box-shadow: inset 0 0 0 1px var(--accent); }
.preview-section { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--line); scroll-margin-top: 1rem; }
.preview-section h3 { margin: 0; font-size: 1.1rem; }
.preview-section .checklist { margin-top: 1rem; }
.hint { font-size: .9rem; color: var(--muted); }

.preview-wrap { background: #e9e6df; border-radius: 8px; padding: 1rem; max-height: 70vh; overflow: auto; margin: .75rem 0 1rem; }
.paper { background: #fff; max-width: 8.5in; margin: 0 auto; padding: .8in .9in; box-shadow: 0 1px 6px rgba(0,0,0,.15); }

.checklist, .data-tools { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.checklist ol { padding-inline-start: 1.3rem; }
.checklist li { margin-bottom: .4rem; }
.data-tools { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.data-tools h3 { width: 100%; margin: 0 0 .3rem; }

footer { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 2rem; }

#print-root { display: none; }

@media (max-width: 760px) {
  :root { font-size: 17px; }
  .doc-row { grid-template-columns: auto 1fr; }
  .doc-actions { grid-column: 1 / -1; justify-content: stretch; }
  .doc-actions button { flex: 1 1 auto; }
  .layout { grid-template-columns: 1fr; }
  nav.steps { display: none; }
  main { padding: 1.1rem; }
  .field.list .row { flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: .5rem; }
  .field.list .row.head { display: none; }
  .field.list .cell, .field.list .cell.narrow, .field.list .cell.tiny { flex: 1 1 100%; }
  .field.list .cell.tiny { flex: 1 1 40%; }
  .field.list .cell.asset-type { flex: 1 1 100%; }
  .field.list.assets .cell.tiny { flex: 0 0 4.5rem; }
  .field.list.assets .cell.note { flex: 1 1 0; }
  .field.list.assets .cell.actions { flex: 0 0 auto; }
  .paper { padding: .4in; }
}

@media print {
  #app { display: none; }
  #print-root { display: block; }
  body { background: #fff; }
}
