/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #f4f6f9;
  color: #1a1a2e;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== VARIABLES ===== */
:root {
  --navy: #0B1D3A;
  --navy-light: #1a3a6b;
  --orange: #E8751A;
  --orange-dark: #c45f0f;
  --white: #ffffff;
  --gray-100: #f4f6f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --success: #16a34a;
  --success-light: #dcfce7;
  --info: #2563eb;
  --info-light: #dbeafe;
}

/* ===== LOGIN ===== */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  padding: 1rem;
}
.login-card {
  background: var(--white);
  border-radius: 1rem;
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo h1 {
  color: var(--navy);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.login-logo .sub {
  color: var(--orange);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 0.375rem;
}
.form-control {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(232,117,26,0.15);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  min-height: 48px;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--orange);
  color: var(--white);
  width: 100%;
}
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-800);
}
.btn-secondary:hover { background: var(--gray-300); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-sm { padding: 0.5rem 0.75rem; font-size: 0.875rem; min-height: 36px; }

/* ===== APP LAYOUT ===== */
#app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.app-header {
  background: var(--navy);
  color: var(--white);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.app-header .brand {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.app-header .brand span { color: var(--orange); }
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.lang-toggle {
  display: flex;
  background: rgba(255,255,255,0.1);
  border-radius: 0.375rem;
  overflow: hidden;
}
.lang-toggle button {
  background: transparent;
  border: none;
  color: var(--white);
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}
.lang-toggle button.active { background: var(--orange); }
.user-name {
  font-size: 0.875rem;
  font-weight: 600;
  display: none;
}
.logout-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--white);
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  cursor: pointer;
}
.logout-btn:hover { background: rgba(255,255,255,0.2); }

.app-body {
  display: flex;
  flex: 1;
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--white);
  width: 260px;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}
.sidebar.open { transform: translateX(0); }
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 150;
  display: none;
}
.sidebar-overlay.open { display: block; }
.sidebar-header {
  background: var(--navy);
  color: var(--white);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header h2 { font-size: 1rem; }
.sidebar-close {
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.25rem;
  cursor: pointer;
}
.nav-list {
  list-style: none;
  padding: 0.5rem;
  flex: 1;
  overflow-y: auto;
}
.nav-list li button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--gray-800);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.nav-list li button:hover { background: var(--gray-100); }
.nav-list li button.active { background: var(--navy); color: var(--white); }
.nav-list li button.active .nav-icon { color: var(--orange); }

.hamburger {
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  padding: 1rem;
  margin-left: 0;
  width: 100%;
}
.page-header {
  margin-bottom: 1.25rem;
}
.page-header h2 {
  font-size: 1.375rem;
  color: var(--navy);
  font-weight: 800;
}
.page-header p {
  color: var(--gray-600);
  font-size: 0.9375rem;
}

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 1rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 0.75rem;
}

/* ===== DASHBOARD CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  border-radius: 0.75rem;
  padding: 1.25rem;
  color: var(--white);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.08);
}
.stat-card .stat-value {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
}
.stat-card .stat-label {
  font-size: 0.9375rem;
  font-weight: 600;
  opacity: 0.95;
}
.stat-card.green { background: linear-gradient(135deg, #16a34a, #15803d); }
.stat-card.yellow { background: linear-gradient(135deg, #d97706, #b45309); }
.stat-card.red { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.stat-card.orange { background: linear-gradient(135deg, #ea580c, #c2410c); }
.stat-card.blue { background: linear-gradient(135deg, #2563eb, #1d4ed8); }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-green { background: var(--success-light); color: var(--success); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }
.badge-blue { background: var(--info-light); color: var(--info); }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
 th, td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}
 th {
  background: var(--gray-100);
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-600);
}
tr:hover { background: var(--gray-100); }

/* ===== GRID LIST (MOBILE TABLE REPLACEMENT) ===== */
.grid-list {
  display: grid;
  gap: 0.75rem;
}
.grid-item {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 0.75rem;
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}
.grid-item .gi-title { font-weight: 700; color: var(--navy); }
.grid-item .gi-meta { font-size: 0.875rem; color: var(--gray-600); grid-column: 1 / -1; }

/* ===== FORMS ===== */
.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--gray-800);
}
select.form-control, textarea.form-control {
  min-height: 48px;
}
textarea.form-control { min-height: 100px; resize: vertical; }

.radio-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.radio-option {
  flex: 1;
  min-width: 80px;
}
.radio-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.radio-option label {
  display: block;
  text-align: center;
  padding: 0.75rem 0.5rem;
  border: 2px solid var(--gray-200);
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--white);
}
.radio-option input:checked + label {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--white);
}
.radio-option input[value="pass"]:checked + label { border-color: var(--success); background: var(--success); color: var(--white); }
.radio-option input[value="fail"]:checked + label { border-color: var(--danger); background: var(--danger); color: var(--white); }
.radio-option input[value="na"]:checked + label { border-color: var(--gray-600); background: var(--gray-600); color: var(--white); }

/* ===== CHECKLIST ===== */
.checklist-item {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.checklist-item.critical { border-left: 4px solid var(--danger); }
.checklist-label {
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.5rem;
  display: block;
}
.checklist-sublabel {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-bottom: 0.75rem;
  display: block;
}

/* ===== ALERTS ===== */
.alert {
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.alert-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fecaca;
}
.alert-warning {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid #fde68a;
}

/* ===== SIGNATURE PAD ===== */
.signature-pad {
  border: 2px dashed var(--gray-300);
  border-radius: 0.5rem;
  background: var(--white);
  width: 100%;
  height: 160px;
  touch-action: none;
}

/* ===== PRINT ===== */
@media print {
  .app-header, .sidebar, .sidebar-overlay, .hamburger, .lang-toggle, .logout-btn, .btn {
    display: none !important;
  }
  .main-content { margin-left: 0 !important; padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  body { background: #fff; color: #000; }
  .alert { border: 2px solid #000; }
}

/* ===== DESKTOP ===== */
@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: repeat(2, 1fr); }
  .user-name { display: block; }
}

@media (min-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .sidebar {
    position: relative;
    transform: none;
    border-right: 1px solid var(--gray-200);
  }
  .hamburger, .sidebar-overlay, .sidebar-close { display: none; }
  .main-content { margin-left: 260px; padding: 1.5rem; }
  .grid-list { display: none; }
}

@media (max-width: 1023px) {
  table { display: none; }
  .grid-list { display: grid; }
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.w-full { width: 100%; }

/* ===== PHASE 2 IMPROVEMENTS ===== */

/* Better radio pills - mobile friendly */
.check-options {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: 2px solid #ccc;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.radio-pill input[type="radio"] {
  display: none;
}
.radio-pill.selected {
  border-color: #0B1D3A;
  background: #0B1D3A;
  color: white;
}
.radio-pill.selected.fail-pill {
  border-color: #e74c3c;
  background: #e74c3c;
}
.check-item.critical {
  border-left: 3px solid #e74c3c;
  padding-left: 8px;
  margin-bottom: 12px;
  background: #fff8f8;
  border-radius: 4px;
  padding: 10px;
}
.check-label {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
  font-weight: 500;
}

/* Stop warning banner */
.stop-warning {
  background: #e74c3c;
  color: white;
  padding: 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  margin: 16px 0;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* Photo preview grid */
.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.photo-preview img {
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  max-height: 150px;
}

/* DP Chart container */
.chart-container {
  background: white;
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* Audit report table enhancements */
.audit-section {
  background: white;
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  overflow-x: auto;
}
.audit-section table {
  width: 100%;
  border-collapse: collapse;
}
.audit-section th {
  background: #0B1D3A;
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
}
.audit-section td {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  font-size: 13px;
}
.audit-section tr:hover td {
  background: #f8f9fa;
}

/* Filter log form */
.filter-log-form {
  background: white;
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.filter-log-form .full-width {
  grid-column: 1 / -1;
}
@media (max-width: 600px) {
  .filter-log-form {
    grid-template-columns: 1fr;
  }
}

/* Login box polish */
.login-box {
  max-width: 400px;
  margin: 0 auto;
  padding: 40px 24px;
}
.login-box .logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-box .logo-icon {
  font-size: 48px;
  margin-bottom: 8px;
}
.login-box h1 {
  color: #0B1D3A;
  font-size: 24px;
}
.login-box .subtitle {
  color: #666;
  font-size: 14px;
  margin-top: 4px;
}
.login-box input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
}
.login-box .btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 16px;
}
.footer-note, .footer-note-es {
  font-size: 11px;
  color: #999;
  text-align: center;
  margin-top: 24px;
  line-height: 1.4;
}
