:root {
  --bg-color: #f4f6f8; --text-color: #333; --card-bg: white;
  --header-bg: #1565c0; --border-color: #ddd; --section-bg: #f9f9f9;
  --input-bg: white; --input-text: #333; --placeholder-color: #bbb;
}
body.dark-mode {
  --bg-color: #121212; --text-color: #e0e0e0; --card-bg: #1e1e1e;
  --header-bg: #0d47a1; --border-color: #333; --input-bg: #2c2c2c; --input-text: #e0e0e0;
  --section-bg: #252525; --placeholder-color: #666;
}
* { box-sizing: border-box; }
body { font-family: 'Roboto', 'Segoe UI', sans-serif; background-color: var(--bg-color); color: var(--text-color); margin: 0; padding: 0; transition: background-color 0.3s; }

.top-header { background-color: var(--header-bg); color: white; padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.2); flex-wrap: wrap; gap: 10px; }
.header-actions { display: flex; gap: 15px; align-items: center; flex-wrap: wrap; }
.header-btn { background: rgba(255,255,255,0.1); color: white; border: 1px solid rgba(255,255,255,0.5); padding: 8px 15px; border-radius: 4px; cursor: pointer; font-weight: 500; font-size: 0.9rem; }
.header-btn:hover { background: rgba(255,255,255,0.25); }
.header-select { background: rgba(255,255,255,0.1); color: white; border: 1px solid rgba(255,255,255,0.5); padding: 6px 10px; border-radius: 4px; font-size: 0.85rem; }
.header-select option { color: #333; }

#global-loader { display: flex; position: fixed; inset: 0; background: linear-gradient(160deg, #0d47a1 0%, #1565c0 55%, #1a237e 100%); z-index: 2000; justify-content: center; align-items: center; flex-direction: column; padding: 30px 20px; }
.gl-logo { font-size: 54px; margin-bottom: 14px; }
.gl-title { font-size: 1.35rem; font-weight: 700; color: white; margin-bottom: 3px; }
.gl-org { font-size: 0.78rem; color: rgba(255,255,255,0.55); margin-bottom: 32px; letter-spacing: 1px; text-transform: uppercase; }
.gl-wrap { width: 100%; max-width: 300px; }
.gl-header { display: flex; justify-content: space-between; margin-bottom: 8px; }
.gl-step { font-size: 0.82rem; color: rgba(255,255,255,0.88); }
.gl-pct { font-size: 0.82rem; color: white; font-weight: 700; }
.gl-track { background: rgba(255,255,255,0.18); border-radius: 10px; height: 6px; overflow: hidden; }
.gl-fill { height: 100%; background: linear-gradient(90deg, #42a5f5, #90caf9); border-radius: 10px; transition: width 0.4s; width: 0%; }

#action-overlay { display: none; position: fixed; inset: 0; background: rgba(255,255,255,0.92); z-index: 1999; justify-content: center; align-items: center; flex-direction: column; color: #1565c0; }
.spinner { border: 6px solid #e3f2fd; border-top: 6px solid #1565c0; border-radius: 50%; width: 44px; height: 44px; animation: spin 0.9s linear infinite; margin-bottom: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

.stats-bar { background-color: #263238; color: white; padding: 12px 20px; display: flex; flex-wrap: wrap; gap: 15px; font-size: 0.9rem; }
.container { padding: 20px; }
.cat-header { background-color: #546e7a; color: white; padding: 10px 15px; font-weight: bold; text-transform: uppercase; border-radius: 4px 4px 0 0; margin-top: 20px; display: flex; justify-content: space-between; align-items: center; }
.cat-collapse-btn { background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.4); color: white; padding: 2px 10px; border-radius: 4px; cursor: pointer; font-size: 0.85rem; }
.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; background-color: var(--card-bg); padding: 20px; border: 1px solid var(--border-color); border-top: none; border-radius: 0 0 4px 4px; }
.grid-container.collapsed { display: none !important; }

.card { border-radius: 12px; padding: 16px; cursor: pointer; color: white; min-height: 110px; display: flex; flex-direction: column; justify-content: space-between; transition: all 0.25s; position: relative; overflow: hidden; font-size: 0.95rem; box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.card:hover { transform: translateY(-4px); box-shadow: 0 10px 18px rgba(0,0,0,0.22); }
.card-title { line-height: 1.2; }
.card-title .loc { font-size: 0.8em; font-weight: 400; opacity: 0.9; }
.card.status-red { background: linear-gradient(135deg, #ef5350 0%, #e53935 50%, #d32f2f 100%); }
.card.status-orange { background: linear-gradient(135deg, #ffb74d 0%, #ff9800 50%, #f57c00 100%); }
.card.status-green { background: linear-gradient(135deg, #66bb6a 0%, #4caf50 50%, #388e3c 100%); }
.card.status-purple { background: linear-gradient(135deg, #ef5350 0%, #e53935 50%, #d32f2f 100%); border: 2px solid #d32f2f; }
.card.status-purple .card-title { text-decoration: line-through; opacity: 0.85; }
.card-info { font-size: 0.9em; opacity: 0.95; line-height: 1.6; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.card-action-btn { display: inline-block; background: rgba(0,0,0,0.30); color: #fff; padding: 4px 8px; border-radius: 8px; font-size: 0.75rem; cursor: pointer; white-space: nowrap; }
.card-action-btn:hover { background: rgba(0,0,0,0.52); }

.check-zone { background: var(--section-bg); border: 2px solid #1976d2; border-radius: 8px; margin-bottom: 20px; overflow: hidden; }
body.dark-mode .check-zone { border-color: #42a5f5; }
.check-zone-header { background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%); color: white; padding: 12px 15px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; }
.sealed-checkbox { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.cam-icon-btn { cursor: pointer; font-size: 1.2rem; }
.cam-icon-btn:hover { transform: scale(1.1); }
.subsection-group { margin: 8px 6px; border-radius: 8px; overflow: hidden; border: 1px solid rgba(66,165,245,0.3); }
.subsection-header { padding: 8px 12px; font-weight: bold; font-size: 0.88rem; color: white; background: linear-gradient(135deg, #42a5f5 0%, #1e88e5 100%); display: flex; align-items: center; gap: 6px; }
.subsection-group .form-row { background: rgba(66,165,245,0.06); }

.form-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-color); font-size: 0.9rem; position: relative; }
.form-input-container { flex: 0 0 40%; display: flex; justify-content: flex-end; align-items: center; max-width: 250px; }
.form-input-container input:not([type="checkbox"]) { width: 100%; max-width: 180px; padding: 6px; border: 1px solid var(--border-color); border-radius: 4px; text-align: right; background-color: var(--input-bg); color: var(--input-text); font-size: 0.9rem; }
.item-tooltip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #263238; color: #fff; padding: 6px 12px; border-radius: 6px; font-size: 0.78rem; z-index: 50; max-width: 320px; text-align: center; }
.form-row:hover .item-tooltip { display: block; }

.switch { position: relative; display: inline-block; width: 50px; height: 26px; flex: 0 0 50px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background-color: #ccc; transition: .4s; border-radius: 26px; cursor: pointer; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #1565c0; }
input:checked + .slider:before { transform: translateX(24px); }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000; justify-content: center; align-items: center; }
.modal { background: var(--card-bg); color: var(--text-color); border-radius: 8px; width: 95%; max-width: 650px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0,0,0,0.3); }
.modal-header { padding: 12px 15px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; background: var(--section-bg); align-items: center; }
.modal-body { padding: 20px; overflow-y: auto; background: var(--card-bg); color: var(--text-color); }
.modal-footer { padding: 15px; border-top: 1px solid var(--border-color); background: var(--section-bg); }
.admin-btn { background: #1565c0; color: white; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }
.admin-btn.secondary { background: #78909c; } .admin-btn.success { background: #43a047; } .admin-btn.danger { background: #d32f2f; }

#splashChoice { position: fixed; inset: 0; z-index: 99999; background: linear-gradient(135deg, #0d47a1 0%, #1a237e 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 20px; }
#splashChoice h2 { color: #fff; font-size: 22px; text-align: center; margin: 0; }
#splashChoice p { color: rgba(255,255,255,.7); font-size: 13px; margin: 0; }
.splashBtn { width: 200px; padding: 18px; border-radius: 14px; border: 2px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; font-size: 17px; font-weight: 700; cursor: pointer; text-align: center; }
.splashBtn:hover { background: rgba(255,255,255,.15); }

body.mobile-mode { padding-bottom: 36px; }
body.mobile-mode .top-header { flex-direction: column; text-align: center; }
body.mobile-mode .grid-container { grid-template-columns: 1fr !important; }
body.mobile-mode .modal { width: 100% !important; max-width: 100% !important; max-height: 100vh !important; height: 100vh !important; border-radius: 0 !important; }
body.mobile-mode .form-row { flex-direction: column; align-items: stretch; gap: 4px; }
body.mobile-mode .form-input-container { flex: none; max-width: none; justify-content: stretch; }
body.mobile-mode .form-input-container input:not([type="checkbox"]) { max-width: none; font-size: 16px !important; padding: 10px; }

/* Admin */
.admin-nav { display: flex; gap: 10px; margin-bottom: 20px; border-bottom: 2px solid var(--border-color); padding-bottom: 10px; flex-wrap: wrap; }
.nav-btn { padding: 10px 20px; background: var(--section-bg); border: none; border-radius: 4px; cursor: pointer; font-weight: bold; color: var(--text-color); }
.nav-btn.active { background: #1565c0; color: white; }
.admin-tab { display: none; } .admin-tab.active { display: block; }
.inv-table { width: 100%; border-collapse: collapse; margin-top: 15px; font-size: 0.9rem; }
.inv-table th { text-align: left; background: var(--section-bg); padding: 10px; border-bottom: 2px solid var(--border-color); }
.inv-table td { padding: 8px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.inv-table td input, .inv-table td select { width: 100%; padding: 6px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--input-bg); color: var(--input-text); }
.section-block { background: var(--section-bg); border: 1px solid var(--border-color); border-radius: 6px; padding: 12px; margin-bottom: 15px; }
.section-header { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.item-row { display: flex; gap: 8px; align-items: center; padding: 8px; border-bottom: 1px solid var(--border-color); background: var(--card-bg); flex-wrap: wrap; }
.item-row:last-child { border-bottom: none; }
.item-row input, .item-row select { padding: 6px; border: 1px solid var(--border-color); border-radius: 3px; font-size: 0.9rem; background: var(--input-bg); color: var(--input-text); }
.photo-thumb { width: 60px; height: 45px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border-color); }
.ds-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--border-color); font-size: 0.88rem; }
.ds-val { font-weight: 600; color: #1565c0; }
.ms-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--border-color); font-size: 0.88rem; }
.ms-expected { color: #388e3c; font-weight: 600; }
.ms-actual { color: #d32f2f; font-weight: 600; }
