/* ==========================================================================
   Components
   ========================================================================== */

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
}
.card-head {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
}
.card-head h3 { font-size: var(--fs-md); font-weight: 700; }
.card-body { padding: var(--s-5); }
.card-body.tight { padding: var(--s-3); }
.card-body.flush { padding: 0; }
.card-foot {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.card.hover { transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast); }
.card.hover:hover { border-color: var(--border-strong); box-shadow: var(--sh-md); }

/* ---------- Stat tile ---------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-1);
}
.stat-label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.stat-value { font-size: var(--fs-3xl); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-meta { font-size: var(--fs-xs); color: var(--text-3); }
.stat-accent { height: 3px; border-radius: var(--r-full); background: var(--primary); margin-bottom: var(--s-2); width: 34px; }

/* ---------- Button ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 7px var(--s-4);
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  font-weight: 600;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
  transition: all var(--t-fast);
}
.btn:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.93); background: var(--danger); border-color: var(--danger); }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(.93); background: var(--success); border-color: var(--success); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); border-color: transparent; color: var(--text); }

.btn-soft { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary); }
.btn-soft:hover:not(:disabled) { background: var(--primary-soft); border-color: var(--primary); }

.btn-sm { padding: 4px var(--s-3); font-size: var(--fs-sm); }
.btn-lg { padding: 10px var(--s-5); font-size: var(--fs-lg); }
.btn-block { width: 100%; }

/* دکمه‌ای که به‌خاطر نبود دسترسی غیرفعال است */
.btn.no-perm { opacity: .4; cursor: not-allowed; position: relative; }

/* ---------- Badge / Chip ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px var(--s-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1.7;
}
.badge .bullet { width: 6px; height: 6px; border-radius: var(--r-full); background: currentColor; flex-shrink: 0; }

.badge-neutral { background: var(--neutral-soft); color: var(--text-2); border-color: var(--neutral-border); }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-border); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge-warn    { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.badge-info    { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }

/* وضعیت‌های تسک */
.st-todo         { background: var(--st-todo-bg);     color: var(--st-todo); }
.st-in_progress  { background: var(--st-progress-bg); color: var(--st-progress); }
.st-review       { background: var(--st-review-bg);   color: var(--st-review); }
.st-needs_changes{ background: var(--st-changes-bg);  color: var(--st-changes); }
.st-approved     { background: var(--st-approved-bg); color: var(--st-approved); }
.st-done         { background: var(--st-done-bg);     color: var(--st-done); }
.st-blocked      { background: var(--st-blocked-bg);  color: var(--st-blocked); }
.st-paused       { background: var(--st-paused-bg);   color: var(--st-paused); }

/* پرچم عقب‌افتادگی — Flag است نه Status (بند ۲۸) */
.flag-overdue {
  background: var(--danger-soft); color: var(--danger);
  border-color: var(--danger-border);
}

/* اولویت */
.pr { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 700; }
.pr-low { color: var(--pr-low); }
.pr-normal { color: var(--pr-normal); }
.pr-high { color: var(--pr-high); }
.pr-urgent { color: var(--pr-urgent); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px var(--s-2) 3px var(--s-2);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.chip button { color: var(--text-3); display: grid; place-items: center; }
.chip button:hover { color: var(--danger); }

/* ---------- Avatar ---------- */
.av {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 700;
  border: 2px solid var(--surface);
  user-select: none;
}
.av-xs { width: 21px; height: 21px; font-size: 9px; border-width: 1.5px; }
.av-sm { width: 24px; height: 24px; font-size: 10px; }
.av-lg { width: 38px; height: 38px; font-size: var(--fs-md); }
.av-xl { width: 60px; height: 60px; font-size: var(--fs-xl); border-width: 3px; }

.av-stack { display: flex; flex-direction: row-reverse; }
.av-stack .av { margin-right: -8px; }
.av-stack .av:last-child { margin-right: 0; }

.user-cell { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.user-cell .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-cell .rl { font-size: var(--fs-xs); color: var(--text-3); }

/* ---------- Table ---------- */
.tbl-wrap { overflow-x: auto; border-radius: var(--r-lg); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
table.tbl th {
  text-align: right;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
table.tbl th.sortable { cursor: pointer; user-select: none; }
table.tbl th.sortable:hover { color: var(--text-1); }
table.tbl td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.tbl tbody tr { transition: background var(--t-fast); }
table.tbl tbody tr:hover { background: var(--surface-hover); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl td.actions { text-align: left; white-space: nowrap; }
table.tbl .row-actions { opacity: 0; transition: opacity var(--t-fast); display: inline-flex; gap: var(--s-1); }
table.tbl tr:hover .row-actions { opacity: 1; }

.tbl-group-row td {
  background: var(--surface-3);
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--text-2);
  padding: var(--s-2) var(--s-4);
}

/* ---------- Form ---------- */
.field { margin-bottom: var(--s-4); }
.field:last-child { margin-bottom: 0; }
.label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: var(--s-2);
}
.label .req { color: var(--danger); margin-right: 2px; }
.label .opt { color: var(--text-3); font-weight: 400; font-size: var(--fs-xs); }

.input, .select, .textarea {
  width: 100%;
  padding: 7px var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--sh-focus);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 78px; line-height: var(--lh-normal); }
.select { cursor: pointer; appearance: none; background-image: none; padding-left: var(--s-6); }
.select-wrap { position: relative; }
.select-wrap::after {
  content: "▾"; position: absolute; left: var(--s-3); top: 50%;
  transform: translateY(-50%); color: var(--text-3); pointer-events: none; font-size: 10px;
}
.input.err, .select.err, .textarea.err { border-color: var(--danger); }
.field-err { color: var(--danger); font-size: var(--fs-xs); margin-top: var(--s-1); }
.field-hint { color: var(--text-3); font-size: var(--fs-xs); margin-top: var(--s-1); line-height: 1.6; }

.check { display: flex; align-items: flex-start; gap: var(--s-2); cursor: pointer; font-size: var(--fs-md); }
.check input { width: 15px; height: 15px; margin: 3px 0 0; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.check input:disabled { cursor: not-allowed; }
.check.disabled { opacity: .5; cursor: not-allowed; }

.switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: var(--r-full);
  transition: background var(--t-fast);
  cursor: pointer;
}
.switch .track::before {
  content: ""; position: absolute;
  width: 15px; height: 15px; top: 2.5px; left: 2.5px;
  background: #fff; border-radius: var(--r-full);
  transition: transform var(--t-fast);
  box-shadow: var(--sh-sm);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::before { transform: translateX(16px); }

.seg {
  display: inline-flex;
  background: var(--surface-3);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 2px;
}
.seg button {
  padding: 4px var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  transition: all var(--t-fast);
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--sh-xs); }

.radio-cards { display: flex; flex-direction: column; gap: var(--s-2); }
.radio-card {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
}
.radio-card:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.radio-card.on { border-color: var(--primary); background: var(--primary-soft); }
.radio-card input { margin: 3px 0 0; accent-color: var(--primary); flex-shrink: 0; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; align-items: center; gap: var(--s-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tabs button {
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: all var(--t-fast);
  display: flex; align-items: center; gap: var(--s-2);
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .tab-count {
  font-size: var(--fs-xs); font-weight: 700;
  background: var(--surface-3); color: var(--text-2);
  padding: 0 6px; border-radius: var(--r-full);
}

/* ---------- Progress ---------- */
.bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: var(--r-full); transition: width var(--t-med); }
.bar.thin { height: 4px; }
.bar.thick { height: 9px; }
.bar > i.ok { background: var(--success); }
.bar > i.warn { background: var(--warn); }
.bar > i.bad { background: var(--danger); }

.ring { --p: 0; --sz: 64px; --col: var(--primary); width: var(--sz); height: var(--sz); position: relative; flex-shrink: 0; }
.ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--col) calc(var(--p) * 1%), var(--surface-3) 0);
}
.ring::after {
  content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--surface);
}
.ring > span {
  position: absolute; inset: 0; display: grid; place-items: center;
  z-index: 1; font-weight: 800; font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -48%);
  width: min(560px, 94vw);
  max-height: 88vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  z-index: 100;
  display: flex; flex-direction: column;
  opacity: 0;
  animation: modalIn var(--t-med) forwards;
}
@keyframes modalIn { to { opacity: 1; transform: translate(-50%, -50%); } }
.modal.md { width: min(720px, 94vw); }
.modal.lg { width: min(940px, 95vw); }
.modal.xl { width: min(1180px, 96vw); }

.modal-head {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3);
  flex-shrink: 0;
}
.modal-body { padding: var(--s-5); overflow-y: auto; flex: 1; }
.modal-foot {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  display: flex; align-items: center; gap: var(--s-2);
  flex-shrink: 0;
}

/* ---------- Dropdown ---------- */
.menu {
  position: fixed;
  min-width: 190px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  padding: var(--s-1);
  z-index: 120;
}
.menu-item {
  display: flex; align-items: center; gap: var(--s-2);
  width: 100%;
  padding: 6px var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  color: var(--text);
  text-align: right;
  transition: background var(--t-fast);
}
.menu-item:hover:not(:disabled) { background: var(--surface-hover); }
.menu-item:disabled { opacity: .4; }
.menu-item.danger { color: var(--danger); }
.menu-item .ico { width: 16px; text-align: center; flex-shrink: 0; opacity: .8; }
.menu-item .tick { margin-right: auto; color: var(--primary); }
.menu-sep { height: 1px; background: var(--border); margin: var(--s-1) 0; }
.menu-title { padding: var(--s-2) var(--s-3) var(--s-1); font-size: var(--fs-xs); font-weight: 700; color: var(--text-3); }

/* ---------- Toast ---------- */
#toasts {
  position: fixed; bottom: var(--s-5); left: var(--s-5);
  display: flex; flex-direction: column-reverse; gap: var(--s-2);
  z-index: 200;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  min-width: 280px; max-width: 420px;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: 3px solid var(--primary);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  font-size: var(--fs-md);
  animation: toastIn var(--t-med);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
.toast.ok { border-right-color: var(--success); }
.toast.err { border-right-color: var(--danger); }
.toast.warn { border-right-color: var(--warn); }
.toast .ico { flex-shrink: 0; }

/* ---------- Empty state ---------- */
.empty {
  padding: var(--s-10) var(--s-5);
  text-align: center;
  color: var(--text-3);
}
.empty .ico { font-size: 34px; opacity: .4; margin-bottom: var(--s-3); }
.empty .t { font-size: var(--fs-lg); font-weight: 700; color: var(--text-2); margin-bottom: var(--s-1); }
.empty .d { font-size: var(--fs-sm); max-width: 380px; margin: 0 auto var(--s-4); line-height: 1.8; }

/* ---------- Kanban ---------- */
.kcol {
  width: 292px; flex-shrink: 0;
  background: var(--surface-3);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  max-height: 100%;
}
.kcol-head {
  padding: var(--s-3) var(--s-3) var(--s-2);
  display: flex; align-items: center; gap: var(--s-2);
  flex-shrink: 0;
}
.kcol-head .nm { font-weight: 700; font-size: var(--fs-sm); }
.kcol-head .ct {
  background: var(--surface); color: var(--text-2);
  font-size: var(--fs-xs); font-weight: 700;
  padding: 0 6px; border-radius: var(--r-full);
}
.kcol-body {
  padding: 0 var(--s-2) var(--s-2);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s-2);
  min-height: 60px;
}
.kcol.drop-target .kcol-body { outline: 2px dashed var(--primary); outline-offset: -4px; border-radius: var(--r-md); }

.kcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  cursor: grab;
  box-shadow: var(--sh-xs);
  transition: box-shadow var(--t-fast), border-color var(--t-fast);
}
.kcard:hover { box-shadow: var(--sh-md); border-color: var(--border-strong); }
.kcard.dragging { opacity: .4; }
.kcard .t { font-weight: 600; font-size: var(--fs-md); line-height: 1.6; margin-bottom: var(--s-2); }
.kcard .meta { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

/* ---------- Calendar (شمسی) ---------- */
.cal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.cal-head {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.cal-head > div {
  padding: var(--s-2);
  text-align: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-3);
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell {
  min-height: 108px;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: var(--s-2);
  display: flex; flex-direction: column; gap: 3px;
  overflow: hidden;
}
.cal-cell:nth-child(7n) { border-left: none; }
.cal-cell.out { background: var(--surface-2); opacity: .5; }
.cal-cell.today { background: var(--primary-soft); }
.cal-cell.holiday { background: var(--danger-soft); }
.cal-day {
  font-size: var(--fs-sm); font-weight: 700; color: var(--text-2);
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
}
.cal-cell.today .cal-day { color: var(--primary); }
.cal-cell.holiday .cal-day { color: var(--danger); }
.cal-day .hn { font-size: 9px; font-weight: 500; color: var(--text-3); }
.cal-ev {
  font-size: var(--fs-xs);
  padding: 2px var(--s-2);
  border-radius: var(--r-xs);
  cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-right: 2px solid currentColor;
  font-weight: 600;
}
.cal-more { font-size: 10px; color: var(--text-3); padding-right: var(--s-2); }

/* تقویم فشرده حضور و غیاب */
.cal.compact .cal-cell { min-height: 62px; }

/* ---------- Tree (سلسله‌مراتب) ---------- */
.tree { --indent: 26px; }
.tree-node { position: relative; }
.tree-row {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.tree-row:hover { background: var(--surface-hover); }
.tree-children { padding-right: var(--indent); border-right: 1px dashed var(--border-2); margin-right: 14px; }
.tree-toggle { width: 16px; color: var(--text-3); font-size: 10px; flex-shrink: 0; }

/* ---------- Timeline (تاریخچه / Audit) ---------- */
.tl { position: relative; padding-right: var(--s-5); }
.tl::before {
  content: ""; position: absolute; top: 6px; bottom: 6px; right: 7px;
  width: 1px; background: var(--border-2);
}
.tl-item { position: relative; padding-bottom: var(--s-4); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; right: -22px; top: 6px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.tl-item.hl::before { border-color: var(--primary); background: var(--primary); }
.tl-time { font-size: var(--fs-xs); color: var(--text-3); }

/* ---------- Comments ---------- */
.cmt { display: flex; gap: var(--s-3); padding: var(--s-3) 0; }
.cmt-body { flex: 1; min-width: 0; }
.cmt-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  font-size: var(--fs-md);
  line-height: 1.8;
}
.cmt-replies { padding-right: var(--s-6); border-right: 1px solid var(--border); margin-right: 14px; }
.cmt .mention { color: var(--primary); background: var(--primary-soft); padding: 0 4px; border-radius: var(--r-xs); font-weight: 600; }
.cmt-actions { display: flex; align-items: center; gap: var(--s-3); margin-top: var(--s-1); font-size: var(--fs-xs); }
.cmt-actions button { color: var(--text-3); font-weight: 600; }
.cmt-actions button:hover { color: var(--primary); }
.reaction {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
}
.reaction.mine { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary); }

/* ---------- Subtask row ---------- */
.sub-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color var(--t-fast);
}
.sub-row:hover { border-color: var(--border-strong); }
.sub-row.done .tt { text-decoration: line-through; color: var(--text-3); }
.sub-row .tt { flex: 1; min-width: 0; }

/* ---------- Approval pipeline ---------- */
.pipe { display: flex; align-items: stretch; gap: 0; overflow-x: auto; }
.pipe-stage {
  flex: 1; min-width: 168px;
  border: 1px solid var(--border);
  padding: var(--s-3);
  background: var(--surface);
  position: relative;
}
.pipe-stage:first-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.pipe-stage:last-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.pipe-stage + .pipe-stage { border-right: none; }
.pipe-stage.active { border-color: var(--primary); background: var(--primary-soft); z-index: 1; }
.pipe-stage.passed { background: var(--success-soft); border-color: var(--success-border); }
.pipe-stage.rejected { background: var(--danger-soft); border-color: var(--danger-border); }
.pipe-stage .sn { font-size: var(--fs-xs); color: var(--text-3); font-weight: 700; }

/* ---------- File row ---------- */
.file-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.file-ico {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-size: 10px; font-weight: 800;
  background: var(--surface-3); color: var(--text-2);
  text-transform: uppercase;
}

/* ---------- Permission matrix ---------- */
.matrix { overflow: auto; max-height: 68vh; border: 1px solid var(--border); border-radius: var(--r-lg); }
.matrix table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: var(--fs-sm); }
.matrix th, .matrix td { padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border); }
.matrix thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2);
  font-size: var(--fs-xs); font-weight: 700; color: var(--text-2);
  text-align: center;
  border-bottom: 1px solid var(--border-2);
  min-width: 92px;
}
.matrix tbody th {
  position: sticky; right: 0; z-index: 2;
  background: var(--surface);
  text-align: right; font-weight: 500;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}
.matrix thead th:first-child { right: 0; z-index: 4; text-align: right; min-width: 260px; }
.matrix td { text-align: center; }
.matrix tr.grp th, .matrix tr.grp td { background: var(--surface-3); font-weight: 700; font-size: var(--fs-xs); color: var(--text-2); }
.matrix .yes { color: var(--success); font-weight: 700; }
.matrix .no { color: var(--border-strong); }

/* ---------- Command palette ---------- */
.cmdk {
  position: fixed; top: 12vh; left: 50%; transform: translateX(-50%);
  width: min(620px, 94vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  z-index: 130;
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: 64vh;
}
.cmdk input {
  width: 100%; padding: var(--s-4) var(--s-5);
  border: none; background: transparent;
  font-size: var(--fs-lg);
  border-bottom: 1px solid var(--border);
}
.cmdk-results { overflow-y: auto; padding: var(--s-2); }
.cmdk-item {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  text-align: right;
}
.cmdk-item:hover, .cmdk-item.sel { background: var(--surface-hover); }
.cmdk-kind {
  font-size: var(--fs-xs); color: var(--text-3);
  background: var(--surface-3); padding: 1px 6px; border-radius: var(--r-xs);
  margin-right: auto; flex-shrink: 0;
}

/* ---------- Callout ---------- */
.callout {
  display: flex; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--info-border);
  background: var(--info-soft);
  font-size: var(--fs-sm);
  line-height: 1.8;
  color: var(--text);
}
.callout .ico { flex-shrink: 0; }
.callout.warn { border-color: var(--warn-border); background: var(--warn-soft); }
.callout.danger { border-color: var(--danger-border); background: var(--danger-soft); }
.callout.success { border-color: var(--success-border); background: var(--success-soft); }
.callout.rule { border-color: var(--primary-border); background: var(--primary-soft); }

/* ---------- Misc ---------- */
.divider-y { width: 1px; align-self: stretch; background: var(--border); margin: 0 var(--s-1); }
.dot-sep { color: var(--text-3); }
.kv { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: var(--s-2) var(--s-3); font-size: var(--fs-md); align-items: center; }
.kv > dt { color: var(--text-2); font-size: var(--fs-sm); }
.kv > dd { margin: 0; }
.skel { background: linear-gradient(90deg, var(--surface-3), var(--surface-hover), var(--surface-3)); border-radius: var(--r-sm); animation: sk 1.3s infinite; }
@keyframes sk { 0%{opacity:.6} 50%{opacity:1} 100%{opacity:.6} }
