:root {
  --canvas: #f3f5f1;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --ink: #17272e;
  --ink-soft: #344950;
  --muted: #63747a;
  --line: #d7dfda;
  --line-strong: #b8c5be;
  --navy: #0d3039;
  --navy-soft: #153f49;
  --teal: #087b69;
  --teal-dark: #045c50;
  --teal-soft: #dff2ec;
  --amber: #a45f08;
  --amber-soft: #fff1d5;
  --red: #ae2d24;
  --red-soft: #fee8e5;
  --blue: #225f96;
  --blue-soft: #e6f0f8;
  --focus: #0b6dd9;
  --shadow: 0 18px 48px rgba(20, 38, 45, 0.14);
  --radius-sm: 5px;
  --radius: 8px;
  --sidebar-width: 208px;
  --topbar-height: 78px;
  --font:
    "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Segoe UI Variable",
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

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

button,
a,
input,
select,
textarea {
  outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 42%, transparent);
  outline-offset: 2px;
}

button {
  cursor: pointer;
}

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

svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.9;
}

[hidden] {
  display: none !important;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  min-height: 100vh;
  opacity: 0;
  background: var(--surface);
  transition: opacity 120ms ease;
}

.login-shell.is-ready {
  opacity: 1;
}

.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  min-height: 100vh;
  padding: 42px 48px;
  color: #f7fbf9;
  background: var(--navy);
}

.login-brand::before,
.login-brand::after {
  position: absolute;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.login-brand::before {
  top: 80px;
  right: -160px;
  width: 460px;
  height: 460px;
}

.login-brand::after {
  right: -80px;
  bottom: -140px;
  width: 350px;
  height: 350px;
}

.brand-lockup {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
}

.brand-lockup small {
  display: block;
  margin-top: 4px;
  color: #a8c2c6;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

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

.brand-mark-logo {
  width: 54px;
  height: 42px;
  overflow: visible;
  padding: 0;
  background: transparent;
}

.brand-mark-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand-lockup-large {
  gap: 16px;
}

.brand-lockup-large .brand-mark {
  width: 50px;
  height: 50px;
}

.brand-lockup-large .brand-mark-logo {
  width: 64px;
  height: 50px;
}

.brand-lockup-large strong {
  font-size: 22px;
}

.login-visual {
  position: relative;
  z-index: 1;
  width: min(560px, 92%);
  height: 360px;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.13);
}

.visual-shelf {
  position: absolute;
  top: 58px;
  left: 60px;
  display: grid;
  grid-template-columns: repeat(2, 84px);
  gap: 12px;
}

.visual-shelf span {
  height: 88px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
}

.visual-shelf span:nth-child(2) {
  height: 66px;
  align-self: end;
  background: rgba(121, 221, 201, 0.12);
}

.visual-shelf span:nth-child(3) {
  height: 58px;
}

.visual-shelf span:nth-child(4) {
  height: 104px;
  align-self: end;
  border-color: rgba(121, 221, 201, 0.45);
}

.visual-line {
  position: absolute;
  top: 182px;
  right: 56px;
  width: 180px;
  height: 1px;
  background: rgba(121, 221, 201, 0.55);
}

.visual-line::after {
  position: absolute;
  top: -4px;
  right: 0;
  width: 9px;
  height: 9px;
  content: "";
  border-radius: 50%;
  background: #79ddc9;
}

.visual-tag {
  position: absolute;
  right: 44px;
  top: 204px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 130px;
  padding: 12px 14px;
  color: #e6f7f2;
  border-left: 3px solid #79ddc9;
  background: #123b44;
}

.visual-tag-low {
  top: 264px;
  border-color: #e0a449;
}

.visual-tag b {
  font-size: 13px;
  font-weight: 600;
}

.login-panel {
  display: grid;
  min-height: 100vh;
  padding: 48px;
  place-items: center;
  background: var(--surface);
}

.login-form {
  width: min(400px, 100%);
}

.login-form .field + .field {
  margin-top: 18px;
}

.login-form .button-block {
  margin-top: 24px;
}

.login-heading {
  margin-bottom: 36px;
}

.login-heading h1 {
  margin: 6px 0 0;
  color: var(--navy);
  font-size: 32px;
  line-height: 1.25;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  color: #e7f0ed;
  background: var(--navy);
}

.sidebar-head {
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.sidebar .sidebar-close {
  display: none;
  color: #d8e5e2;
}

.main-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  padding: 20px 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.nav-section-label {
  margin: 14px 12px 7px;
  color: #83a2a6;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.nav-item {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  color: #bdd0d1;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.07);
}

.nav-item.active {
  color: #ffffff;
  background: var(--navy-soft);
  box-shadow: inset 3px 0 0 #79ddc9;
}

.nav-item.active svg {
  color: #79ddc9;
}

.nav-item span {
  font-size: 15px;
  font-weight: 600;
}

.sidebar-foot {
  display: grid;
  gap: 8px;
  padding: 14px 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.user-summary {
  display: block;
  width: 100%;
  min-width: 0;
}

.user-summary > span:last-child {
  display: block;
  width: 100%;
  min-width: 0;
}

.user-summary strong,
.user-summary small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-summary strong {
  color: #f2f8f6;
  font-size: 14px;
}

.user-summary small {
  margin-top: 1px;
  color: #85a3a6;
  font-size: 11px;
}

.sidebar-foot-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.sidebar-foot-actions .icon-button {
  width: 34px;
  height: 32px;
  flex-basis: 34px;
}

.app-body {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

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

.topbar h1 {
  margin: 1px 0 0;
  color: var(--navy);
  font-size: 27px;
  line-height: 1.25;
  letter-spacing: 0;
}

.topbar-kicker {
  margin: 0;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.main-content {
  width: 100%;
  max-width: 1700px;
  margin: 0 auto;
  padding: 24px 26px 42px;
}

.topbar .menu-button {
  display: none;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  color: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
}

.icon-button:hover {
  background: var(--surface-soft);
  border-color: var(--line);
}

.sidebar .icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.button:hover {
  border-color: #899a91;
  background: var(--surface-soft);
}

.button-primary {
  color: #ffffff;
  border-color: var(--teal);
  background: var(--teal);
}

.button-primary:hover {
  color: #ffffff;
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.button-danger {
  color: var(--red);
  border-color: #e3b1ac;
  background: var(--red-soft);
}

.button-danger:hover {
  color: #ffffff;
  border-color: var(--red);
  background: var(--red);
}

.button-quiet {
  min-height: 38px;
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
}

.button-small {
  min-height: 36px;
  padding: 0 11px;
  font-size: 14px;
}

.button-block {
  width: 100%;
  min-height: 46px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-intro h2 {
  margin: 0;
  color: var(--navy);
  font-size: 22px;
}

.page-intro p {
  max-width: 700px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

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

.metric {
  position: relative;
  min-height: 128px;
  padding: 17px 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-button {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.metric-button:hover,
.metric-button:focus-visible {
  border-color: #9cb8ad;
  background: #fbfdfb;
  box-shadow: 0 8px 24px rgba(18, 49, 57, 0.09);
}

.metric::after {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 54px;
  height: 3px;
  content: "";
  background: var(--teal);
}

.metric.metric-amber::after {
  background: var(--amber);
}

.metric.metric-red::after {
  background: var(--red);
}

.metric.metric-blue::after {
  background: var(--blue);
}

.metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.metric-label svg {
  color: var(--teal);
}

.metric-value {
  margin-top: 17px;
  color: var(--navy);
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
}

.metric-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13.5px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(270px, 0.75fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-head {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  color: var(--navy);
  font-size: 17px;
}

.panel-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-body {
  padding: 16px;
}

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.relation-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.relation-summary > button {
  color: inherit;
  border: 0;
  padding: 14px 16px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.relation-summary > button + button {
  border-left: 1px solid var(--line);
}

.relation-summary > button:hover {
  background: var(--teal-soft);
}

.relation-summary strong {
  display: block;
  color: var(--navy);
  font-size: 27px;
}

.relation-summary span {
  color: var(--muted);
  font-size: 12.5px;
}

.quick-actions {
  display: grid;
  gap: 8px;
}

.quick-action {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 13px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: left;
}

.quick-action:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.quick-action span {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 700;
}

.quick-action svg {
  color: var(--teal);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.filter-field {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.filter-field > span {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.filter-field > input,
.filter-field .combobox-input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.filter-field .combobox {
  min-width: 0;
}

.filter-field .combobox::after {
  top: 17px;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.filter-actions .button {
  min-height: 42px;
}

.search-field {
  position: relative;
  min-width: 260px;
}

.search-field svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px 0 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.search-field input:focus {
  border-color: var(--teal);
}

.segmented {
  display: inline-flex;
  min-height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #edf1ee;
}

.segmented button {
  min-height: 34px;
  padding: 0 11px;
  color: var(--muted);
  border: 0;
  border-radius: 4px;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
}

.segmented button[aria-pressed="true"] {
  color: var(--navy);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(17, 42, 50, 0.13);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
}

@media (min-width: 901px) {
  .table-wrap {
    overflow-x: hidden;
  }
}

.data-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  background: var(--surface);
}

.data-table th,
.data-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: center;
  vertical-align: middle;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #4c5f66;
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.data-table td {
  color: var(--ink-soft);
  font-size: 14px;
}

.data-table .button-small {
  min-height: 32px;
  padding: 0 9px;
  font-size: 13px;
}

.data-table tbody tr:hover {
  background: #f8fbf9;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table th:last-child,
.data-table td:last-child {
  border-right: 0;
}

.data-table .numeric {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.data-table .align-center {
  text-align: center;
}

.data-table .align-right {
  text-align: right;
}

.data-table .select-cell {
  width: 42px;
  padding-right: 5px;
}

.data-table .action-cell {
  position: sticky;
  right: 0;
  z-index: 2;
  width: 1%;
  background: var(--surface);
  box-shadow: -8px 0 12px rgba(23, 39, 46, 0.04);
  white-space: nowrap;
}

.data-table .action-cell .button {
  white-space: nowrap;
}

.data-table th.action-cell {
  z-index: 4;
  background: var(--surface-soft);
}

.inventory-table {
  min-width: 0;
}

.users-table,
.parties-table {
  table-layout: fixed;
}

.resizable-table {
  table-layout: fixed;
}

.column-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  z-index: 6;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.column-resizer::after {
  position: absolute;
  top: 22%;
  right: 3px;
  width: 1px;
  height: 56%;
  content: "";
  background: var(--line-strong);
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: #f4faf7;
}

.table-action {
  color: var(--muted);
  border-color: transparent;
  transition:
    color 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.data-table tbody tr:hover .table-action {
  color: var(--teal-dark);
  border-color: #b9d8cf;
  background: var(--teal-soft);
}

.table-action:hover,
.table-action:focus-visible {
  color: #ffffff;
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.check {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  cursor: pointer;
}

.check input {
  width: 17px;
  height: 17px;
  accent-color: var(--teal);
  cursor: pointer;
}

.item-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.item-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  color: var(--teal);
  border: 1px solid #c9e2da;
  border-radius: var(--radius-sm);
  background: var(--teal-soft);
}

.item-icon svg {
  width: 16px;
  height: 16px;
}

.item-primary strong,
.item-primary small {
  display: block;
}

.item-primary strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.item-primary small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 12px;
}

.status {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status::before {
  width: 6px;
  height: 6px;
  content: "";
  border-radius: 50%;
  background: currentColor;
}

.status-in-stock {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.status-borrowed {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-outbound {
  color: var(--red);
  background: var(--red-soft);
}

.status-partial {
  color: var(--blue);
  background: var(--blue-soft);
}

.status-inactive {
  color: var(--muted);
  background: #edf0ee;
}

.text-link {
  padding: 0;
  color: var(--blue);
  border: 0;
  background: transparent;
  font: inherit;
  text-align: center;
}

.text-link:hover {
  text-decoration: underline;
}

.empty-state {
  display: grid;
  min-height: 220px;
  padding: 30px;
  place-items: center;
  text-align: center;
}

.empty-state svg {
  width: 34px;
  height: 34px;
  color: #91a39b;
}

.empty-state h3 {
  margin: 12px 0 4px;
  color: var(--navy);
  font-size: 15px;
}

.empty-state p {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.selection-bar {
  position: sticky;
  top: calc(var(--topbar-height) + 8px);
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  padding: 9px 12px;
  color: #eaf7f3;
  border-radius: var(--radius-sm);
  background: var(--navy);
}

.selection-bar span {
  font-size: 14px;
  font-weight: 700;
}

.selection-bar .button {
  min-height: 34px;
  color: var(--navy);
  border-color: #ffffff;
  background: #ffffff;
}

.selection-bar .button:hover {
  background: #e3f5ef;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.field > span,
.field-label {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
}

.field-hint {
  margin: -1px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 150ms ease;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  color: var(--muted);
  background: #f1f3f1;
}

.field-error {
  margin: 0;
  color: var(--red);
  font-size: 11px;
}

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

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

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.form-error {
  padding: 9px 11px;
  color: var(--red);
  border: 1px solid #edbbb5;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  font-size: 12px;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  padding: 24px;
  overflow: auto;
  place-items: center;
  background: rgba(9, 27, 33, 0.54);
  animation: fade-in 150ms ease both;
}

.modal {
  width: min(660px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: modal-in 180ms ease both;
}

.modal.modal-wide {
  width: min(1120px, 100%);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.modal-head h2 {
  margin: 0;
  color: var(--navy);
  font-size: 19px;
}

.modal-body {
  padding: 18px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(9, 27, 33, 0.4);
  animation: fade-in 150ms ease both;
}

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 66;
  width: min(470px, 100vw);
  overflow-y: auto;
  background: var(--surface);
  box-shadow: -16px 0 44px rgba(13, 38, 45, 0.18);
  animation: drawer-in 200ms ease both;
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.drawer-head h2 {
  margin: 0;
  color: var(--navy);
  font-size: 17px;
}

.drawer-body {
  padding: 20px;
}

.detail-hero {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-hero h3 {
  margin: 0;
  color: var(--navy);
  font-size: 20px;
}

.detail-hero p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.detail-list {
  display: grid;
  gap: 0;
  margin: 18px 0 0;
}

.detail-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.detail-row dt {
  color: var(--muted);
  font-size: 12.5px;
}

.detail-row dd {
  min-width: 0;
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.detail-stats div {
  padding: 12px;
}

.detail-stats div + div {
  border-left: 1px solid var(--line);
}

.detail-stats strong {
  display: block;
  color: var(--navy);
  font-size: 20px;
}

.detail-stats span {
  color: var(--muted);
  font-size: 12px;
}

.transaction-detail {
  margin-top: 20px;
}

.transaction-detail > h3 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 17px;
}

.transaction-detail-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.transaction-detail-item + .transaction-detail-item {
  margin-top: 9px;
}

.transaction-detail-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.transaction-detail-title strong {
  color: var(--ink);
  font-size: 15px;
}

.transaction-detail-title span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

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

.transaction-detail-grid div {
  min-width: 0;
}

.transaction-detail-grid span,
.transaction-detail-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.transaction-detail-grid span {
  color: var(--muted);
  font-size: 11px;
}

.transaction-detail-grid strong {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

.modal-line-table {
  width: 100%;
  border-collapse: collapse;
}

.modal-line-table th,
.modal-line-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.modal-line-table th {
  color: var(--muted);
  font-size: 14px;
  text-align: left;
}

.modal-line-table td input {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.modal-line-table td input:focus {
  border-color: var(--teal);
}

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

.line-table-wrap .modal-line-table th {
  background: var(--surface-soft);
}

.line-table-wrap .modal-line-table th:first-child,
.line-table-wrap .modal-line-table td:first-child {
  padding-left: 10px;
}

.inbound-lines {
  display: grid;
  gap: 12px;
}

.inbound-line {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.inbound-line-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 14px;
}

.inbound-line-head .remove-inbound-line {
  margin-left: auto;
}

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

.line-product-field {
  grid-column: span 3;
}

.line-brand-field,
.line-model-field {
  grid-column: span 2;
}

.line-target-field {
  grid-column: span 5;
}

.line-location-field {
  grid-column: span 2;
}

.line-quantity-field {
  grid-column: span 1;
}

.line-amount-field {
  grid-column: span 2;
}

.line-serial-field {
  grid-column: span 3;
}

.line-note-field {
  grid-column: span 4;
}

.inbound-line .field input {
  min-height: 44px;
  background: var(--surface);
}

.inbound-line .combobox::after {
  top: 18px;
}

.product-combobox {
  min-width: 118px;
}

.product-combobox .combobox-menu {
  min-width: 280px;
}

.product-combobox .combobox-option {
  align-items: flex-start;
}

.product-combobox .combobox-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.product-combobox .combobox-option small {
  flex: 0 0 auto;
}

.line-number {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
}

.selected-lines {
  display: grid;
  gap: 7px;
}

.selected-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 94px;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.selected-line strong,
.selected-line small {
  display: block;
}

.selected-line strong {
  font-size: 14px;
}

.selected-line small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.selected-line input {
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.combobox {
  position: relative;
}

.combobox input[type="text"] {
  padding-right: 36px;
}

.combobox::after {
  position: absolute;
  top: 18px;
  right: 12px;
  width: 0;
  height: 0;
  content: "";
  border-top: 5px solid var(--muted);
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  pointer-events: none;
}

.combobox-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  z-index: 30;
  max-height: 250px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(12, 37, 44, 0.16);
}

.combobox-option {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  color: var(--ink);
  border: 0;
  border-radius: 4px;
  background: transparent;
  font-size: 14px;
  text-align: left;
}

.combobox-option:hover,
.combobox-option.active {
  background: var(--teal-soft);
}

.combobox-option small {
  color: var(--muted);
  font-size: 12px;
}

.combobox-empty {
  padding: 9px;
  color: var(--muted);
  font-size: 11px;
}

.callout {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 11px;
  color: var(--ink-soft);
  border: 1px solid #c9ded7;
  border-radius: var(--radius-sm);
  background: #eff8f5;
  font-size: 13px;
}

.callout svg {
  flex: 0 0 auto;
  color: var(--teal);
}

.return-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.return-item:last-child {
  border-bottom: 0;
}

.return-item strong,
.return-item small {
  display: block;
}

.return-item strong {
  font-size: 14px;
}

.return-item small {
  color: var(--muted);
  font-size: 12px;
}

.return-item input {
  width: 100%;
  min-height: 38px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  display: grid;
  width: min(380px, calc(100vw - 44px));
  gap: 8px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(12, 37, 44, 0.16);
  animation: toast-in 180ms ease both;
}

.toast.toast-error {
  border-left-color: var(--red);
}

.toast svg {
  flex: 0 0 auto;
  color: var(--teal);
}

.toast.toast-error svg {
  color: var(--red);
}

.toast p {
  margin: 1px 0 0;
  font-size: 13px;
}

.skeleton {
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, transparent, rgba(8, 123, 105, 0.05), transparent),
    var(--surface-soft);
  background-size: 240px 100%, auto;
  animation: skeleton 1.2s linear infinite;
}

.mobile-overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(8, 28, 34, 0.4);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
}

@keyframes drawer-in {
  from {
    transform: translateX(24px);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes skeleton {
  from {
    background-position: -240px 0, 0 0;
  }
  to {
    background-position: calc(100% + 240px) 0, 0 0;
  }
}

@media (max-width: 1180px) {
  .filter-panel {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .filter-actions {
    grid-column: span 3;
  }

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

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .side-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .login-brand {
    min-height: 280px;
    padding: 28px;
  }

  .login-visual {
    display: none;
  }

  .login-panel {
    min-height: auto;
    padding: 54px 24px;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar .sidebar-close,
  .topbar .menu-button {
    display: inline-grid;
  }

  .app-body {
    margin-left: 0;
  }

  .topbar {
    padding: 0 16px;
  }

  .main-content {
    padding: 18px 16px 36px;
  }

  .inbound-line-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .line-product-field,
  .line-target-field,
  .line-serial-field,
  .line-note-field {
    grid-column: span 2;
  }

  .line-brand-field,
  .line-model-field,
  .line-location-field,
  .line-quantity-field,
  .line-amount-field {
    grid-column: span 1;
  }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 70px;
  }

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

  .topbar-actions .button span {
    display: none;
  }

  .metrics-grid,
  .side-stack,
  .form-grid,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3 {
    grid-column: span 1;
  }

  .metric {
    min-height: 108px;
  }

  .metric-value {
    font-size: 27px;
  }

  .toolbar,
  .toolbar-group {
    align-items: stretch;
  }

  .filter-panel {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    grid-column: span 1;
  }

  .filter-actions .button {
    flex: 1;
  }

  .toolbar-group {
    width: 100%;
  }

  .search-field {
    width: 100%;
    min-width: 0;
  }

  .segmented {
    max-width: 100%;
    overflow-x: auto;
  }

  .page-intro {
    align-items: flex-start;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .button {
    flex: 1;
  }

  .selection-bar {
    top: 78px;
    align-items: flex-start;
    flex-direction: column;
  }

  .selection-bar .selection-actions {
    display: flex;
    width: 100%;
    gap: 6px;
  }

  .selection-bar .button {
    flex: 1;
  }

  .modal-backdrop {
    padding: 0;
    place-items: stretch;
  }

  .modal {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .modal-body {
    padding: 14px;
  }

  .modal-line-table {
    min-width: 760px;
  }

  .data-table {
    min-width: 780px;
  }

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

  .inbound-line-grid {
    grid-template-columns: 1fr;
  }

  .line-product-field,
  .line-brand-field,
  .line-model-field,
  .line-target-field,
  .line-location-field,
  .line-quantity-field,
  .line-amount-field,
  .line-serial-field,
  .line-note-field {
    grid-column: span 1;
  }

  .detail-row {
    grid-template-columns: 76px minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
