:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #242440;
  --border: #2e2e50;
  --accent: #6c63ff;
  --accent2: #ff6584;
  --success: #43e97b;
  --warning: #f7971e;
  --danger: #f64f59;
  --text: #e8e8f0;
  --text2: #9999b8;
  --radius: 12px;
  --header: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  min-height: 100dvh;
}

/* Header */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 16px;
}
.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  letter-spacing: -0.5px;
}
nav { display: flex; gap: 4px; }
.nav-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 22px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover, .nav-btn.active { background: var(--surface2); color: var(--text); }

/* Main */
main {
  padding-top: calc(var(--header) + 16px);
  padding-bottom: 32px;
  min-height: 100dvh;
}
.container { padding: 0 16px; max-width: 640px; margin: 0 auto; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card:active { opacity: 0.85; }
.card.clickable { cursor: pointer; transition: border-color 0.15s; }
.card.clickable:hover { border-color: var(--accent); }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}
.stat-card .num {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stat-card .label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-available  { background: rgba(67,233,123,0.15); color: var(--success); }
.badge-checked_out { background: rgba(246,79,89,0.15); color: var(--danger); }
.badge-maintenance { background: rgba(247,151,30,0.15); color: var(--warning); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.75; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-success  { background: var(--success); color: #0a2010; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-block    { width: 100%; justify-content: center; margin-bottom: 8px; }
.btn-sm       { padding: 6px 12px; font-size: 13px; }
.btn-fab {
  position: fixed;
  bottom: 24px; right: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(108,99,255,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}

/* Forms */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 5px; font-weight: 500; }
input, textarea, select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
select option { background: var(--surface2); }

/* Search bar */
.search-bar {
  position: relative;
  margin-bottom: 14px;
}
.search-bar input { padding-left: 36px; }
.search-bar::before {
  content: '⌕';
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text2);
  font-size: 18px;
  pointer-events: none;
}

/* Asset list item */
.asset-item {
  display: flex;
  align-items: center;
  gap: 12px;
}
.asset-thumb {
  width: 48px; height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface2);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  color: var(--text2);
}
.asset-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.asset-info { flex: 1; min-width: 0; }
.asset-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.asset-meta { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* Scanner */
#scanner-container {
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  position: relative;
  margin-bottom: 16px;
}
#scanner-container video { width: 100% !important; }
.scan-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 200px; height: 200px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  pointer-events: none;
  box-shadow: 0 0 0 1000px rgba(0,0,0,0.4);
}

/* Scan results list */
.scan-result-list .card { cursor: pointer; }
.scan-result-list .card:hover { border-color: var(--accent); }

/* Events / timeline */
.event-list { margin-top: 8px; }
.event-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.event-item:last-child { border-bottom: none; }
.event-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}
.event-dot.create    { background: var(--accent); }
.event-dot.check_out { background: var(--danger); }
.event-dot.check_in  { background: var(--success); }
.event-dot.edit      { background: var(--text2); }
.event-time { color: var(--text2); font-size: 11px; }

/* Section title */
.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
  margin: 20px 0 10px;
}

/* Toast */
#toast {
  position: fixed;
  bottom: 90px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Misc */
.loading { text-align: center; padding: 40px; color: var(--text2); }
.empty   { text-align: center; padding: 40px; color: var(--text2); font-size: 14px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text2); }
.detail-img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--surface2);
  margin-bottom: 16px;
}

/* Filter chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.chip.active { border-color: var(--accent); color: var(--accent); background: rgba(108,99,255,0.1); }

@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
