/* =============================================================
   INVENTARIS SEKOLAH PWA - Mobile-First Stylesheet
   ============================================================= */

/* ---------- Design Tokens ---------- */
:root {
  /* Brand colors */
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-light: #14b8a6;
  --primary-bg: #f0fdfa;
  --primary-bg2: #ccfbf1;

  --accent: #f59e0b;
  --accent-dark: #d97706;

  /* Status colors */
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #ea580c;
  --warning-bg: #ffedd5;
  --info: #2563eb;
  --info-bg: #dbeafe;

  /* Neutrals */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --text-inverse: #ffffff;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 11px;
  --fs-sm: 13px;
  --fs-base: 15px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  --fs-3xl: 34px;

  /* Spacing & radius */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 2px 8px rgba(15, 23, 42, .08);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, .1);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .15);

  /* Layout */
  --header-h: 56px;
  --tabbar-h: 64px;
  --max-w: 600px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); font-size: var(--fs-md);
  transition: border-color .15s, box-shadow .15s; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
input[type="checkbox"], input[type="radio"] { width: auto; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-3); }
label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin-bottom: 6px; }

/* ============================================================= APP LAYOUT */
#app {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 60px rgba(15, 23, 42, .08);
}

#app-header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: calc(var(--safe-top)) 0 0;
  box-shadow: var(--shadow-md);
}
.app-header-inner {
  height: var(--header-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
}
.app-title {
  font-size: var(--fs-lg); font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
}
.app-title .logo {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.2);
  display: grid; place-items: center; font-size: 16px;
}
.app-title-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.header-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: #fff; font-size: 20px;
  transition: background .15s;
}
.header-btn:hover, .header-btn:active { background: rgba(255,255,255,.18); }

#app-main {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--tabbar-h) + 24px + var(--safe-bottom));
  width: 100%;
}

#app-tabbar {
  position: fixed; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: var(--max-w);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 99;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 12px rgba(15, 23, 42, .06);
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 10px 4px;
  color: var(--text-3); font-size: var(--fs-xs); font-weight: 500;
  transition: color .15s;
  position: relative;
}
.tab-item .tab-icon { font-size: 22px; line-height: 1; }
.tab-item.active { color: var(--primary); font-weight: 700; }
.tab-item.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 32px; height: 3px; border-radius: var(--radius-full);
  background: var(--primary);
}

/* Scan FAB in tabbar */
.tab-scan {
  flex: 0 0 auto;
  position: relative;
  margin-top: -22px;
}
.tab-scan .scan-btn {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-size: 26px;
  box-shadow: var(--shadow-md);
  border: 4px solid var(--surface);
  transition: transform .15s;
}
.tab-scan:active .scan-btn { transform: scale(.92); }
.tab-scan .tab-label { font-size: var(--fs-xs); color: var(--primary); margin-top: 2px; font-weight: 600; }

/* ============================================================= BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-md); font-weight: 600;
  border: 1.5px solid transparent;
  transition: all .15s;
  user-select: none;
  min-height: 44px;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary); color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary {
  background: var(--surface); color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 8px 12px; font-size: var(--fs-sm); min-height: 36px; }
.btn-lg { padding: 14px 22px; font-size: var(--fs-lg); }
.btn-icon { padding: 10px; min-width: 44px; }
.btn-fab {
  position: fixed; bottom: calc(var(--tabbar-h) + 16px + var(--safe-bottom));
  right: 50%; transform: translateX(min(280px, 50vw - 40px));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 26px;
  box-shadow: var(--shadow-lg); z-index: 90;
}
.btn-fab:active { transform: translateX(min(280px, 50vw - 40px)) scale(.92); }

/* ============================================================= CARDS */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card + .card { margin-top: 12px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 12px;
}
.card-title { font-size: var(--fs-md); font-weight: 700; }

/* ============================================================= BADGES & PILLS */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.4;
}
.badge-icon { font-weight: 700; }

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
}

/* Avatar */
.avatar {
  display: inline-grid; place-items: center;
  border-radius: 50%;
  color: #fff; font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ============================================================= FORM */
.form-group { margin-bottom: 16px; }
.form-group + .form-group { margin-top: 0; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; min-width: 0; }
.form-hint { font-size: var(--fs-xs); color: var(--text-3); margin-top: 4px; }
.form-error { font-size: var(--fs-xs); color: var(--danger); margin-top: 4px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input-icon {
  position: absolute; left: 12px; font-size: 18px; color: var(--text-3);
  pointer-events: none;
}
.input-group input { padding-left: 40px; }
.input-group .input-suffix-btn {
  position: absolute; right: 6px;
  padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm);
  font-size: var(--fs-sm); color: var(--text-2);
}

select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 38px;
}

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--surface-3);
  border-radius: var(--radius-full); transition: .2s;
}
.switch .slider::before {
  content: ''; position: absolute; height: 18px; width: 18px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s;
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ============================================================= LIST */
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
  position: relative;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--surface-2); }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-sub { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.list-item .li-end { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.list-item .li-chevron { color: var(--text-3); font-size: 18px; }

/* ============================================================= STATS / DASHBOARD */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.page-title { font-size: var(--fs-xl); font-weight: 800; }
.page-subtitle { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%;
  background: var(--accent-color, var(--primary));
}
.stat-label { font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: var(--fs-2xl); font-weight: 800; margin-top: 4px; color: var(--text); line-height: 1.1; }
.stat-icon { position: absolute; right: 10px; top: 10px; font-size: 20px; opacity: .25; }

.stat-card.wide { grid-column: span 2; }
.stat-card.accent-teal { --accent-color: #0f766e; }
.stat-card.accent-blue { --accent-color: #2563eb; }
.stat-card.accent-green { --accent-color: #16a34a; }
.stat-card.accent-orange { --accent-color: #ea580c; }
.stat-card.accent-red { --accent-color: #dc2626; }
.stat-card.accent-purple { --accent-color: #7c3aed; }

/* Section title */
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 20px 0 10px; gap: 8px;
}
.section-title h3 { font-size: var(--fs-md); font-weight: 700; }
.section-title a, .section-title button { font-size: var(--fs-sm); color: var(--primary); font-weight: 600; }

/* ============================================================= EMPTY STATE */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-3);
}
.empty-state .empty-icon { font-size: 56px; opacity: .4; margin-bottom: 12px; }
.empty-state .empty-title { font-size: var(--fs-md); font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.empty-state .empty-msg { font-size: var(--fs-sm); }

/* ============================================================= LOGIN */
.login-page {
  min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 60%, #0c4a48 100%);
  display: flex; flex-direction: column; justify-content: center;
  padding: 24px 20px calc(20px + var(--safe-bottom));
  position: relative; overflow: hidden;
}
.login-page::before {
  content: ''; position: absolute; top: -100px; right: -80px;
  width: 280px; height: 280px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.login-page::after {
  content: ''; position: absolute; bottom: -120px; left: -100px;
  width: 260px; height: 260px; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.login-card {
  background: var(--surface); border-radius: var(--radius-xl);
  padding: 32px 24px; box-shadow: var(--shadow-lg);
  position: relative; z-index: 1;
  animation: slideUp .4s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-logo {
  width: 76px; height: 76px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg);
  display: grid; place-items: center;
  font-size: 38px;
  box-shadow: var(--shadow-md);
}
.login-title { text-align: center; font-size: var(--fs-xl); font-weight: 800; margin-bottom: 4px; }
.login-subtitle { text-align: center; font-size: var(--fs-sm); color: var(--text-2); margin-bottom: 24px; }
.login-footer {
  text-align: center; font-size: var(--fs-xs); color: rgba(255,255,255,.7);
  margin-top: 24px; position: relative; z-index: 1;
}

.demo-creds {
  background: var(--primary-bg); border: 1px dashed var(--primary-light);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 16px;
  font-size: var(--fs-xs); color: var(--primary-dark);
}

/* ============================================================= SEARCH BAR */
.search-bar {
  position: relative; margin-bottom: 12px;
}
.search-bar input {
  padding-left: 42px; background: var(--surface);
  border-radius: var(--radius-full);
}
.search-bar .search-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 18px;
}
.search-bar .clear-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-2);
  display: grid; place-items: center; font-size: 14px;
}

/* Filter chips */
.filter-chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 7px 14px; border-radius: var(--radius-full);
  background: var(--surface); border: 1.5px solid var(--border);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 600;
  transition: all .15s;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Filter sheet trigger */
.filter-trigger {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1.5px solid var(--border);
  color: var(--text-2); font-weight: 600; font-size: var(--fs-sm);
  flex-shrink: 0;
}
.filter-trigger.active { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); }

/* ============================================================= TABLE / DETAIL GRID */
.detail-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 8px 16px;
  font-size: var(--fs-sm);
}
.detail-grid dt { color: var(--text-2); font-weight: 500; }
.detail-grid dd { font-weight: 600; text-align: right; word-break: break-word; }
.detail-grid > div {
  display: contents;
}

.kv-list { display: flex; flex-direction: column; gap: 10px; }
.kv { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; font-size: var(--fs-sm); }
.kv .k { color: var(--text-2); flex-shrink: 0; }
.kv .v { font-weight: 600; text-align: right; word-break: break-word; }

/* ============================================================= MODAL / SHEET */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, .5);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .25s;
  padding: 0;
}
.modal-overlay.show { opacity: 1; }
.modal-overlay.center { align-items: center; padding: 20px; }

.modal {
  background: var(--surface);
  width: 100%; max-width: var(--max-w);
  max-height: 90vh; max-height: 90dvh;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.32,.72,0,1);
  overflow: hidden;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-overlay.center .modal {
  border-radius: var(--radius-xl);
  transform: scale(.9) translateY(20px);
}
.modal-overlay.center.show .modal { transform: scale(1) translateY(0); }

.modal-sm { max-width: 360px; }

.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-shrink: 0;
}
.modal-header h3 { font-size: var(--fs-lg); font-weight: 700; }
.modal-handle {
  width: 40px; height: 4px; border-radius: var(--radius-full);
  background: var(--surface-3); margin: 8px auto 4px;
  flex-shrink: 0;
}
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 20px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  display: flex; gap: 10px;
  flex-shrink: 0; background: var(--surface);
}
.modal-footer .btn { flex: 1; }
.modal-close {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-2); display: grid; place-items: center;
  font-size: 18px; color: var(--text-2);
}

/* ============================================================= TOAST */
.toast-container {
  position: fixed; bottom: calc(var(--tabbar-h) + 16px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%);
  z-index: 2000; width: calc(100% - 32px); max-width: 460px;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text); color: #fff;
  padding: 12px 16px; border-radius: var(--radius);
  display: flex; align-items: center; gap: 10px;
  font-size: var(--fs-sm); font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(20px);
  transition: opacity .25s, transform .25s;
  pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-icon {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.toast-success { background: #15803d; }
.toast-success .toast-icon { background: rgba(255,255,255,.25); }
.toast-error { background: #b91c1c; }
.toast-error .toast-icon { background: rgba(255,255,255,.25); }
.toast-warning { background: #c2410c; }
.toast-warning .toast-icon { background: rgba(255,255,255,.25); }
.toast-info { background: #1d4ed8; }
.toast-info .toast-icon { background: rgba(255,255,255,.25); }

/* ============================================================= LOADING / SPINNER */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed; inset: 0; z-index: 1500;
  background: rgba(15, 23, 42, .4);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
  backdrop-filter: blur(2px);
}
.loading-overlay.show { opacity: 1; }
.loading-box {
  background: var(--surface); padding: 24px 32px;
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: var(--shadow-lg);
}
.loading-msg { font-size: var(--fs-sm); color: var(--text-2); }

.loading-inline {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 30px 20px; color: var(--text-3); font-size: var(--fs-sm);
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card { padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line:last-child { margin-bottom: 0; }

/* ============================================================= PAGINATION */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 16px; padding: 8px;
}
.pagination .btn { padding: 8px 14px; font-size: var(--fs-sm); }
.pagination-info { font-size: var(--fs-sm); color: var(--text-2); }

/* Infinite scroll loader */
.load-more-trigger { padding: 20px; text-align: center; }

/* ============================================================= MISC */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-muted { color: var(--text-2); }
.text-faint { color: var(--text-3); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relative { position: relative; }

/* Progress bar */
.progress {
  height: 8px; background: var(--surface-3);
  border-radius: var(--radius-full); overflow: hidden;
}
.progress-bar {
  height: 100%; background: var(--primary);
  border-radius: var(--radius-full);
  transition: width .4s ease;
}

/* Photo / image placeholder */
.photo-placeholder {
  width: 100%; aspect-ratio: 16/9;
  background: var(--surface-2);
  border-radius: var(--radius);
  display: grid; place-items: center;
  color: var(--text-3); font-size: 40px;
}
.photo-placeholder.square { aspect-ratio: 1; }

/* Code block */
.code-block {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  background: var(--surface-2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  word-break: break-all;
}

/* Scan overlay */
.scanner-container {
  position: relative; width: 100%; max-width: 400px; margin: 0 auto;
  aspect-ratio: 1; border-radius: var(--radius-lg); overflow: hidden;
  background: #000;
}
#scan-video {
  width: 100%; height: 100%; object-fit: cover;
}
.scan-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
}
.scan-frame {
  width: 70%; height: 70%;
  border: 3px solid rgba(255,255,255,.9);
  border-radius: var(--radius);
  position: relative;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.4);
}
.scan-frame::before, .scan-frame::after,
.scan-frame > span:first-child, .scan-frame > span:last-child {
  content: ''; position: absolute; width: 24px; height: 24px;
  border: 4px solid var(--primary-light);
}
.scan-frame::before { top: -3px; left: -3px; border-right: none; border-bottom: none; border-radius: 8px 0 0 0; }
.scan-frame::after { top: -3px; right: -3px; border-left: none; border-bottom: none; border-radius: 0 8px 0 0; }
.scan-frame > span:first-child { bottom: -3px; left: -3px; border-right: none; border-top: none; border-radius: 0 0 0 8px; }
.scan-frame > span:last-child { bottom: -3px; right: -3px; border-left: none; border-top: none; border-radius: 0 0 8px 0; }
.scan-line {
  position: absolute; left: 5%; right: 5%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary-light), transparent);
  animation: scanMove 2s linear infinite;
  box-shadow: 0 0 12px var(--primary-light);
}
@keyframes scanMove {
  0%, 100% { top: 10%; }
  50% { top: 90%; }
}

/* ============================================================= ANIMATIONS */
.fade-in { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.slide-up { animation: slideUpFade .3s ease; }
@keyframes slideUpFade { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================= RESPONSIVE - Tablet/Desktop */
@media (min-width: 769px) {
  body { background: var(--surface-2); }
  #app {
    margin: 24px auto;
    border-radius: var(--radius-xl);
    overflow: hidden;
    min-height: calc(100vh - 48px);
    box-shadow: var(--shadow-lg);
  }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-card.wide { grid-column: span 3; }
}

/* Safe area tweaks for iOS notch */
@supports (padding: max(0px)) {
  #app-header { padding-top: var(--safe-top); }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
