@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg: #0d0f1a;
  --bg2: #141726;
  --card: #1c2035;
  --card2: #222540;
  --border: #2a2f4a;
  --text: #e8eaf6;
  --text2: #8b91b5;
  --blue: #4f87ff;
  --blue2: #3a6fdd;
  --ok: #22c55e;
  --wear: #f59e0b;
  --crit: #ef4444;
  --pending: #4b5563;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }

/* ---- Layout ---- */
.container { max-width: 680px; margin: 0 auto; padding: 0 16px; }

/* ---- Header ---- */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(20,23,38,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}
.header-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-brand img { width: 36px; height: 36px; border-radius: 8px; }
.header-brand h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.3px; }
.header-actions { display: flex; gap: 6px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 0.875rem;
  font-weight: 500; border: none; cursor: pointer;
  transition: all 0.15s ease; font-family: inherit; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue2); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--card2); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--crit); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.25); }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body { padding: 16px; }

/* ---- Form elements ---- */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 0.8rem; font-weight: 500; color: var(--text2); }
.form-input, .form-select, .form-textarea {
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
  padding: 10px 12px; font-family: inherit; font-size: 0.9rem;
  transition: border-color 0.15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79,135,255,0.15);
}
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238b91b5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 36px; }
.form-textarea { resize: vertical; min-height: 72px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ---- Progress ---- */
.progress-bar { height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--blue); border-radius: 99px; transition: width 0.4s ease; }

/* ---- Status buttons ---- */
.status-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.status-btn {
  flex: 1; min-width: 70px; padding: 8px 6px;
  border-radius: 8px; border: 1.5px solid transparent;
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s; font-family: inherit;
  text-align: center;
}
.status-btn[data-status="ok"]       { background: rgba(34,197,94,0.1);  color: var(--ok);   border-color: rgba(34,197,94,0.2); }
.status-btn[data-status="wear"]     { background: rgba(245,158,11,0.1); color: var(--wear); border-color: rgba(245,158,11,0.2); }
.status-btn[data-status="critical"] { background: rgba(239,68,68,0.1);  color: var(--crit); border-color: rgba(239,68,68,0.2); }
.status-btn[data-status="pending"]  { background: rgba(75,85,99,0.15);  color: var(--text2);border-color: rgba(75,85,99,0.3); }
.status-btn.active[data-status="ok"]       { background: var(--ok);   color: #000; border-color: var(--ok); }
.status-btn.active[data-status="wear"]     { background: var(--wear); color: #000; border-color: var(--wear); }
.status-btn.active[data-status="critical"] { background: var(--crit); color: #fff; border-color: var(--crit); }
.status-btn.active[data-status="pending"]  { background: var(--pending); color: #fff; border-color: var(--pending); }

/* ---- Inspection item card ---- */
.item-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  transition: border-color 0.2s;
}
.item-card.status-ok   { border-left: 3px solid var(--ok); }
.item-card.status-wear { border-left: 3px solid var(--wear); }
.item-card.status-critical { border-left: 3px solid var(--crit); }
.item-name { font-size: 0.9rem; font-weight: 500; margin-bottom: 4px; }
.item-num  { font-size: 0.75rem; color: var(--text2); margin-bottom: 8px; }

/* ---- Photos ---- */
.photos-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-thumb {
  width: 72px; height: 72px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--border); cursor: pointer;
  transition: transform 0.15s;
}
.photo-thumb:hover { transform: scale(1.05); }
.add-photo-btn {
  width: 72px; height: 72px; border-radius: 8px;
  border: 1.5px dashed var(--border); background: var(--bg2);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; cursor: pointer; color: var(--text2);
  font-size: 0.7rem; gap: 3px; transition: all 0.15s;
}
.add-photo-btn:hover { border-color: var(--blue); color: var(--blue); background: rgba(79,135,255,0.05); }
.add-photo-btn svg { width: 20px; height: 20px; }

/* ---- Section nav tabs ---- */
.section-tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.section-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: 8px; border: none;
  font-size: 0.78rem; font-weight: 500; cursor: pointer;
  white-space: nowrap; transition: all 0.15s; font-family: inherit;
  background: var(--card2); color: var(--text2);
}
.tab-btn.active    { background: var(--blue); color: #fff; }
.tab-btn.complete  { background: rgba(34,197,94,0.15); color: var(--ok); }
.tab-count { font-size: 0.7rem; opacity: 0.8; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-ok   { background: rgba(34,197,94,0.15);  color: var(--ok); }
.badge-wear { background: rgba(245,158,11,0.15); color: var(--wear); }
.badge-crit { background: rgba(239,68,68,0.15);  color: var(--crit); }
.badge-disc { background: rgba(239,68,68,0.15);  color: var(--crit); }
.badge-obs  { background: rgba(245,158,11,0.15); color: var(--wear); }

/* ---- Stats row ---- */
.stats-row { display: flex; gap: 12px; }
.stat-chip { display: flex; align-items: center; gap: 5px; font-size: 0.82rem; font-weight: 600; }

/* ---- Banners ---- */
.banner { padding: 10px 16px; text-align: center; font-size: 0.85rem; font-weight: 600; }
.banner-edit     { background: rgba(79,135,255,0.2); color: var(--blue); border-bottom: 1px solid rgba(79,135,255,0.3); }
.banner-discard  { background: rgba(239,68,68,0.2);  color: var(--crit); border-bottom: 1px solid rgba(239,68,68,0.3); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.modal h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ---- Lightbox ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
}
.lightbox img { max-width: 95vw; max-height: 85vh; border-radius: 8px; object-fit: contain; }
.lightbox-close { position: absolute; top: 16px; right: 16px; color: #fff; font-size: 1.5rem; cursor: pointer; background: rgba(255,255,255,0.1); border: none; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* ---- Login page ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(ellipse at top, #1a2040 0%, var(--bg) 70%); }
.login-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 40px 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); text-align: center; }
.login-logo { width: 72px; height: 72px; border-radius: 16px; margin: 0 auto 16px; }
.login-title { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.5px; }
.login-sub { color: var(--text2); font-size: 0.9rem; margin-top: 6px; margin-bottom: 32px; }
.pin-input {
  width: 100%; padding: 14px; text-align: center;
  font-size: 1.8rem; letter-spacing: 0.5em; border-radius: 10px;
  background: var(--bg2); border: 1.5px solid var(--border);
  color: var(--text); font-family: inherit; transition: border-color 0.15s;
}
.pin-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79,135,255,0.2); }
.pin-input.error { border-color: var(--crit); animation: shake 0.3s ease; }
.pin-error { color: var(--crit); font-size: 0.85rem; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 5px; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* ---- History ---- */
.insp-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 12px; }
.insp-card:hover { border-color: var(--blue); background: var(--card2); transform: translateY(-1px); }
.insp-card .plate { font-size: 1rem; font-weight: 700; letter-spacing: 1px; }
.insp-card .meta { font-size: 0.8rem; color: var(--text2); margin-top: 3px; }
.insp-card-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ---- Spinner ---- */
.spinner { width: 24px; height: 24px; border: 2.5px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Timer ---- */
.timer-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; font-family: monospace; color: var(--blue); font-weight: 600; }

/* ---- Save indicator ---- */
.save-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem; color: var(--ok); }

/* ---- Summary / Report ---- */
.summary-section { margin-bottom: 20px; }
.summary-section h3 { font-size: 0.9rem; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.summary-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(42,47,74,0.5); font-size: 0.875rem; }
.summary-item:last-child { border-bottom: none; }
.summary-item .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.summary-item .dot.ok   { background: var(--ok); }
.summary-item .dot.wear { background: var(--wear); }
.summary-item .dot.critical { background: var(--crit); }

/* ---- Toast ---- */
.toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 500; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--card2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 20px; font-size: 0.875rem; font-weight: 500; box-shadow: var(--shadow); animation: toastIn 0.25s ease; max-width: 90vw; text-align: center; }
.toast.success { border-color: var(--ok); color: var(--ok); }
.toast.error   { border-color: var(--crit); color: var(--crit); }
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ---- Print / PDF ---- */
@media print {
  body { background: #fff !important; color: #000 !important; }
  .app-header, .header-actions, .section-tabs-card, .nav-buttons, .action-bar, .btn-ghost, .no-print { display: none !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; background: #fff !important; }
  .item-card { break-inside: avoid; }
  .photo-thumb { width: 120px !important; height: 120px !important; }
}

/* ---- Utility ---- */
.mt-1 { margin-top: 4px; }  .mt-2 { margin-top: 8px; }  .mt-3 { margin-top: 12px; }  .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.flex { display: flex; } .flex-1 { flex: 1; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.text-sm { font-size: 0.875rem; } .text-xs { font-size: 0.75rem; } .text-muted { color: var(--text2); }
.font-bold { font-weight: 700; } .font-600 { font-weight: 600; }
.w-full { width: 100%; } .hidden { display: none !important; }
.text-ok   { color: var(--ok); } .text-wear { color: var(--wear); } .text-crit { color: var(--crit); }
