@font-face {
  font-family: "B Nazanin";
  src: local("B Nazanin"), url("./assets/fonts/BNazanin.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "B Nazanin";
  src: local("B Nazanin Bold"), url("./assets/fonts/BNazanin-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --navy: #073f68;
  --navy-dark: #063554;
  --blue-soft: #eaf4ff;
  --blue-pale: #f5f9fd;
  --ink: #15202b;
  --muted: #657586;
  --line: #b8c8d7;
  --surface: #ffffff;
  --canvas: #edf2f7;
  --danger: #a82d3b;
  --focus: #1f78b4;
  --shadow: 0 22px 60px rgba(24, 52, 74, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 10%, rgba(68, 143, 193, 0.09), transparent 24rem),
    var(--canvas);
  font-family: "B Nazanin", Tahoma, serif;
  font-size: 18px;
  line-height: 1.35;
}

button,
input {
  font: inherit;
}

button,
label,
summary,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
  display: grid;
  grid-template-columns: minmax(320px, 370px) minmax(700px, 1fr);
  gap: 22px;
  align-items: start;
}

.editor-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 23px;
  border: 1px solid rgba(120, 143, 162, 0.25);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 15px 45px rgba(36, 66, 88, 0.11);
  scrollbar-width: thin;
}

.editor-heading {
  padding: 2px 3px 18px;
}

.editor-heading .eyebrow {
  display: block;
  margin-bottom: 2px;
  color: var(--focus);
  font-size: 15px;
  font-weight: 700;
}

.editor-heading h1 {
  margin: 0;
  color: var(--navy-dark);
  font-size: 31px;
  line-height: 1.15;
}

.editor-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.form-section {
  margin-top: 13px;
  padding: 17px;
  border: 1px solid #dde6ee;
  border-radius: 16px;
  background: #fff;
}

.emphasis-section {
  border-color: #bfd8eb;
  background: linear-gradient(145deg, #f7fbff, #fff 55%);
}

.form-section h2 {
  margin: 0 0 13px;
  color: var(--navy-dark);
  font-size: 19px;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 13px;
}

.section-title-row h2 {
  margin: 0;
}

.month-chip {
  padding: 3px 10px;
  border: 1px solid #bdd6e8;
  border-radius: 999px;
  color: var(--navy);
  background: #eef7ff;
  font-size: 14px;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-grid.two-columns {
  margin-top: 13px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  color: #344656;
  font-size: 15px;
  font-weight: 700;
}

.field-wide {
  grid-column: 1 / -1;
}

.field input {
  width: 100%;
  min-height: 43px;
  padding: 8px 11px;
  border: 1px solid #c8d5df;
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(31, 120, 180, 0.12);
}

.net-field > span:first-child {
  color: var(--navy-dark);
  font-size: 17px;
}

.input-with-unit {
  display: grid;
  grid-template-columns: 1fr auto;
  overflow: hidden;
  border: 1px solid #a8c8df;
  border-radius: 12px;
  background: #fff;
}

.input-with-unit:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(31, 120, 180, 0.12);
}

.input-with-unit input {
  min-width: 0;
  min-height: 50px;
  padding: 8px 13px;
  border: 0;
  outline: 0;
  color: var(--navy-dark);
  background: transparent;
  direction: ltr;
  text-align: right;
  font-size: 23px;
  font-weight: 700;
}

.input-with-unit b {
  display: grid;
  min-width: 53px;
  place-items: center;
  padding: 0 12px;
  color: #fff;
  background: var(--navy);
  font-size: 15px;
}

.field-help,
.field-error,
.section-note,
.local-note {
  margin: 7px 0 0;
  font-size: 14px;
  font-weight: 400;
}

.field-help,
.section-note,
.local-note {
  color: var(--muted);
}

.field-error {
  min-height: 0;
  color: var(--danger);
}

.asset-controls {
  display: grid;
  gap: 10px;
  margin-top: 13px;
}

.asset-control {
  padding: 11px;
  border: 1px solid #e0e8ef;
  border-radius: 12px;
  background: var(--blue-pale);
}

.asset-control-head,
.range-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.file-button,
.text-button {
  border: 0;
  color: var(--navy);
  background: transparent;
  font-weight: 700;
}

.file-button {
  cursor: pointer;
}

.file-button:hover,
.text-button:hover {
  color: var(--focus);
}

.text-button {
  padding: 2px 4px;
  font-size: 14px;
}

.range-field {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

.range-field input {
  width: 55%;
  accent-color: var(--navy);
}

.formula-details {
  margin-top: 13px;
  overflow: hidden;
  border: 1px solid #dce5ec;
  border-radius: 14px;
  background: #fff;
  color: #3d4f5d;
  font-size: 15px;
}

.formula-details summary {
  padding: 13px 15px;
  color: var(--navy-dark);
  cursor: pointer;
  font-weight: 700;
}

.formula-details > div {
  padding: 0 15px 14px;
}

.formula-details p {
  margin: 6px 0;
}

.formula-details code {
  display: block;
  margin: 8px 0;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--navy-dark);
  background: #eef6fb;
  direction: rtl;
  font-family: "B Nazanin", Tahoma, serif;
}

.editor-actions {
  display: grid;
  grid-template-columns: 1fr 0.78fr;
  gap: 9px;
  margin-top: 15px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  padding: 8px 12px;
  border-radius: 11px;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--navy);
  color: #fff;
  background: var(--navy);
  box-shadow: 0 8px 18px rgba(7, 63, 104, 0.18);
}

.primary-button:hover {
  background: #095483;
}

.secondary-button {
  border: 1px solid #c7d4de;
  color: #3d5262;
  background: #fff;
}

.secondary-button:hover {
  border-color: #9db2c1;
  background: #f8fafc;
}

.local-note {
  text-align: center;
}

.preview-area {
  min-width: 0;
  overflow: auto;
  padding-bottom: 18px;
  border-radius: 22px;
}

.preview-toolbar {
  width: min(100%, 900px);
  min-width: 700px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #6f7f8c;
  font-size: 14px;
}

.preview-toolbar span:first-child {
  display: flex;
  align-items: center;
  gap: 7px;
}

.preview-toolbar i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2a9d72;
  box-shadow: 0 0 0 4px rgba(42, 157, 114, 0.12);
}

.payslip {
  width: min(100%, 900px);
  min-width: 700px;
  min-height: 925px;
  margin: 0 auto;
  padding: 39px 42px 35px;
  border: 1px solid #d8e0e7;
  color: #101820;
  background: #fff;
  box-shadow: var(--shadow);
  font-family: "B Nazanin", Tahoma, serif;
  font-size: 17px;
  line-height: 1.25;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.slip-header {
  display: grid;
  grid-template-columns: 175px 1fr 88px;
  grid-template-areas: "meta title logo";
  align-items: center;
  gap: 15px;
  min-height: 83px;
  direction: ltr;
}

.header-meta {
  grid-area: meta;
  align-self: center;
  color: #24323d;
  direction: rtl;
  font-size: 14px;
}

.header-meta p {
  margin: 3px 0;
  white-space: nowrap;
}

.header-title {
  grid-area: title;
  text-align: center;
  direction: rtl;
}

.header-title h2 {
  margin: 0;
  color: var(--navy);
  font-size: 26px;
  line-height: 1.25;
}

.header-title p {
  margin: 4px 0 0;
  color: #334d61;
  font-size: 17px;
  font-weight: 700;
}

.blue-rule {
  height: 3px;
  margin: 7px 0 15px;
  background: var(--navy);
}

.media-slot {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px dashed #a9bac8;
  border-radius: 8px;
  color: #8a9ba8;
  background: #f9fbfc;
  direction: rtl;
  font-size: 13px;
}

.media-slot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(var(--image-scale, 1));
  transform-origin: center;
}

.media-slot:not(.is-empty) {
  border-color: transparent;
  background: transparent;
}

.media-slot:not(.is-empty) .empty-copy,
.media-slot.is-empty img {
  display: none;
}

.logo-slot {
  grid-area: logo;
  width: 82px;
  height: 75px;
  justify-self: end;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.identity-table {
  table-layout: fixed;
  border: 1.5px solid var(--navy);
  font-size: 15px;
}

.identity-table .label-col-wide {
  width: 13%;
}

.identity-table .value-col-wide {
  width: 25%;
}

.identity-table .label-col {
  width: 12%;
}

.identity-table .value-col {
  width: 19%;
}

.identity-table th,
.identity-table td {
  height: 45px;
  padding: 5px 7px;
  border: 1px solid var(--navy);
  text-align: center;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.identity-table th {
  color: var(--navy);
  background: var(--blue-soft);
  font-weight: 700;
}

.identity-table td {
  background: #fff;
}

.ltr-value {
  direction: ltr;
  unicode-bidi: plaintext;
}

.placeholder-value {
  color: #84919a;
}

.money-tables {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
  direction: rtl;
}

.money-table {
  table-layout: fixed;
  border: 1.5px solid var(--navy);
  font-size: 15px;
}

.money-table thead th {
  height: 39px;
  padding: 5px 8px;
  border: 1px solid var(--navy);
  color: var(--navy);
  background: var(--blue-soft);
  font-size: 18px;
}

.money-table tbody td,
.money-table tfoot th {
  height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--navy);
  vertical-align: middle;
}

.money-table tbody td:first-child,
.money-table tfoot th:first-child {
  width: 64%;
  text-align: right;
}

.money-table .amount {
  width: 36%;
  direction: ltr;
  text-align: left;
  white-space: nowrap;
  unicode-bidi: plaintext;
  font-variant-numeric: tabular-nums;
}

.money-table tfoot th {
  background: #fbfdff;
  font-size: 16px;
  font-weight: 700;
}

.net-summary {
  margin-top: 16px;
  border: 2px solid var(--navy);
}

.net-row {
  display: grid;
  grid-template-columns: 24% 1fr;
  min-height: 49px;
  border-bottom: 1px solid var(--navy);
  direction: rtl;
}

.net-row strong {
  display: grid;
  place-items: center;
  padding: 7px 10px;
  color: #fff;
  background: var(--navy);
  font-size: 18px;
}

.net-row .amount {
  display: grid;
  place-items: center;
  padding: 6px 10px;
  direction: ltr;
  text-align: center;
  font-size: 23px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.words-row {
  min-height: 42px;
  padding: 7px 12px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
}

.slip-footer {
  min-height: 145px;
  margin-top: 34px;
  padding: 0 25px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  direction: ltr;
}

.footer-block {
  min-height: 130px;
  text-align: center;
  direction: rtl;
  font-size: 15px;
}

.footer-block strong {
  display: block;
  margin-bottom: 7px;
}

.hr-block {
  justify-self: start;
}

.employee-signature {
  justify-self: end;
}

.seal-slot {
  width: 96px;
  height: 96px;
  margin: 0 auto;
  border-radius: 50%;
}

.signature-slot {
  width: 150px;
  height: 84px;
  margin: 0 auto;
}

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

.toast {
  position: fixed;
  right: 50%;
  bottom: 22px;
  z-index: 30;
  padding: 9px 16px;
  border-radius: 999px;
  color: #fff;
  background: rgba(18, 37, 52, 0.94);
  box-shadow: 0 10px 28px rgba(17, 36, 51, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
  font-size: 15px;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(50%, 0);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(960px, calc(100% - 24px));
  }

  .editor-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: 100%;
    padding-top: 0;
    gap: 14px;
  }

  .editor-panel {
    padding: 18px 14px;
    border-radius: 0 0 20px 20px;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .editor-actions {
    grid-template-columns: 1fr;
  }

  .preview-area {
    border-radius: 0;
    padding: 0 12px 18px;
  }
}

@page {
  size: A4 portrait;
  margin: 8mm;
}

@media print {
  html,
  body {
    min-width: 0;
    background: #fff;
  }

  body {
    margin: 0;
  }

  .screen-only {
    display: none !important;
  }

  .app-shell {
    display: block;
    width: auto;
    margin: 0;
    padding: 0;
  }

  .preview-area {
    overflow: visible;
    padding: 0;
  }

  .payslip {
    width: 194mm;
    min-width: 0;
    min-height: 254mm;
    margin: 0;
    padding: 8mm 8.5mm 7mm;
    border: 0;
    box-shadow: none;
    page-break-inside: avoid;
  }

  .media-slot.is-empty {
    border-color: transparent;
    background: transparent;
  }

  .media-slot.is-empty .empty-copy {
    display: none;
  }
}
