:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #6b7683;
  --line: #e5e8ec;
  --brand: #2f6df6;
  --brand-ink: #ffffff;
  --ok: #1a8a52;
  --warn: #b26a00;
  --bad: #c23b3b;
  --chip: #eef2f7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.6 "Vazirmatn", -apple-system, "Segoe UI", Tahoma, sans-serif;
  direction: rtl;
}
a { color: var(--brand); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.7; }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 2px 4px; }

/* layout */
header.topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 22px;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.topbar .logo { font-weight: 700; font-size: 16px; }
.topbar .logo span { color: var(--brand); }
.topbar nav { display: flex; gap: 4px; margin-inline-start: 8px; }
.topbar nav button {
  border: 0; background: transparent; color: var(--muted); padding: 8px 14px;
  border-radius: 8px; font-weight: 600;
}
.topbar nav button.active { background: var(--chip); color: var(--ink); }
.topbar .spacer { flex: 1; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font-weight: 600;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

main { max-width: 1000px; margin: 22px auto; padding: 0 18px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 15px; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.muted { color: var(--muted); }
.hr { height: 1px; background: var(--line); margin: 14px 0; border: 0; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .n { font-size: 26px; font-weight: 700; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .n.small { font-size: 18px; }

/* table */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: 0; }

/* chips / badges */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--chip); font-size: 12px; font-weight: 600; }
.st-drafted { background: #eef2f7; color: #40506a; }
.st-approved { background: #e6f0ff; color: #1e56c9; }
.st-sent { background: #e2f5ea; color: var(--ok); }
.st-handoff { background: #fdf0dd; color: var(--warn); }
.st-failed { background: #fde6e6; color: var(--bad); }
.st-rejected, .st-skipped { background: #f0f0f2; color: #8a8f98; }
.badge-ok { color: var(--ok); font-weight: 700; }
.badge-bad { color: var(--bad); font-weight: 700; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-start: 6px; }
.dot.on { background: var(--ok); }

/* review letter */
.letter { white-space: pre-wrap; background: #fbfcfe; border: 1px solid var(--line); border-radius: 8px; padding: 14px; line-height: 1.9; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 340px; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; }

.toast { position: fixed; inset-block-end: 20px; inset-inline-start: 50%; transform: translateX(50%);
  background: #1b2430; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }
.toast.err { background: var(--bad); }

@media (max-width: 720px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .topbar nav { flex-wrap: wrap; }
}
