: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;
}

.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;
}

.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: 8%; }
.movement-col-scenario { width: 5%; }
.movement-col-code { width: 9%; }
.movement-col-name { width: 9%; }
.movement-col-direction { width: 4%; }
.movement-col-quantity { width: 5%; }
.movement-col-storage { width: 11%; }
.movement-col-supplier { width: 15%; }
.movement-col-amount { width: 5%; }
.movement-col-unit-price { width: 5%; }
.movement-col-handler { width: 7%; }
.movement-col-project { width: 5%; }
.movement-col-accounting { width: 5%; }
.movement-col-note { width: 3%; }
.movement-col-action { width: 4%; }

.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%);
}

.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;
  }
}
