:root {
  --ink: #1f2933;
  --muted: #64707d;
  --line: #d9e2ec;
  --soft: #f5f8fb;
  --surface: #ffffff;
  --red: #be1e2d;
  --red-2: #e34d59;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #b45309;
  --green: #15803d;
  --shadow: 0 12px 28px rgba(31, 41, 51, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #eef3f8;
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 20px 14px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: #fff;
  background: var(--red);
  font-weight: 800;
}

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

.brand span,
.role-switcher span,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.role-switcher {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.role-switcher select,
.field input,
.field select,
.field textarea,
.searchbar input,
.searchbar select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  padding: 8px 10px;
}

.main-nav {
  display: grid;
  gap: 4px;
}

.nav-button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  background: #f2f6fb;
}

.nav-button.active {
  color: var(--red);
  font-weight: 700;
}

.nav-icon {
  text-align: center;
}

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

.workspace {
  min-width: 0;
  padding: 22px;
}

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

.topbar h1 {
  margin: 2px 0 0;
  font-size: 28px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  font-weight: 700;
}

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

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.icon-button:hover {
  box-shadow: var(--shadow);
}

.icon-button.danger {
  color: var(--red);
}

.visual-band {
  position: relative;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 132px;
  margin-bottom: 18px;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.visual-band img {
  width: 180px;
  height: 132px;
  object-fit: cover;
}

.visual-copy {
  display: grid;
  gap: 4px;
  padding-right: 18px;
}

.visual-copy strong {
  font-size: 18px;
}

.visual-copy span {
  color: var(--muted);
  line-height: 1.45;
}

.view {
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.metrics {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.grid.two {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
}

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

.metric-card,
.panel,
.record-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  min-height: 104px;
  padding: 14px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.metric-card em {
  display: inline-block;
  margin-top: 8px;
  color: var(--teal);
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
}

.panel {
  min-width: 0;
}

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

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

.panel-body {
  padding: 16px;
}

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

.primary,
.secondary,
.quiet {
  min-height: 38px;
  border-radius: 7px;
  padding: 8px 12px;
  font-weight: 700;
}

.primary {
  color: #fff;
  background: var(--red);
}

.secondary {
  color: var(--ink);
  background: #e9f2fb;
}

.quiet {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.searchbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 160px 160px auto;
  gap: 10px;
  margin-bottom: 14px;
}

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

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.table-wrap {
  overflow: auto;
}

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

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

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

.status,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.status.available,
.status.active,
.status.negative,
.status.approved,
.status.compatible,
.status.ready {
  color: #0f5132;
  background: #dff7ea;
}

.status.pending,
.status.under-testing,
.status.reserved,
.status.sample-received,
.status.under-crossmatch {
  color: #7a4b00;
  background: #fff2cc;
}

.status.expired,
.status.reactive,
.status.discarded,
.status.rejected,
.status.incompatible,
.status.blocked {
  color: #842029;
  background: #f8d7da;
}

.status.issued,
.status.transferred,
.status.completed {
  color: #1d4ed8;
  background: #dbeafe;
}

.tag {
  color: #334155;
  background: #eef2f7;
}

.stock-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
}

.stock-tile {
  min-height: 112px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stock-tile strong {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
}

.stock-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

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

.timeline li {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.timeline li::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--red-2);
}

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

.timeline span,
.muted {
  color: var(--muted);
}

.workflow {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 8px;
}

.step {
  min-height: 74px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.step strong {
  display: block;
  margin-bottom: 5px;
}

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

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

.alert-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.alert-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 10px;
}

.kpi {
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.kpi strong {
  display: block;
  font-size: 22px;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #1f2933;
  box-shadow: var(--shadow);
  transform: translateY(90px);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}

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

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .grid.metrics,
  .grid.three,
  .stock-grid,
  .workflow,
  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .workspace {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

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

  .visual-band {
    grid-template-columns: 1fr;
  }

  .visual-band img {
    width: 100%;
    height: 160px;
  }

  .visual-copy {
    padding: 0 14px 14px;
  }

  .grid.metrics,
  .grid.two,
  .grid.three,
  .form-grid,
  .searchbar,
  .stock-grid,
  .workflow,
  .kpi-strip {
    grid-template-columns: 1fr;
  }

  .field.wide {
    grid-column: auto;
  }
}
