:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f4f7f8;
  color: #17212b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f7f8;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: #146c64;
  color: #fff;
  cursor: pointer;
  font-weight: 650;
  padding: 10px 14px;
}

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

.ghost {
  background: #e7eef0;
  color: #1f3438;
}

.hidden {
  display: none !important;
}

.login-screen {
  align-items: center;
  display: flex;
  min-height: 100vh;
  padding: 32px;
}

.login-screen > div {
  max-width: 520px;
}

.login-screen h1,
.topbar h1 {
  font-size: 34px;
  line-height: 1.15;
  margin: 8px 0;
}

.eyebrow {
  color: #146c64;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.muted,
.error,
.message {
  color: #65737b;
}

.error {
  color: #b42318;
}

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

.sidebar {
  background: #17313a;
  color: #f7fafb;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
}

.sidebar-brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-height: 52px;
}

.sidebar-brand .eyebrow {
  color: #8dd1c8;
}

.sidebar-brand strong {
  display: block;
  font-size: 16px;
  margin-top: 3px;
}

.brand-mark {
  align-items: center;
  background: #20a090;
  border-radius: 8px;
  display: inline-flex;
  font-size: 20px;
  font-weight: 800;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  background: transparent;
  border-radius: 6px;
  color: #dce8eb;
  font-weight: 650;
  padding: 11px 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #e7f5f3;
  color: #102a2f;
}

.app-content {
  min-width: 0;
  padding: 20px;
}

.page {
  display: none;
  margin-top: 16px;
}

.page.active {
  display: block;
}

.topbar,
.panel,
.metrics > div {
  background: #fff;
  border: 1px solid #dbe5e7;
  border-radius: 8px;
}

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

.topbar h1 {
  font-size: 26px;
}

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

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

.metrics > div {
  padding: 16px;
}

.metrics span {
  color: #65737b;
  display: block;
  font-size: 13px;
}

.metrics strong {
  display: block;
  font-size: 28px;
  margin-top: 6px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 18px;
  margin: 0;
}

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

label {
  color: #3b4a50;
  display: grid;
  font-size: 13px;
  gap: 6px;
}

input,
select,
textarea {
  border: 1px solid #cbd8dc;
  border-radius: 6px;
  color: #17212b;
  min-width: 0;
  padding: 9px 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.search-select-shell {
  display: block;
  min-width: 0;
  position: relative;
  width: 100%;
}

.search-select-native {
  clip-path: inset(50%);
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  width: 1px;
}

.search-select-input {
  background: #fff;
  padding-right: 30px;
}

.search-select-input:disabled {
  background: #f1f5f5;
  color: #65737b;
}

.search-select-shell::after {
  border: solid #65737b;
  border-width: 0 1.5px 1.5px 0;
  content: '';
  height: 7px;
  pointer-events: none;
  position: absolute;
  right: 13px;
  top: calc(50% - 5px);
  transform: rotate(45deg);
  width: 7px;
}

.search-select-popup {
  background: #fff;
  border: 1px solid #b8cdd0;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(15, 31, 36, 0.17);
  overflow-y: auto;
  position: fixed;
  z-index: 100;
}

.search-select-option {
  background: #fff;
  border-radius: 0;
  color: #17212b;
  display: block;
  font-weight: 400;
  padding: 9px 11px;
  text-align: left;
  width: 100%;
}

.search-select-option:hover,
.search-select-option.active {
  background: #e7f5f3;
  color: #102a2f;
}

.search-select-empty {
  color: #65737b;
  padding: 10px 11px;
}

.wide {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.batch-picker,
.trace-panel {
  border: 1px solid #e5ecee;
  border-radius: 8px;
  margin-top: 14px;
  padding: 14px;
}

.batch-toolbar,
.sn-search {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 320px) auto;
  margin-bottom: 12px;
}

.batch-toolbar h3 {
  font-size: 16px;
  margin: 0 0 4px;
}

.batch-toolbar p {
  margin: 0;
}

.compact-table table {
  min-width: 760px;
}

.batch-quantity {
  max-width: 130px;
}

.trace-panel {
  margin-top: 18px;
}

.trace-summary {
  background: #f7fafb;
  border: 1px solid #e5ecee;
  border-radius: 8px;
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 12px;
}

.settings-panel {
  margin-top: 14px;
}

.settings-panel:first-child,
.movements-panel {
  margin-top: 0;
}

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

.settings-form {
  border: 1px solid #e5ecee;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 14px;
}

.check-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

.check-row input {
  width: auto;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 920px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid #e5ecee;
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #65737b;
  font-size: 12px;
  font-weight: 750;
}

td {
  font-size: 13px;
}

.pill {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
}

.pill-in {
  background: #dcfce7;
  color: #166534;
}

.pill-out {
  background: #fee2e2;
  color: #991b1b;
}

.pill-accounted {
  background: #dcfce7;
  color: #166534;
}

.pill-pending {
  background: #f1f5f9;
  color: #64748b;
}

.table-action {
  border-radius: 5px;
  font-size: 12px;
  padding: 5px 8px;
}

.icon-actions {
  align-items: center;
  display: inline-flex;
  gap: 5px;
  white-space: nowrap;
}

.icon-action {
  align-items: center;
  background: #e7f5f3;
  color: #146c64;
  display: inline-flex;
  height: 30px;
  justify-content: center;
  padding: 5px;
  width: 30px;
}

.icon-action:hover {
  background: #d3eeea;
}

.icon-action.danger {
  background: #fff0ef;
  color: #bd3d36;
}

.icon-action.danger:hover {
  background: #ffe1df;
}

.icon-action svg {
  height: 17px;
  width: 17px;
}

.shelf-list-item {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 5px;
}

.movement-table-wrap {
  width: 100%;
}

.movement-table {
  min-width: 0;
  table-layout: fixed;
}

.movement-table th,
.movement-table td {
  font-size: 12px;
  overflow-wrap: anywhere;
  padding-left: 6px;
  padding-right: 6px;
}

.movement-table td:nth-child(5),
.movement-table td:nth-child(6),
.movement-table td:nth-child(9),
.movement-table td:nth-child(10),
.movement-table td:nth-child(13),
.movement-table td:nth-child(15) {
  overflow-wrap: normal;
}

.movement-table td:nth-child(9),
.movement-table td:nth-child(10) {
  white-space: nowrap;
}

.movement-col-time { width: 7%; }
.movement-col-scenario { width: 4%; }
.movement-col-code { width: 7%; }
.movement-col-name { width: 7%; }
.movement-col-direction { width: 3%; }
.movement-col-quantity { width: 4%; }
.movement-col-storage { width: 7%; }
.movement-col-supplier { width: 8%; }
.movement-col-amount { width: 6%; }
.movement-col-unit-price { width: 4%; }
.movement-col-handler { width: 5%; }
.movement-col-project { width: 5%; }
.movement-col-purpose { width: 4%; }
.movement-col-accounting { width: 6%; }
.movement-col-note { width: 4%; }
.movement-col-action { width: 6%; }

.movements-panel {
  margin-top: 0;
}

.movement-filters {
  border: 1px solid #e5ecee;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
}

.filter-fields {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 1.1fr) minmax(140px, 0.9fr) minmax(180px, 1fr) minmax(180px, 1fr);
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-panel {
  margin-top: 16px;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.modal {
  align-items: center;
  background: rgba(15, 31, 36, 0.42);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 20;
}

.modal-panel {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(15, 31, 36, 0.22);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px;
  width: min(1100px, 100%);
}

.finance-voucher-panel .panel-head {
  margin-bottom: 8px;
}

.voucher-form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 260px) minmax(160px, 220px) minmax(260px, 1fr);
  margin: 14px 0;
}

.voucher-edit-table {
  min-width: 980px;
}

.voucher-edit-table input,
.voucher-edit-table select {
  padding: 7px 8px;
}

.sn-print-panel {
  width: min(960px, 100%);
}

.print-status {
  background: #17313a;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(15, 31, 36, 0.24);
  color: #fff;
  font-size: 14px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 14px;
  position: fixed;
  right: 16px;
  top: 16px;
  z-index: 100;
}

.print-status.error {
  background: #ad332d;
}

.sn-print-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1.2fr) minmax(220px, 1.2fr) minmax(120px, 0.7fr) minmax(120px, 0.7fr);
  margin: 14px 0;
}

.sn-list {
  display: grid;
  gap: 4px;
}

.sn-print-count {
  display: block;
  margin-top: 4px;
}

.voucher-confirm-footer {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

@media (max-width: 980px) {
  .workspace {
    display: block;
  }

  .sidebar {
    gap: 12px;
    padding: 12px;
  }

  .side-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .app-content {
    padding: 12px;
  }

  .topbar,
  .userbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics,
  .form-grid,
  .settings-grid,
    .settings-form,
    .filter-fields,
    .voucher-form-grid,
    .sn-print-grid,
    .batch-toolbar,
    .sn-search {
    grid-template-columns: 1fr;
  }

  .voucher-confirm-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .login-screen h1,
  .topbar h1 {
    font-size: 26px;
  }
}

.movement-metadata-panel { width: min(560px, 100%); }
.material-name-matches { display: block; margin-top: 6px; padding: 10px; border: 1px solid #e3d4a0; border-radius: 6px; background: #fffbee; max-height: 240px; overflow-y: auto; font-size: 13px; }
.material-match-hint { display: block; color: #75571a; margin-bottom: 6px; }
.material-name-match { display: block; padding: 6px 0; border-top: 1px solid #ece3c6; }
.material-name-match .muted { display: block; margin-top: 3px; }

.movement-col-original { width: 6%; }
.movement-col-confirmation { width: 7%; }
.movement-table { min-width: 1450px; }
.confirmation-finance-controls { display:flex; align-items:flex-end; flex-wrap:wrap; gap:10px; margin:12px 0; padding:12px; background:#f4f8f9; border-radius:6px; }
.confirmation-finance-controls label { min-width:170px; }
.cost-confirmation-panel { width:min(860px,100%); }
.confirmation-history { margin-top:16px; border-top:1px solid #dfe7e9; padding-top:12px; }
.confirmation-journal { padding:12px 0; border-bottom:1px solid #dfe7e9; }

#temporaryMaterialField { position: relative; }
.temporary-material-options { position: absolute; z-index: 40; top: 100%; left: 0; right: 0; max-height: 260px; overflow-y: auto; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; box-shadow: 0 8px 24px #0f172a20; }
.temporary-material-options button { display: block; width: 100%; text-align: left; background: #fff; color: #163234; border-radius: 0; padding: 10px 12px; white-space: normal; }
.temporary-material-options button span { display: block; font-size: 12px; }
.temporary-material-options button:hover, .temporary-material-options button[aria-selected="true"] { background: #e8f4f2; }

.invoice-fieldset { border:0; margin:0; padding:0; min-width:0; }
.invoice-upload-row { display:flex; align-items:end; gap:14px; margin:16px 0; flex-wrap:wrap; }
.invoice-upload-row label { flex:1; min-width:260px; }
.invoice-header-grid { margin:18px 0; }
.invoice-import-notice { background:#f2f6f4; color:#395b4b; border-left:3px solid #5b8371; padding:10px 12px; line-height:1.7; }
.invoice-item-table { min-width:850px; table-layout:fixed; }
.invoice-item-table th:nth-child(1) { width:27%; }
.invoice-item-table th:nth-child(2) { width:20%; }
.invoice-item-table th:nth-child(3) { width:10%; }
.invoice-item-table th:nth-child(4) { width:14%; }
.invoice-item-table th:nth-child(5) { width:21%; }
.invoice-item-table th:nth-child(6) { width:8%; }
.invoice-item-table input { width:100%; min-width:0; padding:8px; }
.invoice-remove-line { padding:5px 8px; }
#invoiceImportBalance { font-variant-numeric:tabular-nums; font-weight:600; }
