@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/onest-cyrillic-ext.woff2) format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/onest-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/onest-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/onest-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ink: #2e2a85;          /* muhr siyohi */
  --ink-hover: #231f6b;
  --ink-soft: #ebeaf7;
  --desk: #eceaf5;         /* varaq ostidagi yumshoq fon */
  --desk-deep: #dee4ef;
  --desk-line: #d4d8e7;
  --desk-dot: rgba(46, 42, 133, 0.07);
  --paper: #ffffff;
  --ground: #f3f4f6;
  --text: #1c1f25;
  --muted: #5b6370;
  --line: #d6dae0;
  --line-strong: #b9bfc8;
  --warn: #855000;
  --warn-line: #d9a441;
  --error: #b3261e;
  --ok: #1d7448;
  --radius: 8px;
  --bar-h: 60px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 400 16px/1.5 var(--font);
  color: var(--text);
  background: var(--ground);
}

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

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------------------------------------------------------------- bar */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(16px, 3vw, 28px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
}
.brand svg { width: 28px; height: 28px; }

.bar-actions { display: flex; align-items: center; gap: 12px; }

.switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
}
.switch button {
  border: 0;
  background: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  min-width: 72px;
}
.switch button[aria-checked="true"] { background: var(--ink); color: #fff; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--error); border-color: transparent; }
.btn.is-armed { color: var(--error); border-color: var(--error); background: var(--paper); }
.btn-add { border-style: dashed; margin-top: 4px; }
.btn-add::before { content: "+"; font-size: 18px; line-height: 1; }

/* ---------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: minmax(440px, 660px) minmax(0, 1fr);
  min-height: calc(100vh - var(--bar-h));
}

.editor {
  padding: 36px clamp(16px, 3.5vw, 44px) 120px;
  min-width: 0;
}

.viewer {
  position: sticky;
  top: var(--bar-h);
  height: calc(100vh - var(--bar-h));
  overflow: auto;
  background:
    radial-gradient(var(--desk-dot) 1px, transparent 1.3px) 0 0 / 18px 18px,
    linear-gradient(180deg, var(--desk) 0%, var(--desk-deep) 100%);
  border-left: 1px solid var(--line);
  padding: 0 24px 40px;
}

.tabs, .dock { display: none; }

/* ---------------------------------------------------------------- intro */

.intro h1 {
  margin: 0 0 12px;
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
  max-width: 24ch;
}
.intro p { margin: 0 0 10px; max-width: 62ch; color: var(--text); }
.intro .privacy {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--muted);
  font-size: 15px;
}
.intro .privacy::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border-radius: 4px;
  background: var(--ok);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1 2.5 3v4.2c0 3.3 2.3 6.3 5.5 7.3 3.2-1 5.5-4 5.5-7.3V3L8 1Zm-1 9.6L4.6 8.2l1-1L7 8.6l3.4-3.4 1 1L7 10.6Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1 2.5 3v4.2c0 3.3 2.3 6.3 5.5 7.3 3.2-1 5.5-4 5.5-7.3V3L8 1Zm-1 9.6L4.6 8.2l1-1L7 8.6l3.4-3.4 1 1L7 10.6Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.intro-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* ---------------------------------------------------------------- steps */

.step {
  margin: 36px 0 0;
  padding: 28px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  min-width: 0;
}
.step legend, .step h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  float: left;
  width: 100%;
  margin: 0 0 18px;
  padding: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.step legend + * { clear: both; }
.num {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.grid { display: grid; gap: 0 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-date { grid-template-columns: 180px minmax(0, 1fr); }

.field { margin: 0 0 14px; min-width: 0; }
.field label, .field .label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 16px;
}
textarea { min-height: 72px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #9aa1ab; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: 2px solid var(--ink-soft); outline-offset: 0; }
select {
  appearance: none;
  padding-right: 36px;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%232e2a85' stroke-width='1.6'/%3E%3C/svg%3E") right 13px center / 12px 8px no-repeat;
}

.has-error { border-color: var(--error) !important; }
.has-warn { border-color: var(--warn-line) !important; }

.hint { margin: -6px 0 14px; font-size: 13.5px; color: var(--muted); }
.hint.lead { margin: 0 0 16px; font-size: 15px; }
.field .hint { margin: 6px 0 0; }

.msg { margin: 0; font-size: 13.5px; line-height: 1.4; }
.msg:empty { display: none; }
.msg span { display: block; margin-top: 5px; padding-left: 14px; position: relative; }
.msg span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.msg .error { color: var(--error); }
.msg .warn { color: var(--warn); }
.msg .info { color: var(--muted); }

.sub { margin: 4px 0 18px; }
.sub-title { margin: 0 0 8px; font-size: 14px; font-weight: 600; }

/* ---------------------------------------------------------------- repeatable items */

.list { display: grid; gap: 12px; }
.list:empty { display: none; }

.item {
  position: relative;
  padding: 16px 16px 4px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
}
.item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.item-head select { max-width: 260px; font-weight: 600; }
.item-title { font-weight: 600; font-size: 15px; }
.remove {
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.remove:hover { background: #fbe9e7; color: var(--error); }

.g-grad { grid-template-columns: 96px minmax(0, 1fr) 150px; }
.g-work { grid-template-columns: 110px 110px minmax(0, 1fr); align-items: end; }
.g-year { grid-template-columns: 120px minmax(0, 1fr); }

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 15px;
  cursor: pointer;
}
.check-inline input { width: 18px; height: 18px; accent-color: var(--ink); }

.status {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.status label {
  position: relative;
  padding: 8px 14px;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.status label:last-child { border-right: 0; }
.status input { position: absolute; opacity: 0; pointer-events: none; }
.status label:has(input:checked) { background: var(--ink-soft); color: var(--ink); font-weight: 600; }
.status label:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: -2px; }

/* ---------------------------------------------------------------- photo */

.photo { display: flex; gap: 20px; align-items: flex-start; }
.photo-frame {
  position: relative;
  flex: none;
  width: 132px;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  overflow: hidden;
  background: repeating-linear-gradient(135deg, #f7f7f9 0 8px, #eff0f3 8px 16px);
  border: 1px solid var(--line-strong);
}
.photo-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
.photo-frame canvas:active { cursor: grabbing; }
.photo-frame .photo-empty {
  position: absolute;
  margin: 0;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.photo-empty svg { width: 34px; height: 34px; }
.has-photo .photo-empty { display: none; }
.photo-side { min-width: 0; flex: 1; }
.photo-side .hint { margin: 0 0 10px; }
.photo-zoom { margin-bottom: 10px; }
.photo-zoom label { font-size: 13.5px; font-weight: 500; color: var(--muted); }
.photo-zoom input { width: 100%; max-width: 260px; accent-color: var(--ink); }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- check */

.check h2 { float: none; }
.check-summary { margin: 0 0 14px; font-weight: 600; }
.check-summary .ok { color: var(--ok); }
.check-summary .error { color: var(--error); }
.check-summary .warn { color: var(--warn); }

.rules { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 2px; }
.rules li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 4px 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.rules li:last-child { border-bottom: 0; }
.rules .mark {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.rules .auto .mark, .rules .ok .mark { background: var(--ok); }
.rules .warn .mark { background: var(--warn-line); }
.rules .error .mark { background: var(--error); }
.rules .manual .mark { background: none; border: 1.5px solid var(--line-strong); color: var(--muted); }
.rules small { display: block; color: var(--muted); font-size: 13.5px; margin-top: 2px; }

.downloads { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.btn-big { flex-direction: column; align-items: flex-start; gap: 2px; min-height: 64px; padding: 12px 18px; text-align: left; }
.btn-big span { font-size: 16px; }
.btn-big small { font-weight: 400; font-size: 13px; opacity: 0.82; word-break: break-word; }

/* ---------------------------------------------------------------- viewer */

.viewer-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -24px 8px;
  padding: 12px 24px;
  background: rgba(236, 234, 245, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--desk-line);
}
.viewer-file {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-file b { color: var(--text); font-weight: 600; }

.sheets { width: 210mm; margin: 0 auto; transition: opacity 0.15s ease; }
.sheets.is-switching { opacity: 0.35; }

/* Varaq — Word hujjatining aynan o‘zi: A4, chegaralar 1,5 / 1 / 1 / 2 sm, Times New Roman 11 */
.sheet {
  position: relative;
  width: 210mm;
  min-height: 297mm;
  margin: 16px 0 24px;
  padding: 15mm 10mm 10mm 20mm;
  background: #fff;
  color: #000;
  font-family: "Times New Roman", Times, "Liberation Serif", serif;
  font-size: 11pt;
  line-height: 1.15;
  box-shadow: 0 1px 2px rgba(31, 35, 72, 0.12), 0 12px 32px rgba(31, 35, 72, 0.14);
  overflow-wrap: anywhere;
}
.sheet :where(p) { margin: 0; }
.sheet :where(b) { font-weight: 700; }
.s-title, .s-name { font-size: 14pt; font-weight: 700; text-align: center; padding-right: 60.2pt; }
.s-anchor { position: relative; height: 16.1pt; }
.s-photo { position: absolute; left: 406.75pt; top: 18.1pt; width: 85.05pt; height: 113.4pt; object-fit: cover; display: block; }
.s-photo-empty {
  display: grid;
  place-items: center;
  border: 1px dashed #9aa3ad;
  color: #8a939e;
  font: 600 10pt var(--font);
}
.s-gap { height: 12.65pt; }
.s-current { margin-top: 6pt; padding-right: 108pt; }
.s-row { display: grid; grid-template-columns: 216pt minmax(0, 1fr); }
.s-row .s-cell { padding-top: 6pt; }
.s-row.s-inline .s-cell { padding-top: 12.65pt; }
.s-row.s-beside .s-cell:last-child { padding-right: 108pt; }
.s-full { margin-top: 6pt; }
.s-head { font-size: 14pt; font-weight: 700; text-align: center; }
.s-work { margin-top: 4pt; padding-left: 74.2pt; text-indent: -74.2pt; }
.s-table { width: 100%; margin-top: 5pt; border-collapse: collapse; table-layout: fixed; }
.s-table th, .s-table td {
  border: 0.5pt solid #000;
  padding: 0 5.4pt;
  text-align: center;
  vertical-align: middle;
  font-weight: 400;
}
.s-table thead th, .s-table tbody th { font-weight: 700; }
.s-table tbody th { padding: 0; }
.s-table .s-empty { height: 40pt; }

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 10px;
  background: #1c1f25;
  color: #fff;
  font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, 140%);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
}
.toast.is-on { transform: translate(-50%, 0); opacity: 1; }

/* ---------------------------------------------------------------- narrow screens */

@media (max-width: 1099px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .editor { max-width: 720px; margin: 0 auto; width: 100%; padding-top: 24px; }
  .tabs {
    display: flex;
    position: sticky;
    top: var(--bar-h);
    z-index: 15;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
  }
  .tabs button {
    flex: 1;
    padding: 12px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
  }
  .tabs button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }
  body[data-view="form"] .viewer { display: none; }
  body[data-view="preview"] .editor { display: none; }
  .viewer { position: static; height: auto; overflow: visible; min-height: calc(100vh - var(--bar-h) - 48px); padding: 0 12px 110px; }
  .viewer { border-left: 0; }
  .viewer-head { top: calc(var(--bar-h) + 47px); margin: 0 -12px 8px; padding: 10px 12px; }
  .bar-download { display: none; }
  .dock {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
  }
  .dock .btn { flex: 1; min-height: 48px; }
  .toast { bottom: 84px; }
}

@media (max-width: 640px) {
  :root { --bar-h: 56px; }
  .brand span { display: none; }
  .switch button { min-width: 0; padding: 6px 12px; }
  .g2, .g3, .g-date, .g-year { grid-template-columns: minmax(0, 1fr); }
  .g-grad { grid-template-columns: 90px minmax(0, 1fr); }
  .g-grad .field:last-child { grid-column: 1 / -1; }
  .g-work { grid-template-columns: 1fr 1fr; }
  .g-work .check-inline { grid-column: 1 / -1; min-height: 32px; }
  .downloads { grid-template-columns: 1fr; }
  .photo { gap: 14px; }
  .photo-frame { width: 108px; }
  .item { padding: 14px 12px 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheets, .toast { transition: none; }
}

/* ---------------------------------------------------------------- print: faqat varaqlar */

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .bar, .tabs, .editor, .viewer-head, .dock, .toast { display: none !important; }
  .layout { display: block; }
  .viewer { display: block !important; position: static; height: auto; overflow: visible; background: none; padding: 0; }
  .sheets { width: auto; zoom: 1 !important; }
  .sheet { margin: 0; box-shadow: none; break-after: page; }
  .sheet:last-child { break-after: auto; }
  .s-photo-empty { visibility: hidden; }
}
