:root {
  --bg: #0b0f17;
  --panel: #111827;
  --panel-2: #1f2937;
  --border: #273142;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --danger: #ef4444;
  --success: #10b981;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  overscroll-behavior-x: none;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
  position: relative;
}

#app {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top) 16px 0;
  width: 100%;
  box-sizing: border-box;
}
header .bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
}
header h1 {
  font-size: 18px;
  margin: 0;
  flex: 1;
  font-weight: 600;
}
header .back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  margin-left: -8px;
}

nav.tabs {
  display: flex;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
nav.tabs a {
  flex: 1;
  text-align: center;
  padding: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  border-bottom: 2px solid transparent;
}
nav.tabs a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

main {
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}

button, .btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button:hover, .btn:hover { background: var(--accent-2); }
button.secondary, .btn.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}
button.danger, .btn.danger { background: var(--danger); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, textarea, select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.field { margin-bottom: 12px; }

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.row > * { flex: 1; }
.row > .fixed { flex: 0 0 auto; }

.grid {
  display: grid;
  gap: 12px;
}

.list-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 8px;
}
.list-item .thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-2);
  flex: 0 0 auto;
}
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; margin-bottom: 2px; }
.list-item .sub { color: var(--muted); font-size: 13px; }
.list-item .badge {
  background: var(--panel-2);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}

/* Excel-like table */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 100%;
}
table {
  border-collapse: collapse;
  font-size: 13px;
  min-width: 700px;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  background: var(--panel-2);
  font-weight: 600;
  position: sticky;
  top: 0;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
td img.thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
}

.photos {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.photos .slot {
  aspect-ratio: 1;
  background: var(--panel-2);
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 24px;
  position: relative;
  overflow: hidden;
}
.photos .slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photos .slot .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

#qr-reader {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 12px;
  border-radius: 8px;
  overflow: hidden;
}

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.status.ok { background: rgba(16,185,129,0.15); color: var(--success); }
.status.pending { background: rgba(156,163,175,0.15); color: var(--muted); }
.status.error { background: rgba(239,68,68,0.15); color: var(--danger); }
.status.skipped { background: rgba(156,163,175,0.15); color: var(--muted); }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.fab {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 28px;
  box-shadow: 0 6px 16px rgba(59,130,246,0.4);
  z-index: 50;
}

h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.muted { color: var(--muted); font-size: 13px; }
