:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #61717d;
  --line: #d8e0e5;
  --panel: #ffffff;
  --soft: #f3f7f8;
  --brand: #2f8db7;
  --brand-strong: #1f6f94;
  --accent: #6f7b86;
  --warning: #a85a00;
  --danger: #b83333;
  --shadow: 0 16px 44px rgba(23, 32, 38, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

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

.workspace {
  max-width: 1280px;
  margin: 0 auto;
}

.topbar,
.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.12;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 700;
}

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

.primary-button:hover {
  background: var(--brand-strong);
}

.secondary-button {
  background: #fff1ed;
  color: var(--danger);
  border-color: #f0c8be;
}

.ghost-button,
.icon-button {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.icon-button {
  width: 42px;
  padding: 0;
}

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

.summary-panel,
.inventory-table-wrap,
.detail-panel,
.controls,
.item-dialog form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-panel {
  padding: 18px;
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.summary-panel strong {
  font-size: 30px;
}

.controls {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 14px;
  padding: 16px;
  margin-bottom: 18px;
}

label span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 7px;
}

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

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 88px;
  resize: vertical;
  padding: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.inventory-table-wrap {
  min-height: 430px;
  overflow: hidden;
}

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

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

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

.inventory-table tbody tr {
  background: #fff;
}

.inventory-table tbody tr:hover,
.inventory-table tbody tr.active-row {
  background: #e8f5fb;
}

.item-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.thumb {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 8px;
  background: #dfe8ea;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.thumb img,
.detail-photo img,
.image-preview-grid img,
.detail-gallery img,
.image-dialog img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.item-name {
  display: block;
  font-weight: 800;
}

.item-note {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.status-pill {
  display: inline-flex;
  min-width: 86px;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.status-baik {
  background: #e4f3fa;
  color: #1f6f94;
}

.status-perlu-cek {
  background: #fff4df;
  color: var(--warning);
}

.status-rusak {
  background: #ffe8e8;
  color: var(--danger);
}

.status-dipinjam {
  background: #e7eefb;
  color: #28548f;
}

.detail-panel {
  min-height: 430px;
  padding: 18px;
  position: sticky;
  top: 18px;
}

.detail-photo {
  aspect-ratio: 4 / 3;
  width: 100%;
  border: 0;
  overflow: hidden;
  border-radius: 8px;
  background: var(--soft);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 18px;
  padding: 0;
  text-align: center;
}

button.detail-photo {
  cursor: zoom-in;
}

button.detail-photo:hover {
  outline: 3px solid rgba(47, 141, 183, 0.22);
}

.detail-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: -8px 0 18px;
}

.detail-gallery button {
  aspect-ratio: 1 / 1;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  padding: 0;
  background: var(--soft);
}

.detail-gallery button.active-gallery-image {
  border-color: var(--brand);
}

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

.detail-row span:first-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.empty-state,
.empty-detail {
  min-height: 320px;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.empty-state strong,
.empty-detail strong {
  color: var(--ink);
}

.empty-state[hidden] {
  display: none;
}

.item-dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  background: transparent;
}

.item-dialog::backdrop,
.image-dialog::backdrop {
  background: rgba(16, 30, 36, 0.46);
}

.item-dialog form {
  padding: 22px;
  box-shadow: var(--shadow);
}

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

.full-field {
  display: block;
  margin-bottom: 14px;
}

.image-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 14px;
  align-items: end;
}

.image-preview-grid {
  min-height: 150px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--soft);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: 8px;
}

.image-preview-grid:empty::before {
  content: "Preview gambar";
  grid-column: 1 / -1;
  align-self: center;
  padding: 54px 0;
}

.preview-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
}

.preview-tile button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: rgba(23, 32, 38, 0.78);
  color: #fff;
  font-weight: 800;
  line-height: 1;
}

.image-dialog {
  width: min(1100px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  background: #101820;
  box-shadow: var(--shadow);
}

.image-dialog img {
  width: 100%;
  height: auto;
  max-height: calc(100vh - 28px);
  object-fit: contain;
  background: #101820;
}

.image-dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-weight: 800;
}

.dialog-actions {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.dialog-actions > div {
  display: flex;
  gap: 10px;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 18px;
  }

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

  .controls,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .topbar,
  .dialog-header,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 28px;
  }

  .summary-grid,
  .form-grid,
  .image-input {
    grid-template-columns: 1fr;
  }

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

  .inventory-table {
    min-width: 720px;
  }

  .dialog-actions > div,
  .dialog-actions button {
    width: 100%;
  }
}
