/* Taskham — plain CSS, logical properties only (RTL is the same stylesheet with dir="rtl"). */
@font-face {
  font-family: "Vazirmatn";
  src: url("/assets/fonts/Vazirmatn-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F, U+066A-066C;
}

:root {
  --font: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #1b1f23;
  --muted: #5b6573;
  --border: #d6dce5;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-contrast: #ffffff;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --success: #067647;
  --success-bg: #e6f6ee;
  --warning: #8a5300;
  --warning-bg: #fff4dc;
  --info-bg: #e8f0fe;
  --focus: #1d4ed8;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --topbar-h: 56px;
  --bottomnav-h: 60px;
  --sidenav-w: 232px;
  --touch: 44px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 { line-height: 1.25; margin-block: 0 var(--s3); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin-block: 0 var(--s3); }
a { color: var(--primary); }
.muted { color: var(--muted); }
.lead { font-size: 1.1rem; color: var(--muted); }
.noscript { padding: var(--s4); text-align: center; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr; unicode-bidi: embed; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--s3);
  inset-block-start: -60px;
  background: var(--surface);
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus { inset-block-start: var(--s2); }

/* ---- layout ---- */
.app { min-block-size: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-block-size: var(--topbar-h);
  padding-inline: var(--s4);
  background: var(--surface);
  border-block-end: 1px solid var(--border);
}
.topbar-start, .topbar-end { display: flex; align-items: center; gap: var(--s3); min-inline-size: 0; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.body { flex: 1; display: flex; min-inline-size: 0; }
.main { flex: 1; min-inline-size: 0; padding: var(--s4); padding-block-end: calc(var(--bottomnav-h) + var(--s5)); max-inline-size: 1100px; margin-inline: auto; inline-size: 100%; outline: none; }
.sidenav { display: none; }
.bottomnav {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  background: var(--surface);
  border-block-start: 1px solid var(--border);
  min-block-size: var(--bottomnav-h);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  min-inline-size: var(--touch);
  min-block-size: var(--touch);
  padding: var(--s1);
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: none;
}
.nav-item.is-active { color: var(--primary); font-weight: 700; }

@media (min-width: 640px) {
  .main { padding: var(--s5); padding-block-end: calc(var(--bottomnav-h) + var(--s5)); }
}
@media (min-width: 1024px) {
  .main { padding-block-end: var(--s5); }
  .bottomnav { display: none; }
  .sidenav {
    display: flex;
    flex-direction: column;
    gap: var(--s1);
    inline-size: var(--sidenav-w);
    flex: none;
    padding: var(--s4) var(--s3);
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    min-block-size: calc(100vh - var(--topbar-h));
  }
  .sidenav .nav-item { flex-direction: row; justify-content: flex-start; gap: var(--s3); font-size: 0.95rem; padding-inline: var(--s3); border-radius: var(--radius-sm); }
  .sidenav .nav-item.is-active { background: var(--info-bg); }
}

/* ---- surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s5); box-shadow: var(--shadow); margin-block-end: var(--s4); }
.hero { max-inline-size: 640px; margin-inline: auto; }
.row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.row-between { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between; }
.stack > * + * { margin-block-start: var(--s4); }
.grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-block-end: var(--s4); }
.page-head h1 { margin: 0; }

/* ---- controls ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-block-size: var(--touch);
  padding-inline: var(--s4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn-sm { min-block-size: 36px; padding-inline: var(--s3); font-size: 0.9rem; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-block { inline-size: 100%; }
.btn:disabled, .btn.is-busy { opacity: 0.6; cursor: not-allowed; }
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: var(--touch);
  block-size: var(--touch);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); }
.flip-rtl { display: inline-flex; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
[dir="rtl"] .list-row > .icon:last-child { transform: scaleX(-1); }
.dot { position: absolute; inset-block-start: 4px; inset-inline-end: 2px; min-inline-size: 18px; padding-inline: 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 0.7rem; line-height: 18px; text-align: center; }

.field { margin-block-end: var(--s4); }
.field-label { display: block; font-weight: 600; margin-block-end: var(--s1); }
.field-hint { margin: var(--s1) 0 0; color: var(--muted); font-size: 0.9rem; }
.field-error { margin: var(--s1) 0 0; color: var(--danger); font-size: 0.9rem; font-weight: 600; }
.input {
  inline-size: 100%;
  min-block-size: var(--touch);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { min-block-size: 96px; resize: vertical; }
.input-compact { min-block-size: 36px; inline-size: auto; max-inline-size: 150px; padding-block: 4px; }
.check { display: inline-flex; align-items: center; gap: var(--s2); min-block-size: var(--touch); cursor: pointer; }
.check input { inline-size: 20px; block-size: 20px; }
.lang-switch, .company-switch { display: inline-flex; align-items: center; gap: var(--s1); color: var(--muted); }
.company-switch select { max-inline-size: 160px; }
/* A phone shows brand, company, language, bell, account and menu: let them wrap instead of running off the screen. */
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; padding-block: var(--s2); row-gap: var(--s1); }
  .topbar-end { flex-wrap: wrap; flex: 1 1 auto; justify-content: flex-end; row-gap: var(--s1); gap: var(--s2); }
  .lang-switch svg, .company-switch svg { display: none; }
  .company-switch select { max-inline-size: 42vw; }
}

.matrix-bulk { display: flex; flex-wrap: wrap; gap: var(--s1); margin-block-start: var(--s1); font-weight: 400; }

/* ---- feedback ---- */
.badge { display: inline-block; padding: 2px var(--s2); border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--primary); }
.empty { text-align: center; padding: var(--s6) var(--s4); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty p { color: var(--muted); }
.skeleton-line { block-size: 14px; border-radius: 7px; margin-block: var(--s3); background: linear-gradient(90deg, var(--surface-2), #e3e8ef, var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.toasts { position: fixed; inset-block-end: calc(var(--bottomnav-h) + var(--s3)); inset-inline: var(--s3); z-index: 60; display: flex; flex-direction: column; gap: var(--s2); align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: var(--s2); max-inline-size: 560px; padding: var(--s3) var(--s4); background: #1b1f23; color: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.toast .icon-btn { color: #fff; inline-size: 32px; block-size: 32px; flex: none; }
.toast-error { background: #7a1b12; }
.toast-success { background: #064e30; }
.modal-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(16, 24, 40, 0.5); }
.modal { inline-size: 100%; max-inline-size: 520px; max-block-size: 92vh; overflow: auto; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; box-shadow: var(--shadow-lg); outline: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4); border-block-end: 1px solid var(--border); }
.modal-head h2 { margin: 0; }
.modal-body { padding: var(--s4); }
.modal-actions { display: flex; flex-wrap: wrap; gap: var(--s3); justify-content: flex-end; padding: var(--s4); border-block-start: 1px solid var(--border); }
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius); }
}

/* ---- navigation parts ---- */
.tabs { display: flex; gap: var(--s1); overflow-x: auto; border-block-end: 1px solid var(--border); margin-block-end: var(--s4); }
.tab { min-block-size: var(--touch); padding-inline: var(--s4); border: 0; border-block-end: 3px solid transparent; background: transparent; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab.is-active { color: var(--primary); border-block-end-color: var(--primary); }

/* ---- lists ---- */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding: var(--s3) var(--s4); min-block-size: 56px; color: inherit; text-decoration: none; border-block-end: 1px solid var(--border); background: var(--surface); }
.list-row:last-child { border-block-end: 0; }
.list-row.is-link { cursor: pointer; }
.list-row.is-link:hover { background: var(--surface-2); }
.list-lead { flex: none; }
.list-main { flex: 1 1 14rem; min-inline-size: 0; }
.list-title { font-weight: 600; overflow-wrap: anywhere; }
.list-sub { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.list-meta { flex: 0 1 auto; display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.avatar { display: inline-flex; align-items: center; justify-content: center; inline-size: 36px; block-size: 36px; border-radius: 999px; background: var(--info-bg); color: var(--primary); font-weight: 700; font-size: 0.85rem; flex: none; }
.pagination { margin-block-start: var(--s4); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s1); margin-block-end: var(--s2); }
.chip { padding: 2px var(--s2); border-radius: 999px; background: var(--info-bg); color: var(--primary); font-size: 0.85rem; }
.chip-empty { background: var(--surface-2); color: var(--muted); }
.picker-list { max-block-size: 240px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-block-start: var(--s2); }
.picker-row { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); min-block-size: var(--touch); cursor: pointer; }
.picker-row:hover, .picker-row.is-cursor { background: var(--surface-2); }
.picker-row.is-selected { background: var(--info-bg); font-weight: 700; }
.picker-empty { padding: var(--s3); color: var(--muted); }

/* ---- date picker ---- */
.datepicker { position: relative; }
.datepicker-trigger { display: flex; align-items: center; gap: var(--s2); text-align: start; cursor: pointer; }
.datepicker-pop { position: absolute; inset-inline-start: 0; inset-block-start: calc(100% + 4px); z-index: 30; inline-size: min(320px, 92vw); padding: var(--s3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-block-end: var(--s2); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: 0.75rem; color: var(--muted); padding-block: var(--s1); }
.cal-day { min-block-size: 38px; border: 0; border-radius: var(--radius-sm); background: transparent; font: inherit; cursor: pointer; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.is-selected { background: var(--primary); color: #fff; font-weight: 700; }
.cal-time { display: flex; align-items: center; gap: var(--s2); margin-block-start: var(--s3); }
.cal-actions { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: space-between; margin-block-start: var(--s3); }

/* ---- misc ---- */
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s4); text-decoration: none; color: inherit; display: block; }
.tile .num { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.bar { block-size: 10px; border-radius: 5px; background: var(--primary); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s4); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
table.table { inline-size: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { text-align: start; padding: var(--s2) var(--s3); border-block-end: 1px solid var(--border); vertical-align: top; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media print {
  .topbar, .bottomnav, .sidenav, .btn, .toasts, .no-print { display: none !important; }
  body { background: #fff; }
  .main { max-inline-size: none; padding: 0; }
  .card { box-shadow: none; border: 0; }
}

/* ---- auth ---- */
.auth-card { max-inline-size: 460px; margin-inline: auto; }
.auth-links { margin-block-start: var(--s4); text-align: center; color: var(--muted); }
.form-error { margin-block: var(--s3); padding: var(--s3); border-radius: var(--radius-sm); background: var(--danger-bg); color: var(--danger); font-weight: 600; overflow-wrap: anywhere; }
.captcha { margin-block-end: var(--s4); padding: var(--s3); background: var(--surface-2); border-radius: var(--radius-sm); }
.captcha-question { font-weight: 700; margin-block-end: var(--s2); }
.strength-bar { block-size: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.strength-bar span { display: block; block-size: 100%; inline-size: 0; background: var(--danger); transition: inline-size 0.2s; }
.strength-bar[data-level="3"] span, .strength-bar[data-level="2"] span { background: #b7791f; }
.strength-bar[data-level="4"] span, .strength-bar[data-level="5"] span { background: var(--success); }
.recovery-list { columns: 2; padding-inline-start: var(--s5); }
.recovery-list li { margin-block-end: var(--s1); font-size: 1.05rem; }
.qr { display: flex; justify-content: center; margin-block: var(--s3); }
.checks { display: flex; flex-direction: column; margin-block-end: var(--s3); }
.matrix th, .matrix td { text-align: center; white-space: nowrap; }
.matrix th:first-child, .matrix td:first-child { text-align: start; white-space: normal; min-inline-size: 220px; }
.group-row th { background: var(--surface-2); text-align: start; }
.tag { display: inline-block; padding: 2px var(--s2); border-radius: 999px; font-size: 0.82rem; font-weight: 600; background: #e5e7eb; color: #1f2937; }
.tag-red { background: #fee2e2; color: #991b1b; }
.tag-orange { background: #ffedd5; color: #9a3412; }
.tag-yellow { background: #fef9c3; color: #854d0e; }
.tag-green { background: #dcfce7; color: #166534; }
.tag-teal { background: #ccfbf1; color: #115e59; }
.tag-blue { background: #dbeafe; color: #1e40af; }
.tag-purple { background: #ede9fe; color: #5b21b6; }
.tag-pink { background: #fce7f3; color: #9d174d; }
.checklist { margin-block-end: var(--s4); }
.check-items { list-style: none; padding: 0; margin: 0 0 var(--s2); }
.check-items li { display: flex; align-items: center; gap: var(--s2); }
.check-items .done { text-decoration: line-through; color: var(--muted); }
.comment { padding: var(--s3) 0; border-block-end: 1px solid var(--border); }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-block: var(--s2); }
.mention { color: var(--primary); }
.composer { position: relative; margin-block-start: var(--s3); }
.mention-list { position: absolute; z-index: 5; inline-size: 100%; background: var(--surface); box-shadow: var(--shadow-lg); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.filter-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s4); margin-block: var(--s3); }
.chip-btn { min-block-size: 36px; padding-inline: var(--s3); border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font: inherit; cursor: pointer; }
.chip-btn.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
@media (max-width: 1023px) {
  .filter-sheet { position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 40; max-block-size: 80vh; overflow: auto; border-radius: var(--radius) var(--radius) 0 0; box-shadow: var(--shadow-lg); margin: 0; }
}
.activity-line { padding: var(--s2) 0; border-block-end: 1px solid var(--border); overflow-wrap: anywhere; }
.tile-danger .num { color: var(--danger); }
.bar-row { display: flex; align-items: center; gap: var(--s3); text-decoration: none; color: inherit; }
.bar-label { flex: 0 0 38%; overflow-wrap: anywhere; }
.bar-track { flex: 1; background: var(--surface-2); border-radius: 5px; block-size: 10px; overflow: hidden; }
.bar-num { flex: 0 0 3ch; text-align: end; font-weight: 700; }
.footer { padding: var(--s4); text-align: center; color: var(--muted); padding-block-end: calc(var(--bottomnav-h) + var(--s4)); }
@media (min-width: 1024px) { .footer { padding-block-end: var(--s4); } }
