/* gear-vault v3 */
/* ===== CSS Variables ===== */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-hover: #f0f0f2;
  --text: #1d1d1f;
  --text-secondary: #86868b;
  --text-tertiary: #aeaeb2;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-light: rgba(0,113,227,0.08);
  --success: #34c759;
  --success-light: rgba(52,199,89,0.1);
  --warning: #ff9f0a;
  --warning-light: rgba(255,159,10,0.1);
  --danger: #ff3b30;
  --danger-light: rgba(255,59,48,0.1);
  --border: rgba(0,0,0,0.06);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.04);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  --transition: 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-tertiary); border-radius: 3px; }

/* ===== Login Page ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
  background: white;
  border-radius: 20px;
  padding: 36px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: fadeInUp 0.4s ease;
}
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.login-logo { text-align: center; font-size: 48px; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-sub { text-align: center; font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }
.login-error {
  background: var(--danger-light);
  color: #c41e3a;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
  display: none;
}
.login-error.show { display: block; }

/* ===== App Layout ===== */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; padding-bottom: 80px; }
.header {
  padding: 16px 20px 12px;
  background: rgba(245,245,247,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.header h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-user { font-size: 13px; color: var(--text-secondary); padding: 6px 12px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); }
.header-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--surface); color: var(--accent); font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); transition: var(--transition);
}
.header-btn:hover { background: var(--accent-light); transform: scale(1.05); }
.header-btn.disabled { opacity: 0.4; pointer-events: none; }
.search-box { position: relative; }
.search-box input {
  width: 100%; padding: 10px 14px 10px 38px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface); font-size: 15px; font-family: var(--font);
  color: var(--text); outline: none; transition: var(--transition);
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.search-box .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); font-size: 15px; }

/* Stats */
.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; padding: 0 20px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border-radius: var(--radius-sm); padding: 14px 12px; text-align: center; box-shadow: var(--shadow); transition: var(--transition); }
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.stat-number { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 2px; font-weight: 500; }
.stat-card.total .stat-number { color: var(--accent); }
.stat-card.out .stat-number { color: var(--warning); }
.stat-card.overdue .stat-number { color: var(--danger); }

/* Section */
.section { padding: 0 20px; margin-bottom: 20px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.section-action {
  font-size: 14px; color: var(--accent); cursor: pointer; font-weight: 500;
  border: none; background: none; padding: 4px 8px; border-radius: 6px; transition: var(--transition);
  font-family: var(--font);
}
.section-action:hover { background: var(--accent-light); }

/* Category Pills */
.category-scroll {
  display: flex; gap: 8px; overflow-x: auto; padding: 0 20px 4px; margin-bottom: 16px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.category-scroll::-webkit-scrollbar { display: none; }
.cat-pill {
  flex-shrink: 0; padding: 8px 16px; border-radius: 20px; border: 1.5px solid var(--border);
  background: var(--surface); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: var(--transition); white-space: nowrap; color: var(--text-secondary);
}
.cat-pill:hover { border-color: var(--accent); color: var(--accent); }
.cat-pill.active { background: var(--accent); color: white; border-color: var(--accent); }
.cat-pill .cat-icon { margin-right: 4px; }

/* Equipment Card */
.eq-card {
  background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
  box-shadow: var(--shadow); transition: var(--transition); cursor: pointer; position: relative; overflow: hidden;
}
.eq-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.eq-card:active { transform: scale(0.99); }
.eq-card-top { display: flex; align-items: flex-start; gap: 12px; }
.eq-icon {
  width: 44px; height: 44px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
.eq-icon.camera { background: #e8f4fd; }
.eq-icon.lens { background: #fef3e2; }
.eq-icon.light { background: #fff8e1; }
.eq-icon.battery { background: #e8f5e9; }
.eq-icon.cable { background: #f3e5f5; }
.eq-icon.accessory { background: #fce4ec; }
.eq-info { flex: 1; min-width: 0; }
.eq-name { font-size: 16px; font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eq-meta { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.eq-meta span { white-space: nowrap; }
.eq-status {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
  border-radius: 12px; font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.eq-status.in { background: var(--success-light); color: #1b8a3e; }
.eq-status.out { background: var(--warning-light); color: #b36a00; }
.eq-status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.eq-location { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
.eq-borrower { margin-top: 4px; font-size: 12px; color: var(--warning); font-weight: 500; }

/* Tab Bar */
.tab-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  max-width: 480px; width: 100%;
  background: rgba(255,255,255,0.88); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--border);
  display: flex; padding: 6px 0; padding-bottom: calc(6px + env(safe-area-inset-bottom)); z-index: 200;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0;
  cursor: pointer; border: none; background: none; color: var(--text-tertiary);
  font-size: 10px; font-weight: 500; transition: var(--transition); font-family: var(--font);
}
.tab-item.active { color: var(--accent); }
.tab-item .tab-icon { font-size: 22px; line-height: 1; }
.tab-item .badge {
  position: absolute; top: 2px; right: 50%; margin-right: -18px;
  background: var(--danger); color: white; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* Page */
.page { display: none; }
.page.active { display: block; }

/* Empty State */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-secondary); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state .empty-text { font-size: 15px; margin-bottom: 16px; }
.empty-state .empty-hint { font-size: 13px; color: var(--text-tertiary); }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 500; animation: fadeIn 0.2s ease;
}
.modal-overlay.active { display: flex; align-items: flex-end; justify-content: center; }
.modal-sheet {
  background: var(--surface); border-radius: 20px 20px 0 0; width: 100%; max-width: 480px; max-height: 92vh;
  overflow-y: auto; animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); padding-bottom: env(safe-area-inset-bottom);
}
.modal-sheet.full { max-height: 96vh; border-radius: 0; }
.modal-handle { width: 36px; height: 4px; background: var(--text-tertiary); border-radius: 2px; margin: 10px auto 0; }
.modal-header {
  padding: 16px 20px 12px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--bg);
  color: var(--text-secondary); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-body { padding: 0 20px 24px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Form */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-xs); border: 1.5px solid var(--border);
  background: var(--surface); font-size: 15px; font-family: var(--font); color: var(--text);
  outline: none; transition: var(--transition); -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2386868b' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-textarea { min-height: 80px; resize: vertical; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 24px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600;
  border: none; cursor: pointer; transition: var(--transition); font-family: var(--font); width: 100%;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: scale(0.98); }
.btn-outline { background: var(--surface); color: var(--accent); border: 1.5px solid var(--accent); }
.btn-outline:hover { background: var(--accent-light); }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #e68a00; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #2fb34a; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #e6342a; }
.btn-sm { padding: 8px 16px; font-size: 13px; width: auto; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Toast */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: white; padding: 10px 20px; border-radius: 20px;
  font-size: 14px; font-weight: 500; z-index: 999; opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* Loading */
.loading-overlay {
  display: none; position: fixed; inset: 0; background: rgba(255,255,255,0.7);
  z-index: 998; align-items: center; justify-content: center;
}
.loading-overlay.show { display: flex; }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* History Item */
.history-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.history-dot.in { background: var(--success); }
.history-dot.out { background: var(--warning); }
.history-info { flex: 1; min-width: 0; }
.history-action { font-size: 14px; font-weight: 500; }
.history-time { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.history-who { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

/* Detail Page */
.detail-header { text-align: center; padding: 24px 20px 16px; }
.detail-icon { width: 64px; height: 64px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 32px; margin-bottom: 12px; }
.detail-name { font-size: 22px; font-weight: 700; }
.detail-cat { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }
.detail-section { padding: 16px 20px; }
.detail-section-title { font-size: 13px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-row .label { font-size: 13px; color: var(--text-secondary); }
.detail-row .value { font-size: 14px; font-weight: 500; text-align: right; }
.btn-row { display: flex; gap: 10px; padding: 0 20px; }
.btn-row .btn { flex: 1; }

/* QR Display */
.qr-display { text-align: center; padding: 16px; }
.qr-canvas { display: inline-block; padding: 16px; background: white; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.qr-label { font-size: 12px; color: var(--text-tertiary); margin-top: 8px; }
.qr-id { font-size: 14px; font-weight: 600; margin-top: 4px; }

/* Scanner */
.scanner-tabs { display: flex; border-bottom: 1px solid var(--border); margin: 0 20px; }
.scanner-tab { flex: 1; padding: 10px; border: none; background: none; font-size: 14px; font-weight: 500; color: var(--text-tertiary); cursor: pointer; border-bottom: 2px solid transparent; transition: var(--transition); font-family: var(--font); }
.scanner-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.scanner-container {
  position: relative; width: 100%; aspect-ratio: 1; max-width: 320px; margin: 16px auto 0;
  border-radius: var(--radius); overflow: hidden; background: #111;
}
.scanner-corner { position: absolute; width: 24px; height: 24px; border: 3px solid var(--accent); z-index: 2; }
.scanner-corner.tl { top: 12px; left: 12px; border-right: none; border-bottom: none; border-radius: 6px 0 0 0; }
.scanner-corner.tr { top: 12px; right: 12px; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.scanner-corner.bl { bottom: 12px; left: 12px; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.scanner-corner.br { bottom: 12px; right: 12px; border-left: none; border-top: none; border-radius: 0 0 6px 0; }
.scanner-scan-line {
  position: absolute; top: 12px; left: 12px; right: 12px; height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  z-index: 2; animation: scanMove 2.5s ease-in-out infinite;
}
@keyframes scanMove { 0%,100% { top: 12px; } 50% { top: calc(100% - 15px); } }
.scanner-hint { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; font-size: 12px; color: rgba(255,255,255,0.7); z-index: 2; }
.scanner-error { text-align: center; padding: 24px 20px; }
.scanner-error .err-icon { font-size: 36px; margin-bottom: 8px; }
.scanner-error .err-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.scanner-error .err-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* Upload Area */
.upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px 20px;
  text-align: center; cursor: pointer; transition: var(--transition);
}
.upload-area:hover { border-color: var(--accent); background: var(--accent-light); }
.upload-icon { font-size: 36px; margin-bottom: 8px; }
.upload-text { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.upload-hint { font-size: 12px; color: var(--text-tertiary); }

/* Print */
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; }
  .no-print { display: none !important; }
}

/* Responsive */
@media (max-width: 480px) {
  .header { padding: 12px 16px 10px; }
  .section { padding: 0 16px; }
  .stats-row { padding: 0 16px; gap: 8px; }
  .category-scroll { padding: 0 16px 4px; }
}
