:root {
  --navy: #203052;
  --navy2: #2e456e;
  --ink: #17243d;
  --muted: #7b879b;
  --line: #e7ebf1;
  --bg: #f5f7fb;
  --white: #fff;
  --green: #24966a;
  --red: #c94c58;
  --radius: 15px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 14px;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  border: 0;
}
button:disabled {
  opacity: 0.6;
  cursor: wait;
}
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 15% 15%, #dfe7f4 0, transparent 35%),
    linear-gradient(135deg, #f8faff, #edf1f8);
}
.login-card {
  width: min(100%, 420px);
  background: #fff;
  border: 1px solid #e9edf4;
  border-radius: 22px;
  padding: 38px;
  box-shadow: 0 24px 70px #20305212;
}
.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--navy);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 22px;
  box-shadow: 0 8px 20px #20305230;
}
.brand-mark.small {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 22px;
  margin: 0;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  color: #8290a7;
  font-weight: 700;
  margin: 0 0 8px;
}
.login-card h1 {
  font-size: 23px;
  margin: 0 0 8px;
}
.login-card > p.muted {
  margin: 0 0 27px;
}
.login-card label,
.form-card label,
#entityFields label {
  display: block;
  font-weight: 600;
  margin: 16px 0 8px;
  color: #39465c;
}
.login-card input,
.form-card input,
.form-card select,
#entityFields input,
#entityFields select {
  width: 100%;
  height: 46px;
  border: 1px solid #dfe5ee;
  border-radius: 10px;
  padding: 0 13px;
  background: #fff;
  outline: none;
  color: var(--ink);
}
input:focus,
select:focus {
  border-color: #7e91b5 !important;
  box-shadow: 0 0 0 3px #2030520c;
}
.primary,
.secondary,
.danger {
  height: 42px;
  border-radius: 10px;
  padding: 0 17px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: 0.15s;
}
.primary {
  background: var(--navy);
  color: #fff;
}
.primary:hover {
  background: var(--navy2);
}
.secondary {
  background: #f0f3f8;
  color: #354663;
  border: 1px solid #e6ebf2;
}
.secondary:hover {
  background: #e8edf5;
}
.danger {
  background: #fff0f1;
  color: var(--red);
  border: 1px solid #f4d6d9;
}
.full {
  width: 100%;
  margin-top: 20px;
}
.text-button {
  background: none;
  color: var(--navy2);
  margin-top: 10px;
  padding: 8px;
}
.message {
  font-size: 12px;
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--red);
}
.message.success {
  color: var(--green);
}
.login-foot {
  border-top: 1px solid var(--line);
  margin-top: 25px;
  padding-top: 18px;
  text-align: center;
  color: #98a2b3;
  font-size: 11px;
}
.app-shell {
  min-height: 100vh;
}
.sidebar {
  width: 250px;
  position: fixed;
  inset: 0 0 0 auto;
  background: var(--navy);
  color: #fff;
  padding: 27px 18px;
  display: flex;
  flex-direction: column;
  z-index: 5;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 9px 34px;
}
.sidebar-brand strong {
  display: block;
  font-size: 16px;
}
.sidebar-brand small {
  display: block;
  color: #aab8d0;
  font-size: 11px;
  margin-top: 3px;
}
.nav-caption {
  font-size: 10px;
  color: #8596b5;
  padding: 0 13px 12px;
}
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 10px;
  color: #c5cfe0;
  background: transparent;
  text-align: right;
  margin-bottom: 5px;
  font-weight: 500;
}
.nav-item span {
  font-size: 19px;
  width: 22px;
  text-align: center;
}
.nav-item:hover {
  background: #ffffff0b;
}
.nav-item.active {
  background: #ffffff18;
  color: #fff;
  box-shadow: inset -3px 0 #91a8d1;
}
.sidebar-bottom {
  margin-top: auto;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 8px;
  border-top: 1px solid #ffffff19;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #43577c;
  display: grid;
  place-items: center;
}
.user-chip strong {
  display: block;
  font-size: 12px;
}
.user-chip small {
  display: block;
  font-size: 10px;
  color: #aab8d0;
  margin-top: 3px;
}
.logout-button {
  width: 100%;
  text-align: right;
  padding: 12px 10px;
  background: transparent;
  color: #b8c5d9;
  border-radius: 9px;
}
.logout-button:hover {
  background: #ffffff0b;
}
.main-content {
  margin-right: 250px;
  padding: 0 34px 40px;
  max-width: 1800px;
}
.topbar {
  height: 105px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.topbar-label {
  font-size: 11px;
  color: #97a2b4;
}
.topbar h2 {
  font-size: 22px;
  margin: 3px 0 0;
}
.topbar-status {
  font-size: 12px;
  color: #637087;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 9px 13px;
}
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #32b47e;
  margin-left: 7px;
}
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
}
.page-heading h3 {
  font-size: 19px;
  margin: 0 0 5px;
}
.page-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.heading-actions {
  display: flex;
  gap: 9px;
}
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 13px;
  width: min(360px, 100%);
  height: 42px;
  color: #99a4b5;
}
.search-box input {
  border: 0;
  outline: 0;
  flex: 1;
  min-width: 0;
  background: transparent;
}
.table-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
}
th {
  background: #fafbfd;
  color: #8792a4;
  font-weight: 600;
  font-size: 11px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 15px 20px;
  border-bottom: 1px solid #f0f2f6;
  font-size: 13px;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: #fcfdff;
}
.empty {
  text-align: center;
  color: #9aa5b5;
  padding: 45px !important;
}
.id-text {
  font-size: 11px;
  color: #8995a8;
  direction: ltr;
  display: inline-block;
}
.table-actions {
  display: flex;
  gap: 7px;
}
.table-actions button {
  background: #f3f5f9;
  color: #65728a;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
}
.table-actions button.delete {
  color: var(--red);
  background: #fff2f3;
}
.calc-layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.form-card,
.result-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.card-title {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid #f0f2f6;
  margin-bottom: 8px;
}
.title-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #edf1f8;
  color: var(--navy);
  display: grid;
  place-items: center;
  font-size: 20px;
}
.card-title h4 {
  margin: 0;
  font-size: 15px;
}
.card-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}
.optional {
  font-size: 10px;
  color: #9aa4b4;
  font-weight: 400;
  margin-right: 5px;
}
.field-hint {
  font-size: 11px;
  color: #8b96a7;
  margin: 8px 0 0;
}
.result-content {
  min-height: 300px;
}
.result-placeholder {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #9aa5b5;
}
.result-placeholder span {
  font-size: 40px;
  color: #d4dce8;
  margin-bottom: 14px;
}
.result-placeholder strong {
  font-size: 13px;
  color: #65728a;
}
.result-placeholder p {
  font-size: 11px;
  margin-top: 6px;
}
.global-message {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  background: #eaf7f0;
  color: #247b58;
}
.global-message.error {
  background: #fff0f1;
  color: #b63c48;
}
.result-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 15px 0;
}
.summary-box {
  flex: 1;
  min-width: 120px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfe;
}
.summary-box small {
  display: block;
  color: #8b96a7;
  font-size: 11px;
}
.summary-box strong {
  display: block;
  font-size: 19px;
  margin-top: 5px;
}
.result-json {
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 15px;
  overflow: auto;
  max-height: 420px;
  direction: ltr;
  text-align: left;
  font:
    12px/1.7 Consolas,
    monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.modal {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(460px, calc(100% - 30px));
  box-shadow: 0 25px 80px #10203d35;
}
.modal::backdrop {
  background: #17243d66;
  backdrop-filter: blur(3px);
}
.modal form {
  padding: 24px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 15px;
  margin-bottom: 15px;
}
.modal-head h3,
.confirm-modal h3 {
  margin: 0;
  font-size: 17px;
}
.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #f1f3f7;
  color: #69758a;
  font-size: 22px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 24px;
}
.confirm-modal p {
  color: #69758a;
  font-size: 13px;
}
.confirm-modal form {
  padding: 25px;
}
.confirm-modal .modal-actions {
  margin-top: 20px;
}
@media (max-width: 1000px) {
  .sidebar {
    width: 220px;
  }
  .main-content {
    margin-right: 220px;
    padding: 0 22px 30px;
  }
  .calc-layout {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 700px) {
  .sidebar {
    position: static;
    width: auto;
    height: auto;
    padding: 12px 14px;
  }
  .sidebar-brand {
    padding: 0 5px 12px;
  }
  .sidebar .nav-caption,
  .sidebar-bottom {
    display: none;
  }
  #mainNav {
    display: flex;
    gap: 5px;
    overflow: auto;
  }
  .nav-item {
    white-space: nowrap;
    width: auto;
    margin: 0;
    padding: 10px 12px;
    font-size: 12px;
  }
  .nav-item span {
    font-size: 16px;
  }
  .main-content {
    margin: 0;
    padding: 0 14px 25px;
  }
  .topbar {
    height: 78px;
    margin-bottom: 22px;
  }
  .topbar h2 {
    font-size: 19px;
  }
  .topbar-status {
    font-size: 10px;
  }
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .heading-actions {
    width: 100%;
  }
  .heading-actions button {
    flex: 1;
  }
  .toolbar {
    flex-wrap: wrap;
  }
  .search-box {
    width: 100%;
  }
  .table-card {
    overflow-x: auto;
  }
  table {
    min-width: 520px;
  }
  .form-card,
  .result-card {
    padding: 18px;
  }
  .login-card {
    padding: 28px 22px;
  }
  .login-card h1 {
    font-size: 21px;
  }
}

:root {
  --navy: #1c3153;
  --navy2: #34547c;
  --bg: #f4f7fb;
  --line: #e8edf4;
}
body {
  background: radial-gradient(ellipse at top left, #eaf1fb, transparent 45%), var(--bg);
}
.sidebar {
  background: linear-gradient(165deg, #1d3558, #172943);
  box-shadow: -8px 0 30px #182a4512;
}
.nav-item.active {
  background: #ffffff20;
  box-shadow: inset -3px 0 #7dd4ca;
}
.primary {
  box-shadow: 0 5px 12px #1c31531c;
}
.primary:hover { transform: translateY(-1px); }
.table-card, .form-card, .result-card {
  box-shadow: 0 8px 30px #20305209;
}
.table-card { overflow-x: auto; }
th {
  background: #f7f9fc;
  color: #728097;
  padding: 17px 20px;
  white-space: nowrap;
}
td { padding: 17px 20px; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: #f7faff; }
th:last-child, td:last-child { text-align: center; }
.id-text, .part-code {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}
.action-menu { display: inline-block; }
.action-menu summary {
  list-style: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #e8edf4;
  border-radius: 10px;
  background: #fff;
  color: #66758d;
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
}
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu summary:hover, .action-menu[open] summary { background: #eff4fa; color: var(--navy); }
.action-menu-list {
  position: fixed;
  z-index: 20;
  width: 140px;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: 0 12px 30px #1c315326;
}
.action-menu-list button {
  width: 100%;
  padding: 9px 11px;
  border-radius: 7px;
  background: transparent;
  color: #43536b;
  text-align: right;
}
.action-menu-list button:hover { background: #f3f6fa; }
.action-menu-list button.delete { color: var(--red); }
.action-menu-list button.delete:hover { background: #fff0f1; }
.form-card input[type="file"] {
  height: auto;
  min-height: 52px;
  padding: 7px;
  color: #6b788d;
  font-size: 12px;
  border: 1px dashed #c7d3e2;
  background: #f9fbfe;
}
.form-card input[type="file"]::file-selector-button {
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  margin-left: 10px;
  background: #e8eef7;
  color: #30496d;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.form-card input[type="file"]::file-selector-button:hover { background: #dce6f3; }
.result-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); }
.summary-box { min-width: 0; }
.summary-box .summary-name { font-size: 14px; overflow-wrap: anywhere; }
.summary-available { background: #f0faf5; border-color: #d9f0e4; }
.summary-available strong { color: #21825b; }
.summary-shortage { background: #fff5f5; border-color: #f8dfe1; }
.summary-shortage strong, .shortage-value { color: #c44e5b; }
.result-table-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 24px 0 12px; }
.result-table-heading span { color: var(--muted); font-size: 11px; }
.result-table-wrap { border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.result-table { min-width: 690px; }
.result-table th, .result-table td { padding: 14px 12px; white-space: nowrap; }
.result-table td:first-child { white-space: normal; min-width: 170px; }
.part-code { display: block; color: #96a1b1; font-size: 11px; margin-top: 4px; text-align: right; }
.shortage-value { font-weight: 700; }
.status-badge { display: inline-block; border-radius: 30px; padding: 5px 10px; font-size: 11px; font-weight: 600; }
.is-shortage { background: #fff0f1; color: #ba4654; }
.is-available { background: #eaf8f0; color: #238258; }
.is-unknown { background: #f0f3f7; color: #64748b; }
@media (max-width: 700px) {
  .result-table-heading { align-items: flex-start; flex-direction: column; }
  .result-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.bom-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.bom-list { min-width: 0; }
.bom-list-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 16px; }
.bom-list-heading h4 { margin: 0; font-size: 15px; }
.bom-list-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.bom-count { padding: 6px 12px; border-radius: 20px; background: #eaf0f8; color: #49617f; font-size: 11px; white-space: nowrap; }
.bom-edit-fields label { display: block; font-weight: 600; margin: 16px 0 8px; color: #39465c; }
.bom-edit-fields input { width: 100%; height: 46px; border: 1px solid #dfe5ee; border-radius: 10px; padding: 0 13px; color: var(--ink); }
@media (max-width: 1000px) {
  .bom-layout { grid-template-columns: 1fr; }
}

.brand-mark { background: #fff; border: 1px solid #e8edf4; padding: 9px; }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-mark.small { flex: 0 0 auto; padding: 7px; }
.sidebar-header { flex: 0 0 auto; }
.sidebar-menu { display: flex; flex: 1; min-height: 0; flex-direction: column; overflow-y: auto; }
.mobile-menu-toggle { display: none; }
.main-content, .page, .calc-layout, .form-card, .result-card, .result-content { min-width: 0; }
.table-card, .result-table-wrap { max-width: 100%; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
.table-card:focus-visible, .result-table-wrap:focus-visible, .mobile-menu-toggle:focus-visible { outline: 3px solid #80b9db; outline-offset: 2px; }
.modal { max-height: calc(100dvh - 30px); overflow-y: auto; }

@media (max-width: 700px) {
  .sidebar { padding: 12px 14px; }
  .sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .sidebar-brand { padding: 0; }
  .mobile-menu-toggle { display: flex; flex-direction: column; justify-content: center; gap: 5px; align-items: center; width: 44px; height: 44px; border-radius: 12px; background: #ffffff18; color: #fff; }
  .mobile-menu-toggle span { display: block; width: 20px; height: 2px; border-radius: 2px; background: currentColor; }
  .sidebar-menu { display: none; overflow: visible; padding-top: 14px; }
  .sidebar-menu.is-open { display: flex; }
  #mainNav { display: grid; gap: 5px; overflow: visible; }
  .nav-item { width: 100%; min-height: 44px; padding: 10px 13px; font-size: 13px; }
  .sidebar-bottom { display: block; margin-top: 10px; }
  .user-chip { padding: 12px 8px 6px; }
  .logout-button { min-height: 44px; }
  .main-content { width: 100%; padding-bottom: max(25px, env(safe-area-inset-bottom)); }
  .topbar { gap: 12px; }
  .page-heading, .heading-actions, .toolbar { min-width: 0; }
  .heading-actions button { min-width: 0; padding-inline: 10px; }
  .form-card input[type="file"] { min-width: 0; max-width: 100%; }
  .table-card table { min-width: 520px; }
  .result-table { min-width: 690px; }
  .table-card, .result-table-wrap { scrollbar-width: thin; scrollbar-color: #b5c4d5 #f2f5f9; }
}

.searchable-select { position: relative; min-width: 0; }
.searchable-select::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 18px;
  width: 7px;
  height: 7px;
  border-left: 2px solid #8291a5;
  border-bottom: 2px solid #8291a5;
  transform: rotate(-45deg);
  pointer-events: none;
}
.searchable-select .searchable-select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.form-card .searchable-select-input { padding-left: 38px; text-overflow: ellipsis; }
.searchable-select-input::placeholder { color: #9aa6b6; }
.searchable-select-list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: min(240px, 40vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
  background: #fff;
  border: 1px solid #e0e8f1;
  border-radius: 12px;
  box-shadow: 0 12px 30px #1c315326;
  scrollbar-width: thin;
  scrollbar-color: #b5c4d5 #f2f5f9;
}
.searchable-select.opens-up .searchable-select-list { top: auto; bottom: calc(100% + 6px); }
.searchable-select-option { padding: 10px 12px; border-radius: 8px; color: #34465f; cursor: pointer; overflow-wrap: anywhere; }
.searchable-select-option:hover, .searchable-select-option[aria-selected="true"] { background: #edf3fa; color: #1c3153; }
.searchable-select-hint { padding: 12px; color: #8794a6; font-size: 12px; text-align: center; }
@media (max-width: 700px) {
  .form-card .searchable-select-input { min-height: 48px; font-size: 16px; }
  .searchable-select-option { min-height: 46px; display: flex; align-items: center; }
}
