:root {
  --brand-primary: #0F4C81;
  --brand-accent: #16A34A;
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --surface-alt: #F8FAFC;
  --border: #CBD5E1;
  --text: #0F172A;
  --text-muted: #475569;
  --danger: #DC2626;
  --warning: #D97706;
  --success: #15803D;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

a {
  color: var(--brand-primary);
}

.hidden {
  display: none !important;
}

/* Header corporativo de alto contraste para exteriores */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--brand-primary);
  color: #FFFFFF;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #FFFFFF;
  object-fit: contain;
  padding: 2px;
  flex-shrink: 0;
}

.brand-titles {
  min-width: 0;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 0.78rem;
  opacity: 0.9;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.net-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.net-pill.offline {
  background: #B91C1C;
  border-color: #FCA5A5;
}

.sync-pill {
  background: #F59E0B;
  color: #111827;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

/* Navegación */
.nav-tabs {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  display: flex;
  overflow-x: auto;
  gap: 4px;
  padding: 8px 12px;
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 10px 14px;
  border-radius: 10px;
  white-space: nowrap;
  cursor: pointer;
  min-height: 44px;
}

.nav-tab.active {
  background: var(--brand-primary);
  color: #FFFFFF;
}

/* Contenedor principal */
.main-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px;
  padding-bottom: 84px;
}

/* Tarjetas */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 12px 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}

/* Botones grandes aptos para campo */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 2px solid transparent;
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.06s ease, opacity 0.15s ease;
}

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

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

.btn-primary {
  background: var(--brand-primary);
  color: #FFFFFF;
}

.btn-accent {
  background: var(--brand-accent);
  color: #FFFFFF;
}

.btn-secondary {
  background: #E2E8F0;
  color: #0F172A;
  border-color: #CBD5E1;
}

.btn-outline {
  background: #FFFFFF;
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.btn-warning {
  background: var(--warning);
  color: #FFFFFF;
}

.btn-sm {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

/* Formularios */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--text);
}

.form-control {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: #FFFFFF;
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
}

textarea.form-control {
  min-height: 110px;
  resize: vertical;
}

/* Grid y utilidades */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

.flex-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.flex-between {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.badge-process {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #F59E0B;
}

.badge-done {
  background: #DCFCE7;
  color: #166534;
  border: 1px solid #22C55E;
}

.badge-info {
  background: #DBEAFE;
  color: #1E40AF;
  border: 1px solid #60A5FA;
}

.badge-danger {
  background: #FEE2E2;
  color: #991B1B;
  border: 1px solid #F87171;
}

/* Stepper visual: Inicio -> Proceso -> Final */
.stage-stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stage-step-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  min-height: 68px;
}

.stage-step-btn.active {
  border-color: var(--brand-primary);
  background: var(--brand-primary);
  color: #FFFFFF;
}

.stage-step-btn.has-data:not(.active) {
  border-color: var(--brand-accent);
  background: #F0FDF4;
}

.stage-step-num {
  font-size: 0.78rem;
  opacity: 0.85;
}

/* Galería de fotos */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.photo-thumb-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #0F172A;
  aspect-ratio: 1 / 1;
}

.photo-thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.photo-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 2px solid #FFFFFF;
  background: rgba(220, 38, 38, 0.92);
  color: #FFFFFF;
  font-weight: 900;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Grabadora de voz */
.voice-box {
  background: var(--surface-alt);
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 14px;
}

.voice-recording {
  border-color: var(--danger);
  background: #FEF2F2;
}

.audio-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #FFFFFF;
  margin-top: 8px;
}

.audio-item audio {
  width: 100%;
}

/* Lista de actividades */
.activity-card {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--surface);
  margin-bottom: 10px;
  cursor: pointer;
}

.activity-card:hover {
  border-color: var(--brand-primary);
}

/* KPIs panel */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--brand-primary);
  border-radius: 12px;
  padding: 14px;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text);
}

.kpi-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Tablas responsivas */
.table-wrap {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data-table th,
table.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

table.data-table th {
  background: var(--surface-alt);
  font-weight: 800;
  white-space: nowrap;
}

/* Modal / Lightbox */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: var(--surface);
  border-radius: 14px;
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.lightbox-img {
  max-width: 100%;
  max-height: 75vh;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 440px);
}

.toast {
  background: #0F172A;
  color: #FFFFFF;
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.toast.error {
  background: #991B1B;
}

.toast.success {
  background: #166534;
}

.alert-banner {
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 700;
  margin-bottom: 12px;
  border: 1px solid;
}

.alert-warning {
  background: #FEF3C7;
  color: #92400E;
  border-color: #F59E0B;
}

.alert-danger {
  background: #FEE2E2;
  color: #991B1B;
  border-color: #EF4444;
}

.alert-info {
  background: #EFF6FF;
  color: #1E3A8A;
  border-color: #60A5FA;
}

.muted {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.login-wrapper {
  max-width: 440px;
  margin: 32px auto;
  padding: 0 14px;
}
