@font-face {
  font-family: "IRANYekan";
  src: url("/fonts/iranyekan-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IRANYekan";
  src: url("/fonts/iranyekan-bold.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #fafbfc;
  --ink: #20242b;
  --muted: #747b87;
  --line: #e5e8ed;
  --line-strong: #d6dae1;
  --brand: #d33443;
  --brand-hover: #b92634;
  --green: #087a55;
  --green-soft: #e8f6f0;
  --red: #bd2d3c;
  --red-soft: #fbeaec;
  --blue: #2668a8;
  --blue-soft: #eaf2fb;
  --shadow: 0 8px 28px rgba(20, 27, 38, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: "IRANYekan", Tahoma, sans-serif;
  font-size: 14px;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.header-inner,
.shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  flex: 0 0 40px;
}

.brand-mark img {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand div > span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.header-actions,
.detail-actions,
.form-row,
.list-tools,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button,
.small-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
}

.button {
  min-height: 40px;
  padding: 0 15px;
  font-weight: 700;
}

.button.primary {
  background: var(--brand);
  color: white;
}

.button.primary:hover {
  background: var(--brand-hover);
}

.button.secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.button.secondary:hover {
  border-color: #aeb5c0;
  background: var(--surface-soft);
}

.button.quiet {
  color: var(--red);
}

#notifications-button {
  position: relative;
}

#notifications-button[data-count]:not([data-count=""])::after {
  content: attr(data-count);
  position: absolute;
  top: -8px;
  left: -7px;
  min-width: 20px;
  height: 20px;
  border: 2px solid white;
  border-radius: 10px;
  background: var(--brand);
  color: white;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--muted);
  font-size: 27px;
}

.icon-button:hover {
  background: #eef0f3;
}

.shell {
  padding: 28px 0 60px;
}

.add-panel,
.content-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.add-panel {
  margin-bottom: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-heading h1 {
  margin: 0 0 5px;
  font-size: 19px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.search span {
  color: var(--muted);
  font-size: 12px;
}

.field.full {
  margin-bottom: 14px;
}

.field.grow {
  flex: 1;
}

.field.compact {
  width: 160px;
}

input,
textarea,
select {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
}

input,
textarea {
  width: 100%;
  padding: 10px 12px;
}

select {
  padding: 0 12px;
}

textarea {
  min-height: 126px;
  resize: vertical;
  direction: ltr;
  text-align: left;
  line-height: 1.8;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #89929f;
  box-shadow: 0 0 0 3px rgba(38, 104, 168, 0.09);
}

.submit-button {
  align-self: end;
  min-width: 140px;
}

.overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.overview-item {
  min-height: 92px;
  padding: 19px 22px;
  border-left: 1px solid var(--line);
}

.overview-item:last-child {
  border-left: 0;
}

.overview-item span,
.overview-item strong {
  display: block;
}

.overview-item span {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.overview-item strong {
  font-size: 25px;
}

.overview-item.positive strong {
  color: var(--green);
}

.content-section {
  overflow: hidden;
}

.list-heading {
  align-items: flex-end;
  margin: 0;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.search {
  display: block;
}

.search span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.search input {
  width: 230px;
  min-height: 40px;
}

.list-tools select {
  min-height: 40px;
}

.product-item {
  border-bottom: 1px solid var(--line);
}

.product-group-heading {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: #f1f3f6;
}

.product-group-heading strong {
  font-size: 13px;
}

.product-group-heading span {
  color: var(--muted);
  font-size: 11px;
}

.product-item:last-child {
  border-bottom: 0;
}

.product-summary {
  display: grid;
  width: 100%;
  min-height: 88px;
  grid-template-columns: 24px minmax(280px, 1.8fr) minmax(150px, 0.8fr) minmax(130px, 0.7fr) 116px 72px;
  gap: 18px;
  align-items: center;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 15px 22px;
  text-align: right;
}

.product-summary:hover {
  background: #fbfcfd;
}

.product-item.expanded .product-summary {
  background: #fafbfc;
}

.expand-icon {
  color: var(--muted);
  font-size: 22px;
  transform: rotate(0);
  transition: transform 160ms ease;
}

.product-item.expanded .expand-icon {
  transform: rotate(180deg);
}

.product-identity,
.price-cell,
.seller-cell {
  min-width: 0;
}

.product-identity strong,
.product-identity span,
.price-cell small,
.price-cell strong,
.seller-cell small,
.seller-cell strong {
  display: block;
}

.product-identity strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-identity span,
.price-cell small,
.seller-cell small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.price-cell strong,
.seller-cell strong {
  margin-top: 3px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.numeric {
  white-space: nowrap;
}

.change,
.monitor-status,
.availability {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.change.increase {
  background: var(--red-soft);
  color: var(--red);
}

.change.decrease {
  background: var(--green-soft);
  color: var(--green);
}

.change.unchanged,
.change.neutral {
  background: #eef0f3;
  color: #68717d;
}

.monitor-status {
  min-width: 56px;
  background: #eef0f3;
  color: var(--muted);
}

.monitor-status.active {
  background: var(--green-soft);
  color: var(--green);
}

.product-detail {
  padding: 18px 22px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.detail-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 11px;
}

.detail-info a {
  color: var(--blue);
  text-decoration: none;
}

.seller-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.seller-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.seller-table th,
.seller-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}

.seller-table tr:last-child td {
  border-bottom: 0;
}

.seller-table th {
  background: #fafbfc;
  color: var(--muted);
  font-size: 11px;
}

.seller-table tbody tr:hover {
  background: #fcfcfd;
}

.seller-table tr.is-excluded {
  background: var(--green-soft);
  box-shadow: inset -3px 0 0 var(--green);
}

.seller-table tbody tr.is-excluded:hover {
  background: #ddf2e9;
}

.seller-table tr.is-excluded .seller-name strong,
.seller-table tr.is-excluded .numeric {
  color: var(--green);
}

.rank {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 5px;
  background: #eef0f3;
  font-weight: 700;
}

.seller-name strong,
.seller-name span {
  display: block;
}

.seller-name span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.availability.available {
  color: var(--green);
}

.availability.unavailable {
  color: var(--muted);
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
}

.small-button:hover:not(:disabled) {
  border-color: #aeb5c0;
}

.small-button.exclude-seller {
  color: var(--red);
}

.small-button.global-exclude-seller {
  border-color: #efc8cd;
  color: var(--red);
}

.global-label {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border-radius: 5px;
  background: #d6efe4;
  color: var(--green);
  padding: 0 9px;
  font-size: 10px;
  font-weight: 700;
}

.excluded-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 11px;
}

.excluded-chip {
  min-height: 28px;
  border: 1px solid #f0cdd1;
  border-radius: 5px;
  background: var(--red-soft);
  color: var(--red);
  padding: 0 9px;
}

.excluded-chip.global {
  border-color: #a8d9c5;
  background: var(--green-soft);
  color: var(--green);
}

.table-empty,
.empty-state,
.drawer-empty {
  color: var(--muted);
  text-align: center;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-content: center;
  gap: 6px;
}

.drawer {
  position: fixed;
  z-index: 50;
  top: 0;
  left: 0;
  width: min(420px, 92vw);
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 14px 0 40px rgba(20, 27, 38, 0.14);
  transform: translateX(-105%);
  transition: transform 190ms ease;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  position: sticky;
  top: 0;
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
}

.drawer-head strong,
.drawer-head span {
  display: block;
}

.drawer-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.notification-item {
  display: grid;
  grid-template-columns: 9px 1fr;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}

.notification-item > span {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
}

.decrease-dot {
  background: var(--green);
}

.increase-dot {
  background: var(--red);
}

.notification-item strong,
.notification-item span,
.notification-item small,
.notification-item time {
  display: block;
}

.notification-item div > span {
  margin: 3px 0 5px;
  color: var(--muted);
  font-size: 11px;
}

.notification-item small {
  color: var(--ink);
}

.notification-change {
  margin-top: 7px;
  font-weight: 700;
}

.notification-lowest {
  margin-top: 5px;
  border-radius: 5px;
  background: var(--green-soft);
  color: var(--green) !important;
  padding: 7px 9px;
}

.notification-item time {
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}

.drawer-empty {
  padding: 60px 20px;
}

.account-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.account-section h2 {
  margin: 0 0 12px;
  font-size: 14px;
}

.stack-form {
  display: grid;
  gap: 9px;
}

.user-list {
  margin: 16px -20px -18px;
  border-top: 1px solid var(--line);
}

.user-item {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}

.user-item strong,
.user-item span {
  display: block;
}

.user-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.logout-button {
  width: 100%;
}

.limited-user .admin-only,
.limited-user #manage-exclusions,
.limited-user #show-add,
.limited-user .delete,
.limited-user .exclude-seller,
.limited-user .global-exclude-seller,
.limited-user .restore-seller,
.limited-user .restore-global-inline {
  display: none !important;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(430px, 100%);
}

.auth-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
  color: inherit;
  text-decoration: none;
}

.auth-brand h1,
.auth-brand p {
  margin: 0;
}

.auth-brand h1 {
  font-size: 20px;
}

.auth-brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form .button {
  width: 100%;
  margin-top: 4px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 11px;
  text-align: center;
}

.global-exclusion-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.global-exclusion-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.global-exclusion-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.global-exclusion-title strong,
.global-exclusion-title span {
  display: block;
}

.global-exclusion-title span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.missing-products {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.missing-products summary {
  padding: 10px 12px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.missing-products ol {
  max-height: 260px;
  margin: 0;
  overflow-y: auto;
  padding: 4px 34px 12px 12px;
}

.missing-products li {
  padding: 5px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.missing-products p {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 11px;
}

.backdrop {
  position: fixed;
  z-index: 40;
  inset: 0;
  background: rgba(18, 22, 29, 0.32);
}

.toast-region {
  position: fixed;
  z-index: 70;
  right: 20px;
  bottom: 20px;
  display: grid;
  width: min(370px, calc(100vw - 40px));
  gap: 8px;
}

.toast {
  border: 1px solid #bfe3d3;
  border-radius: 7px;
  background: #f0faf6;
  box-shadow: var(--shadow);
  color: var(--green);
  padding: 13px 15px;
}

.toast.error {
  border-color: #efc8cd;
  background: #fff4f5;
  color: var(--red);
}

@media (max-width: 980px) {
  .product-summary {
    grid-template-columns: 24px minmax(240px, 1fr) 145px 120px 70px;
  }

  .product-group-heading {
    padding: 0 14px;
  }

  .seller-cell {
    display: none;
  }

  .detail-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .header-inner,
  .shell {
    width: min(100% - 24px, 1240px);
  }

  .header-inner {
    min-height: 64px;
  }

  .brand div > span,
  #notifications-button,
  #manage-exclusions {
    display: none;
  }

  .header-actions {
    gap: 5px;
  }

  .header-actions .button {
    min-height: 36px;
    padding: 0 10px;
    font-size: 11px;
  }

  .shell {
    padding-top: 16px;
  }

  .form-row,
  .list-heading,
  .list-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .field.compact,
  .search input,
  .list-tools select {
    width: 100%;
  }

  .overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-item {
    min-height: 82px;
    padding: 15px;
    border-bottom: 1px solid var(--line);
  }

  .overview-item:nth-child(2) {
    border-left: 0;
  }

  .overview-item:nth-child(n + 3) {
    border-bottom: 0;
  }

  .product-summary {
    min-height: 112px;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 14px;
  }

  .product-identity {
    grid-column: 2;
  }

  .price-cell {
    grid-column: 2;
  }

  .change-cell {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  .status-cell,
  .seller-cell {
    display: none;
  }

  .product-detail {
    padding: 14px;
  }

  .detail-actions .button,
  .detail-actions select {
    flex: 1 1 140px;
  }

  .seller-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .seller-table,
  .seller-table tbody,
  .seller-table tr,
  .seller-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .seller-table thead {
    display: none;
  }

  .seller-table tr {
    margin-bottom: 10px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
  }

  .seller-table tr.is-excluded {
    border-color: #a8d9c5;
    box-shadow: inset -3px 0 0 var(--green);
  }

  .seller-table td {
    display: grid;
    grid-template-columns: 92px 1fr;
    align-items: center;
    padding: 9px 12px;
  }

  .seller-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
  }

  .seller-table tr:last-child td {
    border-bottom: 1px solid var(--line);
  }

  .seller-table tr td:last-child {
    border-bottom: 0;
  }

  .row-actions {
    flex-wrap: wrap;
  }

  .global-exclusion-form {
    grid-template-columns: 1fr;
  }
}
