:root {
  --ink: #12202b;
  --muted: #5b6b75;
  --paper: #f3efe6;
  --panel: #fffdf8;
  --line: #d9cfc0;
  --navy: #0d3b4c;
  --navy-2: #16485c;
  --teal: #1a8a78;
  --teal-soft: #d7f1eb;
  --gold: #c48a2a;
  --danger: #a33b32;
  --shadow: 0 16px 40px rgba(13, 59, 76, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Figtree, "Segoe UI", sans-serif;
}

body {
  background-image:
    radial-gradient(circle at top right, rgba(26, 138, 120, 0.08), transparent 28%),
    linear-gradient(180deg, #efe8d8 0%, var(--paper) 220px);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--navy) 0%, #082833 100%);
  color: #e8f4f2;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #7ad4c2;
  color: var(--navy);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-kicker {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ec9c0;
}

.brand h1 {
  margin: 2px 0 0;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 22px;
  font-weight: 600;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
}

.nav-item.is-active,
.nav-item:hover {
  background: var(--navy-2);
}

.sidebar-note {
  margin-top: auto;
  font-size: 13px;
  line-height: 1.5;
  color: #b7d0cb;
}

main {
  padding: 28px 36px 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h2 {
  margin: 4px 0 0;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 34px;
  font-weight: 600;
}

.topbar-actions,
.dialog-actions,
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn.primary {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  color: var(--danger);
  border-color: #efc4c0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  font-family: "Source Serif 4", Georgia, serif;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.search,
select,
input,
textarea {
  font: inherit;
}

.search {
  flex: 1;
  min-width: 240px;
}

.search input,
.filters select,
label input,
label select,
label textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
}

.table-wrap {
  overflow: auto;
  margin-top: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid #eee4d6;
  vertical-align: top;
}

th {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eee;
}

.badge.in-stock { background: var(--teal-soft); color: #0f5e52; }
.badge.assigned { background: #dce9f5; color: #1d4e78; }
.badge.spare { background: #f7ead0; color: #7a5410; }
.badge.damaged,
.badge.expired { background: #f8d9d6; color: #8b2c25; }

.row-actions {
  display: flex;
  gap: 8px;
}

.linkish {
  border: 0;
  background: none;
  color: var(--teal);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.empty {
  margin: 24px 8px;
  color: var(--muted);
}

dialog {
  width: min(720px, 94vw);
  border: 0;
  border-radius: 24px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(8, 28, 36, 0.45);
}

form {
  padding: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.full {
  grid-column: 1 / -1;
}

.spacer {
  flex: 1;
}

.dialog-actions {
  margin-top: 18px;
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-bottom: 1px solid #0a2c38;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  main {
    padding: 20px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
