/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease, transform .06s ease;
}
.btn .ico { width: 18px; height: 18px; }
.btn:active:not([disabled]) { transform: translateY(1px); }
.btn[disabled] { opacity: .4; cursor: not-allowed; box-shadow: none; }

.btn-gold {
  background: var(--btn-gold);
  border-color: #6A4E0E;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 240, 200, .35), 0 1px 2px rgba(92, 67, 12, .25), 0 6px 16px rgba(143, 107, 31, .2);
}
.btn-gold:hover { background: var(--btn-gold-hover); }

.btn-danger, .btn-sell {
  background: linear-gradient(180deg, #BE2C23 0%, #A1211A 100%);
  border-color: #8E1C16;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 1px 2px rgba(120, 20, 15, .25);
}
.btn-danger:hover, .btn-sell:hover:not([disabled]) { background: linear-gradient(180deg, #C9342A 0%, #AA241C 100%); }
.btn-sell { padding: 0 16px; font-size: 15px; }

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

.btn-outline { background: #fff; border-color: var(--line-2); color: var(--gold-800); }
.btn-outline:hover { background: var(--gold-50); border-color: var(--gold-400); }

.btn-block { width: 100%; }

.icon-btn {
  width: 44px; height: 44px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.icon-btn .ico { width: 18px; height: 18px; }
.icon-btn:hover { border-color: var(--gold-400); background: var(--gold-50); color: var(--gold-800); }
.icon-btn.danger:hover { border-color: var(--red-line); background: var(--red-50); color: var(--red); }

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: var(--gold-800);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}
.link .ico { width: 18px; height: 18px; transition: transform .15s ease; }
.link:hover .ico { transform: translateX(-3px); }

/* ---------- cards & stats ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  position: relative;
  padding: 20px 22px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  top: 0; right: 0; left: 0;
  height: 2px;
  background: var(--metal);
  opacity: .8;
}
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text-2); }
.stat-label .ico { width: 18px; height: 18px; color: var(--gold-700); }
.stat-value { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.stat-value .num { font-size: 30px; font-weight: 600; line-height: 1.1; letter-spacing: -.01em; color: var(--text); }
.stat-value .unit { font-size: 15px; color: var(--text-3); }
.stat-sub { margin-top: 6px; font-size: 14px; color: var(--text-3); }

.val { display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.val .num { font-weight: 600; }
.unit { font-size: 14px; color: var(--text-3); font-weight: 400; }

.note, .banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 24px;
  border-radius: var(--radius-l);
  background: var(--gold-50);
  border: 1px solid var(--gold-200);
  color: var(--text-2);
  font-size: 15px;
}
.note .ico, .banner > .ico { width: 20px; height: 20px; color: var(--gold-700); }
.banner span { flex: 1; }
.banner .btn { flex: none; }

/* ---------- list card, toolbar, search, chips ---------- */
.list-card { overflow: hidden; }
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.search { position: relative; display: flex; align-items: center; flex: 1 1 300px; max-width: 440px; }
.search > .ico { position: absolute; right: 14px; width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%;
  height: 44px;
  padding: 0 44px 0 44px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 15px;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.search input::placeholder { color: var(--text-3); opacity: 1; }
.search input:focus-visible, .control input:focus-visible { outline: none; }
.control input::-webkit-calendar-picker-indicator { display: none !important; }
.search input:focus { background: #fff; border-color: var(--gold-500); box-shadow: var(--ring); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search-x {
  position: absolute;
  left: 0; top: 0;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; background: transparent;
  color: var(--text-3);
  cursor: pointer;
  border-radius: var(--radius);
}
.search-x:hover { color: var(--text); }
.search-x .ico { width: 16px; height: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--text-2);
  font-size: 15px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.chip:hover { border-color: var(--gold-400); color: var(--text); }
.chip .n { font-size: 14px; color: var(--text-3); }
.chip.on { background: var(--gold-100); border-color: var(--gold-400); color: var(--gold-900); font-weight: 700; }
.chip.on .n { color: var(--gold-800); }

.toolbar-meta { margin-inline-start: auto; font-size: 14px; color: var(--text-3); white-space: nowrap; }
.toolbar-meta .sep { margin: 0 4px; color: var(--gold-400); }

/* ---------- table ---------- */
.table-wrap { position: relative; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; }
.table th {
  padding: 12px 20px;
  text-align: right;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  height: 64px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--row-line);
  vertical-align: middle;
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: #FFFCF5; }
.table .c-name { white-space: normal; min-width: 170px; font-weight: 700; color: var(--text); }
.table .c-code { width: 1%; }
.table .c-date { color: var(--text-2); }
.table .c-date .time { margin-right: 10px; color: var(--text-3); }
.table .c-act { width: 1%; text-align: left; }
.table tr.is-out td { color: var(--text-3); }
.table tr.is-out .c-name { color: var(--text-3); font-weight: 400; }
.row-actions { display: inline-flex; align-items: center; gap: 8px; }

.code {
  display: inline-block;
  direction: ltr;
  unicode-bidi: isolate;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--gold-50);
  border: 1px solid var(--gold-200);
  color: var(--gold-800);
  font-family: "ZarixLatin", sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .06em;
  line-height: 1.45;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.tag-inventory { background: #FAF0D6; color: #6F520F; }
.tag-purchases { background: #F8E7E1; color: #85402E; }
.tag-coins { background: #EAEFF3; color: #3C4955; }

.badge-out {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-3);
  font-size: 14px;
}

.seller { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.seller .ico { width: 16px; height: 16px; color: var(--gold-700); }

.more { display: flex; justify-content: center; padding: 16px; border-top: 1px solid var(--line); }

/* ---------- empty state ---------- */
.empty { padding: 56px 24px 64px; text-align: center; }
.empty-ic {
  width: 72px; height: 72px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFFDF7 0%, #F4E8C8 100%);
  border: 1px solid var(--gold-200);
  color: var(--gold-700);
  box-shadow: 0 8px 20px rgba(143, 107, 31, .12);
}
.empty-ic .ico { width: 30px; height: 30px; }
.empty h3 { font-size: 19px; font-weight: 700; }
.empty p { max-width: 440px; margin: 6px auto 22px; color: var(--text-2); }

/* ---------- modal ---------- */
.modal-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  padding: 24px;
  overflow-y: auto;
  background: rgba(34, 27, 12, .38);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .18s ease;
}
.modal-back.in { opacity: 1; }
.modal {
  position: relative;
  width: 100%;
  max-width: 580px;
  margin: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-3);
  transform: translateY(10px) scale(.985);
  transition: transform .2s ease;
}
.modal-back.in .modal { transform: none; }
.modal::before {
  content: "";
  position: absolute;
  top: -1px; right: 28px; left: 28px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--metal);
}
.modal-sm { max-width: 480px; }
.modal-head { display: flex; align-items: center; gap: 14px; padding: 24px 24px 12px; }
.modal-ic {
  width: 44px; height: 44px;
  flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius);
  background: var(--gold-100);
  border: 1px solid var(--gold-200);
  color: var(--gold-800);
}
.tone-danger .modal-ic { background: var(--red-50); border-color: var(--red-line); color: var(--red); }
.modal-titles { flex: 1; min-width: 0; }
.modal-titles h2 { font-size: 20px; font-weight: 700; }
.modal-titles p { font-size: 14px; color: var(--text-3); }
.modal-x { border-color: transparent; margin-inline-start: auto; }
.modal-body { padding: 8px 24px 8px; }
.modal-foot { display: flex; gap: 12px; padding: 20px 24px 24px; }
.modal-foot .btn:first-child { min-width: 150px; }

/* ---------- forms ---------- */
.form-code {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: var(--gold-50);
  border: 1px dashed var(--gold-300);
  font-size: 15px;
  color: var(--text-2);
}
.form-code .ico { width: 18px; height: 18px; color: var(--gold-700); }
.form-code em { margin-inline-start: auto; font-style: normal; font-size: 14px; color: var(--text-3); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.field.full { grid-column: 1 / -1; }
.field label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-2);
}
.field .req { color: var(--gold-700); }
.field .opt { margin-inline-start: auto; font-size: 14px; font-weight: 400; color: var(--text-3); }
.control { position: relative; display: flex; align-items: center; }
.control input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: #FFFEFB;
  font-size: 16px;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.control input::placeholder { color: #9A8F7C; opacity: 1; }
.control input:focus { background: #fff; border-color: var(--gold-500); box-shadow: var(--ring); }
.control.has-suffix input { padding-left: 64px; }
.control.has-btn input { padding-left: 52px; }
.suffix { position: absolute; left: 14px; font-size: 14px; color: var(--text-3); pointer-events: none; }
.field-btn {
  position: absolute;
  left: 2px; top: 2px;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--gold-700);
  cursor: pointer;
}
.field-btn:hover { background: var(--gold-50); }
.field-msg { min-height: 24px; padding-top: 4px; font-size: 14px; line-height: 1.4; color: var(--text-3); }
.field.has-error input { border-color: #D77B72; box-shadow: 0 0 0 3px rgba(179, 38, 30, .12); }
.field.has-error .field-msg { color: var(--red); }

/* ---------- confirm ---------- */
.confirm-q { font-size: 20px; font-weight: 700; margin-bottom: 14px; color: var(--text); }
.confirm-item {
  padding: 16px 18px;
  border-radius: var(--radius-l);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.ci-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ci-name { font-size: 18px; font-weight: 700; color: var(--text); }
.ci-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 4px; font-size: 15px; color: var(--text-2); }
.confirm-note { display: flex; align-items: flex-start; gap: 8px; margin-top: 16px; font-size: 14px; color: var(--text-2); }
.confirm-note .ico { width: 18px; height: 18px; margin-top: 2px; color: var(--gold-700); }
.tone-danger .confirm-note .ico { color: var(--red); }

.qty-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 14px; margin-top: 16px; }
.qty-label { font-weight: 700; color: var(--text-2); font-size: 15px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; background: #fff; }
.stepper button {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0;
  background: var(--surface-2);
  color: var(--gold-800);
  cursor: pointer;
}
.stepper button:hover { background: var(--gold-100); }
.stepper button .ico { width: 18px; height: 18px; }
.stepper input {
  width: 64px; height: 44px;
  border: 0;
  border-inline: 1px solid var(--line-2);
  text-align: center;
  font-size: 18px;
  font-weight: 600;
}
.qty-max { font-size: 14px; color: var(--text-3); }
.qty-weight { margin-top: 10px; font-size: 15px; color: var(--text-2); }
.qty-weight b { color: var(--text); font-weight: 700; }

/* ---------- Jalali date picker ---------- */
.dp {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  width: 320px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-3);
}
.dp.up { top: auto; bottom: calc(100% + 8px); }
.dp.al { right: auto; left: 0; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-head strong { font-size: 16px; }
.dp-nav {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
}
.dp-nav:hover { border-color: var(--gold-400); color: var(--gold-800); }
.dp-nav .ico { width: 18px; height: 18px; }
.dp-week, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dp-week span { padding: 6px 0; font-size: 14px; color: var(--text-3); }
.dp-day {
  height: 40px;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  font-family: "ZarixLatin", sans-serif;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.dp-day:hover { background: var(--gold-50); }
.dp-day.today { box-shadow: inset 0 0 0 1px var(--gold-400); color: var(--gold-800); font-weight: 700; }
.dp-day.sel { background: var(--btn-gold); color: #fff; font-weight: 700; box-shadow: none; }
.dp-foot { display: flex; justify-content: center; margin-top: 8px; }
.dp-today {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--gold-800);
  font-weight: 700;
  cursor: pointer;
}
.dp-today:hover { background: var(--gold-50); }

/* ---------- toasts ---------- */
#toast-root {
  position: fixed;
  left: 24px; bottom: 24px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 440px;
  padding: 14px 18px;
  border-radius: var(--radius-l);
  background: #fff;
  border: 1px solid var(--gold-200);
  box-shadow: var(--shadow-2);
  font-size: 15px;
  color: var(--text);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .25s ease, transform .25s ease;
}
.toast.in { opacity: 1; transform: none; }
.toast-ic .ico { width: 20px; height: 20px; color: var(--gold-700); }
.toast-error { border-color: var(--red-line); }
.toast-error .toast-ic .ico { color: var(--red); }

/* ---------- backup ---------- */
.bk-text { color: var(--text-2); }
.bk-last {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 15px;
  color: var(--text-2);
}
.bk-last .ico { width: 18px; height: 18px; color: var(--gold-700); }
.bk-last b { color: var(--text); }
.bk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bk-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 18px;
  text-align: right;
  border-radius: var(--radius-l);
  border: 1px solid var(--line-2);
  background: #fff;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.bk-opt:hover { border-color: var(--gold-400); background: var(--gold-50); box-shadow: var(--shadow-2); }
.bk-opt b { font-size: 16px; color: var(--text); }
.bk-opt span:last-child { font-size: 14px; color: var(--text-3); }
.bk-ic {
  width: 40px; height: 40px;
  margin-bottom: 8px;
  display: grid; place-items: center;
  border-radius: var(--radius);
  background: var(--gold-100);
  color: var(--gold-800);
}
.bk-ic .ico { width: 20px; height: 20px; }
.bk-now { margin-top: 18px; font-size: 14px; color: var(--text-3); }
.bk-counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; }
.bk-counts li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 14px;
  color: var(--text-2);
}
.bk-counts b { color: var(--text); font-weight: 600; }
.confirm-item .bk-counts { margin-top: 12px; }
.confirm-item .bk-counts li { background: #fff; border: 1px solid var(--line); }

@media (max-width: 640px) {
  .modal-back { padding: 12px; }
  .modal-head { padding: 20px 18px 10px; }
  .modal-body { padding: 8px 18px; }
  .modal-foot { padding: 16px 18px 20px; flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .bk-grid { grid-template-columns: 1fr; }
  .toolbar { padding: 14px; }
  .search { max-width: none; flex-basis: 100%; }
  .toolbar-meta { margin-inline-start: 0; }
  #toast-root { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
  .table td, .table th { padding-left: 14px; padding-right: 14px; }
}
