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

:root {
  --bg: #f4f5f7; --surface: #fff; --surface-2: #f8f9fb; --border: #e2e5ea; --text: #1d2330; --muted: #667085;
  --primary: #1f4e79; --primary-2: #2c6aa3; --primary-soft: #e8f0f8;
  --ok: #1e7b4f; --ok-soft: #e4f4ec; --warn: #a15c00; --warn-soft: #fff3df; --danger: #b42318; --danger-soft: #fdecea;
  --info: #4a5cd0; --info-soft: #eceffd; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Vazirmatn, Tahoma, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.7; }
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }

/* layout */
.topbar { background: var(--primary); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar .in { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: .55rem 16px; }
.brand { color: #fff; font-weight: 700; white-space: nowrap; }
.topnav { display: flex; gap: .25rem; flex: 1; }
.topnav a { color: #dbe7f3; padding: .3rem .7rem; border-radius: 8px; }
.topnav a.on, .topnav a:hover { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
.who { font-size: .85rem; color: #dbe7f3; white-space: nowrap; position: relative; margin-inline-start: auto; }
.who > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem; }
.who > summary::-webkit-details-marker { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #fff; color: var(--primary); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; border: 2px solid rgba(255,255,255,.5); }
.who[open] .avatar { box-shadow: 0 0 0 3px rgba(255,255,255,.35); }
.who .menu { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16,24,40,.18); min-width: 220px; padding: 4px 0; z-index: 40; white-space: normal; }
.who .menu .me { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.who .menu a, .who .menu .role { display: block; width: 100%; text-align: start; padding: 8px 12px; background: none; border: 0;
  font: inherit; color: var(--text); cursor: pointer; }
.who .menu a:hover, .who .menu .role:hover:not(:disabled) { background: var(--primary-soft); text-decoration: none; }
.who .menu .role.on { color: var(--primary); font-weight: 700; cursor: default; }
.who .menu form { margin: 0; }
label.check { display: flex; align-items: center; gap: .45rem; color: var(--text); margin: .2rem 0; cursor: pointer; }
label.check input { width: auto; margin: 0; }
.badge-n { background: #f04438; color: #fff; border-radius: 99px; padding: 0 .45rem; font-size: .75rem; margin-inline-start: .25rem; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; padding-bottom: 90px; }
.bottomnav { display: none; }

@media (max-width: 760px) {
  .topnav, .who .uname { display: none; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a { flex: 1; text-align: center; padding: .45rem 0 .35rem; color: var(--muted); font-size: .75rem; }
  .bottomnav a .i { display: block; font-size: 1.25rem; line-height: 1.2; }
  .bottomnav a.on { color: var(--primary); font-weight: 700; }
  body { font-size: 15px; }
}

/* components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.card > h2:first-child { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 760px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: block; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--primary-2); }
.stat .n { font-size: 1.7rem; font-weight: 800; line-height: 1.2; }
.stat .l { color: var(--muted); font-size: .85rem; }
.stat.hl { background: var(--primary); color: #fff; border-color: var(--primary); }
.stat.hl .l { color: #dbe7f3; }
.stat.warn .n { color: var(--danger); }

.pill { display: inline-block; padding: .05rem .6rem; border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.pill.yours { background: #fde7c7; color: #8a4b00; }
.pill.progress { background: var(--info-soft); color: var(--info); }
.pill.returned { background: var(--danger-soft); color: var(--danger); }
.pill.done, .pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.closed { background: #eaecf0; color: #475467; }
.pill.other { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.pill.late { background: var(--danger); color: #fff; }

/* case rows: stack on mobile, no wide tables */
.cases { display: flex; flex-direction: column; gap: 8px; }
.crow { display: grid; grid-template-columns: 1.1fr 1.6fr 1.2fr 2fr auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; color: var(--text); }
.crow:hover { border-color: var(--primary-2); text-decoration: none; }
.crow.mine { border-inline-start: 4px solid #f79009; }
.crow .no { font-weight: 700; }
.crow .sub { color: var(--muted); font-size: .82rem; }
.crow .last { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.refchips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.chip { font-size: .72rem; padding: 0 .45rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); }
.chip.done { background: var(--ok-soft); border-color: #b7e2cb; color: var(--ok); }
.chip.open { background: #fff7e8; border-color: #f7d49b; color: var(--warn); }
.chip.returned { background: var(--danger-soft); border-color: #f5c2bd; color: var(--danger); }
@media (max-width: 900px) {
  .crow { grid-template-columns: 1fr auto; }
  .crow .c-cust, .crow .c-last { grid-column: 1 / -1; }
  .crow .c-refs { grid-column: 1 / -1; }
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters > * { flex: 1 1 160px; }

/* forms */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 3px; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=tel], select, textarea {
  width: 100%; font: inherit; padding: .5rem .7rem; border: 1px solid #cfd4dc; border-radius: 8px; background: #fff; color: var(--text); }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b3cbe3; border-color: var(--primary-2); }
.field { margin-bottom: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font: inherit; font-weight: 600; padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; min-height: 40px; }
.btn:hover { background: var(--primary-2); text-decoration: none; }
.btn.sec { background: #fff; color: var(--primary); }
.btn.sec:hover { background: var(--primary-soft); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.danger { background: #fff; color: var(--danger); border-color: #f1a8a1; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: .2rem .6rem; min-height: 30px; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
details.act { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: var(--surface-2); }
details.act > summary { cursor: pointer; padding: .55rem .8rem; font-weight: 600; list-style: none; }
details.act > summary::before { content: "＋ "; color: var(--primary-2); }
details.act[open] > summary::before { content: "－ "; }
details.act > div { padding: 0 .8rem .8rem; }

/* messages */
.msg { padding: .6rem .9rem; border-radius: 8px; margin-bottom: 10px; border: 1px solid; }
.msg.success { background: var(--ok-soft); border-color: #b7e2cb; color: #0f5132; }
.msg.error { background: var(--danger-soft); border-color: #f5c2bd; color: #7a1a12; }
.msg.info, .msg.warning { background: var(--warn-soft); border-color: #f7d49b; color: #6b3d00; }
.notice { padding: .6rem .9rem; border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--border); color: var(--muted); }
.alert-late { background: var(--danger-soft); border: 1px solid #f5c2bd; color: var(--danger); padding: .5rem .8rem; border-radius: 8px; margin-bottom: 10px; font-weight: 600; }

/* tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 14px; scrollbar-width: none; }
.tabs a { padding: .5rem .9rem; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--primary); border-color: var(--primary); font-weight: 700; }
.tabs a:hover { text-decoration: none; color: var(--primary); }

/* key-value */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .88rem; }
dl.kv dd { margin: 0; font-weight: 500; }

/* referral cards */
.refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.ref { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); }
.ref.done { border-color: #b7e2cb; background: #f6fbf8; }
.ref.returned { border-color: #f5c2bd; background: #fffafa; }
.ref.mine { box-shadow: 0 0 0 2px #f79009 inset; }
.ref h3 { display: flex; justify-content: space-between; gap: 6px; align-items: center; }

/* history list */
.events { list-style: none; margin: 0; padding: 0; }
.events li { padding: 9px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 9.5rem 1fr; gap: 10px; }
.events li:last-child { border-bottom: 0; }
.events .when { color: var(--muted); font-size: .82rem; }
.events .what { font-weight: 600; }
.events .meta { color: var(--muted); font-size: .8rem; }
.events .desc { white-space: pre-wrap; font-size: .9rem; }
.events li.mg { background: #fffaf0; }
@media (max-width: 600px) { .events li { grid-template-columns: 1fr; gap: 0; } }

/* timeline */
.tl { list-style: none; padding: 0; margin: 0; position: relative; }
.tl li { position: relative; padding: 0 2rem 1.1rem 0; }
.tl li::before { content: ""; position: absolute; right: .55rem; top: .4rem; bottom: -.4rem; width: 2px; background: var(--border); }
.tl li:last-child::before { display: none; }
.tl li::after { content: ""; position: absolute; right: .2rem; top: .35rem; width: .8rem; height: .8rem; border-radius: 50%; background: #fff; border: 2px solid #cfd4dc; }
.tl li.done::after { background: var(--ok); border-color: var(--ok); }
.tl li.current::after { background: #f79009; border-color: #f79009; box-shadow: 0 0 0 4px #fde7c7; }
.tl li.todo { color: var(--muted); }

/* simple tables (desktop-only data, collapse on mobile) */
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { text-align: right; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; font-size: .82rem; }
table.t tr.void td { text-decoration: line-through; color: var(--muted); }
table.t .num { text-align: left; direction: ltr; white-space: nowrap; }
table.t tfoot td { font-weight: 700; }
@media (max-width: 640px) {
  table.t.stack thead { display: none; }
  table.t.stack tr { display: block; border-bottom: 1px solid var(--border); padding: .4rem 0; }
  table.t.stack td { display: flex; justify-content: space-between; border: 0; padding: .15rem 0; }
  table.t.stack td::before { content: attr(data-l); color: var(--muted); font-size: .8rem; margin-inline-end: 8px; }
}
.sum-box { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sum-box > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.sum-box .v { font-weight: 800; font-size: 1.1rem; }
.debt .v { color: var(--danger); }

.login-wrap { max-width: 380px; margin: 8vh auto; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem; }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 12px; align-items: center; }
.upload-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.upload-btns label.btn { color: #fff; margin: 0; }
.upload-btns label.btn.sec { color: var(--primary); }
.upload-btns input[type=file] { display: none; }
.filelist { font-size: .85rem; color: var(--muted); margin-top: 6px; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.doc { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface); overflow: hidden; }
.doc img { width: 100%; height: 130px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.doc .nm { font-weight: 600; font-size: .85rem; overflow-wrap: anywhere; }
.install { display: none; }

/* customer messaging */
details.tpl { border-top: 1px solid var(--border); padding: 8px 0; }
details.tpl > summary { cursor: pointer; }
textarea[readonly] { background: var(--surface-2); }

/* delegated cartable banner */
.acting { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: .6rem .9rem;
  margin-bottom: 10px; border-radius: 8px; background: var(--info-soft); border: 1px solid #b9d3ee; color: var(--info); }
.checks { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.fin-tot { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.amt-in { color: var(--ok); } .amt-out { color: var(--danger); }
tr.voided td { opacity: .55; text-decoration: line-through; }

.refunit { margin-bottom: 4px; }
.unit-items { margin: 2px 22px 8px 0; padding: 6px 10px; border-right: 3px solid var(--border); background: var(--surface-2); border-radius: 6px; }
.site-foot { text-align: center; color: var(--muted); font-size: .75rem; padding: 18px 0 90px; }
