@font-face { font-family: "VazirFD"; src: url("../fonts/Vazirmatn-UI-FD-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "VazirFD"; src: url("../fonts/Vazirmatn-UI-FD-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "VazirFD"; src: url("../fonts/Vazirmatn-UI-FD-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --paper: #f1f4f3;
  --panel: #ffffff;
  --ink: #14262c;
  --ink-2: #4a5d63;
  --ink-3: #7b8c91;
  --line: #d8dfdd;
  --line-2: #e9eeec;
  --side: #0f242a;
  --side-2: #183840;
  --brand: #0f6a6d;
  --brand-dark: #0a4f52;
  --q: #2f5fa8;      /* ISO 9001  */
  --e: #2f8555;      /* ISO 14001 */
  --h: #cc7a12;      /* ISO 45001 */
  --ok: #2f8555; --ok-bg: #e4f3ea;
  --warn: #a86400; --warn-bg: #fdf0d6;
  --danger: #b3312b; --danger-bg: #fbe5e3;
  --info: #2f5fa8; --info-bg: #e5edf8;
  --muted: #62747a; --muted-bg: #e9eeec;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 36, 42, .06);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: "VazirFD", Tahoma, "Segoe UI", sans-serif; line-height: 1.85;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.5; margin: 0 0 .5rem; font-weight: 700; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
:focus-visible { outline: 3px solid #7fc4c6; outline-offset: 2px; border-radius: 4px; }

/* ---------- چیدمان ---------- */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.side { background: var(--side); color: #cfe0e2; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding-bottom: 1.5rem; }
.tricolor { display: flex; height: 5px; }
.tricolor i { flex: 1; } .tricolor i:nth-child(1) { background: var(--q); } .tricolor i:nth-child(2) { background: var(--e); } .tricolor i:nth-child(3) { background: var(--h); }
.brand { padding: 1.1rem 1.25rem .9rem; border-bottom: 1px solid var(--side-2); }
.brand b { display: block; color: #fff; font-size: 1.05rem; }
.brand span { font-size: .8rem; color: #8fb0b4; }
.side nav { padding: .6rem .6rem 0; }
.side .grp { font-size: .78rem; color: #78a0a5; margin: 1rem .7rem .3rem; }
.side a.nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: #cfe0e2; padding: .38rem .7rem; border-radius: 6px; font-size: .93rem; }
.side a.nav:hover { background: var(--side-2); text-decoration: none; color: #fff; }
.side a.nav.on { background: #1f4a52; color: #fff; box-shadow: inset -3px 0 0 #6cc3c6; }
.side .cnt { background: #2b5860; color: #fff; border-radius: 10px; font-size: .75rem; padding: 0 .5rem; }
.side .std-dot { width: .6rem; height: .6rem; border-radius: 50%; display: inline-block; margin-inline-end: .4rem; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1.5rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .date { color: var(--ink-2); font-size: .9rem; }
.topbar .who { display: flex; align-items: center; gap: .8rem; font-size: .9rem; }
.topbar .who a { color: var(--ink); }
.menu-btn { display: none; }
.content { padding: 1.5rem; max-width: 1180px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--ink-2); max-width: 62ch; }
.crumbs { font-size: .85rem; color: var(--ink-3); margin-bottom: .3rem; }
.crumbs a { color: var(--ink-2); }

/* ---------- اجزا ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card h2 { margin-bottom: .75rem; }
.grid { display: grid; gap: 1rem; }
.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)); }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }

.btn { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-size: .92rem; font-weight: 500; padding: .42rem 1rem; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.btn:hover { background: #f3f7f6; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--danger); border-color: #e3b5b2; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: .15rem .65rem; font-size: .84rem; }
.btn-lg { padding: .7rem 1.5rem; font-size: 1.05rem; }

.badge { display: inline-block; padding: 0 .6rem; border-radius: 10px; font-size: .8rem; font-weight: 500; white-space: nowrap; }
.badge.muted { background: var(--muted-bg); color: var(--muted); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }

.flash { padding: .6rem 1rem; border-radius: 6px; margin-bottom: .7rem; border-inline-start: 4px solid; background: #fff; }
.flash.ok { border-color: var(--ok); background: var(--ok-bg); }
.flash.warn { border-color: var(--h); background: var(--warn-bg); }
.flash.danger { border-color: var(--danger); background: var(--danger-bg); }
.flash.info { border-color: var(--info); background: var(--info-bg); }

table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th { text-align: start; font-weight: 500; color: var(--ink-2); font-size: .82rem; padding: .5rem .7rem; border-bottom: 1px solid var(--line); background: #f7f9f8; white-space: nowrap; }
table.t td { padding: .55rem .7rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.t tr:hover td { background: #fafcfb; }
.table-wrap { overflow-x: auto; }
.empty { text-align: center; padding: 2.2rem 1rem; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); margin-bottom: .3rem; }

/* ---------- فرم‌ها ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.25rem; }
.field.wide { grid-column: 1 / -1; }
.field label.lbl { display: block; font-weight: 500; font-size: .9rem; margin-bottom: .2rem; }
.field .req { color: var(--danger); margin-inline-start: .2rem; }
.field .help { font-size: .82rem; color: var(--ink-3); margin-top: .15rem; }
.field .err { font-size: .84rem; color: var(--danger); margin-top: .15rem; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=file], select, textarea {
  width: 100%; font: inherit; font-size: .95rem; padding: .45rem .7rem; border: 1px solid #bcc9c7; border-radius: 6px; background: #fff; color: var(--ink);
}
textarea { min-height: 5.5rem; resize: vertical; line-height: 1.8; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 3px solid #cfe8e8; }
.has-err input, .has-err select, .has-err textarea { border-color: var(--danger); }
.checks { display: flex; gap: 1.1rem; flex-wrap: wrap; padding: .3rem 0; }
.checks label { display: inline-flex; gap: .35rem; align-items: center; font-size: .93rem; }
.value-block { background: #f7f9f8; border: 1px solid var(--line-2); border-radius: 6px; padding: .4rem .7rem; min-height: 2.1rem; }
dl.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1.25rem; margin: 0; }
dl.facts .wide { grid-column: 1 / -1; }
dl.facts dt { font-size: .82rem; color: var(--ink-2); }
dl.facts dd { margin: 0; }
.ltr-input { direction: ltr; text-align: left; }
input.jdate { text-align: right; cursor: pointer; }

/* ---------- گردش کار ---------- */
.stepper { display: flex; flex-wrap: wrap; gap: .35rem; margin: .2rem 0 .3rem; }
.step { font-size: .82rem; padding: .05rem .7rem; border-radius: 12px; background: var(--muted-bg); color: var(--muted); }
.step.past { background: #d3e6dd; color: #226141; }
.step.now { background: var(--brand); color: #fff; font-weight: 500; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 1.4rem .9rem 0; border-inline-start: 0; }
.timeline li::before { content: ""; position: absolute; right: .28rem; top: .65rem; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; right: 0; top: .5rem; width: .6rem; height: .6rem; border-radius: 50%; background: var(--brand); }
.timeline li.k-comment::after { background: var(--h); } .timeline li.k-edit::after { background: var(--ink-3); }
.timeline .who { font-weight: 500; }
.timeline .when { color: var(--ink-3); font-size: .82rem; }
.tr-box { border: 1px solid var(--line); border-radius: 6px; padding: .7rem .9rem; background: #fbfcfc; }
.tr-box + .tr-box { margin-top: .6rem; }
.tr-box .row { align-items: flex-end; }
.tr-box .grow { flex: 1 1 200px; }

/* ---------- داشبورد ---------- */
.hero-report { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; background: var(--side); color: #fff; border-radius: var(--radius); padding: 1.4rem 1.6rem; position: relative; overflow: hidden; }
.hero-report::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 6px; background: linear-gradient(var(--q) 0 33%, var(--e) 33% 66%, var(--h) 66%); }
.hero-report h1 { color: #fff; margin: 0 0 .2rem; }
.hero-report p { margin: 0; color: #b6cfd2; max-width: 52ch; }
.hero-report .btn-primary { background: #f2f7f6; color: var(--side); border-color: #f2f7f6; }
.hero-report .btn { border-color: #3d6870; background: transparent; color: #dcecee; }
.stat { text-align: center; }
.stat b { display: block; font-size: 1.8rem; line-height: 1.3; }
.stat.warn b { color: var(--danger); }
.bar { height: .55rem; border-radius: 4px; background: var(--muted-bg); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .done { background: var(--ok); } .bar .prog { background: #e2a93a; } .bar .na { background: #9db3b8; }
.std-card { border-inline-start: 5px solid var(--q); }
.std-9001 { --c: var(--q); } .std-14001 { --c: var(--e); } .std-45001 { --c: var(--h); }
.std-card[data-std="14001"] { border-color: var(--e); } .std-card[data-std="45001"] { border-color: var(--h); }
.chart { display: flex; align-items: flex-end; gap: .35rem; height: 130px; padding-top: .3rem; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: .74rem; color: var(--ink-2); }
.chart .col i { display: block; width: 100%; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; }
.chart .col.zero i { background: var(--line); }
.chart .col span { margin-top: .2rem; white-space: nowrap; }
.chart.amber .col i { background: var(--h); }

/* ---------- بندها ---------- */
.clause-row td:first-child { white-space: nowrap; font-weight: 500; }
.clause-row.l1 td { background: #eef3f2; font-weight: 700; }
.clause-row.l3 td:nth-child(2) { padding-inline-start: 2.5rem; }
.clause-row.l2 td:nth-child(2) { padding-inline-start: 1.4rem; }
.hint { background: #f4f8f7; border-inline-start: 4px solid var(--brand); padding: .6rem .9rem; border-radius: 4px; }

/* ---------- تقویم ---------- */
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; background: #fff; }
.cal th { padding: .4rem; background: #f0f4f3; font-size: .85rem; border: 1px solid var(--line); }
.cal th.fri, .cal td.fri { background-color: #fbf3f2; }
.cal td { border: 1px solid var(--line); vertical-align: top; height: 100px; padding: .25rem .35rem; font-size: .8rem; }
.cal td.empty-cell { background: #f7f9f8; }
.cal .dn { font-weight: 700; color: var(--ink-2); }
.cal td.today { outline: 2px solid var(--brand); outline-offset: -2px; }
.cal .chip { display: block; margin-top: .15rem; padding: 0 .35rem; border-radius: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .chip.event { background: var(--info-bg); color: var(--info); }
.cal .chip.due { background: var(--warn-bg); color: var(--warn); }
.cal .chip.due.late { background: var(--danger-bg); color: var(--danger); }

/* ---------- ورود ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 1fr) minmax(320px, 460px); }
.auth-side { background: var(--side); color: #cfe0e2; padding: 3rem 3rem 2rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; }
.auth-side h1 { color: #fff; font-size: 1.9rem; }
.auth-side .stds { display: grid; gap: .7rem; margin-top: 1.6rem; max-width: 30rem; }
.auth-side .stds div { padding-inline-start: .9rem; border-inline-start: 4px solid var(--q); }
.auth-side .stds div:nth-child(2) { border-color: var(--e); } .auth-side .stds div:nth-child(3) { border-color: var(--h); }
.auth-side .stds b { color: #fff; display: block; }
.auth-form { padding: 3rem 2.2rem; display: flex; flex-direction: column; justify-content: center; background: var(--panel); }
.auth-form .field { margin-bottom: 1rem; }

/* ---------- انتخاب‌گر تاریخ شمسی ---------- */
.jd-pop { position: absolute; z-index: 60; background: #fff; border: 1px solid #aebdbb; border-radius: 8px; box-shadow: 0 8px 24px rgba(15, 36, 42, .18); padding: .6rem; width: 17.5rem; direction: rtl; }
.jd-head { display: flex; align-items: center; gap: .3rem; margin-bottom: .4rem; }
.jd-head select { padding: .1rem .3rem; font-size: .88rem; }
.jd-head button, .jd-foot button { font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 5px; cursor: pointer; padding: 0 .55rem; }
.jd-grid { width: 100%; border-collapse: collapse; text-align: center; }
.jd-grid th { font-size: .75rem; color: var(--ink-2); font-weight: 500; padding: .15rem 0; }
.jd-grid th.f, .jd-grid td.f button { color: var(--danger); }
.jd-grid td { padding: 1px; }
.jd-grid td button { width: 100%; font: inherit; font-size: .88rem; border: 0; background: transparent; border-radius: 5px; cursor: pointer; padding: .2rem 0; }
.jd-grid td button:hover { background: #e3efef; }
.jd-grid td button.sel { background: var(--brand); color: #fff; }
.jd-grid td button.tod { box-shadow: inset 0 0 0 1px var(--brand); }
.jd-foot { display: flex; justify-content: space-between; margin-top: .4rem; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 0 0 auto; width: 270px; z-index: 40; transform: translateX(100%); transition: transform .2s; }
  body.menu-open .side { transform: none; }
  .menu-btn { display: inline-flex; }
  .g2, .g3, .g4, .form-grid, dl.facts { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; }
  .cal td { height: 64px; }
  .cal .chip { font-size: 0; height: .5rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .side, .topbar, .btn, form.noprint { display: none !important; } .shell { display: block; } body { background: #fff; } }
