@font-face { font-family: Vazirmatn; src: url(fonts/Vazirmatn-wght.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
:root {
  --bg: #f3f5f8; --panel: #fff; --ink: #172033; --muted: #5d6a80; --line: #dde3ec; --soft: #eef2f7;
  --brand: #1f6feb; --brand-ink: #fff; --ok: #1a8f4c; --warn: #b26b00; --bad: #c62f3a; --info: #6b4bd6;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.7 Vazirmatn, Tahoma, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.ltr { direction: ltr; unicode-bidi: embed; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* layout */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: #142033; color: #fff; }
.top .name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.top .scan { flex: 1; max-width: 420px; display: flex; }
.top .scan input { width: 100%; border: 0; border-radius: 8px; padding: 6px 12px; background: #24324a; color: #fff; }
.top .scan input::placeholder { color: #9fb0c8; }
.top .me { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.top .me button { background: transparent; border: 1px solid #3a4b66; color: #dbe5f3; border-radius: 8px; padding: 3px 10px; cursor: pointer; }
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 52px); }
.nav { background: var(--panel); border-inline-end: 1px solid var(--line); padding: 12px 8px; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: 8px;
  color: var(--ink); text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: var(--soft); }
.nav a.on { background: var(--brand); color: #fff; font-weight: 700; }
.nav .badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: 12px; padding: 0 7px; }
main { padding: 20px; min-width: 0; }
h1 { font-size: 21px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.spacer { flex: 1; }

/* forms */
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
label.f > span b { color: var(--bad); }
input[type=text], input[type=password], input[type=tel], input[type=number], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc2ff; border-color: var(--brand); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: #fff; border-radius: 8px; padding: 7px 14px; cursor: pointer; text-decoration: none; color: var(--ink);
  white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn.big { padding: 11px 20px; font-size: 16px; }
.btn:disabled { opacity: .55; cursor: default; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px; }
.checks label { display: inline-flex; gap: 5px; align-items: center; }
.err { color: var(--bad); margin: 6px 0; }
.note { background: #fff8e6; border: 1px solid #f1d9a6; border-radius: 8px; padding: 8px 12px; margin: 8px 0; }

/* status chips */
.chip { display: inline-block; border-radius: 99px; padding: 1px 10px; font-size: 13px; font-weight: 700;
  background: var(--soft); color: var(--muted); white-space: nowrap; }
.st-received { background: #e7efff; color: #1d4fb8; }
.st-diagnosing, .st-repairing { background: #efe9ff; color: #5a3cc4; }
.st-awaiting_quote, .st-awaiting_approval, .st-waiting_parts { background: #fff2dc; color: #965a00; }
.st-repaired { background: #e2f6ea; color: #157a40; }
.st-unrepairable, .st-rejected { background: #fde6e8; color: #b0242f; }
.st-delivered { background: #e9edf2; color: #4b5668; }
.st-sent_out { background: #e3f4f7; color: #0f6b7c; }

/* dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.tile:hover { border-color: var(--brand); }
.tile .n { font-size: 28px; font-weight: 800; line-height: 1.3; }
.tile .l { color: var(--muted); font-size: 13px; }

/* job list */
.jobs { display: grid; gap: 8px; }
.job { display: grid; grid-template-columns: 110px 1fr auto; gap: 4px 12px; align-items: center; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; text-decoration: none; color: var(--ink); }
.job:hover { border-color: var(--brand); }
.job .code { font-weight: 800; direction: ltr; text-align: right; }
.job .what { font-weight: 600; }
.job .meta { grid-column: 2 / 4; font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { padding: 5px 12px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line);
  text-decoration: none; color: var(--ink); font-size: 14px; }
.tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* job page */
.jhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.jhead .code { font-size: 24px; font-weight: 800; direction: ltr; }
dl.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 14px; }
dl.kv dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.photos .ph { position: relative; }
.photos img { width: 92px; height: 92px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; display: block; }
.photos .x { position: absolute; top: 3px; inset-inline-start: 3px; background: rgba(0,0,0,.6); color: #fff; border: 0;
  border-radius: 99px; width: 22px; height: 22px; line-height: 20px; cursor: pointer; padding: 0; }
.photos .tag { position: absolute; bottom: 3px; inset-inline-end: 3px; background: rgba(0,0,0,.55); color: #fff;
  font-size: 11px; border-radius: 4px; padding: 0 4px; }
.timeline { border-inline-start: 3px solid var(--line); padding-inline-start: 14px; margin-inline-start: 4px; }
.titem { position: relative; margin-bottom: 14px; }
.titem::before { content: ""; position: absolute; inset-inline-start: -21px; top: 7px; width: 11px; height: 11px;
  border-radius: 99px; background: var(--brand); border: 2px solid #fff; }
.titem .h { font-size: 13px; color: var(--muted); }
.parts { width: 100%; border-collapse: collapse; margin: 4px 0; font-size: 14px; }
.parts th, .parts td { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: right; }
.parts th { color: var(--muted); font-weight: 600; }
.prow { display: grid; grid-template-columns: 1fr 70px 1fr 32px; gap: 6px; margin-bottom: 6px; }
.prow button { border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; }
.money { font-weight: 800; font-size: 18px; }
.events { font-size: 13px; }
.events div { padding: 3px 0; border-bottom: 1px dashed var(--line); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 24px; }
.login h1 { text-align: center; }
.login .sub { text-align: center; color: var(--muted); margin: -8px 0 16px; }

/* overlays */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 22, 35, .55); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; padding: 18px; width: 100%; max-width: 460px; max-height: 92vh; overflow: auto; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 60; display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 94vh; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #172033; color: #fff;
  padding: 9px 18px; border-radius: 10px; z-index: 70; box-shadow: var(--shadow); max-width: 90vw; }
#toast.bad { background: var(--bad); }

/* phones */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .nav { display: flex; overflow-x: auto; gap: 4px; padding: 6px 8px; border: 0; border-bottom: 1px solid var(--line);
    position: sticky; top: 50px; z-index: 10; }
  .nav a { white-space: nowrap; margin: 0; padding: 6px 12px; }
  main { padding: 14px 12px; }
  .grid2 { grid-template-columns: 1fr; }
  .top { gap: 8px; padding: 8px 12px; }
  .top .name { display: none; }
  .top .me .who { display: none; }
  .job { grid-template-columns: 1fr auto; }
  .job .what { grid-column: 1 / 3; }
  .job .meta { grid-column: 1 / 3; }
  dl.kv { grid-template-columns: 105px 1fr; }
  .prow { grid-template-columns: 1fr 58px 32px; }
  .prow .pn { display: none; }
}

/* printing: only #print is shown */
#print { display: none; }
@media print {
  body { background: #fff; }
  #app, #toast, .modal-bg, .lightbox { display: none !important; }
  #print { display: block; color: #000; }
}
.rc { font-size: 10pt; line-height: 1.55; color: #000; }
.rc .rh { display: flex; justify-content: space-between; align-items: flex-start; gap: 4mm; border-bottom: 1.2pt solid #000; padding-bottom: 2mm; }
.rc .shop { font-size: 13pt; font-weight: 800; }
.rc .title { font-size: 12pt; font-weight: 800; text-align: center; margin: 2.5mm 0; }
.rc .bc { text-align: center; }
.rc .bc .c { font: 700 11pt/1.2 Vazirmatn, monospace; direction: ltr; letter-spacing: 1pt; }
.rc table { width: 100%; border-collapse: collapse; margin-bottom: 2mm; }
.rc td { border: .6pt solid #000; padding: 1mm 2mm; vertical-align: top; }
.rc td.k { width: 26mm; background: #eee; font-weight: 700; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.rc .terms { font-size: 8.5pt; white-space: pre-wrap; border-top: .6pt solid #000; padding-top: 1.5mm; margin-top: 2mm; }
.rc .sign { display: flex; gap: 6mm; margin-top: 3mm; }
.rc .sign div { flex: 1; border: .6pt solid #000; height: 16mm; padding: 1mm 2mm; font-size: 9pt; }
.sheet { position: relative; width: 210mm; height: 297mm; overflow: hidden; page-break-after: always; break-after: page; }
.sheet:last-child { page-break-after: auto; break-after: auto; }
.lbl { position: absolute; overflow: hidden; padding: 1.5mm 2mm; color: #000; display: flex; flex-direction: column;
  justify-content: space-between; font-size: 7.5pt; line-height: 1.3; }
.lbl .l1 { display: flex; justify-content: space-between; gap: 2mm; font-weight: 700; white-space: nowrap; }
.lbl .l1 span { overflow: hidden; text-overflow: ellipsis; }
.lbl .bcw { text-align: center; line-height: 0; }
.lbl .c { font: 800 9.5pt/1.1 Vazirmatn, monospace; direction: ltr; text-align: center; letter-spacing: .6pt; }
.lbl .d { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbl.outline { outline: .3pt dashed #999; }
