/* Existing page components use the compatibility aliases in tokens.css. */
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--ivory);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
[hidden] {
  display: none !important;
}
h1,
h2,
h3,
p {
  margin: 0;
}
.muted {
  color: var(--ink3);
}
.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.12s,
    background 0.15s;
  white-space: nowrap;
}
.btn:active {
  transform: scale(0.97);
}
.btn--primary {
  background: var(--sun);
  color: var(--g950);
  box-shadow: 0 6px 14px -8px rgba(214, 160, 20, 0.8);
}
.btn--green {
  background: var(--g700);
  color: var(--ivory);
}
.btn--ghost,
.btn--secondary {
  background: var(--g50);
  color: var(--g800);
}
dialog {
  direction: rtl;
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border: 0;
  border-radius: 18px;
  padding: 24px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.25);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}
dialog form {
  display: grid;
  gap: 14px;
}
dialog .manual-error:not(:empty) {
  color: var(--red);
  background: var(--red50);
  padding: 10px;
  border-radius: 10px;
}
dialog .manual-error:empty {
  display: none;
}
.btn--danger {
  background: var(--red50);
  color: var(--red);
}
.btn--block {
  width: 100%;
}
.btn--sm {
  height: 36px;
  padding: 0 14px;
  font-size: 14px;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--ink2);
}
.icon-btn:hover {
  background: var(--ivory2);
}
.icon-btn--danger {
  color: var(--red);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* forms */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink2);
}
input,
select,
textarea {
  height: 44px;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  font-weight: 500;
  color: var(--ink);
  outline: none;
}
textarea {
  height: auto;
  min-height: 70px;
  padding: 10px 12px;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--g700);
  box-shadow: 0 0 0 3px var(--g100);
}
input[type='number'],
input[type='date'] {
  direction: ltr;
  text-align: right;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid .full {
  grid-column: 1 / -1;
}
.form-error {
  color: var(--red);
  background: var(--red50);
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
}
.hint {
  font-size: 13px;
  color: var(--ink3);
  font-weight: 500;
}
label.req {
  position: relative;
}
.req::after {
  content: '*';
  color: var(--red);
  position: absolute;
  top: 0;
  left: 0;
  font-size: 16px;
}

/* switch */
.switch {
  position: relative;
  width: 50px;
  height: 28px;
  flex: none;
  cursor: pointer;
}
.switch input {
  opacity: 0;
  position: absolute;
  inset: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
  width: 100%;
  height: 100%;
}
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--line2);
  transition: 0.2s;
}
.switch span::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: 0.2s;
}
.switch input:checked + span {
  background: var(--g700);
}
.switch input:checked + span::after {
  right: 25px;
}
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

/* login */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(60rem 40rem at 50% 20%, #eaf3ec, transparent 70%), var(--ivory);
}
.login__card {
  width: min(400px, 100%);
  background: var(--paper);
  border-radius: 22px;
  padding: 32px 28px;
  box-shadow: var(--sh);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.login__card label {
  text-align: right;
}
.login__logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  align-self: center;
}
.login__card h1 {
  font-size: 24px;
  color: var(--g900);
}

/* shell */
.shell {
  display: flex;
  min-height: 100vh;
}
.side {
  width: 240px;
  flex: none;
  background: var(--g900);
  color: var(--ivory);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
}
.side__brand img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
}
.side__brand strong {
  display: block;
  font-size: 18px;
}
.side__brand span {
  font-size: 13px;
  opacity: 0.7;
}
.side__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.side__toggle {
  display: none;
}
.btn:disabled,
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 3px;
}
.side__nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  color: rgba(251, 247, 239, 0.82);
  text-decoration: none;
  font-weight: 600;
}
.side__nav a svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.side__nav a:hover {
  background: rgba(255, 255, 255, 0.06);
}
.side__nav a.is-on {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: inset -3px 0 0 var(--sun);
}
.side__nav a.is-on svg {
  color: var(--sun);
}
.side__foot {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.side__link {
  color: var(--sun);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 0 8px;
}
.side .btn--ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ivory);
}
.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 60px;
}

/* page header */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: 26px;
  color: var(--g900);
}
.page-head p {
  color: var(--ink3);
  margin-top: 2px;
}
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.card {
  background: var(--paper);
  border-radius: var(--r);
  box-shadow: var(--sh);
  border: 1px solid rgba(230, 222, 206, 0.6);
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}
.card__head h2 {
  font-size: 17px;
}

/* chips / segmented */
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  font-weight: 600;
  cursor: pointer;
  color: var(--ink2);
}
.chip.is-on {
  background: var(--g900);
  border-color: var(--g900);
  color: #fff;
}

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.kpi__value {
  font-size: 24px;
  font-weight: 800;
  color: var(--g900);
}
.kpi__sub {
  font-size: 13px;
  color: var(--ink3);
}
.kpi--total {
  background: var(--g900);
  border-color: var(--g900);
}
.kpi--total .kpi__label,
.kpi--total .kpi__sub {
  color: rgba(251, 247, 239, 0.75);
}
.kpi--total .kpi__value {
  color: var(--sun);
  font-size: 28px;
}
.kpi--profit .kpi__value {
  color: var(--g700);
}
.kpi--loss .kpi__value {
  color: var(--red);
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* tables */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 12px 16px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  font-size: 13px;
  color: var(--ink3);
  font-weight: 600;
  background: #fdfbf6;
  white-space: nowrap;
}
tr:last-child td {
  border-bottom: 0;
}
tfoot td {
  font-weight: 800;
  background: var(--g50);
  color: var(--g900);
  border-top: 2px solid var(--g100);
}
.thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--g700);
  object-fit: contain;
  padding: 3px;
  display: block;
}
.thumb--lg {
  width: 64px;
  height: 64px;
}
.name {
  font-weight: 700;
  min-width: 170px;
}
.name small {
  display: block;
  font-weight: 500;
  color: var(--ink3);
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
.tag--fib {
  background: var(--sun100);
  color: #7a5a00;
}
.tag--card {
  background: var(--blue50);
  color: var(--blue);
}
.tag--green {
  background: var(--g100);
  color: var(--g800);
}
.tag--grey {
  background: var(--ivory2);
  color: var(--ink3);
}
.tag--red {
  background: var(--red50);
  color: var(--red);
}
.tag--sun {
  background: var(--sun100);
  color: #7a5a00;
}
.pos {
  color: var(--g700);
  font-weight: 700;
}
.neg {
  color: var(--red);
  font-weight: 700;
}
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink3);
}
.grid2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  align-items: start;
}
.mt {
  margin-top: 18px;
}

/* product list */
.prod-row.is-off td {
  opacity: 0.55;
}
.prod-row.is-off td:last-child,
.prod-row.is-off td.td-switch {
  opacity: 1;
}
.actions {
  display: flex;
  gap: 6px;
  justify-content: flex-start;
}
.search {
  width: 240px;
}

/* banners */
.banners {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.banner {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.banner__preview {
  height: 140px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  color: var(--ivory);
}
.banner__preview.green {
  background: var(--g800);
}
.banner__preview.amber {
  background: var(--g950);
}
.banner__preview.berry {
  background: #f6e9c4;
  color: var(--g950);
}
.banner__preview h3 {
  font-size: 17px;
  line-height: 1.4;
}
.banner__preview p {
  font-size: 12.5px;
  opacity: 0.8;
  margin-top: 4px;
}
.banner__preview img {
  width: 120px;
  height: 110px;
  object-fit: contain;
  flex: none;
}
.banner__body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.banner__dates {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink2);
  gap: 8px;
  flex-wrap: wrap;
}
.banner__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.note {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--sun100);
  color: #5e4600;
  font-size: 14px;
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
}

/* image picker */
.picker {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1.5px dashed var(--line2);
  border-radius: 12px;
  background: #fdfbf6;
}
.picker img {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  object-fit: contain;
  background: var(--g700);
  padding: 4px;
  flex: none;
}
.picker__ph {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  background: var(--ivory2);
  display: grid;
  place-items: center;
  color: var(--ink3);
  font-size: 12px;
  text-align: center;
  flex: none;
}

/* modal & toast */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(11, 42, 23, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
}
.modal__card {
  width: min(680px, 100%);
  background: var(--paper);
  border-radius: 20px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.4);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal__head h2 {
  font-size: 19px;
  color: var(--g900);
}
#modalBody {
  padding: 20px 22px;
  overflow-y: auto;
}
.modal__foot {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
}
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--g900);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4);
}
.toast.is-error {
  background: var(--red);
}
.dashboard-loading,
.dashboard-error {
  padding: 24px;
}
.dashboard-loading {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dashboard-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--g100);
  border-top-color: var(--g700);
  border-radius: 50%;
  animation: dashboard-spin 0.8s linear infinite;
}
@keyframes dashboard-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .dashboard-spinner {
    animation-duration: 2s;
  }
}

@media (max-width: 860px) {
  .shell {
    flex-direction: column;
  }
  .side {
    width: auto;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 10px;
    gap: 8px;
    overflow-x: auto;
    flex-wrap: wrap;
  }
  .side__brand {
    padding: 0;
  }
  .side__brand div,
  .side__link {
    display: none;
  }
  .side__nav {
    display: none;
    flex-direction: column;
    flex: 1 0 100%;
  }
  .side.is-expanded .side__nav {
    display: flex;
  }
  .side__toggle {
    display: inline-flex;
  }
  .side__nav a {
    padding: 10px 12px;
    white-space: nowrap;
  }
  .side__foot {
    flex-direction: row;
  }
  .side__foot .btn {
    width: auto;
  }
  .main {
    padding: 18px 14px 40px;
  }
  .grid2,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .search {
    width: 100%;
  }
}

/* categories */
.cat-ico {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--g50);
  color: var(--g700);
  display: grid;
  place-items: center;
}
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
}
.icon-pick {
  height: 56px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--g700);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-pick.is-on {
  border-color: var(--g900);
  background: var(--g50);
  box-shadow: 0 0 0 3px var(--sun100);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.system-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}
.system-card {
  padding: 18px;
}
.system-card h2 {
  margin: 0 0 12px;
  font-size: 17px;
}
.system-card p {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 9px 0;
}
.system-alert {
  margin-bottom: 16px;
  padding: 14px 18px;
  border: 1px solid var(--red);
  border-radius: 14px;
  background: var(--red50);
  color: var(--red);
}
.system-subhead {
  margin-top: 26px;
}

/* storage quota meter */
.storage-meter {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.04);
  display: grid;
  gap: 6px;
  font-size: 12px;
}
.storage-label {
  font-weight: 700;
}
.storage-bar {
  height: 8px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.1);
  overflow: hidden;
}
.storage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #1f7a4d;
}
.storage-bar--orange span {
  background: #e88a1a;
}
.storage-bar--red span {
  background: #d23b3b;
}
.storage-card .storage-bar {
  height: 14px;
}
.storage-text {
  direction: ltr;
  text-align: right;
}

.log-stack {
  max-width: 640px;
  max-height: 240px;
  overflow: auto;
  direction: ltr;
  text-align: left;
  font-size: 11px;
  white-space: pre-wrap;
}
