/* ===== VARIABLES ===== */
:root {
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --header-h: 56px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 14px; color: var(--gray-800); background: var(--gray-100); line-height: 1.5; }
button { cursor: pointer; font-family: inherit; font-size: 13px; }
input, select, textarea { font-family: inherit; font-size: 14px; }
.hidden { display: none !important; }

/* ===== LOGIN ===== */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
  padding: 16px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 28px; color: var(--primary); }
.login-logo svg { margin-bottom: 12px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--gray-800); }
.login-logo p { color: var(--gray-500); font-size: 13px; margin-top: 4px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.error-msg { color: var(--danger); font-size: 13px; text-align: center; padding: 8px; background: var(--danger-light); border-radius: var(--radius); }

/* ===== INPUTS ===== */
.input-field {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius); background: #fff; color: var(--gray-800); outline: none;
  transition: border-color 0.15s;
}
.input-field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,64,175,0.08); }
.input-field::placeholder { color: var(--gray-400); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border: none; border-radius: var(--radius); font-weight: 500; transition: all 0.15s; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-200); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { background: #b45309; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-ghost { background: transparent; color: rgba(255,255,255,0.8); border: 1px solid rgba(255,255,255,0.3); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn-upload { background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.4); }
.btn-upload:hover { background: rgba(255,255,255,0.25); }
.btn-full { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ===== HEADER ===== */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: linear-gradient(90deg, #1e3a8a, #1e40af);
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
  z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.header-brand { color: #fff; font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-nav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.nav-btn {
  background: transparent; color: rgba(255,255,255,0.75); border: none;
  padding: 7px 14px; border-radius: 6px; font-weight: 500; transition: all 0.15s;
}
.nav-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,0.2); color: #fff; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ===== CONTENT ===== */
.app-content { margin-top: var(--header-h); min-height: calc(100vh - var(--header-h)); padding: 20px; }
.page { }

/* ===== CARDS / SECTIONS ===== */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 16px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--gray-700); margin-bottom: 12px; }

/* ===== STATS CHIPS ===== */
.stats-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-chip {
  background: #fff; border-radius: var(--radius); padding: 12px 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 120px;
}
.stat-chip .stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-500); margin-bottom: 4px; }
.stat-chip .stat-value { font-size: 24px; font-weight: 700; }
.stat-chip.total .stat-value { color: var(--primary); }
.stat-chip.done .stat-value { color: var(--success); }
.stat-chip.pending .stat-value { color: var(--warning); }

/* ===== FILTER BAR ===== */
.filter-bar {
  background: #fff; border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--gray-500); }
.filter-group select, .filter-group input { padding: 7px 10px; border: 1.5px solid var(--gray-200); border-radius: 6px; background: #fff; color: var(--gray-800); outline: none; }
.filter-group select:focus, .filter-group input:focus { border-color: var(--primary); }
.filter-group input[type="date"] { width: 138px; }

/* ===== SEARCH BAR ===== */
.search-wrapper {
  position: relative; margin-bottom: 14px;
}
.search-wrapper input {
  width: 100%; padding: 9px 14px 9px 36px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius); background: #fff; outline: none;
}
.search-wrapper input:focus { border-color: var(--primary); }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none;
}
.autocomplete-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  box-shadow: var(--shadow-md); z-index: 50; max-height: 280px; overflow-y: auto;
}
.autocomplete-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--gray-100); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--primary-light); }
.ac-main { font-weight: 500; color: var(--gray-800); }
.ac-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ===== BULK ACTIONS ===== */
.bulk-bar {
  display: none; background: var(--primary-light); border: 1px solid #bfdbfe;
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px;
  align-items: center; gap: 10px; flex-wrap: wrap;
}
.bulk-bar.visible { display: flex; }
.bulk-count { font-weight: 600; color: var(--primary); flex: 1; font-size: 13px; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: #fff; }
thead th {
  background: var(--gray-800); color: #fff; padding: 10px 12px;
  text-align: left; font-size: 12px; font-weight: 600; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.4px;
}
thead th:first-child { border-radius: var(--radius) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius) 0 0; }
tbody tr { border-bottom: 1px solid var(--gray-100); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
tbody td { padding: 9px 12px; vertical-align: middle; white-space: nowrap; font-size: 13px; }
.group-header td {
  background: var(--gray-100); font-weight: 700; color: var(--gray-700);
  padding: 8px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
tr.row-selected { background: #eff6ff !important; }
input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
.no-data { text-align: center; padding: 48px 16px; color: var(--gray-400); }
.no-data svg { display: block; margin: 0 auto 12px; }
.no-data p { font-size: 15px; }
.no-data small { font-size: 12px; margin-top: 4px; display: block; }

/* ===== STATUS BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-done { background: var(--success-light); color: var(--success); }
.badge-pending { background: var(--gray-100); color: var(--gray-500); }
.badge-warning { background: var(--warning-light); color: var(--warning); }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px;
}
.modal-box {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
}
.modal-sm { max-width: 420px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
}
.modal-header h2, .modal-header h3 { font-size: 16px; font-weight: 700; color: var(--gray-800); }
.modal-close {
  background: none; border: none; font-size: 18px; color: var(--gray-400);
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 4px;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--gray-200);
}
.text-muted { color: var(--gray-500); font-size: 13px; padding: 12px 20px; }

/* ===== UPLOAD ===== */
.upload-area {
  display: block; border: 2px dashed var(--gray-300); border-radius: var(--radius);
  padding: 32px 20px; text-align: center; cursor: pointer; margin: 0 20px 16px;
  transition: border-color 0.15s, background 0.15s; color: var(--gray-500);
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-area svg { display: block; margin: 0 auto 10px; color: var(--gray-400); }
.upload-area p { font-weight: 500; margin-bottom: 4px; }
.upload-area small { font-size: 12px; }
#upload-selected { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--success); }
#upload-selected p { font-weight: 500; color: var(--gray-700); }
.progress-bar { height: 6px; background: var(--gray-200); border-radius: 3px; margin: 0 20px 8px; overflow: hidden; }
#progress-fill { height: 100%; background: var(--primary); border-radius: 3px; width: 0%; transition: width 0.3s; }
#upload-progress { padding-bottom: 8px; }
#upload-progress-text { text-align: center; font-size: 13px; color: var(--gray-500); }

/* ===== CONFIRM BODY ===== */
.confirm-body { padding: 16px 20px; }
.confirm-detail { background: var(--gray-50); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; }
.confirm-detail table { width: 100%; }
.confirm-detail td { padding: 3px 0; vertical-align: top; font-size: 13px; }
.confirm-detail td:first-child { color: var(--gray-500); width: 110px; font-size: 12px; }
.confirm-detail td:last-child { font-weight: 500; }
.confirm-warning { font-size: 13px; color: var(--gray-600); margin-bottom: 4px; }
.confirm-count { font-size: 15px; font-weight: 700; color: var(--gray-800); }

/* ===== LOCATION MODAL ===== */
.location-item-info { padding: 12px 20px; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); font-size: 13px; }
.location-item-info strong { display: block; font-size: 14px; margin-bottom: 4px; }
.location-form { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.location-form label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--gray-500); }
.location-form select { padding: 9px 12px; border: 1.5px solid var(--gray-200); border-radius: var(--radius); outline: none; width: 100%; }
.location-form select:focus { border-color: var(--primary); }

/* ===== LOADING ===== */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center; z-index: 300;
}
.loading-box {
  background: #fff; border-radius: 12px; padding: 28px 36px;
  text-align: center; box-shadow: var(--shadow-lg); min-width: 180px;
}
.loading-box p { margin-top: 14px; color: var(--gray-600); font-size: 13px; }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--gray-200);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-400); }
.empty-state svg { display: block; margin: 0 auto 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; color: var(--gray-500); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ===== MISC ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-header h2 { font-size: 18px; font-weight: 700; color: var(--gray-800); }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .app-content { padding: 12px; }
  .app-header { gap: 8px; padding: 0 10px; }
  .header-brand { font-size: 14px; }
  .header-brand svg { display: none; }
  .nav-btn { padding: 6px 10px; font-size: 12px; }
  .btn-ghost { display: none; }
  .stats-row { gap: 8px; }
  .stat-chip { min-width: 90px; padding: 10px 12px; }
  .stat-chip .stat-value { font-size: 20px; }
  .filter-bar { gap: 8px; }
  .filter-group select, .filter-group input { font-size: 13px; }
  tbody td { font-size: 12px; padding: 8px 8px; }
  thead th { font-size: 11px; padding: 8px 8px; }
}
