@font-face { font-family: Vazirmatn; font-weight: 400; font-display: swap;
  src: url('fonts/Vazirmatn-Regular.woff2') format('woff2'), url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Regular.woff2') format('woff2'); }
@font-face { font-family: Vazirmatn; font-weight: 500; font-display: swap;
  src: url('fonts/Vazirmatn-Medium.woff2') format('woff2'), url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Medium.woff2') format('woff2'); }
@font-face { font-family: Vazirmatn; font-weight: 700; font-display: swap;
  src: url('fonts/Vazirmatn-Bold.woff2') format('woff2'), url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Bold.woff2') format('woff2'); }

:root {
  --navy: #13294b; --blue: #1f5fbf; --blue-soft: #eaf2fd; --accent: #f08a24;
  --bg: #f4f6fa; --card: #fff; --ink: #1d2433; --muted: #6b7385; --line: #e2e7ef;
  --ok: #16794c; --ok-soft: #e6f5ee; --warn: #9a5b00; --warn-soft: #fff4e0; --bad: #b42318; --bad-soft: #fdecea;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Vazirmatn, Tahoma, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.8; direction: rtl; }
a { color: var(--blue); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 16px; color: var(--navy); }
h2 { font-size: 18px; margin: 0 0 12px; color: var(--navy); }
h3 { font-size: 16px; margin: 0 0 10px; color: var(--navy); }
.ic { width: 20px; height: 20px; flex: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }

.topbar { position: sticky; top: 0; z-index: 30; height: 56px; background: var(--navy); color: #fff; display: flex; align-items: center; gap: 10px; padding: 0 14px; }
.brand { color: #fff; font-weight: 700; font-size: 17px; }
.topbar-left { margin-right: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { background: none; border: 0; color: #fff; cursor: pointer; padding: 6px; border-radius: 8px; position: relative; display: inline-flex; }
.icon-btn:hover { background: rgba(255,255,255,.12); }
.badge-dot { position: absolute; top: -2px; left: -4px; background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 5px; line-height: 18px; }
.user-chip { color: #fff; font-size: 14px; }
.user-chip small { color: #c9d6ec; margin-right: 4px; }
.menu-toggle { display: none; }

.shell { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 220px; flex: 0 0 220px; background: #fff; border-left: 1px solid var(--line); padding: 12px 8px; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink); margin-bottom: 2px; }
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { background: var(--blue-soft); color: var(--blue); font-weight: 500; }
.content { flex: 1; padding: 22px; min-width: 0; max-width: 1280px; }
.content-guest { max-width: 420px; margin: 8vh auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; color: var(--navy); line-height: 1.5; }
.stat .sub { font-size: 12px; color: var(--muted); }
.progress { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; margin-top: 6px; }
.progress span { display: block; height: 100%; background: var(--blue); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--blue); background: var(--blue); color: #fff; border-radius: 10px; padding: 8px 16px; font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn-light { background: #fff; color: var(--blue); border-color: var(--line); }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-ok { background: var(--ok); border-color: var(--ok); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 15px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.req::after { content: ' *'; color: var(--bad); }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.check input { width: auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: right; background: #f7f9fc; color: var(--muted); font-weight: 500; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:hover td { background: #fafbfd; }
td.num, th.num { text-align: left; direction: ltr; white-space: nowrap; }

.badge { display: inline-block; font-size: 12px; padding: 1px 10px; border-radius: 20px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.st-new { background: #eef1f6; color: #4a5568; }
.st-contacted { background: #e8f1fd; color: #1f5fbf; }
.st-interested { background: #e7f6f9; color: #0b6e83; }
.st-meeting_set { background: #fff4e0; color: #9a5b00; }
.st-meeting_done { background: #f1ebfd; color: #5b3cc4; }
.st-proposal { background: #fdf0e6; color: #b5520d; }
.st-won { background: var(--ok-soft); color: var(--ok); }
.st-lost { background: var(--bad-soft); color: var(--bad); }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }

.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--bad-soft); color: var(--bad); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-right: 2px solid var(--line); padding: 0 16px 14px 0; position: relative; }
.timeline li::before { content: ''; position: absolute; right: -6px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.timeline .meta { font-size: 12px; color: var(--muted); }

.pager { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 14px; }
.pager a, .pager span { padding: 4px 11px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
.pager a.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.month-picker { display: flex; align-items: center; gap: 10px; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal .day { min-height: 92px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font-size: 12px; }
.cal .day.empty { background: transparent; border: 0; }
.cal .day.today { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.cal .day .dnum { font-weight: 700; color: var(--navy); }
.cal .ev { display: block; margin-top: 3px; padding: 1px 5px; border-radius: 5px; background: var(--blue-soft); color: var(--blue); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal .ev.valid { background: var(--ok-soft); color: var(--ok); }
.cal .ev.invalid { background: var(--bad-soft); color: var(--bad); }

.bars .bar-row { display: grid; grid-template-columns: 150px 1fr 90px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 14px; }
.bars .bar { height: 22px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bars .bar span { display: block; height: 100%; background: var(--blue); border-radius: 6px; }
.bars .bar-val { text-align: left; font-size: 13px; color: var(--muted); }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-family: Vazirmatn, Tahoma, sans-serif; font-size: 11px; fill: var(--muted); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 7px 14px; border-radius: 10px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: 14px; }
.tabs a.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.notif-item { display: block; padding: 12px; border-bottom: 1px solid var(--line); color: var(--ink); }
.notif-item.unread { background: var(--blue-soft); }
.empty-state { text-align: center; color: var(--muted); padding: 30px 10px; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.login-card h1 { text-align: center; }
.bottombar { display: none; }
.payslip { max-width: 720px; }
.payslip table td:last-child { text-align: left; }
.total-row td { font-weight: 700; color: var(--navy); background: var(--blue-soft); }

@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .menu-toggle { display: inline-flex; }
  .sidebar { position: fixed; top: 56px; right: 0; bottom: 0; z-index: 40; transform: translateX(100%); transition: transform .2s; overflow-y: auto; box-shadow: -4px 0 20px rgba(0,0,0,.08); }
  .sidebar.open { transform: none; }
  .content { padding: 14px 12px 90px; }
  .user-chip small { display: none; }
  .bottombar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 35; background: #fff; border-top: 1px solid var(--line); justify-content: space-around; align-items: center; height: 62px; padding-bottom: env(safe-area-inset-bottom); }
  .bottombar a { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); gap: 2px; }
  .bottombar .fab { width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: #fff; justify-content: center; margin-top: -26px; box-shadow: 0 4px 12px rgba(240,138,36,.4); }
  .bottombar .fab .ic { width: 26px; height: 26px; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .grid-4.stats { grid-template-columns: repeat(2, 1fr); }
  .stat .value { font-size: 20px; }
  .bars .bar-row { grid-template-columns: 90px 1fr 70px; font-size: 12px; }
  .cal .day { min-height: 60px; font-size: 10px; }
  .cal .ev { font-size: 10px; }
  table.responsive thead { display: none; }
  table.responsive tr { display: block; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: #fff; }
  table.responsive td { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
  table.responsive td:last-child { border-bottom: 0; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
}
@media print {
  .topbar, .sidebar, .bottombar, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
}
