:root {
  --bg: #f4f9f8;
  --panel: #ffffff;
  --ink: #142320;
  --muted: #69738a;
  --line: #dce7e4;
  --primary: #00a99d;
  --primary-dark: #00887f;
  --accent: #ffc928;
  --accent-dark: #d99b00;
  --danger: #b42318;
  --warning: #b7791f;
  --success: #047857;
  --shadow: 0 14px 35px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

.sidebar {
  background: #050807;
  color: #e5e7eb;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 26px;
}

.brand-logo {
  display: block;
  max-height: 38px;
  max-width: 150px;
  object-fit: contain;
  width: min(150px, 100%);
}

.brand-mark {
  align-items: center;
  background: var(--accent);
  border-radius: 8px;
  color: #07110f;
  display: inline-flex;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.brand h1 {
  font-size: 15px;
  margin: 0;
}

.brand span {
  color: #9ca3af;
  display: block;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  align-items: center;
  border-radius: 8px;
  color: #cbd5e1;
  display: flex;
  gap: 10px;
  padding: 10px 12px;
}

.nav a.active,
.nav a:hover {
  background: rgba(0, 169, 157, 0.18);
  color: #fff;
}

.nav a.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.main {
  min-width: 0;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 16px 26px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h2 {
  font-size: 21px;
  margin: 0;
}

.topbar-title {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.topbar-title > div {
  min-width: 0;
}

.topbar p {
  color: var(--muted);
  margin: 2px 0 0;
}

.content {
  padding: 24px 26px 42px;
}

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

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

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

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

.panel,
.card,
.install-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

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

.panel-title h3 {
  font-size: 17px;
  margin: 0;
}

.stat {
  padding: 18px;
}

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

.stat strong {
  display: block;
  font-size: 30px;
  margin-top: 6px;
}

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

.approval-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.filters {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

label span {
  color: #374151;
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #cfd7e3;
  border-radius: 7px;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 11px;
  width: 100%;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.btn {
  align-items: center;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 9px 13px;
  white-space: nowrap;
}

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

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #08110f;
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn.small {
  min-height: 32px;
  padding: 6px 10px;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #475569;
  font-size: 12px;
  text-transform: uppercase;
}

tr:hover td {
  background: #f8fafc;
}

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

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 9px;
}

.badge-available,
.badge-good,
.badge-received,
.badge-fulfilled,
.badge-completed,
.badge-done,
.badge-in,
.badge-log-in,
.badge-log-initial,
.badge-return,
.badge-finance {
  background: #dcfce7;
  color: #166534;
}

.badge-in-use,
.badge-requested,
.badge-out,
.badge-transfer,
.badge-sent,
.badge-pic,
.badge-log-distribute {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-maintenance,
.badge-in-progress,
.badge-repair,
.badge-maintenance-service,
.badge-calibration,
.badge-minor-damage,
.badge-ordered {
  background: #fef3c7;
  color: #92400e;
}

.badge-damaged,
.badge-lost,
.badge-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.badge-retired,
.badge-draft,
.badge-admin {
  background: #e5e7eb;
  color: #374151;
}

.badge-admin {
  background: #fef3c7;
  color: #92400e;
}

.stock-low {
  color: var(--danger);
  font-weight: 800;
}

.receipt-photo {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  max-height: 280px;
  max-width: 420px;
  object-fit: cover;
  width: min(100%, 420px);
}

.alert {
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 11px 13px;
}

.alert-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

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

.form-grid .full,
.form-actions {
  grid-column: 1 / -1;
}

.embedded-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.form-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

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

.detail-list div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

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

.detail-list strong {
  display: block;
  margin-top: 2px;
}

.label-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.asset-label {
  background: #fff;
  border: 1px dashed #94a3b8;
  border-radius: 6px;
  display: grid;
  gap: 10px;
  grid-template-columns: 118px minmax(0, 1fr);
  min-height: 154px;
  padding: 12px;
  break-inside: avoid;
}

.asset-label h4 {
  font-size: 15px;
  margin: 0 0 4px;
}

.asset-label p {
  margin: 0 0 6px;
}

.barcode {
  max-width: 100%;
}

.asset-photo-cell {
  min-width: 62px;
  width: 62px;
}

.asset-photo-cell img,
.asset-thumb {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: block;
  height: 44px !important;
  max-height: 44px !important;
  max-width: 44px !important;
  object-fit: cover;
  width: 44px !important;
}

.photo-empty {
  align-items: center;
  background: #eef4f3;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  display: inline-flex;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.asset-photo-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  height: 130px;
  margin-bottom: 10px;
  object-fit: cover;
  width: 190px;
}

.asset-photo-large {
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  margin-bottom: 16px;
  object-fit: cover;
  width: min(100%, 520px);
}

.scan-box {
  background: #111827;
  border-radius: 8px;
  min-height: 330px;
  overflow: hidden;
}

.hidden {
  display: none;
}

.install-page,
.login-page {
  background: #eef2f7;
}

.install-shell,
.login-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.install-card,
.login-card {
  max-width: 860px;
  padding: 26px;
  width: 100%;
}

.login-card {
  max-width: 430px;
}

.brand-block {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}

.login-logo {
  display: block;
  max-height: 48px;
  max-width: 190px;
  object-fit: contain;
  width: min(190px, 42vw);
}

.brand-block h1 {
  font-size: 24px;
  margin: 0;
}

.brand-block p {
  color: var(--muted);
  margin: 4px 0 0;
}

.role-list {
  display: grid;
  gap: 12px;
}

.role-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.role-list strong,
.role-list span {
  display: block;
}

.role-list span {
  color: var(--muted);
  margin-top: 4px;
}

.inline-form {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 280px;
}

.inline-form input {
  min-width: 160px;
}

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

  .sidebar {
    height: auto;
    position: static;
  }

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

  .brand-logo {
    max-height: 34px;
    max-width: 140px;
    width: min(140px, 55vw);
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .form-grid,
  .detail-list {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .inline-form {
    align-items: stretch;
    flex-direction: column;
    min-width: 220px;
  }
}

@media print {
  @page {
    margin: 10mm;
    size: A4 portrait;
  }

  body {
    background: #fff;
    zoom: 80%;
  }

  .sidebar,
  .topbar,
  .toolbar,
  .no-print {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .content {
    padding: 0;
  }

  .panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}
