/* ============================================================
   Reportes Fixser — Mobile-First Design System
   ============================================================ */

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

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

:root {
  /* Brand */
  --primary: #4a307c;
  --primary-dark: #341d5e;
  --primary-light: #7c5cb4;
  --secondary: #16213e;
  --accent: #16c94f;
  --success: #16c94f;
  --warning: #d97706;
  --danger: #dc2626;

  /* Sizing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --glass-blur: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --transition: 0.18s ease;
}

:root,
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b0b18;
  --bg-2: #111128;
  --bg-3: #161636;
  --surface: #1a1a3a;
  --surface-2: #22224a;
  --border: rgba(124, 92, 180, 0.28);
  --border-light: rgba(255, 255, 255, 0.08);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --glass-bg: rgba(22, 22, 51, 0.82);
  --glass-border: rgba(124, 92, 180, 0.35);

  --navbar-bg: rgba(11, 11, 24, 0.92);
  --input-bg: rgba(255, 255, 255, 0.04);
  --input-border: rgba(255, 255, 255, 0.1);
  --check-bg: rgba(255, 255, 255, 0.04);
  --check-border: rgba(255, 255, 255, 0.18);

  --btn-secondary-bg: #252550;
  --btn-secondary-text: #e2e8f0;
  --btn-secondary-border: rgba(255, 255, 255, 0.12);
  --btn-ghost-bg: transparent;
  --btn-ghost-text: #cbd5e1;
  --btn-ghost-border: rgba(255, 255, 255, 0.14);

  --badge-draft-bg: #334155;
  --badge-draft-text: #e2e8f0;
  --badge-pending-bg: #92400e;
  --badge-pending-text: #fde68a;
  --badge-completed-bg: #065f46;
  --badge-completed-text: #a7f3d0;
  --badge-error-bg: #991b1b;
  --badge-error-text: #fecaca;

  --status-draft: #64748b;
  --status-pending: #f59e0b;
  --status-completed: #10b981;
  --status-error: #ef4444;
}

[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f6fb;
  --bg-2: #eef1f7;
  --bg-3: #e8ecf4;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: rgba(74, 48, 124, 0.14);
  --border-light: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;

  --glass-bg: rgba(255, 255, 255, 0.92);
  --glass-border: rgba(74, 48, 124, 0.12);

  --navbar-bg: rgba(255, 255, 255, 0.94);
  --input-bg: #ffffff;
  --input-border: rgba(15, 23, 42, 0.12);
  --check-bg: #ffffff;
  --check-border: rgba(15, 23, 42, 0.18);

  --btn-secondary-bg: #ffffff;
  --btn-secondary-text: #334155;
  --btn-secondary-border: rgba(15, 23, 42, 0.12);
  --btn-ghost-bg: #ffffff;
  --btn-ghost-text: #334155;
  --btn-ghost-border: rgba(15, 23, 42, 0.12);

  --badge-draft-bg: #e2e8f0;
  --badge-draft-text: #475569;
  --badge-pending-bg: #fef3c7;
  --badge-pending-text: #92400e;
  --badge-completed-bg: #d1fae5;
  --badge-completed-text: #065f46;
  --badge-error-bg: #fee2e2;
  --badge-error-text: #991b1b;

  --status-draft: #64748b;
  --status-pending: #d97706;
  --status-completed: #059669;
  --status-error: #dc2626;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  width: 100%;
}

/* ============================================================
   Auth Page
   ============================================================ */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  position: relative;
}

.auth-theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
}

.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg);
}

.auth-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% -20%, rgba(74, 48, 124, 0.15) 0%, transparent 60%);
}

[data-theme="light"] .auth-bg::before {
  background: radial-gradient(ellipse 80% 60% at 50% -20%, rgba(74, 48, 124, 0.08) 0%, transparent 60%);
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
}

.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 2.5rem;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.logo-icon {
  display: inline-block;
  margin-bottom: 0.75rem;
}

.logo-icon svg {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

.auth-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.auth-title span {
  color: var(--text);
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.auth-footer {
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.75rem;
  margin-top: 1.75rem;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.3px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 0.875rem;
  width: 18px;
  height: 18px;
  color: var(--text-subtle);
  pointer-events: none;
  flex-shrink: 0;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  padding: 0.75rem 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.input-wrapper .form-input {
  padding-left: 2.75rem;
}

.input-wrapper .form-input:has(+ .toggle-password) {
  padding-right: 2.75rem;
}

.form-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(74, 48, 124, 0.12);
}

/* Custom Checkbox Aesthetic */
.custom-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: color 0.2s;
}
.custom-checkbox:hover { color: var(--text); }
.custom-checkbox input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }

.checkmark {
  position: relative;
  height: 20px;
  width: 20px;
  background: var(--check-bg);
  border: 1.5px solid var(--check-border);
  border-radius: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.custom-checkbox:hover input ~ .checkmark {
  border-color: var(--primary-light);
}

.custom-checkbox input:checked ~ .checkmark {
  background: var(--success);
  border-color: var(--success);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
  left: 6px; top: 2px;
  width: 5px; height: 10px;
  border: solid white;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.custom-checkbox input:checked ~ .checkmark:after { display: block; }

/* Dark Modern Calendar (Flatpickr) */
.flatpickr-calendar {
  background: var(--surface) !important;
  border: 1px solid var(--glass-border) !important;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5) !important;
  color: var(--text) !important;
  border-radius: var(--radius-lg) !important;
}
.flatpickr-day { color: var(--text) !important; border-radius: 10px !important; }
.flatpickr-day.today { border-color: var(--primary-light) !important; }
.flatpickr-day.selected { background: var(--primary) !important; border-color: var(--primary) !important; box-shadow: none !important; }
.flatpickr-months .flatpickr-month, .flatpickr-current-month, .flatpickr-weekday { color: var(--text) !important; fill: var(--text) !important; }
.flatpickr-time { border-top: 1px solid var(--border-light) !important; height: 45px !important; }
.flatpickr-time input:hover { background: rgba(255,255,255,0.05) !important; }

/* Mobile Thumb Optimization for Calendar */
@media (max-width: 600px) {
  .flatpickr-calendar {
    width: 310px !important;
    font-size: 1.1rem;
    left: 50% !important;
    transform: translateX(-50%) translateY(10px) !important;
  }
  .flatpickr-day {
    height: 42px !important;
    line-height: 42px !important;
    max-width: 42px !important;
    font-size: 1rem !important;
  }
  .flatpickr-innerContainer, .flatpickr-rContainer { width: 100% !important; }
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-subtle);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.form-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px;
  padding-right: 2.5rem;
}

.form-select option {
  background: var(--surface);
}

.form-textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

.form-input[type="number"]::-webkit-inner-spin-button {
  opacity: 0.4;
}

.toggle-password {
  position: absolute;
  right: 0.875rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-subtle);
  padding: 0;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}

.toggle-password:hover {
  color: var(--primary-light);
}

/* Checkbox */
.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.check-item:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--border);
}

.check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.check-item .check-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.3;
  cursor: pointer;
}

/* Measurement row (3 numbers side by side) */
.meas-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.meas-row-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.meas-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.meas-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.meas-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

.meas-input {
  text-align: center;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.8rem 1.5rem;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border: 1px solid var(--btn-secondary-border);
}

.btn-secondary:hover:not(:disabled) {
  filter: brightness(0.97);
}

[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-success {
  background: linear-gradient(135deg, #059669, var(--success));
  color: #fff;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #1e293b;
}

.btn-warning:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  font-size: 0.8125rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 0.6rem;
  border-radius: var(--radius-sm);
}

.btn-spinner svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.alert-success {
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.alert-info {
  background: rgba(6, 182, 212, 0.12);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.25);
}

/* ============================================================
   Layout — App Shell
   ============================================================ */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navbar-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  padding: 0 1rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
  min-width: 0;
}

@media (max-width: 480px) {
  .navbar-brand { font-size: 0.875rem; }
  .navbar-brand svg { width: 28px; height: 28px; }
}

.navbar-brand span {
  color: var(--text);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.navbar-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

@media (max-width: 400px) {
  .navbar-actions .btn:has(svg) span:not(.badge) {
    display: none;
  }
  .navbar-actions .btn:has(svg) {
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .navbar-actions .btn svg {
    width: 18px;
    height: 18px;
  }
}

.navbar-user {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.main-content {
  flex: 1;
  padding: 1.25rem 1rem 4rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.main-content.admin-page {
  max-width: min(100%, 1280px);
}

/* ============================================================
   Multi-Step Form Wizard
   ============================================================ */
.wizard-wrap {
  position: relative;
}

/* Progress bar */
.progress-bar-wrap {
  margin-bottom: 1.5rem;
}

.progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 100%;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  gap: 4px;
}

.progress-label {
  font-size: 0.6rem;
  color: var(--text-subtle);
  font-weight: 600;
  text-align: center;
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: color 0.3s;
}

.progress-label.active {
  color: var(--primary-light);
}

@media (max-width: 600px) {
  .progress-label {
    display: none;
  }

  .progress-label.active {
    display: block;
    width: 100%;
    font-size: 0.75rem;
    letter-spacing: 1px;
  }
}

/* Step counter */
.step-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.step-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  flex-shrink: 0;
}

.step-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.step-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Step panels */
.step-panel {
  display: none;
  animation: fadeSlide 0.3s ease;
}

.step-panel.active {
  display: block;
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Section card */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.section-card-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--primary-light);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-card-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* Form navigation */
.form-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  gap: 0.75rem;
}

.form-nav-right {
  display: flex;
  gap: 0.75rem;
}

/* ============================================================
   Signature Pads
   ============================================================ */
.sig-wrap {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
  position: relative;
  touch-action: none;
  user-select: none;
}

.sig-canvas {
  display: block;
  width: 100%;
  height: 180px;
  cursor: crosshair;
  touch-action: none;
}

.sig-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  pointer-events: none;
  transition: opacity 0.3s;
  color: var(--text-subtle);
  font-size: 0.8rem;
}

.sig-placeholder svg {
  opacity: 0.4;
}

.sig-placeholder.hidden {
  opacity: 0;
}

.sig-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* ============================================================
   Admin Dashboard
   ============================================================ */
.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.875rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.125rem 1.25rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.table-title {
  font-size: 0.9rem;
  font-weight: 700;
}

.reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.reports-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.reports-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.reports-table tr:last-child td {
  border-bottom: none;
}

.reports-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
}

.badge-draft {
  background: var(--badge-draft-bg);
  color: var(--badge-draft-text);
  border: 1px solid transparent;
}

.badge-pending {
  background: var(--badge-pending-bg);
  color: var(--badge-pending-text);
  border: 1px solid transparent;
}

.badge-completed {
  background: var(--badge-completed-bg);
  color: var(--badge-completed-text);
  border: 1px solid transparent;
}

.badge-error {
  background: var(--badge-error-bg);
  color: var(--badge-error-text);
  border: 1px solid transparent;
}

/* Theme toggle — show target mode (sun = switch to light, moon = switch to dark) */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
}

.theme-toggle .theme-icon-sun,
.theme-toggle .theme-icon-moon {
  display: none;
  flex-shrink: 0;
}

[data-theme="dark"] .theme-toggle .theme-icon-sun {
  display: block;
}

[data-theme="light"] .theme-toggle .theme-icon-moon {
  display: block;
}

/* Shared action buttons (admin table + mobile cards) */
.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  font-family: inherit;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.action-btn svg {
  flex-shrink: 0;
}

.action-btn-neutral {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border-color: var(--btn-secondary-border);
}

.action-btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.action-btn-success {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.action-btn-warning {
  background: var(--warning);
  color: #ffffff;
  border-color: var(--warning);
}

.action-btn:hover {
  filter: brightness(1.05);
}

.action-btn:active {
  transform: scale(0.98);
}

.status-select {
  border: 1.5px solid transparent;
  padding: 0.25rem 1.6rem 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 14px;
  transition: all var(--transition);
  outline: none;
}

.status-select:hover {
  border-color: rgba(255, 255, 255, 0.2);
  filter: brightness(1.2);
}

.status-select.badge-pending {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23fcd34d'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
}

.status-select.badge-completed {
  background-color: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236ee7b7'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
}

.status-select.badge-draft {
  background-color: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
}

.status-select option {
  background: var(--surface-2);
  color: var(--text);
}

.table-actions {
  display: flex;
  gap: 0.375rem;
  align-items: center;
}

.admin-reports-table {
  table-layout: fixed;
  font-size: 0.9rem;
}

.admin-reports-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  padding: 0.875rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #94a3b8;
  border-bottom: 1px solid var(--border-light);
}

.admin-reports-table td {
  padding: 0.875rem 0.75rem;
  font-size: 0.9rem;
  line-height: 1.4;
  border-bottom: 1px solid var(--border-light);
}

.admin-reports-table tbody tr {
  transition: background 0.15s;
}

.admin-reports-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.admin-reports-table tbody tr:hover td {
  background: rgba(99, 102, 241, 0.06);
}

.admin-reports-table tr[data-status="draft"] .col-check {
  box-shadow: inset 3px 0 0 #64748b;
}

.admin-reports-table tr[data-status="pending"] .col-check {
  box-shadow: inset 3px 0 0 #f59e0b;
}

.admin-reports-table tr[data-status="completed"] .col-check {
  box-shadow: inset 3px 0 0 #10b981;
}

.admin-reports-table tr[data-status="email_failed"] .col-check {
  box-shadow: inset 3px 0 0 #ef4444;
}

.admin-reports-table .cell-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-reports-table .col-check { width: 40px; }
.admin-reports-table .col-folio { width: 13%; }
.admin-reports-table .col-tipo { width: 12%; }
.admin-reports-table .col-empresa { width: 10%; }
.admin-reports-table .col-cliente { width: 14%; }
.admin-reports-table .col-ingeniero { width: 11%; }
.admin-reports-table .col-fecha { width: 14%; }
.admin-reports-table .col-estado { width: 11%; }
.admin-reports-table .col-acciones {
  width: 230px;
  min-width: 230px;
  overflow: hidden;
  vertical-align: top;
}

.admin-reports-table .col-folio strong {
  font-size: 0.95rem;
  font-weight: 700;
}

.admin-reports-table .col-estado .badge {
  max-width: 100%;
  box-sizing: border-box;
  justify-content: center;
  text-align: center;
}

.admin-reports-table .badge {
  font-size: 0.78rem;
  padding: 0.35rem 0.65rem;
  white-space: nowrap;
}

.admin-status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  padding: 0.875rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.admin-status-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-reports-table .row-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  width: 100%;
  min-width: 0;
}

.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 70vh;
}

.admin-report-cards {
  display: none;
}

.admin-report-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.admin-report-card[data-status="draft"] {
  border-left: 4px solid var(--status-draft);
}

.admin-report-card[data-status="pending"] {
  border-left: 4px solid var(--status-pending);
}

.admin-report-card[data-status="completed"] {
  border-left: 4px solid var(--status-completed);
}

.admin-report-card[data-status="email_failed"] {
  border-left: 4px solid var(--status-error);
}

.admin-report-cards-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
}

.custom-checkbox.admin-select-all-mobile {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin: 0;
  cursor: pointer;
}

.admin-select-all-mobile .checkmark {
  margin-right: 0.75rem;
}

.admin-select-all-label {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text-muted);
}

.admin-report-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.admin-report-card-title {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

.admin-report-card-title strong {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

.admin-report-card-body {
  padding: 0.875rem 1rem;
}

.admin-report-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin: 0;
}

.admin-report-card-meta div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
}

.admin-report-card-meta dt {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  flex-shrink: 0;
}

.admin-report-card-meta dd {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  word-break: break-word;
}

.admin-report-card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.875rem 1rem 1rem;
  background: var(--bg-2);
  border-top: 1px solid var(--border-light);
}

.admin-report-card-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-md);
}

.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.admin-filters .form-group {
  margin: 0;
  min-width: 160px;
  flex: 1 1 160px;
}

.admin-filters-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (max-width: 900px) {
  .admin-reports-table .col-ingeniero,
  .admin-reports-table .col-empresa {
    display: none;
  }

  .admin-reports-table .col-acciones {
    width: 210px;
    min-width: 210px;
  }
}

@media (max-width: 768px) {
  .main-content.admin-page {
    max-width: 100%;
    padding: 1rem 0.75rem 3rem;
  }

  .admin-table-wrap {
    display: none;
  }

  .admin-report-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0;
  }

  .admin-status-legend {
    display: none;
  }

  .admin-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.625rem;
    align-items: start;
  }

  .admin-filters .form-group {
    width: 100%;
    min-width: 0;
  }

  .admin-filters-actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  .admin-filters-actions .btn {
    flex: 1;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.625rem;
  }

  .stat-card {
    padding: 0.875rem 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .table-header {
    flex-direction: column;
    align-items: stretch;
  }

  .table-header .table-actions {
    width: 100%;
  }

  .table-header .table-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .admin-report-card-actions .action-btn {
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
  }

  .page-title {
    font-size: 1.35rem;
  }
}

@media (max-width: 640px) {
  .admin-reports-table .col-fecha {
    display: none;
  }

  .admin-reports-table .col-acciones {
    width: 200px;
    min-width: 200px;
  }

  .admin-reports-table .action-btn {
    font-size: 0.75rem;
    padding: 0.45rem 0.6rem;
  }

  .admin-report-card-meta {
    gap: 0.5rem;
  }

  .navbar-actions .btn:has(svg) span:not(.badge) {
    display: none;
  }

  .navbar-actions .btn:has(svg) {
    padding: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 1rem;
}

.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all var(--transition);
}

.page-link:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
  color: var(--text);
}

.page-link.active {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border-color: var(--primary);
}

/* ============================================================
   PDF Preview iframe
   ============================================================ */
.pdf-embed {
  width: 100%;
  min-height: 600px;
  border: none;
  border-radius: var(--radius-md);
}

/* ============================================================
   Utilities
   ============================================================ */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.gap-1 {
  gap: 0.5rem;
}

.gap-2 {
  gap: 1rem;
}

.w100 {
  width: 100%;
}

.divider {
  height: 1px;
  background: var(--border-light);
  margin: 1rem 0;
}

.required {
  color: var(--danger);
}

/* Toast notification */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  animation: toastin 0.3s ease;
  max-width: 320px;
}

@keyframes toastin {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast-success {
  border-color: rgba(16, 185, 129, 0.4);
}

.toast-error {
  border-color: rgba(239, 68, 68, 0.4);
}

/* ============================================================
   Responsive adjustments
   ============================================================ */
@media (max-width: 768px) {

  .meas-row,
  .meas-row-2,
  .meas-row-4 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .meas-row-3 {
    grid-template-columns: 1fr;
  }

  /* Allow 2 columns for very short inputs if they fit */
  .meas-row-4.compact-mobile {
    grid-template-columns: repeat(2, 1fr);
    min-width: 0;
  }
}

/* Force prevent horizontal scroll globally */
.app-layout {
  min-height: 100vh;
  overflow-x: hidden !important;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  position: relative;
}

@media (max-width: 480px) {
  .navbar-user {
    display: none;
  }

  .navbar {
    padding: 0 0.75rem;
  }

  .main-content {
    padding: 1rem 0.75rem 4rem;
  }

  .glass-card {
    padding: 1.5rem;
  }

  .check-grid {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 1.25rem;
  }

  .form-nav {
    flex-direction: column-reverse;
    gap: 0.75rem;
  }

  .form-nav-right {
    width: 100%;
    flex-direction: column;
  }

  .form-nav .btn {
    width: 100%;
  }

  /* Make admin filters even tighter on very small screens */
  .admin-filters {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

@media (min-width: 640px) {
  .main-content {
    padding: 1.5rem 1.25rem 4rem;
  }
}

@media (min-width: 1024px) {
  .meas-row-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.35);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.6);
}

/* ============================================================
   PWA & Sync Enhancements
   ============================================================ */

/* Sync Button & Badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  margin-left: 4px;
  vertical-align: middle;
}

#sync-btn {
  position: relative;
  overflow: visible;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(124, 92, 180, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(124, 92, 180, 0); }
  100% { box-shadow: 0 0 0 0 rgba(124, 92, 180, 0); }
}

.pulse {
  animation: pulse 2s infinite;
}

/* iOS Install Tooltip */
.ios-tooltip {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  background: var(--surface-2);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: slideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ios-tooltip-content p {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.4;
}

.ios-tooltip-content button {
  margin-top: 0.75rem;
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Toast Enhancements */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: var(--surface-2);
  border-left: 4px solid var(--primary);
  color: var(--text);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-weight: 500;
  min-width: 280px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideIn 0.3s ease-out;
}

.toast-success { border-color: var(--success); }
.toast-error { border-color: var(--danger); }
.toast-warning { border-color: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Photo Upload & Evidence */
.evidence-section {
  border-left: 4px solid var(--primary-light);
}

.photo-upload-zone {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.photo-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  background: rgba(255, 255, 255, 0.02);
}

.photo-upload-btn:hover {
  border-color: var(--primary-light);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.photo-upload-btn input {
  display: none;
}

.photo-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.photo-preview-item {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: fadeIn 0.3s ease;
}

.photo-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #000;
}

.photo-desc {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.75rem;
  padding: 0.4rem;
  width: 100%;
}

.photo-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}