:root {
  --bg: #f4f7f6;
  --panel: #ffffff;
  --panel-2: #eef5f1;
  --ink: #1c2523;
  --muted: #66736f;
  --line: #dbe4e0;
  --brand: #0f7a66;
  --brand-2: #1f9a8a;
  --accent: #c6762a;
  --danger: #b73b45;
  --ok: #2d7d46;
  --shadow: 0 18px 45px rgba(22, 44, 37, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.purchase-entry-panel {
  display: none !important;
}

.inbound-manual-panel {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(15, 122, 102, 0.12), rgba(198, 118, 42, 0.08)),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 22px;
}

.login-page-form {
  display: grid;
  gap: 14px;
  padding: 0;
  border: 0;
  background: transparent;
}

.login-page-form label {
  display: grid;
  gap: 6px;
}

.login-page-form label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-page-form input {
  width: 100%;
  height: 42px;
  border-color: var(--line);
  background: #f9fbfa;
}

.login-page-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 2px;
}

.login-page-actions .primary-btn,
.login-page-actions .soft-btn {
  min-height: 42px;
}

.setup-admin-btn {
  width: 100%;
  min-height: 42px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell[hidden],
.login-screen[hidden] {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #14221f;
  color: #eef6f3;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e4f4ee;
  color: var(--brand);
}

.brand-mark svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

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

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

.brand div > span {
  margin-top: 2px;
  color: #a8bbb6;
  font-size: 12px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab,
.ghost-btn,
.soft-btn,
.primary-btn,
.icon-btn {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.nav-tab {
  width: 100%;
  padding: 10px 12px;
  justify-content: flex-start;
  color: #d6e4df;
  background: transparent;
}

.nav-tab:hover,
.nav-tab.active {
  background: #263a35;
  border-color: #38524b;
}

.nav-tab.locked,
.nav-tab:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.nav-tab.locked:hover,
.nav-tab:disabled:hover {
  background: transparent;
  border-color: transparent;
}

.icon {
  width: 22px;
  text-align: center;
}

.side-actions {
  margin-top: auto;
  display: grid;
  gap: 9px;
}

.ghost-btn {
  width: 100%;
  padding: 9px 10px;
  color: #ecf4f1;
  background: #223632;
  border-color: #344d47;
}

.ghost-btn:hover {
  background: #2e4741;
}

.file-action input {
  display: none;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.top-actions,
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.login-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.login-box input {
  width: 120px;
  height: 34px;
  border-color: transparent;
  background: #f6faf8;
}

.login-box .primary-btn {
  min-height: 34px;
  padding: 0 13px;
}

.login-status {
  min-height: 42px;
  padding: 5px 6px 5px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.login-status[hidden],
.login-box[hidden] {
  display: none;
}

.login-status span {
  max-width: 190px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-status .soft-btn {
  min-height: 30px;
  padding: 0 10px;
}

.search-wrap {
  min-width: min(360px, 100%);
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.soft-btn {
  padding: 0 13px;
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

.soft-btn:hover {
  border-color: #b8c8c2;
  background: #f9fbfa;
}

.soft-btn.active {
  border-color: #8fbdb3;
  background: #f2faf7;
  color: var(--brand);
}

.primary-btn {
  padding: 0 16px;
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  font-weight: 700;
}

.primary-btn:hover {
  background: #0b6656;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.work-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
  min-height: 126px;
  display: grid;
  gap: 6px;
}

.metric span,
.metric em,
.section-head p,
label span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.metric em {
  font-style: normal;
}

.metric.alert strong {
  color: var(--danger);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.overview-item {
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  display: grid;
  gap: 6px;
}

.overview-item span,
.overview-item em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.overview-item strong {
  font-size: 22px;
  line-height: 1.15;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.8fr);
  gap: 16px;
  margin: 16px 0;
}

.work-panel {
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head.split {
  align-items: center;
}

.pill,
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.pill {
  color: var(--brand);
  background: #e5f4ee;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.suggestion-controls label {
  width: 96px;
}

.suggestion-controls input {
  height: 36px;
}

label {
  display: grid;
  gap: 6px;
}

input,
select {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(31, 154, 138, 0.13);
}

.wide {
  grid-column: span 2;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  background: #fff;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  background: #eef5f1;
  color: #495853;
  font-size: 12px;
  font-weight: 800;
  z-index: 1;
}

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

tbody tr:hover {
  background: #f8fbfa;
}

.num {
  font-variant-numeric: tabular-nums;
}

.muted-text {
  color: var(--muted);
  font-size: 12px;
}

.status.ok {
  color: var(--ok);
  background: #e7f4eb;
}

.status.warn {
  color: var(--danger);
  background: #f9e9e8;
}

.status.in {
  color: var(--brand);
  background: #e5f4ee;
}

.status.out {
  color: var(--accent);
  background: #fbefe5;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.icon-btn {
  width: 34px;
  height: 34px;
  background: #f4f7f6;
  color: #2a3835;
  border-color: var(--line);
}

.icon-btn:hover {
  background: #e9f1ee;
}

.finance-detail-btn {
  color: var(--brand);
  font-size: 18px;
  font-weight: 800;
}

.danger-btn:hover {
  color: var(--danger);
  border-color: #e8b8bc;
  background: #fff4f4;
}

.stack-list {
  display: grid;
  gap: 10px;
}

.stack-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  display: grid;
  gap: 7px;
}

.stack-item strong {
  font-size: 15px;
}

.stack-item div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.import-help {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--muted);
  font-size: 13px;
}

.import-summary {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}

.import-summary.ok {
  border-color: #b9dec8;
  background: #eff8f2;
  color: var(--ok);
}

.import-summary.warn {
  border-color: #efc4c4;
  background: #fff5f4;
  color: var(--danger);
}

.import-preview {
  margin-bottom: 12px;
}

.import-preview table {
  min-width: 1060px;
  table-layout: fixed;
}

.import-preview th:nth-child(1),
.import-preview td:nth-child(1) {
  width: 74px;
}

.import-preview th:nth-child(2),
.import-preview td:nth-child(2) {
  width: 210px;
}

.import-preview th:nth-child(3),
.import-preview td:nth-child(3) {
  width: 140px;
}

.import-preview th:nth-child(4),
.import-preview td:nth-child(4) {
  width: 120px;
}

.import-preview th:nth-child(5),
.import-preview td:nth-child(5) {
  width: 130px;
}

.import-preview th:nth-child(6),
.import-preview td:nth-child(6) {
  width: 110px;
}

.import-preview th:nth-child(7),
.import-preview td:nth-child(7) {
  width: auto;
}

.import-warning-row {
  background: #fff8eb;
}

.import-warning-row:hover {
  background: #fff2da;
}

.import-warning-text {
  color: var(--accent);
  font-weight: 700;
}

.import-error-text {
  color: var(--danger);
  font-weight: 700;
}

.purchase-lines {
  margin-top: 12px;
  margin-bottom: 12px;
}

.image-field {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.image-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.image-field-head > span {
  color: var(--muted);
  font-size: 13px;
}

.image-paste-zone {
  min-height: 128px;
  padding: 14px;
  border: 1px dashed #aebfba;
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  text-align: center;
  outline: none;
}

.image-paste-zone:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(31, 154, 138, 0.13);
}

.image-paste-zone strong,
.image-paste-zone span {
  display: block;
}

.image-paste-zone span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.image-paste-zone img {
  max-width: min(520px, 100%);
  max-height: 260px;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: contain;
  cursor: zoom-in;
}

.purchase-lines table {
  min-width: 860px;
}

.purchase-lines select,
.purchase-lines input {
  min-width: 120px;
}

.line-total {
  font-weight: 800;
  white-space: nowrap;
}

.payment-image-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.payment-image-list[hidden] {
  display: none;
}

.payment-image-list.compact-list {
  margin-top: 6px;
}

.detail-payment-images {
  margin-top: 12px;
}

.payment-thumb {
  width: 56px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.thumb-button {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: transparent;
}

.image-preview-backdrop {
  position: fixed;
  inset: 0;
  padding: 24px;
  background: rgba(10, 18, 16, 0.72);
  display: grid;
  place-items: start center;
  overflow: auto;
  z-index: 45;
}

.image-preview-backdrop[hidden] {
  display: none;
}

.image-preview-panel {
  position: relative;
  width: max-content;
  height: max-content;
  margin: auto;
  padding: 14px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.image-preview-panel .icon-btn {
  position: absolute;
  right: 10px;
  top: 10px;
  background: #fff;
}

.image-preview-panel img {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100vw - 76px);
  max-height: calc(100vh - 76px);
  border-radius: 8px;
  object-fit: contain;
}

.detail-modal {
  width: min(1180px, 100%);
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.detail-summary article,
.detail-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.detail-summary article {
  padding: 13px;
  display: grid;
  gap: 5px;
}

.detail-summary span,
.detail-fields span {
  color: var(--muted);
  font-size: 13px;
}

.detail-summary strong {
  font-size: 18px;
}

.detail-block {
  margin-top: 12px;
  padding: 14px;
}

.detail-block h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.detail-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 14px;
}

.editable-fields {
  margin-bottom: 12px;
}

.editable-fields label,
.purchase-change-form .wide {
  display: grid;
  gap: 6px;
}

.editable-fields input,
.change-lines-wrap input,
.change-lines-wrap select,
.purchase-change-form textarea {
  width: 100%;
  min-width: 0;
}

.purchase-change-form textarea {
  resize: vertical;
}

.request-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.change-request-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.change-request-card + .change-request-card {
  margin-top: 10px;
}

.change-request-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.change-request-head div {
  display: grid;
  gap: 3px;
}

.change-request-head span,
.change-request-card p {
  color: var(--muted);
  font-size: 13px;
}

.change-request-image {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.change-list {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.change-list li {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto minmax(120px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: #f6faf8;
  font-size: 13px;
}

.danger-text {
  color: #a03535;
}

.payment-proof {
  display: block;
  max-width: 260px;
  max-height: 180px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
}

.batch-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-btn:disabled,
.soft-btn:disabled,
.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.eye-btn {
  color: var(--brand);
}

.hidden-product-row {
  color: #697873;
  background: #fbfcfc;
}

.hidden-product-row td {
  opacity: 0.78;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  padding: 22px;
  background: rgba(20, 34, 31, 0.38);
  display: grid;
  place-items: center;
  z-index: 30;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(1080px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(22, 44, 37, 0.25);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.modal-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.product-edit-modal {
  width: min(760px, 100%);
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-actions .soft-btn,
.modal-actions .primary-btn {
  width: auto;
  min-width: 120px;
}

.fixed-product {
  margin-bottom: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  display: grid;
  gap: 5px;
}

.fixed-product span,
.fixed-product div {
  color: var(--muted);
  font-size: 13px;
}

.fixed-product strong {
  font-size: 18px;
}

.quick-purchase-layout {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 12px;
  align-items: stretch;
}

.compact-payment {
  margin-top: 0;
  padding: 10px;
}

.compact-payment .image-field-head {
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
}

.compact-payment .filters {
  width: 100%;
}

.compact-payment .soft-btn {
  flex: 1;
  min-width: 0;
  padding: 0 8px;
}

.compact-payment .image-paste-zone {
  min-height: 96px;
  padding: 10px;
}

.compact-payment .image-paste-zone strong {
  font-size: 14px;
}

.compact-payment .image-paste-zone span {
  font-size: 12px;
}

.compact-payment .image-paste-zone img {
  max-height: 140px;
}

.quick-purchase-lines table {
  min-width: 810px;
  table-layout: fixed;
}

.quick-purchase-lines th:nth-child(1),
.quick-purchase-lines td:nth-child(1) {
  width: 118px;
}

.quick-purchase-lines th:nth-child(3),
.quick-purchase-lines td:nth-child(3),
.quick-purchase-lines th:nth-child(4),
.quick-purchase-lines td:nth-child(4),
.quick-purchase-lines th:nth-child(5),
.quick-purchase-lines td:nth-child(5) {
  width: 108px;
}

.quick-purchase-lines th:nth-child(6),
.quick-purchase-lines td:nth-child(6) {
  width: 120px;
}

.last-price-btn {
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid #b8c8c2;
  border-radius: 8px;
  background: #f7fbfa;
  color: var(--brand);
  font-weight: 800;
  white-space: nowrap;
}

.last-price-btn:hover {
  border-color: var(--brand-2);
  background: #eef8f5;
}

.last-price-empty {
  color: var(--muted);
}

.quick-purchase-lines input[name="quickQuantity"],
.quick-purchase-lines input[name="quickUnitPrice"] {
  width: 86px;
  min-width: 86px;
  padding: 0 8px;
  text-align: right;
}

.inline-purchase-change-form {
  margin-top: 12px;
}

.inline-purchase-change-form .quick-purchase-lines table {
  min-width: 900px;
}

.inline-purchase-change-form .quick-purchase-lines th:nth-child(1),
.inline-purchase-change-form .quick-purchase-lines td:nth-child(1) {
  width: 250px;
}

.inline-purchase-change-form .quick-purchase-lines th:nth-child(2),
.inline-purchase-change-form .quick-purchase-lines td:nth-child(2),
.inline-purchase-change-form .quick-purchase-lines th:nth-child(3),
.inline-purchase-change-form .quick-purchase-lines td:nth-child(3),
.inline-purchase-change-form .quick-purchase-lines th:nth-child(4),
.inline-purchase-change-form .quick-purchase-lines td:nth-child(4) {
  width: 118px;
}

.inline-purchase-change-form .quick-purchase-lines th:nth-child(5),
.inline-purchase-change-form .quick-purchase-lines td:nth-child(5) {
  width: 180px;
}

.inline-purchase-change-form .quick-purchase-lines select,
.inline-purchase-change-form .quick-purchase-lines input {
  width: 100%;
  min-width: 0;
}

.inline-purchase-change-form .quick-purchase-lines input[name="lineQuantity"],
.inline-purchase-change-form .quick-purchase-lines input[name="lineUnitPrice"] {
  text-align: right;
}

.inventory-check-wrap table {
  min-width: 1220px;
  table-layout: fixed;
}

.inventory-check-wrap th:nth-child(1),
.inventory-check-wrap td:nth-child(1) {
  width: 210px;
}

.inventory-check-wrap th:nth-child(2),
.inventory-check-wrap td:nth-child(2),
.inventory-check-wrap th:nth-child(3),
.inventory-check-wrap td:nth-child(3),
.inventory-check-wrap th:nth-child(4),
.inventory-check-wrap td:nth-child(4) {
  width: 118px;
}

.inventory-check-wrap th:nth-child(5),
.inventory-check-wrap td:nth-child(5),
.inventory-check-wrap th:nth-child(6),
.inventory-check-wrap td:nth-child(6) {
  width: 132px;
}

.inventory-check-wrap th:nth-child(7),
.inventory-check-wrap td:nth-child(7) {
  width: 150px;
}

.inventory-check-wrap th:nth-child(9),
.inventory-check-wrap td:nth-child(9) {
  width: 138px;
}

.inventory-check-wrap input,
.inventory-check-wrap select {
  height: 36px;
  min-width: 0;
  padding: 0 8px;
}

.inventory-check-wrap .inventory-check-confirm {
  width: 100%;
  min-height: 36px;
  padding: 0 8px;
  white-space: normal;
  line-height: 1.2;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #1c2523;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.finance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.finance-subnav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.purchase-subnav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.finance-subtab,
.purchase-subtab {
  min-height: 86px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: grid;
  gap: 6px;
  align-content: start;
  text-align: left;
}

.finance-subtab:hover,
.purchase-subtab:hover {
  border-color: #b8c8c2;
  background: #f7fbfa;
}

.finance-subtab.active,
.purchase-subtab.active {
  border-color: #8fbdb3;
  background: #f2faf7;
}

.finance-subtab strong,
.purchase-subtab strong {
  font-size: 20px;
}

.finance-subtab span,
.purchase-subtab span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.finance-view,
.purchase-view {
  display: none;
}

.finance-view.active,
.purchase-view.active {
  display: grid;
  gap: 16px;
}

.finance-advance-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.finance-view[data-finance-panel="summary"] .finance-metrics {
  margin-bottom: 0;
}

.finance-workspace {
  display: grid;
  grid-template-columns: minmax(340px, 0.9fr) minmax(0, 1.35fr);
  gap: 16px;
  align-items: start;
}

.finance-entry-panel,
.finance-summary-panel {
  min-height: 100%;
}

.finance-advance-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.finance-advance-form > .primary-btn.wide {
  grid-column: 1 / -1;
}

.finance-advance-layout .advance-side-panel {
  display: none;
}

.finance-summary-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: start;
}

.finance-summary-layout .finance-grid {
  grid-template-columns: 1fr;
}

.finance-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  display: grid;
  gap: 12px;
}

.finance-card span,
.finance-card dt {
  color: var(--muted);
  font-size: 12px;
}

.finance-card strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.finance-card dl {
  margin: 0;
  display: grid;
  gap: 8px;
}

.finance-card dl div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.finance-card dd {
  margin: 0;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.finance-card dd.negative {
  color: var(--danger);
}

.advance-side-panel {
  min-height: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.advance-side-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.advance-side-head span {
  font-weight: 800;
}

.advance-side-head small {
  color: var(--muted);
}

.advance-side-list {
  display: grid;
  gap: 8px;
  max-height: 310px;
  overflow: auto;
  padding-right: 2px;
}

.advance-link-card {
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
}

.advance-link-card:hover {
  border-color: #b8c8c2;
  background: #f7fbfa;
}

.advance-link-card span,
.advance-link-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.advance-link-card strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.advance-link-card em {
  grid-column: 1 / -1;
}

.row-highlight {
  animation: rowFlash 1.8s ease;
}

.finance-ledgers {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

@keyframes rowFlash {
  0%,
  100% {
    background: transparent;
  }

  18%,
  72% {
    background: #fff3d8;
  }
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.account-form {
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
}

.permission-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.permission-field > span {
  color: var(--muted);
  font-size: 13px;
}

.permission-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.permission-head > span {
  color: var(--muted);
  font-size: 13px;
}

.admin-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-option input,
.permission-row input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.permission-matrix {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.permission-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 72px 72px;
  align-items: center;
  min-height: 34px;
  border-top: 1px solid var(--line);
}

.permission-row:first-child {
  border-top: 0;
}

.permission-row.header {
  background: #eef5f1;
  color: #495853;
  font-size: 13px;
  font-weight: 800;
}

.permission-row span,
.permission-row label {
  padding: 8px 10px;
}

.permission-row label {
  display: flex;
  justify-content: center;
}

.account-form.admin-selected .permission-matrix {
  opacity: 0.62;
}

.binding-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.binding-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.binding-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

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

.binding-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.compact-empty {
  padding: 14px;
  text-align: left;
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-tabs,
  .side-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid,
  .overview-grid,
  .finance-subnav,
  .finance-advance-layout,
  .finance-workspace,
  .finance-summary-layout,
  .finance-grid,
  .dashboard-layout,
  .form-grid,
  .detail-summary,
  .detail-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .binding-list,
  .inline-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finance-advance-layout {
    grid-template-columns: 1fr;
  }

  .purchase-subnav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .section-head,
  .section-head.split {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .filters,
  .search-wrap,
  .login-box,
  .login-status {
    width: 100%;
  }

  .login-box {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
  }

  .login-box input {
    width: 100%;
  }

  .login-status {
    justify-content: space-between;
  }

  .metric-grid,
  .overview-grid,
  .finance-subnav,
  .purchase-subnav,
  .finance-advance-layout,
  .finance-workspace,
  .finance-advance-form,
  .finance-summary-layout,
  .finance-grid,
  .dashboard-layout,
  .form-grid,
  .nav-tabs,
  .side-actions,
  .detail-summary,
  .detail-fields {
    grid-template-columns: 1fr;
  }

  .binding-list,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: span 1;
  }

  .batch-footer {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .quick-purchase-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .login-box {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .top-actions,
  .no-print,
  .toast,
  .image-preview-backdrop[hidden] {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .main {
    padding: 0;
  }

  .work-panel,
  .metric,
  .detail-summary article,
  .detail-block {
    box-shadow: none;
    break-inside: avoid;
  }

  .tab-panel:not(.active) {
    display: none !important;
  }

  .modal-backdrop:not([hidden]) {
    position: static;
    padding: 0;
    background: transparent;
    display: block;
  }

  .modal-backdrop:not([hidden]) .modal-panel {
    width: 100%;
    max-height: none;
    overflow: visible;
    border: 0;
    box-shadow: none;
  }

  body:has(.modal-backdrop:not([hidden])) .app-shell {
    display: none !important;
  }

  th {
    position: static;
  }
}
