body {
  background: var(--bg-soft);
  color: var(--text);
  font-family: 'Vazirmatn', system-ui, sans-serif;
  margin: 0;
}

.shell { max-width: 1180px; margin: 0 auto; padding: 0 var(--s-5) var(--s-12); }

.top {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-8);
}
.top__in {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--s-4) var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}
.brand { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.brand__mark {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: var(--r-md);
  background: var(--primary);
  color: var(--on-primary);
  display: grid; place-items: center;
  font-size: 19px; font-weight: 700;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
.brand__title { font-size: 15px; font-weight: 700; }
.brand__sub { font-size: 11.5px; color: var(--text-3); }

.who { display: flex; align-items: center; gap: var(--s-3); }
.who__name { font-size: 12.5px; color: var(--text-2); }
.who__name b { color: var(--text); }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6);
}
.page-head h1 { font-size: 22px; margin-bottom: 4px; }
.page-head p { font-size: 13px; color: var(--text-3); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-8);
}
.stat {
  position: relative;
  overflow: hidden;
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.stat::after {
  content: '';
  position: absolute; inset-block-start: 0; inset-inline: 0;
  height: 3px; background: var(--accent, var(--primary));
}
.stat__label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.stat__value {
  font-size: 26px; font-weight: 700; line-height: 1.25;
  letter-spacing: -0.02em; margin-top: var(--s-2);
  font-variant-numeric: tabular-nums;
}
.stat__unit { font-size: 13px; font-weight: 500; color: var(--text-3); margin-inline-start: 4px; }
.stat__foot {
  margin-top: var(--s-3); padding-top: var(--s-3);
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px; color: var(--text-3);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  margin-bottom: var(--s-6);
}
.card__head {
  padding: var(--s-5);
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); flex-wrap: wrap;
}
.card__head h2 { font-size: 16px; margin-bottom: 3px; }
.card__head p { font-size: 12.5px; color: var(--text-3); }

.search {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 340px;
}
.search input {
  width: 100%;
  padding: 9px 38px 9px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}
.search input:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.search::before {
  content: '⌕';
  position: absolute;
  inset-inline-start: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 17px;
  pointer-events: none;
}

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-3); line-height: 1.8; }
.input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.input.mono { font-variant-numeric: tabular-nums; direction: ltr; text-align: left; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: var(--on-primary);
  font-family: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--ghost { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--secondary); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { padding: 7px 12px; font-size: 12px; }
.btn--block { width: 100%; }

.spin {
  width: 13px; height: 13px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: right;
  padding: var(--s-3) var(--s-4);
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 600; font-size: 11.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: var(--s-4);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--dur-fast) var(--ease); }
tbody tr:hover { background: var(--surface-2); }

.ident { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.ident__avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--r-md);
  background: var(--surface-3);
  color: var(--primary);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.ident__meta { display: flex; flex-direction: column; line-height: 1.5; min-width: 0; }
.ident__name { font-weight: 600; font-size: 13px; }
.ident__sub { font-size: 11.5px; color: var(--text-3); direction: ltr; text-align: right; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag--on { background: var(--success-soft); color: var(--success); }
.tag--off { background: var(--danger-soft); color: var(--danger); }
.tag--warn { background: var(--warning-soft); color: var(--warning); }

.metric { display: flex; flex-direction: column; line-height: 1.45; }
.metric b { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.metric span { font-size: 11px; color: var(--text-3); }

.note {
  padding: var(--s-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 12.5px; color: var(--text-2); line-height: 1.9;
}
.note--danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 24%, transparent);
  color: var(--danger);
}

.empty { padding: var(--s-12) var(--s-5); text-align: center; }
.empty h3 { font-size: 15px; margin-bottom: 6px; }
.empty p { font-size: 13px; color: var(--text-3); }

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  place-items: center;
  padding: var(--s-5);
  background: var(--overlay);
  backdrop-filter: blur(3px);
}
.modal.is-open { display: grid; }
.modal__box {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-pop);
  animation: pop var(--dur) var(--ease);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal__head {
  padding: var(--s-5);
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4);
}
.modal__head h3 { font-size: 16px; margin-bottom: 3px; }
.modal__head p { font-size: 12.5px; color: var(--text-3); direction: ltr; text-align: right; }
.modal__x {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 18px; line-height: 1;
  cursor: pointer;
}
.modal__x:hover { background: var(--surface-3); color: var(--text); }
.modal__body { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-5); }
.modal__foot {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border-soft);
  display: flex; justify-content: flex-end; gap: var(--s-2);
}

.mg-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-2);
}
.mg-stat {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  font-size: 12.5px;
}
.mg-stat span { color: var(--text-3); }
.mg-stat b { font-variant-numeric: tabular-nums; }

.mg-block {
  padding-top: var(--s-4);
  border-top: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: var(--s-3);
}
.modal__box--wide { max-width: 860px; }
.modal__box--wide .modal__body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4) var(--s-5);
  align-items: start;
}
.modal__box--wide .grid {
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.modal__box--wide .note { grid-column: 1 / -1; }
.modal__box--wide .mg-summary { grid-column: 1 / -1; }
.modal__box--wide .mg-block { padding-top: 0; border-top: 0; }
.modal__box--wide .mg-block--actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border-soft);
}
@media (max-width: 900px) {
  .modal__box--wide .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .modal__box--wide .modal__body,
  .modal__box--wide .grid,
  .modal__box--wide .mg-block--actions { grid-template-columns: 1fr; }
}
.mg-row { display: flex; gap: var(--s-2); }
.mg-row .input { flex: 1; }

#toasts {
  position: fixed;
  inset-block-end: var(--s-5);
  inset-inline-start: var(--s-5);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--s-2);
}
.toast {
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  font-size: 13px; font-weight: 600;
  max-width: 380px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  border: 1px solid transparent;
}
.toast.is-in { opacity: 1; transform: none; }
.toast--success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 26%, transparent); }
.toast--danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 26%, transparent); }
.toast--warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 26%, transparent); }

.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-5); }
.auth__box { width: 100%; max-width: 400px; }
.auth__brand { text-align: center; margin-bottom: var(--s-6); }
.auth__brand .brand__mark { margin: 0 auto var(--s-4); width: 52px; height: 52px; font-size: 24px; }
.auth__brand h1 { font-size: 19px; margin-bottom: 5px; }
.auth__brand p { font-size: 13px; color: var(--text-3); }
.auth .card { padding: var(--s-6); }
.auth .field + .field { margin-top: var(--s-4); }
.auth .btn { margin-top: var(--s-6); }
.setup-note {
  padding: var(--s-4);
  margin-bottom: var(--s-5);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--text-2);
}

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .shell { padding-inline: var(--s-4); }
  .top__in { padding-inline: var(--s-4); }
  .grid, .mg-summary { grid-template-columns: 1fr; }
  .stats { gap: var(--s-3); }
  .stat { padding: var(--s-4); }
  .stat__value { font-size: 22px; }
  .brand__sub, .who__name { display: none; }
  .search { max-width: none; }
  #toasts { inset-inline: var(--s-4); }
  .toast { max-width: none; }
}
