:root {
  color-scheme: light;
  --ink: #15211f;
  --muted: #64716e;
  --line: #dce5e1;
  --panel: #ffffff;
  --wash: #f4f8f6;
  --teal: #008f7a;
  --teal-dark: #00685a;
  --amber: #b86f00;
  --red: #b42318;
  --blue: #265f9f;
  --shadow: 0 14px 34px rgba(26, 45, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a.icon-btn {
  min-height: 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 42px);
  background: #0f1917;
  color: #fff;
  border-bottom: 4px solid var(--teal);
}

.topbar h1,
.section-head h2,
.dialog-head h3 {
  margin: 0;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #74d6c7;
}

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

.icon-btn,
.tab,
.primary,
.secondary,
.small-icon,
.row-action {
  border: 0;
  cursor: pointer;
}

.icon-btn,
.tab,
.primary,
.secondary,
.row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 7px;
  text-decoration: none;
  white-space: nowrap;
}

.icon-btn {
  padding: 10px 14px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.icon-btn.ghost {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

main {
  width: min(1420px, calc(100% - 28px));
  margin: 20px auto 44px;
}

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

.metric,
.case-card,
.table-shell,
.reservation-card,
.unit-card,
.location-card,
.stock-toolbar,
.movement-item,
.dialog-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
  min-height: 92px;
}

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

.metric span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  background: #e6efeb;
  color: #23312e;
  padding: 10px 14px;
  font-weight: 800;
}

.tab.active {
  background: #0f1917;
  color: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 12px 0;
}

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

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

.case-grid,
.unit-grid,
.location-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.case-card,
.reservation-card,
.location-card,
.unit-card {
  padding: 16px;
}

.qr-thumb {
  width: 92px;
  height: 92px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px;
  background: #fff;
}

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

.card-head h3,
.unit-card h3 {
  margin: 0;
  font-size: 18px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  background: #e9f6f3;
  color: var(--teal-dark);
}

.pill.warn {
  background: #fff4df;
  color: var(--amber);
}

.pill.danger {
  background: #ffeceb;
  color: var(--red);
}

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

.meta-list div {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  min-height: 58px;
  background: #fbfdfc;
}

.meta-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.meta-list strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.required-list,
.history-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.required-item,
.history-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px;
  border-radius: 7px;
  background: #f4f8f6;
}

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

.primary,
.row-action {
  background: var(--teal);
  color: #fff;
  padding: 9px 12px;
  font-weight: 850;
}

.secondary {
  background: #e8eeeb;
  color: var(--ink);
  padding: 9px 12px;
  font-weight: 800;
}

.row-action.subtle {
  background: #e8eeeb;
  color: var(--ink);
}

.row-action.danger {
  background: #ffeceb;
  color: var(--red);
}

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

.stock-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  margin: 0 0 12px;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

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

.movement-head {
  margin-top: 24px;
}

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

.movement-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.movement-item strong,
.movement-item span {
  overflow-wrap: anywhere;
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(520px, calc(100% - 24px));
}

dialog::backdrop {
  background: rgba(15, 25, 23, 0.42);
}

.dialog-card {
  padding: 18px;
}

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

.small-icon {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: #eef4f1;
}

label {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

label input,
label select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px;
  color: var(--ink);
  background: #fff;
}

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

.check-row {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  color: var(--ink);
}

.check-row input {
  width: auto;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 12px 14px;
  border-radius: 7px;
  background: #0f1917;
  color: #fff;
  opacity: 0;
  transform: translateY(12px);
  transition: 180ms ease;
  pointer-events: none;
}

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

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

.qr-label {
  break-inside: avoid;
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 12px;
  align-items: center;
  min-height: 180px;
  padding: 16px;
  border: 1px solid #111;
  border-radius: 8px;
  background: #fff;
}

.qr-label h2,
.qr-label p {
  margin: 0 0 7px;
}

.qr-label img {
  width: 130px;
  height: 130px;
}

.qr-label code {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--muted);
}

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

@media (max-width: 980px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .case-grid,
  .unit-grid,
  .location-grid,
  .reservation-list,
  .movement-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar,
  .section-head,
  .stock-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions .icon-btn {
    flex: 1;
  }

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

  .metric strong {
    font-size: 25px;
  }

  .search-wrap {
    min-width: 0;
  }

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

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

  .no-print {
    display: none !important;
  }

  main {
    width: auto;
    margin: 0;
  }

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

  .qr-label {
    box-shadow: none;
    page-break-inside: avoid;
  }
}
