#app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  background: var(--color-header-bg);
  color: var(--color-header-text);
  box-shadow: var(--shadow-sm);
  gap: var(--space-3);
}

.app-header__title {
  flex: 1;
  font-size: var(--font-md);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header__actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.app-header__actions button {
  color: var(--color-header-text);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.app-header__actions button:hover {
  background: rgba(255,255,255,.15);
}

.app-header__actions button svg {
  width: 20px;
  height: 20px;
}

.app-main {
  flex: 1;
  padding: var(--space-4);
  padding-bottom: calc(var(--nav-height) + var(--space-4));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--color-nav-bg);
  border-top: 1px solid var(--color-nav-border);
  display: flex;
  box-shadow: 0 -2px 8px rgba(0,0,0,.06);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: var(--font-xs);
  color: var(--color-text-muted);
  padding: var(--space-2);
  transition: color var(--transition);
}

.bottom-nav__item svg {
  width: 22px;
  height: 22px;
}

.bottom-nav__item.active,
.bottom-nav__item:hover {
  color: var(--color-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--font-base);
  font-weight: 500;
  transition: background var(--transition), opacity var(--transition);
  white-space: nowrap;
}

.btn:disabled {
  opacity: .5;
  pointer-events: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover { background: var(--color-primary-dark); }

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover { background: #b91c1c; }

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
}

.btn-ghost:hover { background: var(--color-primary-light); }

.btn-outline {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-outline:hover { background: var(--color-bg); }

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-sm);
}

.btn-full { width: 100%; }

.btn svg {
  width: 18px;
  height: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--color-text);
}

.form-control {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--font-base);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.form-control::placeholder { color: var(--color-text-muted); }

.search-bar {
  position: relative;
  margin-bottom: var(--space-4);
}

.search-bar__input {
  padding-left: 40px;
}

.search-bar__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.filter-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.filter-tab {
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  font-size: var(--font-sm);
  font-weight: 500;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-surface);
  transition: all var(--transition);
}

.filter-tab.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:active {
  transform: scale(.99);
  box-shadow: var(--shadow-md);
}

.card__info { flex: 1; min-width: 0; }

.card__title {
  font-size: var(--font-base);
  font-weight: 600;
  margin-bottom: var(--space-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__subtitle {
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__meta {
  font-size: var(--font-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.card__actions {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--font-xs);
  font-weight: 600;
  white-space: nowrap;
}

.badge-available {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-loaned {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.badge-overdue {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.badge-open {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.badge-closed {
  background: var(--color-success-light);
  color: var(--color-success);
}

.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--color-text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  color: var(--color-border);
}

.empty-state__title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-4);
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal__header {
  display: flex;
  align-items: center;
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-3);
}

.modal__title {
  flex: 1;
  font-size: var(--font-md);
  font-weight: 600;
}

.modal__close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: background var(--transition);
}

.modal__close:hover { background: var(--color-bg); }

.modal__close svg {
  width: 18px;
  height: 18px;
}

.modal__body {
  overflow-y: auto;
  padding: var(--space-5);
  flex: 1;
}

.modal__footer {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
}

.modal__footer .btn { flex: 1; }

.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--space-4));
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  width: min(calc(100vw - 32px), 400px);
}

.toast {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in .2s ease;
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-success { background: var(--color-success); color: #fff; }
.toast-error { background: var(--color-danger); color: #fff; }
.toast-warning { background: var(--color-warning); color: #fff; }

.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--space-6);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-6);
}

.login-logo svg {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-3);
  color: var(--color-primary);
}

.login-logo h1 {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--color-text);
}

.login-logo p {
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.offline-banner {
  background: var(--color-warning);
  color: #fff;
  text-align: center;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-sm);
  font-weight: 500;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.page-header h2 {
  font-size: var(--font-lg);
  font-weight: 700;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  color: var(--color-text-muted);
}

.icon-btn:hover { background: var(--color-bg); color: var(--color-text); }

.icon-btn svg { width: 20px; height: 20px; }

.icon-btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.icon-btn-primary:hover { background: var(--color-primary-dark); color: #fff; }

.scanner-preview {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: var(--radius-md);
  background: #000;
  overflow: hidden;
  position: relative;
  margin-bottom: var(--space-4);
}

.scanner-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-crosshair {
  position: absolute;
  inset: 20%;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 9999px rgba(0,0,0,.4);
}

.detail-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}

.detail-row:last-child { border-bottom: none; }

.detail-row__label {
  width: 130px;
  flex-shrink: 0;
  font-size: var(--font-sm);
  color: var(--color-text-muted);
}

.detail-row__value {
  flex: 1;
  font-size: var(--font-sm);
  font-weight: 500;
  word-break: break-word;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: var(--space-8) auto;
}

@keyframes spin { to { transform: rotate(360deg); } }
