:root {
  --bg: #f4f5fa;
  --card: #ffffff;
  --ink: #161a26;
  --muted: #6b7280;
  --line: #e5e7f0;
  --accent: #5b5bd6;
  --accent-soft: #ececfb;
  --teal: #0f9d8f;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --ok: #067647;
  --ok-soft: #e7f6ec;
  --shadow: 0 1px 2px rgba(22, 26, 38, .06), 0 8px 24px -12px rgba(22, 26, 38, .18);
  --radius: 16px;
  --font: Vazirmatn, "IRANSansX", "IRANSans", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100dvh; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.4; }
p { margin: 0; }

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 14px 96px;
  min-height: 100dvh;
}

/* ---------------------------------------------------------------- boot/login */
.boot {
  min-height: 70vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
}
.boot-logo {
  width: 64px; height: 64px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--accent), #8b5cf6);
  color: #fff; font-size: 28px; font-weight: 800;
  display: grid; place-items: center;
  box-shadow: var(--shadow);
}

.login { max-width: 420px; margin: 8vh auto 0; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 24px; box-shadow: var(--shadow); }
.login h1 { font-size: 22px; margin-bottom: 6px; }
.login .sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.login .note { margin-top: 14px; font-size: 12.5px; color: var(--muted); line-height: 1.8; }
.login .bale-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #1f8a70; color: #fff; border: 0; border-radius: 14px;
  padding: 13px 18px; font-weight: 700; width: 100%;
}

/* ------------------------------------------------------------------- header */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 2px 14px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), #8b5cf6);
  color: #fff; font-weight: 800; display: grid; place-items: center;
}
.brand-text strong { display: block; font-size: 16px; }
.brand-text span { color: var(--muted); font-size: 12px; }
.topbar .spacer { flex: 1; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  border: 1px solid #ddd9fb; overflow: hidden; flex: 0 0 auto;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 15px;
}
.icon-btn:hover { background: #fafaff; }

.page-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.page-head h1 { font-size: 20px; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* --------------------------------------------------------------------- cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.section { margin-top: 18px; }
.section-title { font-size: 14px; color: var(--muted); font-weight: 600; margin: 0 4px 8px; display: flex; align-items: center; gap: 8px; }
.section-title .count { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 8px; font-size: 12px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { padding: 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.stat b { font-size: 22px; display: block; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.danger b { color: var(--danger); }

.project-list { display: grid; gap: 10px; }
@media (min-width: 760px) {
  .project-grid { grid-template-columns: 1fr 1fr; }
}
.project-card { padding: 14px 16px; display: block; color: inherit; }
.project-card:hover { border-color: #cfcdf7; }
.project-card .row1 { display: flex; align-items: center; gap: 10px; }
.project-key {
  font-size: 11px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 8px; padding: 2px 7px;
}
.project-card h3 { font-size: 16px; flex: 1; }
.project-card .meta { display: flex; gap: 14px; margin-top: 8px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.project-card .meta b { color: var(--ink); font-weight: 700; }
.bar { height: 5px; border-radius: 99px; background: #eef0f7; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #8b5cf6); border-radius: 99px; }

/* -------------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 600;
  background: #f1f2f8; color: #4b5563; white-space: nowrap;
}
.chip.due { background: var(--warn-soft); color: var(--warn); }
.chip.overdue { background: var(--danger-soft); color: var(--danger); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.p-urgent { background: #fee4e2; color: #b42318; }
.chip.p-high { background: #fff4e5; color: #b54708; }
.chip.p-low { background: #eef4ff; color: #3538cd; }
.chip.role { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  padding: 9px 14px; font-weight: 600; font-size: 13.5px; color: var(--ink);
  transition: .15s ease;
}
.btn:hover { background: #fafaff; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4b4bc4; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: #f6c9c4; }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

/* --------------------------------------------------------------------- forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); background: #fff;
  border-radius: 12px; padding: 10px 12px; outline: none; transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: #b9b7f3; box-shadow: 0 0 0 3px #eeeefd; }
.textarea { min-height: 92px; resize: vertical; line-height: 1.8; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); }

/* --------------------------------------------------------------------- board */
.board-wrap { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; }
.col {
  flex: 0 0 268px; scroll-snap-align: start;
  background: #eef0f7; border-radius: 16px; padding: 10px;
  display: flex; flex-direction: column; min-height: 200px;
}
.col.drop { outline: 2px dashed #a5a3f0; background: #e9e8fc; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 8px; font-weight: 700; font-size: 13px; }
.col-head .dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa1b1; }
.col[data-status="doing"] .dot { background: #3b82f6; }
.col[data-status="review"] .dot { background: #f59e0b; }
.col[data-status="done"] .dot { background: #10b981; }
.col-head .count { margin-inline-start: auto; color: var(--muted); font-size: 12px; font-weight: 600; }
.col-body { display: grid; gap: 8px; }

.task-card {
  background: var(--card); border-radius: 12px; padding: 10px 12px;
  border: 1px solid #e8eaf3; box-shadow: 0 1px 1px rgba(20,24,40,.04);
  cursor: pointer; transition: .15s;
}
.task-card:hover { border-color: #c9c7f4; transform: translateY(-1px); }
.task-card.dragging { opacity: .45; }
.task-card h4 { font-size: 13.5px; font-weight: 600; line-height: 1.6; }
.task-card .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.task-card .key { font-size: 10.5px; color: var(--muted); font-weight: 700; letter-spacing: .3px; }
.task-card .foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); font-size: 11.5px; }
.task-card .foot .avatar { width: 22px; height: 22px; font-size: 10px; }
.task-card .foot .spacer { flex: 1; }

/* ---------------------------------------------------------------------- task */
.detail-card { padding: 16px; }
.detail-card h1 { font-size: 19px; line-height: 1.6; }
.detail-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.detail-grid .field { margin: 0; }
.desc { margin-top: 16px; white-space: pre-wrap; color: #2b3040; line-height: 2; }
.desc.empty { color: var(--muted); font-style: italic; }

.comment { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid #f1f2f8; }
.comment:first-child { border-top: 0; }
.comment .body { flex: 1; }
.comment .who { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.comment .who b { color: var(--ink); font-size: 13px; }
.comment p { margin-top: 4px; white-space: pre-wrap; font-size: 13.5px; }
.comment .tools { display: flex; gap: 6px; }

.composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.composer .textarea { min-height: 46px; height: 46px; max-height: 160px; padding: 8px 12px; }
.composer .btn { height: 46px; }

.file-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #f1f2f8; font-size: 13px; }
.file-row:first-child { border-top: 0; }
.file-ico { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.file-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.timeline { font-size: 12.5px; color: var(--muted); }
.timeline li { list-style: none; padding: 6px 0; border-top: 1px dashed #eceef6; display: flex; gap: 8px; }
.timeline li:first-child { border-top: 0; }
.timeline b { color: var(--ink); font-weight: 600; }

/* -------------------------------------------------------------------- people */
.member-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid #f1f2f8; }
.member-row:first-child { border-top: 0; }
.member-row .grow { flex: 1; }
.member-row .name { font-weight: 600; font-size: 13.5px; }
.member-row .sub { color: var(--muted); font-size: 11.5px; }

/* -------------------------------------------------------------------- misc */
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { font-size: 30px; margin-bottom: 8px; }
.skeleton { border-radius: 12px; background: linear-gradient(90deg, #eef0f7, #f7f8fc, #eef0f7); background-size: 200% 100%; animation: sk 1.2s infinite; height: 76px; margin-bottom: 10px; }
@keyframes sk { 0% { background-position: 0 0 } 100% { background-position: -200% 0 } }
.offline-banner { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 8px 12px; font-size: 12.5px; margin-bottom: 12px; }
.list-card { padding: 4px 16px; }
.hr { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; direction: ltr; }
.search-row { display: flex; gap: 8px; margin-bottom: 12px; }

/* ------------------------------------------------------------------- tabbar */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: none; grid-template-columns: repeat(4, 1fr);
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .tab {
  border: 0; background: none; padding: 9px 4px 8px;
  display: grid; justify-items: center; gap: 2px;
  font-size: 11px; color: var(--muted);
}
.tabbar .tab .tab-ico { font-size: 17px; line-height: 1; }
.tabbar .tab.active { color: var(--accent); font-weight: 700; }

/* -------------------------------------------------------------------- toast */
.toast {
  position: fixed; inset-inline: 0; bottom: 82px; z-index: 60;
  margin: 0 auto; width: max-content; max-width: 92vw;
  background: #161a26; color: #fff; border-radius: 12px;
  padding: 10px 16px; font-size: 13px; box-shadow: var(--shadow);
  animation: pop .18s ease;
}
.toast.err { background: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0 } }

/* -------------------------------------------------------------------- sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(18, 21, 32, .45); }
.sheet {
  position: absolute; inset-inline: 0; bottom: 0;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow: auto;
  animation: up .2s ease;
}
@keyframes up { from { transform: translateY(30px); opacity: .6 } }
.sheet-head { display: flex; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { font-size: 16px; flex: 1; }

@media (min-width: 760px) {
  .app { padding-bottom: 28px; }
  .sheet { inset-inline: auto; left: 50%; transform: translateX(-50%); width: 520px; border-radius: 20px; bottom: 6vh; }
  .board-wrap { gap: 14px; }
  .col { flex: 1 1 0; min-width: 220px; }
}
@media (max-width: 759px) {
  .tabbar { display: grid; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 18px; }
}
